Skip to content

Commit 963e5e4

Browse files
montywivuvova
authored andcommitted
Changed field_index to use field_index_t instead of uint16
1 parent 00d1306 commit 963e5e4

File tree

10 files changed

+42
-36
lines changed

10 files changed

+42
-36
lines changed

sql/field.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -828,10 +828,10 @@ class Field: public Value_source
828828

829829
utype unireg_check;
830830
field_visibility_t invisible;
831-
uint32field_length; // Length of field
832-
uint32flags;
833-
uint16 field_index; // field number in fields array
834-
ucharnull_bit; // Bit used to test null bit
831+
uint32 field_length; // Length of field
832+
uint32 flags;
833+
field_index_t field_index; // field number in fields array
834+
uchar null_bit; // Bit used to test null bit
835835

836836
/**
837837
If true, this field was created in create_tmp_field_from_item from a NULL

sql/item.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3277,7 +3277,7 @@ class Item_num: public Item_literal
32773277
}
32783278
};
32793279

3280-
#define NO_CACHED_FIELD_INDEX ((uint16) ~0)
3280+
#define NO_CACHED_FIELD_INDEX ((field_index_t) ~0U)
32813281

32823282
class st_select_lex;
32833283

@@ -3354,7 +3354,7 @@ class Item_ident :public Item_result_field
33543354
stmts for speeding up their re-execution. Holds NO_CACHED_FIELD_INDEX
33553355
if index value is not known.
33563356
*/
3357-
uint16 cached_field_index;
3357+
field_index_t cached_field_index;
33583358
/*
33593359
Some Items resolved in another select should not be marked as dependency
33603360
of the subquery where they are. During normal name resolution, we check
@@ -6752,7 +6752,7 @@ class Item_trigger_field : public Item_field,
67526752
enum __attribute__((packed)) row_version_type {OLD_ROW, NEW_ROW};
67536753
row_version_type row_version;
67546754
/* Index of the field in the TABLE::field array */
6755-
uint16 field_idx;
6755+
field_index_t field_idx;
67566756

67576757
private:
67586758
/*

sql/opt_range.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11670,8 +11670,8 @@ static bool is_key_scan_ror(PARAM *param, uint keynr, uint8 nparts)
1167011670

1167111671
for (KEY_PART_INFO *kp= table_key->key_part; kp < key_part; kp++)
1167211672
{
11673-
uint16 fieldnr= param->table->key_info[keynr].
11674-
key_part[kp - table_key->key_part].fieldnr - 1;
11673+
field_index_t fieldnr= (param->table->key_info[keynr].
11674+
key_part[kp - table_key->key_part].fieldnr - 1);
1167511675
if (param->table->field[fieldnr]->key_length() != kp->length)
1167611676
return FALSE;
1167711677
}

sql/sql_acl.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6982,7 +6982,7 @@ int mysql_table_grant(THD *thd, TABLE_LIST *table_list,
69826982

69836983
while ((column = column_iter++))
69846984
{
6985-
uint16 unused_field_idx= NO_CACHED_FIELD_INDEX;
6985+
field_index_t unused_field_idx= NO_CACHED_FIELD_INDEX;
69866986
TABLE_LIST *dummy;
69876987
Field *f=find_field_in_table_ref(thd, table_list, column->column.ptr(),
69886988
column->column.length(),

sql/sql_base.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6014,10 +6014,10 @@ find_field_in_natural_join(THD *thd, TABLE_LIST *table_ref, const char *name, si
60146014

60156015
Field *
60166016
find_field_in_table(THD *thd, TABLE *table, const char *name, size_t length,
6017-
bool allow_rowid, uint16 *cached_field_index_ptr)
6017+
bool allow_rowid, field_index_t *cached_field_index_ptr)
60186018
{
60196019
Field *field;
6020-
uint16 cached_field_index= *cached_field_index_ptr;
6020+
field_index_t cached_field_index= *cached_field_index_ptr;
60216021
DBUG_ENTER("find_field_in_table");
60226022
DBUG_PRINT("enter", ("table: '%s', field name: '%s'", table->alias.c_ptr(),
60236023
name));
@@ -6113,7 +6113,7 @@ find_field_in_table_ref(THD *thd, TABLE_LIST *table_list,
61136113
ignored_tables_list_t ignored_tables,
61146114
Item **ref,
61156115
bool check_privileges, bool allow_rowid,
6116-
uint16 *cached_field_index_ptr,
6116+
field_index_t *cached_field_index_ptr,
61176117
bool register_tree_change, TABLE_LIST **actual_table)
61186118
{
61196119
Field *fld;

sql/sql_base.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,11 +205,11 @@ find_field_in_table_ref(THD *thd, TABLE_LIST *table_list,
205205
const char *table_name,
206206
ignored_tables_list_t ignored_tables,
207207
Item **ref, bool check_privileges, bool allow_rowid,
208-
uint16 *cached_field_index_ptr,
208+
field_index_t *cached_field_index_ptr,
209209
bool register_tree_change, TABLE_LIST **actual_table);
210210
Field *
211211
find_field_in_table(THD *thd, TABLE *table, const char *name, size_t length,
212-
bool allow_rowid, uint16 *cached_field_index_ptr);
212+
bool allow_rowid, field_index_t *cached_field_index_ptr);
213213
Field *
214214
find_field_in_table_sef(TABLE *table, const char *name);
215215
Item ** find_item_in_list(Item *item, List<Item> &items, uint *counter,

sql/structs.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ class Index_statistics;
3636

3737
class THD;
3838

39+
/* Array index type for table.field[] */
40+
typedef uint16 field_index_t;
41+
3942
typedef struct st_date_time_format {
4043
uchar positions[8];
4144
char time_separator;/* Separator between hour and minute */
@@ -82,10 +85,10 @@ typedef struct st_key_part_info { /* Info about a key part */
8285
*/
8386
uint16 store_length;
8487
uint16 key_type;
85-
uint16 fieldnr; /* Fieldnr begins counting from 1 */
88+
field_index_t fieldnr; /* Fieldnr begins counting from 1 */
8689
uint16 key_part_flag; /* 0 or HA_REVERSE_SORT */
8790
uint8 type;
88-
uint8 null_bit;/* Position to null_bit */
91+
uint8 null_bit; /* Position to null_bit */
8992
} KEY_PART_INFO ;
9093

9194
class engine_option_value;

sql/table.cc

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ static bool fix_type_pointers(const char ***typelib_value_names,
115115
TYPELIB *point_to_type, uint types,
116116
char *names, size_t names_length);
117117

118-
static uint find_field(Field **fields, uchar *record, uint start, uint length);
118+
static field_index_t find_field(Field **fields, uchar *record, uint start,
119+
uint length);
119120

120121
inline bool is_system_table_name(const char *name, size_t length);
121122

@@ -3002,10 +3003,10 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write,
30023003
{
30033004
Field *field;
30043005
if (new_field_pack_flag <= 1)
3005-
key_part->fieldnr= (uint16) find_field(share->field,
3006-
share->default_values,
3007-
(uint) key_part->offset,
3008-
(uint) key_part->length);
3006+
key_part->fieldnr= find_field(share->field,
3007+
share->default_values,
3008+
(uint) key_part->offset,
3009+
(uint) key_part->length);
30093010
if (!key_part->fieldnr)
30103011
goto err;
30113012

@@ -4631,10 +4632,11 @@ fix_type_pointers(const char ***typelib_value_names,
46314632
# field number +1
46324633
*/
46334634

4634-
static uint find_field(Field **fields, uchar *record, uint start, uint length)
4635+
static field_index_t find_field(Field **fields, uchar *record, uint start,
4636+
uint length)
46354637
{
46364638
Field **field;
4637-
uint i, pos;
4639+
field_index_t i, pos;
46384640

46394641
pos= 0;
46404642
for (field= fields, i=1 ; *field ; i++,field++)

sql/table.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -892,8 +892,8 @@ struct TABLE_SHARE
892892
*/
893893
struct period_info_t
894894
{
895-
uint16 start_fieldno;
896-
uint16 end_fieldno;
895+
field_index_t start_fieldno;
896+
field_index_t end_fieldno;
897897
Lex_ident name;
898898
Lex_ident constr_name;
899899
uint unique_keys;
@@ -1909,14 +1909,14 @@ class IS_table_read_plan;
19091909
constexpr uint frm_fieldno_size= 2;
19101910
/** number of bytes used by key position number in frm */
19111911
constexpr uint frm_keyno_size= 2;
1912-
static inline uint16 read_frm_fieldno(const uchar *data)
1912+
static inline field_index_t read_frm_fieldno(const uchar *data)
19131913
{ return uint2korr(data); }
1914-
static inline void store_frm_fieldno(uchar *data, uint16 fieldno)
1914+
static inline void store_frm_fieldno(uchar *data, field_index_t fieldno)
19151915
{ int2store(data, fieldno); }
19161916
static inline uint16 read_frm_keyno(const uchar *data)
19171917
{ return uint2korr(data); }
1918-
static inline void store_frm_keyno(uchar *data, uint16 fieldno)
1919-
{ int2store(data, fieldno); }
1918+
static inline void store_frm_keyno(uchar *data, uint16 keyno)
1919+
{ int2store(data, keyno); }
19201920
static inline size_t extra2_str_size(size_t len)
19211921
{ return (len > 255 ? 3 : 1) + len; }
19221922

sql/unireg.cc

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -133,26 +133,27 @@ static uchar *extra2_write_index_properties(uchar *pos, const KEY *keyinfo,
133133
return pos;
134134
}
135135

136-
static uint16
137-
get_fieldno_by_name(HA_CREATE_INFO *create_info, List<Create_field> &create_fields,
136+
static field_index_t
137+
get_fieldno_by_name(HA_CREATE_INFO *create_info,
138+
List<Create_field> &create_fields,
138139
const Lex_ident &field_name)
139140
{
140141
List_iterator<Create_field> it(create_fields);
141142
Create_field *sql_field = NULL;
142143

143144
DBUG_ASSERT(field_name);
144145

145-
for (unsigned field_no = 0; (sql_field = it++); ++field_no)
146+
for (field_index_t field_no= 0; (sql_field = it++); ++field_no)
146147
{
147148
if (field_name.streq(sql_field->field_name))
148149
{
149-
DBUG_ASSERT(field_no <= uint16(~0U));
150-
return uint16(field_no);
150+
DBUG_ASSERT(field_no < NO_CACHED_FIELD_INDEX);
151+
return field_no;
151152
}
152153
}
153154

154155
DBUG_ASSERT(0); /* Not Reachable */
155-
return 0;
156+
return NO_CACHED_FIELD_INDEX;
156157
}
157158

158159
static inline

0 commit comments

Comments
 (0)