simplify READ_RECORD usage NFC

READ_RECORD read_record;
...
// this
// read_record.read_record(&read_record);
// becomes just
read_record.read_record();
This commit is contained in:
Eugene Kosov 2017-08-25 14:36:13 +03:00 committed by Sergey Vojtovich
parent e1051590b6
commit 5dd8e1bf2d
19 changed files with 64 additions and 62 deletions

View File

@ -499,7 +499,7 @@ Event_db_repository::table_scan_all_for_i_s(THD *thd, TABLE *schema_table,
*/
do
{
ret= read_record_info.read_record(&read_record_info);
ret= read_record_info.read_record();
if (ret == 0)
ret= copy_event_to_schema_table(thd, schema_table, event_table);
} while (ret == 0);
@ -1008,7 +1008,7 @@ Event_db_repository::drop_schema_events(THD *thd, const LEX_CSTRING *schema)
if (init_read_record(&read_record_info, thd, table, NULL, NULL, 1, 0, FALSE))
goto end;
while (!ret && !(read_record_info.read_record(&read_record_info)) )
while (!ret && !(read_record_info.read_record()))
{
char *et_field= get_field(thd->mem_root, table->field[field]);

View File

@ -1156,7 +1156,7 @@ Events::load_events_from_db(THD *thd)
DBUG_RETURN(TRUE);
}
while (!(read_record_info.read_record(&read_record_info)))
while (!(read_record_info.read_record()))
{
Event_queue_element *et;
bool created, dropped;

View File

@ -3828,8 +3828,8 @@ int subselect_single_select_engine::exec()
{
/* Change the access method to full table scan */
tab->save_read_first_record= tab->read_first_record;
tab->save_read_record= tab->read_record.read_record;
tab->read_record.read_record= rr_sequential;
tab->save_read_record= tab->read_record.read_record_func;
tab->read_record.read_record_func= rr_sequential;
tab->read_first_record= read_first_record_seq;
tab->read_record.record= tab->table->record[0];
tab->read_record.thd= join->thd;
@ -3851,8 +3851,8 @@ int subselect_single_select_engine::exec()
JOIN_TAB *tab= *ptab;
tab->read_record.record= 0;
tab->read_record.ref_length= 0;
tab->read_first_record= tab->save_read_first_record;
tab->read_record.read_record= tab->save_read_record;
tab->read_first_record= tab->save_read_first_record;
tab->read_record.read_record_func= tab->save_read_record;
}
executed= 1;
if (!(uncacheable() & ~UNCACHEABLE_EXPLAIN) &&

View File

@ -11042,7 +11042,7 @@ int QUICK_INDEX_MERGE_SELECT::get_next()
if (doing_pk_scan)
DBUG_RETURN(pk_quick_select->get_next());
if ((result= read_record.read_record(&read_record)) == -1)
if ((result= read_record.read_record()) == -1)
{
result= HA_ERR_END_OF_FILE;
end_read_record(&read_record);
@ -11078,7 +11078,7 @@ int QUICK_INDEX_INTERSECT_SELECT::get_next()
int result;
DBUG_ENTER("QUICK_INDEX_INTERSECT_SELECT::get_next");
if ((result= read_record.read_record(&read_record)) == -1)
if ((result= read_record.read_record()) == -1)
{
result= HA_ERR_END_OF_FILE;
end_read_record(&read_record);

View File

@ -3872,7 +3872,7 @@ bool setup_sj_materialization_part2(JOIN_TAB *sjm_tab)
sjm_tab->read_record.copy_field= sjm->copy_field;
sjm_tab->read_record.copy_field_end= sjm->copy_field +
sjm->sjm_table_cols.elements;
sjm_tab->read_record.read_record= rr_sequential_and_unpack;
sjm_tab->read_record.read_record_func= rr_sequential_and_unpack;
}
sjm_tab->bush_children->end[-1].next_select= end_sj_materialize;

View File

@ -89,8 +89,8 @@ bool init_read_record_idx(READ_RECORD *info, THD *thd, TABLE *table,
table->file->print_error(error, MYF(0));
}
/* read_record will be changed to rr_index in rr_index_first */
info->read_record= reverse ? rr_index_last : rr_index_first;
/* read_record_func will be changed to rr_index in rr_index_first */
info->read_record_func= reverse ? rr_index_last : rr_index_first;
DBUG_RETURN(error != 0);
}
@ -229,8 +229,8 @@ bool init_read_record(READ_RECORD *info,THD *thd, TABLE *table,
if (tempfile && !(select && select->quick))
{
DBUG_PRINT("info",("using rr_from_tempfile"));
info->read_record= (addon_field ?
rr_unpack_from_tempfile : rr_from_tempfile);
info->read_record_func=
addon_field ? rr_unpack_from_tempfile : rr_from_tempfile;
info->io_cache= tempfile;
reinit_io_cache(info->io_cache,READ_CACHE,0L,0,0);
info->ref_pos=table->file->ref;
@ -260,14 +260,14 @@ bool init_read_record(READ_RECORD *info,THD *thd, TABLE *table,
if (! init_rr_cache(thd, info))
{
DBUG_PRINT("info",("using rr_from_cache"));
info->read_record=rr_from_cache;
info->read_record_func= rr_from_cache;
}
}
}
else if (select && select->quick)
{
DBUG_PRINT("info",("using rr_quick"));
info->read_record=rr_quick;
info->read_record_func= rr_quick;
}
else if (filesort && filesort->record_pointers)
{
@ -277,13 +277,13 @@ bool init_read_record(READ_RECORD *info,THD *thd, TABLE *table,
info->cache_pos= filesort->record_pointers;
info->cache_end= (info->cache_pos+
filesort->return_rows * info->ref_length);
info->read_record= (addon_field ?
rr_unpack_from_buffer : rr_from_pointers);
info->read_record_func=
addon_field ? rr_unpack_from_buffer : rr_from_pointers;
}
else if (table->file->keyread_enabled())
{
int error;
info->read_record= rr_index_first;
info->read_record_func= rr_index_first;
if (!table->file->inited &&
(error= table->file->ha_index_init(table->file->keyread, 1)))
{
@ -295,7 +295,7 @@ bool init_read_record(READ_RECORD *info,THD *thd, TABLE *table,
else
{
DBUG_PRINT("info",("using rr_sequential"));
info->read_record=rr_sequential;
info->read_record_func= rr_sequential;
if (table->file->ha_rnd_init_with_error(1))
DBUG_RETURN(1);
/* We can use record cache if we don't update dynamic length tables */
@ -331,7 +331,7 @@ void end_read_record(READ_RECORD *info)
{
if (info->table->is_created())
(void) info->table->file->extra(HA_EXTRA_NO_CACHE);
if (info->read_record != rr_quick) // otherwise quick_range does it
if (info->read_record_func != rr_quick) // otherwise quick_range does it
(void) info->table->file->ha_index_or_rnd_end();
info->table=0;
}
@ -399,7 +399,7 @@ static int rr_index_first(READ_RECORD *info)
}
tmp= info->table->file->ha_index_first(info->record);
info->read_record= rr_index;
info->read_record_func= rr_index;
if (tmp)
tmp= rr_handle_error(info, tmp);
return tmp;
@ -422,7 +422,7 @@ static int rr_index_first(READ_RECORD *info)
static int rr_index_last(READ_RECORD *info)
{
int tmp= info->table->file->ha_index_last(info->record);
info->read_record= rr_index_desc;
info->read_record_func= rr_index_desc;
if (tmp)
tmp= rr_handle_error(info, tmp);
return tmp;

View File

@ -55,7 +55,7 @@ struct READ_RECORD
//handler *file;
TABLE **forms; /* head and ref forms */
Unlock_row_func unlock_row;
Read_func read_record;
Read_func read_record_func;
THD *thd;
SQL_SELECT *select;
uint cache_records;
@ -70,6 +70,8 @@ struct READ_RECORD
bool print_error, ignore_not_found_rows;
void (*unpack)(struct st_sort_addon_field *, uchar *, uchar *);
int read_record() { return read_record_func(this); }
/*
SJ-Materialization runtime may need to read fields from the materialized
table and unpack them into original table fields:

View File

@ -1828,7 +1828,7 @@ static bool acl_load(THD *thd, const Grant_tables& tables)
{
if (host_table.init_read_record(&read_record_info, thd))
DBUG_RETURN(true);
while (!(read_record_info.read_record(&read_record_info)))
while (!(read_record_info.read_record()))
{
ACL_HOST host;
update_hostname(&host.host, get_field(&acl_memroot, host_table.host()));
@ -1932,7 +1932,7 @@ static bool acl_load(THD *thd, const Grant_tables& tables)
}
allow_all_hosts=0;
while (!(read_record_info.read_record(&read_record_info)))
while (!(read_record_info.read_record()))
{
ACL_USER user;
bool is_role= FALSE;
@ -2144,7 +2144,7 @@ static bool acl_load(THD *thd, const Grant_tables& tables)
const Db_table& db_table= tables.db_table();
if (db_table.init_read_record(&read_record_info, thd))
DBUG_RETURN(TRUE);
while (!(read_record_info.read_record(&read_record_info)))
while (!(read_record_info.read_record()))
{
ACL_DB db;
char *db_name;
@ -2211,7 +2211,7 @@ static bool acl_load(THD *thd, const Grant_tables& tables)
{
if (proxies_priv_table.init_read_record(&read_record_info, thd))
DBUG_RETURN(TRUE);
while (!(read_record_info.read_record(&read_record_info)))
while (!(read_record_info.read_record()))
{
ACL_PROXY_USER proxy;
proxy.init(proxies_priv_table, &acl_memroot);
@ -2240,7 +2240,7 @@ static bool acl_load(THD *thd, const Grant_tables& tables)
MEM_ROOT temp_root;
init_alloc_root(&temp_root, ACL_ALLOC_BLOCK_SIZE, 0, MYF(0));
while (!(read_record_info.read_record(&read_record_info)))
while (!(read_record_info.read_record()))
{
char *hostname= safe_str(get_field(&temp_root, roles_mapping_table.host()));
char *username= safe_str(get_field(&temp_root, roles_mapping_table.user()));

View File

@ -588,7 +588,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
deltempfile= new (thd->mem_root) Unique (refpos_order_cmp, table->file,
table->file->ref_length,
MEM_STRIP_BUF_SIZE);
while (!(error=info.read_record(&info)) && !thd->killed &&
while (!(error=info.read_record()) && !thd->killed &&
! thd->is_error())
{
if (record_should_be_deleted(thd, table, select, explain))
@ -613,7 +613,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
delete_record= true;
}
while (!(error=info.read_record(&info)) && !thd->killed &&
while (!(error=info.read_record()) && !thd->killed &&
! thd->is_error())
{
if (delete_while_scanning)
@ -1286,7 +1286,7 @@ int multi_delete::do_table_deletes(TABLE *table, SORT_INFO *sort_info,
*/
info.ignore_not_found_rows= 1;
bool will_batch= !table->file->start_bulk_delete();
while (!(local_error= info.read_record(&info)) && !thd->killed)
while (!(local_error= info.read_record()) && !thd->killed)
{
if (table->triggers &&
table->triggers->process_triggers(thd, TRG_EVENT_DELETE,

View File

@ -202,7 +202,7 @@ int search_topics(THD *thd, TABLE *topics, struct st_find_field *find_fields,
FALSE))
DBUG_RETURN(0);
while (!read_record_info.read_record(&read_record_info))
while (!read_record_info.read_record())
{
if (!select->cond->val_int()) // Doesn't match like
continue;
@ -246,7 +246,7 @@ int search_keyword(THD *thd, TABLE *keywords,
FALSE))
DBUG_RETURN(0);
while (!read_record_info.read_record(&read_record_info) && count<2)
while (!read_record_info.read_record() && count<2)
{
if (!select->cond->val_int()) // Dosn't match like
continue;
@ -380,7 +380,7 @@ int search_categories(THD *thd, TABLE *categories,
if (init_read_record(&read_record_info, thd, categories, select, NULL,
1, 0, FALSE))
DBUG_RETURN(0);
while (!read_record_info.read_record(&read_record_info))
while (!read_record_info.read_record())
{
if (select && !select->cond->val_int())
continue;
@ -418,7 +418,7 @@ void get_all_items_for_category(THD *thd, TABLE *items, Field *pfname,
FALSE))
DBUG_VOID_RETURN;
while (!read_record_info.read_record(&read_record_info))
while (!read_record_info.read_record())
{
if (!select->cond->val_int())
continue;

View File

@ -3373,7 +3373,7 @@ int JOIN_TAB_SCAN::next()
if (is_first_record)
is_first_record= FALSE;
else
err= info->read_record(info);
err= info->read_record();
if (!err)
{
@ -3388,7 +3388,7 @@ int JOIN_TAB_SCAN::next()
Move to the next record if the last retrieved record does not
meet the condition pushed to the table join_tab.
*/
err= info->read_record(info);
err= info->read_record();
if (!err)
{
join_tab->tracker->r_rows++;

View File

@ -1840,7 +1840,7 @@ static void plugin_load(MEM_ROOT *tmp_root)
goto end;
}
table->use_all_columns();
while (!(error= read_record_info.read_record(&read_record_info)))
while (!(error= read_record_info.read_record()))
{
DBUG_PRINT("info", ("init plugin record"));
String str_name, str_dl;

View File

@ -10972,32 +10972,32 @@ pick_table_access_method(JOIN_TAB *tab)
{
case JT_REF:
tab->read_first_record= join_read_always_key;
tab->read_record.read_record= join_read_next_same;
tab->read_record.read_record_func= join_read_next_same;
break;
case JT_REF_OR_NULL:
tab->read_first_record= join_read_always_key_or_null;
tab->read_record.read_record= join_read_next_same_or_null;
tab->read_record.read_record_func= join_read_next_same_or_null;
break;
case JT_CONST:
tab->read_first_record= join_read_const;
tab->read_record.read_record= join_no_more_records;
tab->read_record.read_record_func= join_no_more_records;
break;
case JT_EQ_REF:
tab->read_first_record= join_read_key;
tab->read_record.read_record= join_no_more_records;
tab->read_record.read_record_func= join_no_more_records;
break;
case JT_FT:
tab->read_first_record= join_ft_read_first;
tab->read_record.read_record= join_ft_read_next;
tab->read_record.read_record_func= join_ft_read_next;
break;
case JT_SYSTEM:
tab->read_first_record= join_read_system;
tab->read_record.read_record= join_no_more_records;
tab->read_record.read_record_func= join_no_more_records;
break;
/* keep gcc happy */
@ -18883,7 +18883,7 @@ sub_select(JOIN *join,JOIN_TAB *join_tab,bool end_of_records)
skip_over= TRUE;
}
error= info->read_record(info);
error= info->read_record();
if (skip_over && !error)
{
@ -19726,7 +19726,7 @@ int read_first_record_seq(JOIN_TAB *tab)
{
if (tab->read_record.table->file->ha_rnd_init_with_error(1))
return 1;
return (*tab->read_record.read_record)(&tab->read_record);
return tab->read_record.read_record();
}
static int
@ -19781,7 +19781,7 @@ int join_init_read_record(JOIN_TAB *tab)
if (init_read_record(&tab->read_record, tab->join->thd, tab->table,
tab->select, tab->filesort_result, 1,1, FALSE))
return 1;
return (*tab->read_record.read_record)(&tab->read_record);
return tab->read_record.read_record();
}
int
@ -19801,9 +19801,9 @@ join_read_record_no_init(JOIN_TAB *tab)
tab->read_record.copy_field= save_copy;
tab->read_record.copy_field_end= save_copy_end;
tab->read_record.read_record= rr_sequential_and_unpack;
tab->read_record.read_record_func= rr_sequential_and_unpack;
return (*tab->read_record.read_record)(&tab->read_record);
return tab->read_record.read_record();
}
@ -19836,7 +19836,7 @@ join_read_first(JOIN_TAB *tab)
!table->covering_keys.is_set(tab->index) ||
table->file->keyread == tab->index);
tab->table->status=0;
tab->read_record.read_record=join_read_next;
tab->read_record.read_record_func= join_read_next;
tab->read_record.table=table;
tab->read_record.index=tab->index;
tab->read_record.record=table->record[0];
@ -19876,7 +19876,7 @@ join_read_last(JOIN_TAB *tab)
!table->covering_keys.is_set(tab->index) ||
table->file->keyread == tab->index);
tab->table->status=0;
tab->read_record.read_record=join_read_prev;
tab->read_record.read_record_func= join_read_prev;
tab->read_record.table=table;
tab->read_record.index=tab->index;
tab->read_record.record=table->record[0];
@ -21842,7 +21842,7 @@ check_reverse_order:
with key part (A) and then traverse the index backwards.
*/
tab->read_first_record= join_read_last_key;
tab->read_record.read_record= join_read_prev_same;
tab->read_record.read_record_func= join_read_prev_same;
/*
Cancel Pushed Index Condition, as it doesn't work for reverse scans.
*/
@ -26767,7 +26767,7 @@ AGGR_OP::end_send()
error= join_init_read_record(join_tab);
}
else
error= join_tab->read_record.read_record(&join_tab->read_record);
error= join_tab->read_record.read_record();
if (error > 0 || (join->thd->is_error())) // Fatal error
rc= NESTED_LOOP_ERROR;

View File

@ -208,7 +208,7 @@ static bool servers_load(THD *thd, TABLE_LIST *tables)
if (init_read_record(&read_record_info,thd,table=tables[0].table, NULL, NULL,
1,0, FALSE))
DBUG_RETURN(1);
while (!(read_record_info.read_record(&read_record_info)))
while (!(read_record_info.read_record()))
{
/* return_val is already TRUE, so no need to set */
if ((get_server_from_table_to_cache(table)))

View File

@ -9727,7 +9727,7 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to,
thd->progress.max_counter= from->file->records();
time_to_report_progress= MY_HOW_OFTEN_TO_WRITE/10;
while (!(error=info.read_record(&info)))
while (!(error= info.read_record()))
{
if (thd->killed)
{

View File

@ -189,7 +189,7 @@ void udf_init()
}
table->use_all_columns();
while (!(error= read_record_info.read_record(&read_record_info)))
while (!(error= read_record_info.read_record()))
{
DBUG_PRINT("info",("init udf record"));
LEX_CSTRING name;

View File

@ -616,7 +616,7 @@ int mysql_update(THD *thd,
THD_STAGE_INFO(thd, stage_searching_rows_for_update);
ha_rows tmp_limit= limit;
while (!(error=info.read_record(&info)) && !thd->killed)
while (!(error=info.read_record()) && !thd->killed)
{
explain->buf_tracker.on_record_read();
thd->inc_examined_row_count(1);
@ -732,7 +732,7 @@ int mysql_update(THD *thd,
can_compare_record= records_are_comparable(table);
explain->tracker.on_scan_init();
while (!(error=info.read_record(&info)) && !thd->killed)
while (!(error=info.read_record()) && !thd->killed)
{
explain->tracker.on_record_read();
thd->inc_examined_row_count(1);

View File

@ -739,7 +739,7 @@ public:
void init(READ_RECORD *info)
{
ref_length= info->ref_length;
if (info->read_record == rr_from_pointers)
if (info->read_record_func == rr_from_pointers)
{
io_cache= NULL;
cache_start= info->cache_pos;
@ -2699,7 +2699,7 @@ bool compute_window_func(THD *thd,
while (true)
{
if ((err= info.read_record(&info)))
if ((err= info.read_record()))
break; // End of file.
/* Remember current row so that we can restore it before computing

View File

@ -2688,7 +2688,7 @@ int spider_initinal_xa_recover(
FALSE);
}
SPD_INIT_ALLOC_ROOT(&mem_root, 4096, 0, MYF(MY_WME));
while ((!(read_record->read_record(read_record))) && cnt < (int) len)
while ((!(read_record->read_record())) && cnt < (int) len)
{
spider_get_sys_xid(table_xa, &xid_list[cnt], &mem_root);
cnt++;