Skip to content

Commit 103715d

Browse files
committed
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
1 parent 8cd3d2d commit 103715d

File tree

10 files changed

+65
-63
lines changed

10 files changed

+65
-63
lines changed

sql/item.cc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6214,11 +6214,11 @@ bool Item_field::fix_fields(THD *thd, Item **reference)
62146214

62156215
set_field(from_field);
62166216
}
6217-
else if (thd->mark_used_columns != MARK_COLUMNS_NONE)
6217+
else if (thd->column_usage != MARK_COLUMNS_NONE)
62186218
{
62196219
TABLE *table= field->table;
62206220
MY_BITMAP *current_bitmap, *other_bitmap;
6221-
if (thd->mark_used_columns == MARK_COLUMNS_READ)
6221+
if (thd->column_usage == MARK_COLUMNS_READ)
62226222
{
62236223
current_bitmap= table->read_set;
62246224
other_bitmap= table->write_set;
@@ -8947,7 +8947,7 @@ bool Item_direct_view_ref::fix_fields(THD *thd, Item **reference)
89478947
*/
89488948
Field *fld= ((Item_field*) ref_item)->field;
89498949
DBUG_ASSERT(fld && fld->table);
8950-
if (thd->mark_used_columns == MARK_COLUMNS_READ)
8950+
if (thd->column_usage == MARK_COLUMNS_READ)
89518951
bitmap_set_bit(fld->table->read_set, fld->field_index);
89528952
}
89538953
}
@@ -9248,7 +9248,7 @@ bool Item_default_value::fix_fields(THD *thd, Item **items)
92489248
if (!newptr)
92499249
goto error;
92509250
fix_session_vcol_expr_for_read(thd, def_field, def_field->default_value);
9251-
if (thd->mark_used_columns != MARK_COLUMNS_NONE)
9251+
if (thd->column_usage != MARK_COLUMNS_NONE)
92529252
def_field->default_value->expr->walk(&Item::register_field_in_read_map, 1, 0);
92539253
def_field->move_field(newptr+1, def_field->maybe_null() ? newptr : 0, 1);
92549254
}
@@ -9526,15 +9526,15 @@ void Item_trigger_field::setup_field(THD *thd, TABLE *table,
95269526
So instead we do it in Table_triggers_list::mark_fields_used()
95279527
method which is called during execution of these statements.
95289528
*/
9529-
enum_mark_columns save_mark_used_columns= thd->mark_used_columns;
9530-
thd->mark_used_columns= MARK_COLUMNS_NONE;
9529+
enum_column_usage saved_column_usage= thd->column_usage;
9530+
thd->column_usage= MARK_COLUMNS_NONE;
95319531
/*
95329532
Try to find field by its name and if it will be found
95339533
set field_idx properly.
95349534
*/
95359535
(void)find_field_in_table(thd, table, field_name.str, field_name.length,
95369536
0, &field_idx);
9537-
thd->mark_used_columns= save_mark_used_columns;
9537+
thd->column_usage= saved_column_usage;
95389538
triggers= table->triggers;
95399539
table_grants= table_grant_info;
95409540
}

sql/sql_base.cc

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5352,7 +5352,7 @@ Field *view_ref_found= (Field*) 0x2;
53525352
static void update_field_dependencies(THD *thd, Field *field, TABLE *table)
53535353
{
53545354
DBUG_ENTER("update_field_dependencies");
5355-
if (thd->mark_used_columns != MARK_COLUMNS_NONE)
5355+
if (thd->column_usage != MARK_COLUMNS_NONE)
53565356
{
53575357
MY_BITMAP *bitmap;
53585358

@@ -5366,21 +5366,21 @@ static void update_field_dependencies(THD *thd, Field *field, TABLE *table)
53665366
if (field->vcol_info)
53675367
table->mark_virtual_col(field);
53685368

5369-
if (thd->mark_used_columns == MARK_COLUMNS_READ)
5369+
if (thd->column_usage == MARK_COLUMNS_READ)
53705370
bitmap= table->read_set;
53715371
else
53725372
bitmap= table->write_set;
53735373

53745374
/*
53755375
The test-and-set mechanism in the bitmap is not reliable during
53765376
multi-UPDATE statements under MARK_COLUMNS_READ mode
5377-
(thd->mark_used_columns == MARK_COLUMNS_READ), as this bitmap contains
5377+
(thd->column_usage == MARK_COLUMNS_READ), as this bitmap contains
53785378
only those columns that are used in the SET clause. I.e they are being
53795379
set here. See multi_update::prepare()
53805380
*/
53815381
if (bitmap_fast_test_and_set(bitmap, field->field_index))
53825382
{
5383-
if (thd->mark_used_columns == MARK_COLUMNS_WRITE)
5383+
if (thd->column_usage == MARK_COLUMNS_WRITE)
53845384
{
53855385
DBUG_PRINT("warning", ("Found duplicated field"));
53865386
thd->dup_field= field;
@@ -5834,7 +5834,7 @@ find_field_in_table_ref(THD *thd, TABLE_LIST *table_list,
58345834
fld= WRONG_GRANT;
58355835
else
58365836
#endif
5837-
if (thd->mark_used_columns != MARK_COLUMNS_NONE)
5837+
if (thd->column_usage != MARK_COLUMNS_NONE)
58385838
{
58395839
/*
58405840
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,
58515851
field_to_set= ((Item_field*)it)->field;
58525852
else
58535853
{
5854-
if (thd->mark_used_columns == MARK_COLUMNS_READ)
5854+
if (thd->column_usage == MARK_COLUMNS_READ)
58555855
it->walk(&Item::register_field_in_read_map, 0, 0);
58565856
else
58575857
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,
58635863
{
58645864
TABLE *table= field_to_set->table;
58655865
DBUG_ASSERT(table);
5866-
if (thd->mark_used_columns == MARK_COLUMNS_READ)
5866+
if (thd->column_usage == MARK_COLUMNS_READ)
58675867
bitmap_set_bit(table->read_set, field_to_set->field_index);
58685868
else
58695869
bitmap_set_bit(table->write_set, field_to_set->field_index);
@@ -7213,21 +7213,21 @@ int setup_wild(THD *thd, TABLE_LIST *tables, List<Item> &fields,
72137213
****************************************************************************/
72147214

72157215
bool setup_fields(THD *thd, Ref_ptr_array ref_pointer_array,
7216-
List<Item> &fields, enum_mark_columns mark_used_columns,
7216+
List<Item> &fields, enum_column_usage column_usage,
72177217
List<Item> *sum_func_list, List<Item> *pre_fix,
72187218
bool allow_sum_func)
72197219
{
72207220
reg2 Item *item;
7221-
enum_mark_columns save_mark_used_columns= thd->mark_used_columns;
7221+
enum_column_usage saved_column_usage= thd->column_usage;
72227222
nesting_map save_allow_sum_func= thd->lex->allow_sum_func;
72237223
List_iterator<Item> it(fields);
72247224
bool save_is_item_list_lookup;
72257225
bool make_pre_fix= (pre_fix && (pre_fix->elements == 0));
72267226
DBUG_ENTER("setup_fields");
72277227
DBUG_PRINT("enter", ("ref_pointer_array: %p", ref_pointer_array.array()));
72287228

7229-
thd->mark_used_columns= mark_used_columns;
7230-
DBUG_PRINT("info", ("thd->mark_used_columns: %d", thd->mark_used_columns));
7229+
thd->column_usage= column_usage;
7230+
DBUG_PRINT("info", ("thd->column_usage: %d", thd->column_usage));
72317231
if (allow_sum_func)
72327232
thd->lex->allow_sum_func|=
72337233
(nesting_map)1 << thd->lex->current_select->nest_level;
@@ -7280,8 +7280,8 @@ bool setup_fields(THD *thd, Ref_ptr_array ref_pointer_array,
72807280
{
72817281
thd->lex->current_select->is_item_list_lookup= save_is_item_list_lookup;
72827282
thd->lex->allow_sum_func= save_allow_sum_func;
7283-
thd->mark_used_columns= save_mark_used_columns;
7284-
DBUG_PRINT("info", ("thd->mark_used_columns: %d", thd->mark_used_columns));
7283+
thd->column_usage= saved_column_usage;
7284+
DBUG_PRINT("info", ("thd->column_usage: %d", thd->column_usage));
72857285
DBUG_RETURN(TRUE); /* purecov: inspected */
72867286
}
72877287
if (!ref.is_null())
@@ -7308,8 +7308,8 @@ bool setup_fields(THD *thd, Ref_ptr_array ref_pointer_array,
73087308
thd->lex->current_select->cur_pos_in_select_list= UNDEF_POS;
73097309

73107310
thd->lex->allow_sum_func= save_allow_sum_func;
7311-
thd->mark_used_columns= save_mark_used_columns;
7312-
DBUG_PRINT("info", ("thd->mark_used_columns: %d", thd->mark_used_columns));
7311+
thd->column_usage= saved_column_usage;
7312+
DBUG_PRINT("info", ("thd->column_usage: %d", thd->column_usage));
73137313
DBUG_RETURN(MY_TEST(thd->is_error()));
73147314
}
73157315

@@ -7992,8 +7992,8 @@ int setup_conds(THD *thd, TABLE_LIST *tables, List<TABLE_LIST> &leaves,
79927992

79937993
select_lex->is_item_list_lookup= 0;
79947994

7995-
thd->mark_used_columns= MARK_COLUMNS_READ;
7996-
DBUG_PRINT("info", ("thd->mark_used_columns: %d", thd->mark_used_columns));
7995+
thd->column_usage= MARK_COLUMNS_READ;
7996+
DBUG_PRINT("info", ("thd->column_usage: %d", thd->column_usage));
79977997
select_lex->cond_count= 0;
79987998
select_lex->between_count= 0;
79997999
select_lex->max_equal_elems= 0;

sql/sql_base.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#ifndef SQL_BASE_INCLUDED
1717
#define SQL_BASE_INCLUDED
1818

19-
#include "sql_class.h" /* enum_mark_columns */
19+
#include "sql_class.h" /* enum_column_usage */
2020
#include "sql_trigger.h" /* trg_event_type */
2121
#include "mysqld.h" /* key_map */
2222
#include "table_cache.h"
@@ -159,7 +159,7 @@ void make_leaves_list(THD *thd, List<TABLE_LIST> &list, TABLE_LIST *tables,
159159
int setup_wild(THD *thd, TABLE_LIST *tables, List<Item> &fields,
160160
List<Item> *sum_func_list, uint wild_num);
161161
bool setup_fields(THD *thd, Ref_ptr_array ref_pointer_array,
162-
List<Item> &item, enum_mark_columns mark_used_columns,
162+
List<Item> &item, enum_column_usage column_usage,
163163
List<Item> *sum_func_list, List<Item> *pre_fix,
164164
bool allow_sum_func);
165165
void unfix_fields(List<Item> &items);
@@ -353,13 +353,13 @@ inline TABLE_LIST *find_table_in_global_list(TABLE_LIST *table,
353353

354354
inline bool setup_fields_with_no_wrap(THD *thd, Ref_ptr_array ref_pointer_array,
355355
List<Item> &item,
356-
enum_mark_columns mark_used_columns,
356+
enum_column_usage column_usage,
357357
List<Item> *sum_func_list,
358358
bool allow_sum_func)
359359
{
360360
bool res;
361361
thd->lex->select_lex.no_wrap_view_item= TRUE;
362-
res= setup_fields(thd, ref_pointer_array, item, mark_used_columns,
362+
res= setup_fields(thd, ref_pointer_array, item, column_usage,
363363
sum_func_list, NULL, allow_sum_func);
364364
thd->lex->select_lex.no_wrap_view_item= FALSE;
365365
return res;

sql/sql_class.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3803,7 +3803,7 @@ Statement::Statement(LEX *lex_arg, MEM_ROOT *mem_root_arg,
38033803
enum enum_state state_arg, ulong id_arg)
38043804
:Query_arena(mem_root_arg, state_arg),
38053805
id(id_arg),
3806-
mark_used_columns(MARK_COLUMNS_READ),
3806+
column_usage(MARK_COLUMNS_READ),
38073807
lex(lex_arg),
38083808
db(null_clex_str)
38093809
{
@@ -3820,7 +3820,7 @@ Query_arena::Type Statement::type() const
38203820
void Statement::set_statement(Statement *stmt)
38213821
{
38223822
id= stmt->id;
3823-
mark_used_columns= stmt->mark_used_columns;
3823+
column_usage= stmt->column_usage;
38243824
lex= stmt->lex;
38253825
query_string= stmt->query_string;
38263826
}

sql/sql_class.h

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,21 @@ enum enum_slave_run_triggers_for_rbr { SLAVE_RUN_TRIGGERS_FOR_RBR_NO,
9292
SLAVE_RUN_TRIGGERS_FOR_RBR_LOGGING};
9393
enum enum_slave_type_conversions { SLAVE_TYPE_CONVERSIONS_ALL_LOSSY,
9494
SLAVE_TYPE_CONVERSIONS_ALL_NON_LOSSY};
95-
enum enum_mark_columns
95+
96+
/*
97+
MARK_COLUMNS_NONE: It is unknown whether the column will be read or written
98+
MARK_COLUMNS_READ: A column is goind to be read.
99+
A bit in read set is set to inform handler that the field
100+
is to be read. If field list contains duplicates, then
101+
thd->dup_field is set to point to the last found
102+
duplicate.
103+
MARK_COLUMNS_WRITE: A column is going to be written to.
104+
A bit is set in write set to inform handler that it needs
105+
to update this field in write_row and update_row.
106+
*/
107+
enum enum_column_usage
96108
{ MARK_COLUMNS_NONE, MARK_COLUMNS_READ, MARK_COLUMNS_WRITE};
109+
97110
enum enum_filetype { FILETYPE_CSV, FILETYPE_XML };
98111

99112
enum enum_binlog_row_image {
@@ -1076,18 +1089,7 @@ class Statement: public ilink, public Query_arena
10761089
*/
10771090
ulong id;
10781091

1079-
/*
1080-
MARK_COLUMNS_NONE: Means mark_used_colums is not set and no indicator to
1081-
handler of fields used is set
1082-
MARK_COLUMNS_READ: Means a bit in read set is set to inform handler
1083-
that the field is to be read. If field list contains
1084-
duplicates, then thd->dup_field is set to point
1085-
to the last found duplicate.
1086-
MARK_COLUMNS_WRITE: Means a bit is set in write set to inform handler
1087-
that it needs to update this field in write_row
1088-
and update_row.
1089-
*/
1090-
enum enum_mark_columns mark_used_columns;
1092+
enum enum_column_usage column_usage;
10911093

10921094
LEX_CSTRING name; /* name for named prepared statements */
10931095
LEX *lex; // parse tree descriptor

sql/sql_insert.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,7 +1299,7 @@ static bool check_view_insertability(THD * thd, TABLE_LIST *view)
12991299
uint used_fields_buff_size= bitmap_buffer_size(table->s->fields);
13001300
uint32 *used_fields_buff= (uint32*)thd->alloc(used_fields_buff_size);
13011301
MY_BITMAP used_fields;
1302-
enum_mark_columns save_mark_used_columns= thd->mark_used_columns;
1302+
enum_column_usage saved_column_usage= thd->column_usage;
13031303
DBUG_ENTER("check_key_in_view");
13041304

13051305
if (!used_fields_buff)
@@ -1315,20 +1315,20 @@ static bool check_view_insertability(THD * thd, TABLE_LIST *view)
13151315
we must not set query_id for fields as they're not
13161316
really used in this context
13171317
*/
1318-
thd->mark_used_columns= MARK_COLUMNS_NONE;
1318+
thd->column_usage= MARK_COLUMNS_NONE;
13191319
/* check simplicity and prepare unique test of view */
13201320
for (trans= trans_start; trans != trans_end; trans++)
13211321
{
13221322
if (!trans->item->fixed && trans->item->fix_fields(thd, &trans->item))
13231323
{
1324-
thd->mark_used_columns= save_mark_used_columns;
1324+
thd->column_usage= saved_column_usage;
13251325
DBUG_RETURN(TRUE);
13261326
}
13271327
Item_field *field;
13281328
/* simple SELECT list entry (field without expression) */
13291329
if (!(field= trans->item->field_for_view_update()))
13301330
{
1331-
thd->mark_used_columns= save_mark_used_columns;
1331+
thd->column_usage= saved_column_usage;
13321332
DBUG_RETURN(TRUE);
13331333
}
13341334
if (field->field->unireg_check == Field::NEXT_NUMBER)
@@ -1340,7 +1340,7 @@ static bool check_view_insertability(THD * thd, TABLE_LIST *view)
13401340
*/
13411341
trans->item= field;
13421342
}
1343-
thd->mark_used_columns= save_mark_used_columns;
1343+
thd->column_usage= saved_column_usage;
13441344
/* unique test */
13451345
for (trans= trans_start; trans != trans_end; trans++)
13461346
{

sql/sql_partition.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1583,15 +1583,15 @@ bool fix_partition_func(THD *thd, TABLE *table,
15831583
{
15841584
bool result= TRUE;
15851585
partition_info *part_info= table->part_info;
1586-
enum_mark_columns save_mark_used_columns= thd->mark_used_columns;
1586+
enum_column_usage saved_column_usage= thd->column_usage;
15871587
DBUG_ENTER("fix_partition_func");
15881588

15891589
if (part_info->fixed)
15901590
{
15911591
DBUG_RETURN(FALSE);
15921592
}
1593-
thd->mark_used_columns= MARK_COLUMNS_NONE;
1594-
DBUG_PRINT("info", ("thd->mark_used_columns: %d", thd->mark_used_columns));
1593+
thd->column_usage= MARK_COLUMNS_NONE;
1594+
DBUG_PRINT("info", ("thd->column_usage: %d", thd->column_usage));
15951595

15961596
if (!is_create_table_ind ||
15971597
thd->lex->sql_command != SQLCOM_CREATE_TABLE)
@@ -1756,8 +1756,8 @@ bool fix_partition_func(THD *thd, TABLE *table,
17561756
table->file->set_part_info(part_info);
17571757
result= FALSE;
17581758
end:
1759-
thd->mark_used_columns= save_mark_used_columns;
1760-
DBUG_PRINT("info", ("thd->mark_used_columns: %d", thd->mark_used_columns));
1759+
thd->column_usage= saved_column_usage;
1760+
DBUG_PRINT("info", ("thd->column_usage: %d", thd->column_usage));
17611761
DBUG_RETURN(result);
17621762
}
17631763

sql/sql_select.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23219,7 +23219,7 @@ setup_new_fields(THD *thd, List<Item> &fields,
2321923219
enum_resolution_type not_used;
2322023220
DBUG_ENTER("setup_new_fields");
2322123221

23222-
thd->mark_used_columns= MARK_COLUMNS_READ; // Not really needed, but...
23222+
thd->column_usage= MARK_COLUMNS_READ; // Not really needed, but...
2322323223
for (; new_field ; new_field= new_field->next)
2322423224
{
2322523225
if ((item= find_item_in_list(*new_field->item, fields, &counter,

sql/sql_view.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1934,19 +1934,19 @@ bool check_key_in_view(THD *thd, TABLE_LIST *view)
19341934
this operation should not have influence on Field::query_id, to avoid
19351935
marking as used fields which are not used
19361936
*/
1937-
enum_mark_columns save_mark_used_columns= thd->mark_used_columns;
1938-
thd->mark_used_columns= MARK_COLUMNS_NONE;
1939-
DBUG_PRINT("info", ("thd->mark_used_columns: %d", thd->mark_used_columns));
1937+
enum_column_usage saved_column_usage= thd->column_usage;
1938+
thd->column_usage= MARK_COLUMNS_NONE;
1939+
DBUG_PRINT("info", ("thd->column_usage: %d", thd->column_usage));
19401940
for (Field_translator *fld= trans; fld < end_of_trans; fld++)
19411941
{
19421942
if (!fld->item->fixed && fld->item->fix_fields(thd, &fld->item))
19431943
{
1944-
thd->mark_used_columns= save_mark_used_columns;
1944+
thd->column_usage= saved_column_usage;
19451945
DBUG_RETURN(TRUE);
19461946
}
19471947
}
1948-
thd->mark_used_columns= save_mark_used_columns;
1949-
DBUG_PRINT("info", ("thd->mark_used_columns: %d", thd->mark_used_columns));
1948+
thd->column_usage= saved_column_usage;
1949+
DBUG_PRINT("info", ("thd->column_usage: %d", thd->column_usage));
19501950
}
19511951
/* Loop over all keys to see if a unique-not-null key is used */
19521952
for (;key_info != key_info_end ; key_info++)

sql/table.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2858,12 +2858,12 @@ static bool fix_vcol_expr(THD *thd, Virtual_column_info *vcol)
28582858
{
28592859
DBUG_ENTER("fix_vcol_expr");
28602860

2861-
const enum enum_mark_columns save_mark_used_columns= thd->mark_used_columns;
2862-
thd->mark_used_columns= MARK_COLUMNS_NONE;
2861+
const enum enum_column_usage saved_column_usage= thd->column_usage;
2862+
thd->column_usage= MARK_COLUMNS_NONE;
28632863

28642864
int error= vcol->expr->fix_fields(thd, &vcol->expr);
28652865

2866-
thd->mark_used_columns= save_mark_used_columns;
2866+
thd->column_usage= saved_column_usage;
28672867

28682868
if (unlikely(error))
28692869
{

0 commit comments

Comments
 (0)