Skip to content

Commit

Permalink
simplify READ_RECORD usage NFC
Browse files Browse the repository at this point in the history
READ_RECORD read_record;
...
// this
// read_record.read_record(&read_record);
// becomes just
read_record.read_record();
  • Loading branch information
kevgs authored and svoj committed Aug 31, 2017
1 parent e105159 commit 5dd8e1b
Show file tree
Hide file tree
Showing 19 changed files with 64 additions and 62 deletions.
4 changes: 2 additions & 2 deletions sql/event_db_repository.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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]);

Expand Down
2 changes: 1 addition & 1 deletion sql/events.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions sql/item_subselect.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) &&
Expand Down
4 changes: 2 additions & 2 deletions sql/opt_range.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion sql/opt_subselect.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
26 changes: 13 additions & 13 deletions sql/records.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)
{
Expand All @@ -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)))
{
Expand All @@ -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 */
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion sql/records.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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:
Expand Down
10 changes: 5 additions & 5 deletions sql/sql_acl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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()));
Expand Down
6 changes: 3 additions & 3 deletions sql/sql_delete.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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)
Expand Down Expand Up @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions sql/sql_help.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions sql/sql_join_cache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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++;
Expand Down
2 changes: 1 addition & 1 deletion sql/sql_plugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading

0 comments on commit 5dd8e1b

Please sign in to comment.