Changed field_index to use field_index_t instead of uint16

This commit is contained in:
Monty 2020-08-14 11:28:39 +03:00 committed by Sergei Golubchik
parent 00d13069dd
commit 963e5e406d
10 changed files with 42 additions and 36 deletions

View file

@ -828,10 +828,10 @@ public:
utype unireg_check;
field_visibility_t invisible;
uint32 field_length; // Length of field
uint32 flags;
uint16 field_index; // field number in fields array
uchar null_bit; // Bit used to test null bit
uint32 field_length; // Length of field
uint32 flags;
field_index_t field_index; // field number in fields array
uchar null_bit; // Bit used to test null bit
/**
If true, this field was created in create_tmp_field_from_item from a NULL

View file

@ -3277,7 +3277,7 @@ public:
}
};
#define NO_CACHED_FIELD_INDEX ((uint16) ~0)
#define NO_CACHED_FIELD_INDEX ((field_index_t) ~0U)
class st_select_lex;
@ -3354,7 +3354,7 @@ public:
stmts for speeding up their re-execution. Holds NO_CACHED_FIELD_INDEX
if index value is not known.
*/
uint16 cached_field_index;
field_index_t cached_field_index;
/*
Some Items resolved in another select should not be marked as dependency
of the subquery where they are. During normal name resolution, we check
@ -6752,7 +6752,7 @@ public:
enum __attribute__((packed)) row_version_type {OLD_ROW, NEW_ROW};
row_version_type row_version;
/* Index of the field in the TABLE::field array */
uint16 field_idx;
field_index_t field_idx;
private:
/*

View file

@ -11670,8 +11670,8 @@ static bool is_key_scan_ror(PARAM *param, uint keynr, uint8 nparts)
for (KEY_PART_INFO *kp= table_key->key_part; kp < key_part; kp++)
{
uint16 fieldnr= param->table->key_info[keynr].
key_part[kp - table_key->key_part].fieldnr - 1;
field_index_t fieldnr= (param->table->key_info[keynr].
key_part[kp - table_key->key_part].fieldnr - 1);
if (param->table->field[fieldnr]->key_length() != kp->length)
return FALSE;
}

View file

@ -6982,7 +6982,7 @@ int mysql_table_grant(THD *thd, TABLE_LIST *table_list,
while ((column = column_iter++))
{
uint16 unused_field_idx= NO_CACHED_FIELD_INDEX;
field_index_t unused_field_idx= NO_CACHED_FIELD_INDEX;
TABLE_LIST *dummy;
Field *f=find_field_in_table_ref(thd, table_list, column->column.ptr(),
column->column.length(),

View file

@ -6014,10 +6014,10 @@ find_field_in_natural_join(THD *thd, TABLE_LIST *table_ref, const char *name, si
Field *
find_field_in_table(THD *thd, TABLE *table, const char *name, size_t length,
bool allow_rowid, uint16 *cached_field_index_ptr)
bool allow_rowid, field_index_t *cached_field_index_ptr)
{
Field *field;
uint16 cached_field_index= *cached_field_index_ptr;
field_index_t cached_field_index= *cached_field_index_ptr;
DBUG_ENTER("find_field_in_table");
DBUG_PRINT("enter", ("table: '%s', field name: '%s'", table->alias.c_ptr(),
name));
@ -6113,7 +6113,7 @@ find_field_in_table_ref(THD *thd, TABLE_LIST *table_list,
ignored_tables_list_t ignored_tables,
Item **ref,
bool check_privileges, bool allow_rowid,
uint16 *cached_field_index_ptr,
field_index_t *cached_field_index_ptr,
bool register_tree_change, TABLE_LIST **actual_table)
{
Field *fld;

View file

@ -205,11 +205,11 @@ find_field_in_table_ref(THD *thd, TABLE_LIST *table_list,
const char *table_name,
ignored_tables_list_t ignored_tables,
Item **ref, bool check_privileges, bool allow_rowid,
uint16 *cached_field_index_ptr,
field_index_t *cached_field_index_ptr,
bool register_tree_change, TABLE_LIST **actual_table);
Field *
find_field_in_table(THD *thd, TABLE *table, const char *name, size_t length,
bool allow_rowid, uint16 *cached_field_index_ptr);
bool allow_rowid, field_index_t *cached_field_index_ptr);
Field *
find_field_in_table_sef(TABLE *table, const char *name);
Item ** find_item_in_list(Item *item, List<Item> &items, uint *counter,

View file

@ -36,6 +36,9 @@ class Index_statistics;
class THD;
/* Array index type for table.field[] */
typedef uint16 field_index_t;
typedef struct st_date_time_format {
uchar positions[8];
char time_separator; /* Separator between hour and minute */
@ -82,10 +85,10 @@ typedef struct st_key_part_info { /* Info about a key part */
*/
uint16 store_length;
uint16 key_type;
uint16 fieldnr; /* Fieldnr begins counting from 1 */
field_index_t fieldnr; /* Fieldnr begins counting from 1 */
uint16 key_part_flag; /* 0 or HA_REVERSE_SORT */
uint8 type;
uint8 null_bit; /* Position to null_bit */
uint8 null_bit; /* Position to null_bit */
} KEY_PART_INFO ;
class engine_option_value;

View file

@ -115,7 +115,8 @@ static bool fix_type_pointers(const char ***typelib_value_names,
TYPELIB *point_to_type, uint types,
char *names, size_t names_length);
static uint find_field(Field **fields, uchar *record, uint start, uint length);
static field_index_t find_field(Field **fields, uchar *record, uint start,
uint length);
inline bool is_system_table_name(const char *name, size_t length);
@ -3002,10 +3003,10 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write,
{
Field *field;
if (new_field_pack_flag <= 1)
key_part->fieldnr= (uint16) find_field(share->field,
share->default_values,
(uint) key_part->offset,
(uint) key_part->length);
key_part->fieldnr= find_field(share->field,
share->default_values,
(uint) key_part->offset,
(uint) key_part->length);
if (!key_part->fieldnr)
goto err;
@ -4631,10 +4632,11 @@ fix_type_pointers(const char ***typelib_value_names,
# field number +1
*/
static uint find_field(Field **fields, uchar *record, uint start, uint length)
static field_index_t find_field(Field **fields, uchar *record, uint start,
uint length)
{
Field **field;
uint i, pos;
field_index_t i, pos;
pos= 0;
for (field= fields, i=1 ; *field ; i++,field++)

View file

@ -892,8 +892,8 @@ struct TABLE_SHARE
*/
struct period_info_t
{
uint16 start_fieldno;
uint16 end_fieldno;
field_index_t start_fieldno;
field_index_t end_fieldno;
Lex_ident name;
Lex_ident constr_name;
uint unique_keys;
@ -1909,14 +1909,14 @@ class IS_table_read_plan;
constexpr uint frm_fieldno_size= 2;
/** number of bytes used by key position number in frm */
constexpr uint frm_keyno_size= 2;
static inline uint16 read_frm_fieldno(const uchar *data)
static inline field_index_t read_frm_fieldno(const uchar *data)
{ return uint2korr(data); }
static inline void store_frm_fieldno(uchar *data, uint16 fieldno)
static inline void store_frm_fieldno(uchar *data, field_index_t fieldno)
{ int2store(data, fieldno); }
static inline uint16 read_frm_keyno(const uchar *data)
{ return uint2korr(data); }
static inline void store_frm_keyno(uchar *data, uint16 fieldno)
{ int2store(data, fieldno); }
static inline void store_frm_keyno(uchar *data, uint16 keyno)
{ int2store(data, keyno); }
static inline size_t extra2_str_size(size_t len)
{ return (len > 255 ? 3 : 1) + len; }

View file

@ -133,8 +133,9 @@ static uchar *extra2_write_index_properties(uchar *pos, const KEY *keyinfo,
return pos;
}
static uint16
get_fieldno_by_name(HA_CREATE_INFO *create_info, List<Create_field> &create_fields,
static field_index_t
get_fieldno_by_name(HA_CREATE_INFO *create_info,
List<Create_field> &create_fields,
const Lex_ident &field_name)
{
List_iterator<Create_field> it(create_fields);
@ -142,17 +143,17 @@ get_fieldno_by_name(HA_CREATE_INFO *create_info, List<Create_field> &create_fiel
DBUG_ASSERT(field_name);
for (unsigned field_no = 0; (sql_field = it++); ++field_no)
for (field_index_t field_no= 0; (sql_field = it++); ++field_no)
{
if (field_name.streq(sql_field->field_name))
{
DBUG_ASSERT(field_no <= uint16(~0U));
return uint16(field_no);
DBUG_ASSERT(field_no < NO_CACHED_FIELD_INDEX);
return field_no;
}
}
DBUG_ASSERT(0); /* Not Reachable */
return 0;
return NO_CACHED_FIELD_INDEX;
}
static inline