cleanup: renames

enum_mark_columns -> enum_column_usage
mark_used_columns -> column_usage

further commits will replace MARK_COLUMN_NONE with
COLUMN_READ and COLUMN_WRITE that convey the intention
without causing columns to be marked
This commit is contained in:
Sergei Golubchik 2018-02-09 19:43:42 +01:00
parent 8cd3d2d941
commit 103715d0fa
10 changed files with 65 additions and 63 deletions

View file

@ -6214,11 +6214,11 @@ bool Item_field::fix_fields(THD *thd, Item **reference)
set_field(from_field);
}
else if (thd->mark_used_columns != MARK_COLUMNS_NONE)
else if (thd->column_usage != MARK_COLUMNS_NONE)
{
TABLE *table= field->table;
MY_BITMAP *current_bitmap, *other_bitmap;
if (thd->mark_used_columns == MARK_COLUMNS_READ)
if (thd->column_usage == MARK_COLUMNS_READ)
{
current_bitmap= table->read_set;
other_bitmap= table->write_set;
@ -8947,7 +8947,7 @@ bool Item_direct_view_ref::fix_fields(THD *thd, Item **reference)
*/
Field *fld= ((Item_field*) ref_item)->field;
DBUG_ASSERT(fld && fld->table);
if (thd->mark_used_columns == MARK_COLUMNS_READ)
if (thd->column_usage == MARK_COLUMNS_READ)
bitmap_set_bit(fld->table->read_set, fld->field_index);
}
}
@ -9248,7 +9248,7 @@ bool Item_default_value::fix_fields(THD *thd, Item **items)
if (!newptr)
goto error;
fix_session_vcol_expr_for_read(thd, def_field, def_field->default_value);
if (thd->mark_used_columns != MARK_COLUMNS_NONE)
if (thd->column_usage != MARK_COLUMNS_NONE)
def_field->default_value->expr->walk(&Item::register_field_in_read_map, 1, 0);
def_field->move_field(newptr+1, def_field->maybe_null() ? newptr : 0, 1);
}
@ -9526,15 +9526,15 @@ void Item_trigger_field::setup_field(THD *thd, TABLE *table,
So instead we do it in Table_triggers_list::mark_fields_used()
method which is called during execution of these statements.
*/
enum_mark_columns save_mark_used_columns= thd->mark_used_columns;
thd->mark_used_columns= MARK_COLUMNS_NONE;
enum_column_usage saved_column_usage= thd->column_usage;
thd->column_usage= MARK_COLUMNS_NONE;
/*
Try to find field by its name and if it will be found
set field_idx properly.
*/
(void)find_field_in_table(thd, table, field_name.str, field_name.length,
0, &field_idx);
thd->mark_used_columns= save_mark_used_columns;
thd->column_usage= saved_column_usage;
triggers= table->triggers;
table_grants= table_grant_info;
}

View file

@ -5352,7 +5352,7 @@ Field *view_ref_found= (Field*) 0x2;
static void update_field_dependencies(THD *thd, Field *field, TABLE *table)
{
DBUG_ENTER("update_field_dependencies");
if (thd->mark_used_columns != MARK_COLUMNS_NONE)
if (thd->column_usage != MARK_COLUMNS_NONE)
{
MY_BITMAP *bitmap;
@ -5366,7 +5366,7 @@ static void update_field_dependencies(THD *thd, Field *field, TABLE *table)
if (field->vcol_info)
table->mark_virtual_col(field);
if (thd->mark_used_columns == MARK_COLUMNS_READ)
if (thd->column_usage == MARK_COLUMNS_READ)
bitmap= table->read_set;
else
bitmap= table->write_set;
@ -5374,13 +5374,13 @@ static void update_field_dependencies(THD *thd, Field *field, TABLE *table)
/*
The test-and-set mechanism in the bitmap is not reliable during
multi-UPDATE statements under MARK_COLUMNS_READ mode
(thd->mark_used_columns == MARK_COLUMNS_READ), as this bitmap contains
(thd->column_usage == MARK_COLUMNS_READ), as this bitmap contains
only those columns that are used in the SET clause. I.e they are being
set here. See multi_update::prepare()
*/
if (bitmap_fast_test_and_set(bitmap, field->field_index))
{
if (thd->mark_used_columns == MARK_COLUMNS_WRITE)
if (thd->column_usage == MARK_COLUMNS_WRITE)
{
DBUG_PRINT("warning", ("Found duplicated field"));
thd->dup_field= field;
@ -5834,7 +5834,7 @@ find_field_in_table_ref(THD *thd, TABLE_LIST *table_list,
fld= WRONG_GRANT;
else
#endif
if (thd->mark_used_columns != MARK_COLUMNS_NONE)
if (thd->column_usage != MARK_COLUMNS_NONE)
{
/*
Get rw_set correct for this field so that the handler
@ -5851,7 +5851,7 @@ find_field_in_table_ref(THD *thd, TABLE_LIST *table_list,
field_to_set= ((Item_field*)it)->field;
else
{
if (thd->mark_used_columns == MARK_COLUMNS_READ)
if (thd->column_usage == MARK_COLUMNS_READ)
it->walk(&Item::register_field_in_read_map, 0, 0);
else
it->walk(&Item::register_field_in_write_map, 0, 0);
@ -5863,7 +5863,7 @@ find_field_in_table_ref(THD *thd, TABLE_LIST *table_list,
{
TABLE *table= field_to_set->table;
DBUG_ASSERT(table);
if (thd->mark_used_columns == MARK_COLUMNS_READ)
if (thd->column_usage == MARK_COLUMNS_READ)
bitmap_set_bit(table->read_set, field_to_set->field_index);
else
bitmap_set_bit(table->write_set, field_to_set->field_index);
@ -7213,12 +7213,12 @@ int setup_wild(THD *thd, TABLE_LIST *tables, List<Item> &fields,
****************************************************************************/
bool setup_fields(THD *thd, Ref_ptr_array ref_pointer_array,
List<Item> &fields, enum_mark_columns mark_used_columns,
List<Item> &fields, enum_column_usage column_usage,
List<Item> *sum_func_list, List<Item> *pre_fix,
bool allow_sum_func)
{
reg2 Item *item;
enum_mark_columns save_mark_used_columns= thd->mark_used_columns;
enum_column_usage saved_column_usage= thd->column_usage;
nesting_map save_allow_sum_func= thd->lex->allow_sum_func;
List_iterator<Item> it(fields);
bool save_is_item_list_lookup;
@ -7226,8 +7226,8 @@ bool setup_fields(THD *thd, Ref_ptr_array ref_pointer_array,
DBUG_ENTER("setup_fields");
DBUG_PRINT("enter", ("ref_pointer_array: %p", ref_pointer_array.array()));
thd->mark_used_columns= mark_used_columns;
DBUG_PRINT("info", ("thd->mark_used_columns: %d", thd->mark_used_columns));
thd->column_usage= column_usage;
DBUG_PRINT("info", ("thd->column_usage: %d", thd->column_usage));
if (allow_sum_func)
thd->lex->allow_sum_func|=
(nesting_map)1 << thd->lex->current_select->nest_level;
@ -7280,8 +7280,8 @@ bool setup_fields(THD *thd, Ref_ptr_array ref_pointer_array,
{
thd->lex->current_select->is_item_list_lookup= save_is_item_list_lookup;
thd->lex->allow_sum_func= save_allow_sum_func;
thd->mark_used_columns= save_mark_used_columns;
DBUG_PRINT("info", ("thd->mark_used_columns: %d", thd->mark_used_columns));
thd->column_usage= saved_column_usage;
DBUG_PRINT("info", ("thd->column_usage: %d", thd->column_usage));
DBUG_RETURN(TRUE); /* purecov: inspected */
}
if (!ref.is_null())
@ -7308,8 +7308,8 @@ bool setup_fields(THD *thd, Ref_ptr_array ref_pointer_array,
thd->lex->current_select->cur_pos_in_select_list= UNDEF_POS;
thd->lex->allow_sum_func= save_allow_sum_func;
thd->mark_used_columns= save_mark_used_columns;
DBUG_PRINT("info", ("thd->mark_used_columns: %d", thd->mark_used_columns));
thd->column_usage= saved_column_usage;
DBUG_PRINT("info", ("thd->column_usage: %d", thd->column_usage));
DBUG_RETURN(MY_TEST(thd->is_error()));
}
@ -7992,8 +7992,8 @@ int setup_conds(THD *thd, TABLE_LIST *tables, List<TABLE_LIST> &leaves,
select_lex->is_item_list_lookup= 0;
thd->mark_used_columns= MARK_COLUMNS_READ;
DBUG_PRINT("info", ("thd->mark_used_columns: %d", thd->mark_used_columns));
thd->column_usage= MARK_COLUMNS_READ;
DBUG_PRINT("info", ("thd->column_usage: %d", thd->column_usage));
select_lex->cond_count= 0;
select_lex->between_count= 0;
select_lex->max_equal_elems= 0;

View file

@ -16,7 +16,7 @@
#ifndef SQL_BASE_INCLUDED
#define SQL_BASE_INCLUDED
#include "sql_class.h" /* enum_mark_columns */
#include "sql_class.h" /* enum_column_usage */
#include "sql_trigger.h" /* trg_event_type */
#include "mysqld.h" /* key_map */
#include "table_cache.h"
@ -159,7 +159,7 @@ void make_leaves_list(THD *thd, List<TABLE_LIST> &list, TABLE_LIST *tables,
int setup_wild(THD *thd, TABLE_LIST *tables, List<Item> &fields,
List<Item> *sum_func_list, uint wild_num);
bool setup_fields(THD *thd, Ref_ptr_array ref_pointer_array,
List<Item> &item, enum_mark_columns mark_used_columns,
List<Item> &item, enum_column_usage column_usage,
List<Item> *sum_func_list, List<Item> *pre_fix,
bool allow_sum_func);
void unfix_fields(List<Item> &items);
@ -353,13 +353,13 @@ inline TABLE_LIST *find_table_in_global_list(TABLE_LIST *table,
inline bool setup_fields_with_no_wrap(THD *thd, Ref_ptr_array ref_pointer_array,
List<Item> &item,
enum_mark_columns mark_used_columns,
enum_column_usage column_usage,
List<Item> *sum_func_list,
bool allow_sum_func)
{
bool res;
thd->lex->select_lex.no_wrap_view_item= TRUE;
res= setup_fields(thd, ref_pointer_array, item, mark_used_columns,
res= setup_fields(thd, ref_pointer_array, item, column_usage,
sum_func_list, NULL, allow_sum_func);
thd->lex->select_lex.no_wrap_view_item= FALSE;
return res;

View file

@ -3803,7 +3803,7 @@ Statement::Statement(LEX *lex_arg, MEM_ROOT *mem_root_arg,
enum enum_state state_arg, ulong id_arg)
:Query_arena(mem_root_arg, state_arg),
id(id_arg),
mark_used_columns(MARK_COLUMNS_READ),
column_usage(MARK_COLUMNS_READ),
lex(lex_arg),
db(null_clex_str)
{
@ -3820,7 +3820,7 @@ Query_arena::Type Statement::type() const
void Statement::set_statement(Statement *stmt)
{
id= stmt->id;
mark_used_columns= stmt->mark_used_columns;
column_usage= stmt->column_usage;
lex= stmt->lex;
query_string= stmt->query_string;
}

View file

@ -92,8 +92,21 @@ enum enum_slave_run_triggers_for_rbr { SLAVE_RUN_TRIGGERS_FOR_RBR_NO,
SLAVE_RUN_TRIGGERS_FOR_RBR_LOGGING};
enum enum_slave_type_conversions { SLAVE_TYPE_CONVERSIONS_ALL_LOSSY,
SLAVE_TYPE_CONVERSIONS_ALL_NON_LOSSY};
enum enum_mark_columns
/*
MARK_COLUMNS_NONE: It is unknown whether the column will be read or written
MARK_COLUMNS_READ: A column is goind to be read.
A bit in read set is set to inform handler that the field
is to be read. If field list contains duplicates, then
thd->dup_field is set to point to the last found
duplicate.
MARK_COLUMNS_WRITE: A column is going to be written to.
A bit is set in write set to inform handler that it needs
to update this field in write_row and update_row.
*/
enum enum_column_usage
{ MARK_COLUMNS_NONE, MARK_COLUMNS_READ, MARK_COLUMNS_WRITE};
enum enum_filetype { FILETYPE_CSV, FILETYPE_XML };
enum enum_binlog_row_image {
@ -1076,18 +1089,7 @@ public:
*/
ulong id;
/*
MARK_COLUMNS_NONE: Means mark_used_colums is not set and no indicator to
handler of fields used is set
MARK_COLUMNS_READ: Means a bit in read set is set to inform handler
that the field is to be read. If field list contains
duplicates, then thd->dup_field is set to point
to the last found duplicate.
MARK_COLUMNS_WRITE: Means a bit is set in write set to inform handler
that it needs to update this field in write_row
and update_row.
*/
enum enum_mark_columns mark_used_columns;
enum enum_column_usage column_usage;
LEX_CSTRING name; /* name for named prepared statements */
LEX *lex; // parse tree descriptor

View file

@ -1299,7 +1299,7 @@ static bool check_view_insertability(THD * thd, TABLE_LIST *view)
uint used_fields_buff_size= bitmap_buffer_size(table->s->fields);
uint32 *used_fields_buff= (uint32*)thd->alloc(used_fields_buff_size);
MY_BITMAP used_fields;
enum_mark_columns save_mark_used_columns= thd->mark_used_columns;
enum_column_usage saved_column_usage= thd->column_usage;
DBUG_ENTER("check_key_in_view");
if (!used_fields_buff)
@ -1315,20 +1315,20 @@ static bool check_view_insertability(THD * thd, TABLE_LIST *view)
we must not set query_id for fields as they're not
really used in this context
*/
thd->mark_used_columns= MARK_COLUMNS_NONE;
thd->column_usage= MARK_COLUMNS_NONE;
/* check simplicity and prepare unique test of view */
for (trans= trans_start; trans != trans_end; trans++)
{
if (!trans->item->fixed && trans->item->fix_fields(thd, &trans->item))
{
thd->mark_used_columns= save_mark_used_columns;
thd->column_usage= saved_column_usage;
DBUG_RETURN(TRUE);
}
Item_field *field;
/* simple SELECT list entry (field without expression) */
if (!(field= trans->item->field_for_view_update()))
{
thd->mark_used_columns= save_mark_used_columns;
thd->column_usage= saved_column_usage;
DBUG_RETURN(TRUE);
}
if (field->field->unireg_check == Field::NEXT_NUMBER)
@ -1340,7 +1340,7 @@ static bool check_view_insertability(THD * thd, TABLE_LIST *view)
*/
trans->item= field;
}
thd->mark_used_columns= save_mark_used_columns;
thd->column_usage= saved_column_usage;
/* unique test */
for (trans= trans_start; trans != trans_end; trans++)
{

View file

@ -1583,15 +1583,15 @@ bool fix_partition_func(THD *thd, TABLE *table,
{
bool result= TRUE;
partition_info *part_info= table->part_info;
enum_mark_columns save_mark_used_columns= thd->mark_used_columns;
enum_column_usage saved_column_usage= thd->column_usage;
DBUG_ENTER("fix_partition_func");
if (part_info->fixed)
{
DBUG_RETURN(FALSE);
}
thd->mark_used_columns= MARK_COLUMNS_NONE;
DBUG_PRINT("info", ("thd->mark_used_columns: %d", thd->mark_used_columns));
thd->column_usage= MARK_COLUMNS_NONE;
DBUG_PRINT("info", ("thd->column_usage: %d", thd->column_usage));
if (!is_create_table_ind ||
thd->lex->sql_command != SQLCOM_CREATE_TABLE)
@ -1756,8 +1756,8 @@ bool fix_partition_func(THD *thd, TABLE *table,
table->file->set_part_info(part_info);
result= FALSE;
end:
thd->mark_used_columns= save_mark_used_columns;
DBUG_PRINT("info", ("thd->mark_used_columns: %d", thd->mark_used_columns));
thd->column_usage= saved_column_usage;
DBUG_PRINT("info", ("thd->column_usage: %d", thd->column_usage));
DBUG_RETURN(result);
}

View file

@ -23219,7 +23219,7 @@ setup_new_fields(THD *thd, List<Item> &fields,
enum_resolution_type not_used;
DBUG_ENTER("setup_new_fields");
thd->mark_used_columns= MARK_COLUMNS_READ; // Not really needed, but...
thd->column_usage= MARK_COLUMNS_READ; // Not really needed, but...
for (; new_field ; new_field= new_field->next)
{
if ((item= find_item_in_list(*new_field->item, fields, &counter,

View file

@ -1934,19 +1934,19 @@ bool check_key_in_view(THD *thd, TABLE_LIST *view)
this operation should not have influence on Field::query_id, to avoid
marking as used fields which are not used
*/
enum_mark_columns save_mark_used_columns= thd->mark_used_columns;
thd->mark_used_columns= MARK_COLUMNS_NONE;
DBUG_PRINT("info", ("thd->mark_used_columns: %d", thd->mark_used_columns));
enum_column_usage saved_column_usage= thd->column_usage;
thd->column_usage= MARK_COLUMNS_NONE;
DBUG_PRINT("info", ("thd->column_usage: %d", thd->column_usage));
for (Field_translator *fld= trans; fld < end_of_trans; fld++)
{
if (!fld->item->fixed && fld->item->fix_fields(thd, &fld->item))
{
thd->mark_used_columns= save_mark_used_columns;
thd->column_usage= saved_column_usage;
DBUG_RETURN(TRUE);
}
}
thd->mark_used_columns= save_mark_used_columns;
DBUG_PRINT("info", ("thd->mark_used_columns: %d", thd->mark_used_columns));
thd->column_usage= saved_column_usage;
DBUG_PRINT("info", ("thd->column_usage: %d", thd->column_usage));
}
/* Loop over all keys to see if a unique-not-null key is used */
for (;key_info != key_info_end ; key_info++)

View file

@ -2858,12 +2858,12 @@ static bool fix_vcol_expr(THD *thd, Virtual_column_info *vcol)
{
DBUG_ENTER("fix_vcol_expr");
const enum enum_mark_columns save_mark_used_columns= thd->mark_used_columns;
thd->mark_used_columns= MARK_COLUMNS_NONE;
const enum enum_column_usage saved_column_usage= thd->column_usage;
thd->column_usage= MARK_COLUMNS_NONE;
int error= vcol->expr->fix_fields(thd, &vcol->expr);
thd->mark_used_columns= save_mark_used_columns;
thd->column_usage= saved_column_usage;
if (unlikely(error))
{