diff --git a/sql/field.cc b/sql/field.cc index a46517241e3..82e9966af51 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -1836,12 +1836,12 @@ String *Field::val_int_as_str(String *val_buffer, bool unsigned_val) Field::Field(uchar *ptr_arg,uint32 length_arg,uchar *null_ptr_arg, uchar null_bit_arg, utype unireg_check_arg, const LEX_CSTRING *field_name_arg) - :ptr(ptr_arg), invisible(VISIBLE), + :ptr(ptr_arg), null_ptr(null_ptr_arg), table(0), orig_table(0), table_name(0), field_name(*field_name_arg), option_list(0), option_struct(0), key_start(0), part_of_key(0), part_of_key_not_clustered(0), part_of_sortkey(0), - unireg_check(unireg_check_arg), field_length(length_arg), + unireg_check(unireg_check_arg), invisible(VISIBLE), field_length(length_arg), null_bit(null_bit_arg), is_created_from_null_item(FALSE), read_stats(NULL), collected_stats(0), vcol_info(0), check_constraint(0), default_value(0) @@ -10740,24 +10740,24 @@ bool Field_vers_trx_id::test_if_equality_guarantees_uniqueness(const Item* item) Column_definition_attributes::Column_definition_attributes(const Field *field) :length(field->character_octet_length() / field->charset()->mbmaxlen), - decimals(field->decimals()), - unireg_check(field->unireg_check), interval(NULL), charset(field->charset()), // May be NULL ptr srid(0), - pack_flag(0) + pack_flag(0), + decimals(field->decimals()), + unireg_check(field->unireg_check) {} Column_definition_attributes:: Column_definition_attributes(const Type_all_attributes &attr) :length(attr.max_length), - decimals(attr.decimals), - unireg_check(Field::NONE), interval(attr.get_typelib()), charset(attr.collation.collation), srid(0), - pack_flag(attr.unsigned_flag ? 0 : FIELDFLAG_DECIMAL) + pack_flag(attr.unsigned_flag ? 0 : FIELDFLAG_DECIMAL), + decimals(attr.decimals), + unireg_check(Field::NONE) {} diff --git a/sql/field.h b/sql/field.h index b14440d9fc6..555ecf16ce4 100644 --- a/sql/field.h +++ b/sql/field.h @@ -648,76 +648,76 @@ public: SIGN_UNSIGNED, SIGN_NOT_APPLICABLE // for non-numeric types }; - uchar m_type_code; // according to Field::binlog_type() /** Retrieve the field metadata for fields. */ - uint16 m_metadata; - uint8 m_metadata_size; - binlog_sign_t m_signedness; CHARSET_INFO *m_cs; // NULL if not relevant TYPELIB *m_enum_typelib; // NULL if not relevant TYPELIB *m_set_typelib; // NULL if not relevant + binlog_sign_t m_signedness; + uint16 m_metadata; + uint8 m_metadata_size; + uchar m_type_code; // according to Field::binlog_type() uchar m_geom_type; // Non-geometry fields can return 0 + Binlog_type_info(uchar type_code, uint16 metadata, uint8 metadata_size) - :m_type_code(type_code), - m_metadata(metadata), - m_metadata_size(metadata_size), - m_signedness(SIGN_NOT_APPLICABLE), - m_cs(NULL), + :m_cs(NULL), m_enum_typelib(NULL), m_set_typelib(NULL), + m_signedness(SIGN_NOT_APPLICABLE), + m_metadata(metadata), + m_metadata_size(metadata_size), + m_type_code(type_code), m_geom_type(0) {}; Binlog_type_info(uchar type_code, uint16 metadata, uint8 metadata_size, binlog_sign_t signedness) - :m_type_code(type_code), - m_metadata(metadata), - m_metadata_size(metadata_size), - m_signedness(signedness), - m_cs(NULL), + : m_cs(NULL), m_enum_typelib(NULL), m_set_typelib(NULL), + m_signedness(signedness), + m_metadata(metadata), + m_metadata_size(metadata_size), + m_type_code(type_code), m_geom_type(0) {}; Binlog_type_info(uchar type_code, uint16 metadata, - uint8 metadata_size, - CHARSET_INFO *cs) - :m_type_code(type_code), - m_metadata(metadata), - m_metadata_size(metadata_size), - m_signedness(SIGN_NOT_APPLICABLE), - m_cs(cs), + uint8 metadata_size, CHARSET_INFO *cs) + :m_cs(cs), m_enum_typelib(NULL), m_set_typelib(NULL), + m_signedness(SIGN_NOT_APPLICABLE), + m_metadata(metadata), + m_metadata_size(metadata_size), + m_type_code(type_code), m_geom_type(0) {}; Binlog_type_info(uchar type_code, uint16 metadata, uint8 metadata_size, CHARSET_INFO *cs, TYPELIB *t_enum, TYPELIB *t_set) - :m_type_code(type_code), - m_metadata(metadata), - m_metadata_size(metadata_size), - m_signedness(SIGN_NOT_APPLICABLE), - m_cs(cs), + :m_cs(cs), m_enum_typelib(t_enum), m_set_typelib(t_set), + m_signedness(SIGN_NOT_APPLICABLE), + m_metadata(metadata), + m_metadata_size(metadata_size), + m_type_code(type_code), m_geom_type(0) {}; Binlog_type_info(uchar type_code, uint16 metadata, uint8 metadata_size, CHARSET_INFO *cs, uchar geom_type) - :m_type_code(type_code), - m_metadata(metadata), - m_metadata_size(metadata_size), - m_signedness(SIGN_NOT_APPLICABLE), - m_cs(cs), + :m_cs(cs), m_enum_typelib(NULL), m_set_typelib(NULL), + m_signedness(SIGN_NOT_APPLICABLE), + m_metadata(metadata), + m_metadata_size(metadata_size), + m_type_code(type_code), m_geom_type(geom_type) {}; static void *operator new(size_t size, MEM_ROOT *mem_root) throw () @@ -781,7 +781,6 @@ public: uchar *ptr; // Position to field in record - field_visibility_t invisible; /** Byte where the @c NULL bit is stored inside a record. If this Field is a @c NOT @c NULL field, this member is @c NULL. @@ -816,7 +815,7 @@ public: in more clean way with transition to new text based .frm format. See also comment for Field_timestamp::Field_timestamp(). */ - enum utype { + enum __attribute__((packed)) utype { NONE=0, NEXT_NUMBER=15, // AUTO_INCREMENT TIMESTAMP_OLD_FIELD=18, // TIMESTAMP created before 4.1.3 @@ -827,11 +826,13 @@ public: }; enum imagetype { itRAW, itMBR}; - utype unireg_check; - uint32 field_length; // Length of field + 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 + uint16 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 value. This means that the type of the field is just a guess, and the type @@ -2336,7 +2337,7 @@ class Field_new_decimal final :public Field_num { public: /* The maximum number of decimal digits can be stored */ decimal_digits_t precision; - uint bin_size; + uint32 bin_size; /* Constructors take max_length of the field as a parameter - not the precision as the number of decimal digits allowed. @@ -2422,7 +2423,7 @@ public: return Information_schema_numeric_attributes(precision, dec); } uint size_of() const override { return sizeof *this; } - uint32 pack_length() const override { return (uint32) bin_size; } + uint32 pack_length() const override { return bin_size; } uint pack_length_from_metadata(uint field_metadata) const override; uint row_pack_length() const override { return pack_length(); } bool compatible_field_size(uint field_metadata, const Relay_log_info *rli, @@ -5107,20 +5108,20 @@ public: max number of characters. */ ulonglong length; - decimal_digits_t decimals; - Field::utype unireg_check; - const TYPELIB *interval; // Which interval to use + const TYPELIB *interval; CHARSET_INFO *charset; uint32 srid; - uint pack_flag; + uint32 pack_flag; + decimal_digits_t decimals; + Field::utype unireg_check; Column_definition_attributes() :length(0), - decimals(0), - unireg_check(Field::NONE), interval(NULL), charset(&my_charset_bin), srid(0), - pack_flag(0) + pack_flag(0), + decimals(0), + unireg_check(Field::NONE) { } Column_definition_attributes(const Field *field); Column_definition_attributes(const Type_all_attributes &attr); diff --git a/sql/item.cc b/sql/item.cc index e14c8029573..9071455afc4 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -410,14 +410,14 @@ int Item::save_str_value_in_field(Field *field, String *result) Item::Item(THD *thd): - is_expensive_cache(-1), rsize(0), name(null_clex_str), orig_name(0), - common_flags(IS_AUTO_GENERATED_NAME) + name(null_clex_str), orig_name(0), is_expensive_cache(-1) { DBUG_ASSERT(thd); + common_flags= IS_AUTO_GENERATED_NAME; marker= 0; - maybe_null= null_value= with_window_func= with_field= false; - in_rollup= 0; - with_param= 0; + maybe_null= with_window_func= with_field= in_rollup= with_param= 0; + fixed= 1; // Simple Item's doesn't have to be fixed + null_value= 0; /* Initially this item is not attached to any JOIN_TAB. */ join_tab_idx= MAX_TABLES; @@ -444,13 +444,13 @@ Item::Item(THD *thd): */ Item::Item(): - is_expensive_cache(-1), name(null_clex_str), orig_name(0) + name(null_clex_str), orig_name(0), is_expensive_cache(-1) { DBUG_ASSERT(my_progname == NULL); // before main() marker= 0; - maybe_null= null_value= with_window_func= with_field= false; - in_rollup= 0; - with_param= 0; + maybe_null= with_window_func= with_field= in_rollup= with_param= 0; + fixed= 1; + null_value= 0; join_tab_idx= MAX_TABLES; } @@ -473,20 +473,19 @@ const TABLE_SHARE *Item::field_table_or_null() */ Item::Item(THD *thd, Item *item): Type_all_attributes(*item), - join_tab_idx(item->join_tab_idx), - is_expensive_cache(-1), - rsize(0), str_value(item->str_value), name(item->name), orig_name(item->orig_name), - marker(item->marker), maybe_null(item->maybe_null), in_rollup(item->in_rollup), - null_value(item->null_value), with_param(item->with_param), with_window_func(item->with_window_func), with_field(item->with_field), - common_flags(item->common_flags) + marker(item->marker), + null_value(item->null_value), + is_expensive_cache(-1), + common_flags(item->common_flags), + join_tab_idx(item->join_tab_idx) { next= thd->free_list; // Put in free list thd->free_list= this; @@ -655,8 +654,9 @@ Item_ident::Item_ident(THD *thd, Name_resolution_context *context_arg, orig_field_name(field_name_arg), context(context_arg), db_name(db_name_arg), table_name(table_name_arg), field_name(field_name_arg), - alias_name_used(FALSE), cached_field_index(NO_CACHED_FIELD_INDEX), - cached_table(0), depended_from(0), can_be_depended(TRUE) + cached_table(NULL), depended_from(NULL), + cached_field_index(NO_CACHED_FIELD_INDEX), + can_be_depended(TRUE), alias_name_used(FALSE) { name= field_name_arg; } @@ -671,8 +671,9 @@ Item_ident::Item_ident(THD *thd, TABLE_LIST *view_arg, context(&view_arg->view->first_select_lex()->context), db_name(null_clex_str), table_name(view_arg->alias), field_name(field_name_arg), - alias_name_used(FALSE), cached_field_index(NO_CACHED_FIELD_INDEX), - cached_table(NULL), depended_from(NULL), can_be_depended(TRUE) + cached_table(NULL), depended_from(NULL), + cached_field_index(NO_CACHED_FIELD_INDEX), + can_be_depended(TRUE), alias_name_used(FALSE) { name= field_name_arg; } @@ -691,11 +692,11 @@ Item_ident::Item_ident(THD *thd, Item_ident *item) db_name(item->db_name), table_name(item->table_name), field_name(item->field_name), - alias_name_used(item->alias_name_used), - cached_field_index(item->cached_field_index), cached_table(item->cached_table), depended_from(item->depended_from), - can_be_depended(item->can_be_depended) + cached_field_index(item->cached_field_index), + can_be_depended(item->can_be_depended), + alias_name_used(item->alias_name_used) {} void Item_ident::cleanup() @@ -6532,19 +6533,16 @@ static int save_field_in_field(Field *from, bool *null_value, DBUG_RETURN(set_field_to_null_with_conversions(to, no_conversions)); } to->set_notnull(); + (*null_value)= 0; /* If we're setting the same field as the one we're reading from there's nothing to do. This can happen in 'SET x = x' type of scenarios. */ if (to == from) - { - (*null_value)= 0; DBUG_RETURN(0); - } res= field_conv(to, from); - (*null_value)= 0; DBUG_RETURN(res); } @@ -9764,7 +9762,7 @@ bool Item_trigger_field::fix_fields(THD *thd, Item **items) /* Set field. */ - if (likely(field_idx != (uint)-1)) + if (likely(field_idx != NO_CACHED_FIELD_INDEX)) { #ifndef NO_EMBEDDED_ACCESS_CHECKS /* @@ -10122,7 +10120,7 @@ bool Item_cache_timestamp::val_native(THD *thd, Native *to) null_value= true; return true; } - return null_value= to->copy(m_native); + return (null_value= to->copy(m_native)); } diff --git a/sql/item.h b/sql/item.h index 22b6aa6656f..0686d01f655 100644 --- a/sql/item.h +++ b/sql/item.h @@ -734,20 +734,9 @@ public: #define STOP_PTR ((void *) 1) -class Item: public Value_source, +class Item :public Value_source, public Type_all_attributes { - /** - The index in the JOIN::join_tab array of the JOIN_TAB this Item is attached - to. Items are attached (or 'pushed') to JOIN_TABs during optimization by the - make_cond_for_table procedure. During query execution, this item is - evaluated when the join loop reaches the corresponding JOIN_TAB. - - If the value of join_tab_idx >= MAX_TABLES, this means that there is no - corresponding JOIN_TAB. - */ - uint join_tab_idx; - static void *operator new(size_t size); public: @@ -780,22 +769,9 @@ public: EXPR_CACHE_ITEM}; enum cond_result { COND_UNDEF,COND_OK,COND_TRUE,COND_FALSE }; - enum traverse_order { POSTFIX, PREFIX }; - - /* Cache of the result of is_expensive(). */ - int8 is_expensive_cache; - - /* Reuse size, only used by SP local variable assignment, otherwise 0 */ - uint rsize; protected: - /* - str_values's main purpose is to be used to cache the value in - save_in_field - */ - String str_value; - SEL_TREE *get_mm_tree_for_const(RANGE_OPT_PARAM *param); /** @@ -899,7 +875,7 @@ protected: const Type_handler *handler) { DBUG_ASSERT(is_fixed()); - return null_value= item->val_native_with_conversion(thd, to, handler); + return (null_value= item->val_native_with_conversion(thd, to, handler)); } my_decimal *val_decimal_from_item(Item *item, my_decimal *decimal_value) { @@ -927,9 +903,8 @@ public: const MY_LOCALE *locale_from_val_str(); - LEX_CSTRING name; /* Name of item */ - /* Original item name (if it was renamed)*/ - const char *orig_name; + /* All variables for the Item class */ + /** Intrusive list pointer for free list. If not null, points to the next Item on some Query_arena's free list. For instance, stored procedures @@ -938,18 +913,48 @@ public: @see Query_arena::free_list */ Item *next; - int marker; - bool maybe_null; /* If item may be null */ - bool in_rollup; /* If used in GROUP BY list - of a query with ROLLUP */ - bool null_value; /* if item is null */ - bool with_param; /* True if contains an SP parameter */ - bool with_window_func; /* True if item contains a window func */ - /** - True if any item except Item_sum contains a field. Set during parsing. + + /* + str_values's main purpose is to be used to cache the value in + save_in_field */ - bool with_field; - uint8 common_flags; + String str_value; + + LEX_CSTRING name; /* Name of item */ + /* Original item name (if it was renamed)*/ + const char *orig_name; + + uint32 /* All common bool variables for Item stored here */ + maybe_null:1, /* If item may be null */ + in_rollup:1, /* If used in GROUP BY list of a query with ROLLUP */ + with_param:1, /* True if Item contains an SP parameter */ + with_window_func:1, /* True if item contains a window func */ + with_field:1, /* True if any item except Item_sum contains a field. + Set during parsing. */ + fixed:1; /* If item was fixed with fix_fields */ + + int16 marker; + + /* + Tells is the val() value of the item is/was null. + This should not be part of the bit flags as it's changed a lot and also we use + pointers to it + */ + bool null_value; + /* Cache of the result of is_expensive(). */ + int8 is_expensive_cache; + uint8 common_flags; /* To be integrated into above flags soon... */ + /** + The index in the JOIN::join_tab array of the JOIN_TAB this Item is attached + to. Items are attached (or 'pushed') to JOIN_TABs during optimization by the + make_cond_for_table procedure. During query execution, this item is + evaluated when the join loop reaches the corresponding JOIN_TAB. + + If the value of join_tab_idx >= MAX_TABLES, this means that there is no + corresponding JOIN_TAB. + */ + uint8 join_tab_idx; + bool is_autogenerated_name() { return (common_flags & IS_AUTO_GENERATED_NAME); } // alloc & destruct is done as start of select on THD::mem_root @@ -1380,7 +1385,7 @@ public: * Item_func_rollup_const */ DBUG_ASSERT(0); - return null_value= true; + return (null_value= 1); } virtual bool val_native_result(THD *thd, Native *to) { @@ -2424,7 +2429,7 @@ public: Item is attached. The number is an index is depth_first_tab() traversal order. */ - virtual void set_join_tab_idx(uint join_tab_idx_arg) + virtual void set_join_tab_idx(uint8 join_tab_idx_arg) { if (join_tab_idx_arg < join_tab_idx) join_tab_idx= join_tab_idx_arg; @@ -2472,7 +2477,7 @@ public: { return marker & FULL_EXTRACTION_FL; } int get_extraction_flag() { return marker & EXTRACTION_MASK; } - void set_extraction_flag(int flags) + void set_extraction_flag(int16 flags) { marker &= ~EXTRACTION_MASK; marker|= flags; @@ -2769,13 +2774,15 @@ class Item_string; class Item_fixed_hybrid: public Item { public: - bool fixed; // If item was fixed with fix_fields -public: - Item_fixed_hybrid(THD *thd): Item(thd), fixed(false) - { } + Item_fixed_hybrid(THD *thd): Item(thd) + { + fixed= false; + } Item_fixed_hybrid(THD *thd, Item_fixed_hybrid *item) - :Item(thd, item), fixed(item->fixed) - { } + :Item(thd, item) + { + fixed= item->fixed; + } bool fix_fields(THD *thd, Item **ref) { DBUG_ASSERT(!fixed); @@ -3273,7 +3280,7 @@ public: } }; -#define NO_CACHED_FIELD_INDEX ((uint)(-1)) +#define NO_CACHED_FIELD_INDEX ((uint16) ~0) class st_select_lex; @@ -3338,13 +3345,6 @@ public: LEX_CSTRING db_name; LEX_CSTRING table_name; LEX_CSTRING field_name; - bool alias_name_used; /* true if item was resolved against alias */ - /* - Cached value of index for this field in table->field array, used by prep. - stmts for speeding up their re-execution. Holds NO_CACHED_FIELD_INDEX - if index value is not known. - */ - uint cached_field_index; /* Cached pointer to table which contains this field, used for the same reason by prep. stmt. too in case then we have not-fully qualified field. @@ -3352,6 +3352,12 @@ public: */ TABLE_LIST *cached_table; st_select_lex *depended_from; + /* + Cached value of index for this field in table->field array, used by prepared + stmts for speeding up their re-execution. Holds NO_CACHED_FIELD_INDEX + if index value is not known. + */ + uint16 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 @@ -3365,6 +3371,8 @@ public: this variable. */ bool can_be_depended; + bool alias_name_used; /* true if item was resolved against alias */ + Item_ident(THD *thd, Name_resolution_context *context_arg, const LEX_CSTRING &db_name_arg, const LEX_CSTRING &table_name_arg, const LEX_CSTRING &field_name_arg); @@ -3712,7 +3720,8 @@ public: Item_null(THD *thd, const char *name_par=0, CHARSET_INFO *cs= &my_charset_bin): Item_basic_constant(thd) { - maybe_null= null_value= TRUE; + maybe_null= TRUE; + null_value= TRUE; max_length= 0; name.str= name_par ? name_par : "NULL"; name.length= strlen(name.str); @@ -4309,7 +4318,7 @@ public: Item_bool_static(const char *str_arg, longlong i): Item_bool(str_arg, i) {}; - void set_join_tab_idx(uint join_tab_idx_arg) override + void set_join_tab_idx(uint8 join_tab_idx_arg) override { DBUG_ASSERT(0); } }; @@ -6227,7 +6236,8 @@ protected: { DBUG_ASSERT(i->is_fixed()); item= i; - null_value=maybe_null=item->maybe_null; + null_value= item->maybe_null; + maybe_null= item->maybe_null; Type_std_attributes::set(item); name= item->name; set_handler(item->type_handler()); @@ -6594,7 +6604,7 @@ public: bool get_date(THD *, MYSQL_TIME *, date_mode_t) override { DBUG_ASSERT(0); // never should be called - return null_value= true; + return (null_value= true); } bool send(Protocol *, st_value *) override { @@ -6734,25 +6744,50 @@ class Table_triggers_list; class Item_trigger_field : public Item_field, private Settable_routine_parameter { +private: + GRANT_INFO *table_grants; public: - /* Is this item represents row from NEW or OLD row ? */ - enum row_version_type {OLD_ROW, NEW_ROW}; - row_version_type row_version; /* Next in list of all Item_trigger_field's in trigger */ Item_trigger_field *next_trg_field; - /* Index of the field in the TABLE::field array */ - uint field_idx; /* Pointer to Table_trigger_list object for table of this trigger */ Table_triggers_list *triggers; + /* Is this item represents row from NEW or OLD row ? */ + 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; - Item_trigger_field(THD *thd, Name_resolution_context *context_arg, +private: + /* + Trigger field is read-only unless it belongs to the NEW row in a + BEFORE INSERT of BEFORE UPDATE trigger. + */ + bool read_only; + + /* + 'want_privilege' holds privileges required to perform operation on + this trigger field (SELECT_ACL if we are going to read it and + UPDATE_ACL if we are going to update it). It is initialized at + parse time but can be updated later if this trigger field is used + as OUT or INOUT parameter of stored routine (in this case + set_required_privilege() is called to appropriately update + want_privilege and cleanup() is responsible for restoring of + original want_privilege once parameter's value is updated). + */ + privilege_t original_privilege; + privilege_t want_privilege; +public: + +Item_trigger_field(THD *thd, Name_resolution_context *context_arg, row_version_type row_ver_arg, const LEX_CSTRING &field_name_arg, privilege_t priv, const bool ro) :Item_field(thd, context_arg, field_name_arg), - row_version(row_ver_arg), field_idx((uint)-1), original_privilege(priv), - want_privilege(priv), table_grants(NULL), read_only (ro) - {} + table_grants(NULL), next_trg_field(NULL), triggers(NULL), + row_version(row_ver_arg), field_idx(NO_CACHED_FIELD_INDEX), + read_only (ro), original_privilege(priv), want_privilege(priv) + { + } void setup_field(THD *thd, TABLE *table, GRANT_INFO *table_grant_info); Type type() const override { return TRIGGER_FIELD_ITEM; } bool eq(const Item *item, bool binary_cmp) const override; @@ -6779,25 +6814,6 @@ public: return set_value(thd, NULL, it); } -private: - /* - 'want_privilege' holds privileges required to perform operation on - this trigger field (SELECT_ACL if we are going to read it and - UPDATE_ACL if we are going to update it). It is initialized at - parse time but can be updated later if this trigger field is used - as OUT or INOUT parameter of stored routine (in this case - set_required_privilege() is called to appropriately update - want_privilege and cleanup() is responsible for restoring of - original want_privilege once parameter's value is updated). - */ - privilege_t original_privilege; - privilege_t want_privilege; - GRANT_INFO *table_grants; - /* - Trigger field is read-only unless it belongs to the NEW row in a - BEFORE INSERT of BEFORE UPDATE trigger. - */ - bool read_only; public: bool unknown_splocal_processor(void *) override { return false; } bool check_vcol_func_processor(void *arg) override; diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index d8f884145e9..2bc3475c7e0 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -381,7 +381,7 @@ public: Item *expr_cache_insert_transformer(THD *thd, uchar *unused) override; bool is_expensive_processor(void *arg) override; bool is_expensive() override; - void set_join_tab_idx(uint join_tab_idx_arg) override + void set_join_tab_idx(uint8 join_tab_idx_arg) override { args[1]->set_join_tab_idx(join_tab_idx_arg); } void get_cache_parameters(List ¶meters) override; bool is_top_level_item() const override; diff --git a/sql/item_func.h b/sql/item_func.h index 1e4788b1ff2..3fced75661d 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -3533,7 +3533,7 @@ public: { if (execute()) return true; - return null_value= sp_result_field->val_native(to); + return (null_value= sp_result_field->val_native(to)); } void update_null_value() diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 3123844865f..8b5465ffdb6 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -2474,10 +2474,12 @@ bool Item_func_current_role::fix_fields(THD *thd, Item **ref) system_charset_info)) return 1; str_value.mark_as_const(); - null_value= maybe_null= 0; + null_value= 0; + maybe_null= 0; return 0; } - null_value= maybe_null= 1; + null_value= 1; + maybe_null= 1; return 0; } diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h index 36300e57f03..70a23ebf294 100644 --- a/sql/item_strfunc.h +++ b/sql/item_strfunc.h @@ -879,7 +879,8 @@ public: bool fix_length_and_dec() { max_length= 512 * system_charset_info->mbmaxlen; - null_value= maybe_null= false; + null_value= false; + maybe_null= false; return FALSE; } Item *get_copy(THD *thd) diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 537eaaf8dcd..71759169376 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -890,7 +890,8 @@ bool Aggregator_distinct::setup(THD *thd) mem_root. */ - item_sum->null_value= item_sum->maybe_null= 1; + item_sum->null_value= 1; + item_sum->maybe_null= 1; item_sum->quick_group= 0; DBUG_ASSERT(item_sum->get_arg(0)->is_fixed()); diff --git a/sql/item_sum.h b/sql/item_sum.h index 118f78ec5c1..a51d5677711 100644 --- a/sql/item_sum.h +++ b/sql/item_sum.h @@ -1412,7 +1412,7 @@ public: bool val_native(THD *thd, Native *to) { - return null_value= execute() || sp_result_field->val_native(to); + return (null_value= execute()) || sp_result_field->val_native(to); } String *val_str(String *str) diff --git a/sql/item_timefunc.h b/sql/item_timefunc.h index a910b2cb723..107c3372a15 100644 --- a/sql/item_timefunc.h +++ b/sql/item_timefunc.h @@ -1221,10 +1221,11 @@ public: { Datetime dt(thd, args[0], Datetime::Options(TIME_CONV_NONE, thd)); if (!dt.is_valid_datetime()) - return null_value= true; + return (null_value= 1); + Interval_DDhhmmssff it(thd, args[1]); if (!it.is_valid_interval_DDhhmmssff()) - return null_value= true; + return (null_value= true); return (null_value= Sec6_add(dt.get_mysql_time(), it.get_mysql_time(), 1). to_datetime(ltime)); } @@ -1594,13 +1595,13 @@ public: Datetime::Options opt(TIME_CONV_NONE, thd); Datetime dt(thd, item->arguments()[0], opt); if (!dt.is_valid_datetime()) - return item->null_value= true; + return (item->null_value= true); Interval_DDhhmmssff it(thd, item->arguments()[1]); if (!it.is_valid_interval_DDhhmmssff()) - return item->null_value= true; + return (item->null_value= true); return (item->null_value= (Sec6_add(dt.get_mysql_time(), it.get_mysql_time(), m_sign). - to_datetime(to))); + to_datetime(to))); } }; @@ -1627,10 +1628,10 @@ public: DBUG_ASSERT(item->is_fixed()); Time t(thd, item->arguments()[0]); if (!t.is_valid_time()) - return item->null_value= true; + return (item->null_value= true); Interval_DDhhmmssff i(thd, item->arguments()[1]); if (!i.is_valid_interval_DDhhmmssff()) - return item->null_value= true; + return (item->null_value= true); return (item->null_value= (Sec6_add(t.get_mysql_time(), i.get_mysql_time(), m_sign). to_time(thd, to, item->decimals))); diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 723092d8aa0..8c9f2de9192 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -6982,7 +6982,7 @@ int mysql_table_grant(THD *thd, TABLE_LIST *table_list, while ((column = column_iter++)) { - uint unused_field_idx= NO_CACHED_FIELD_INDEX; + uint16 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(), diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 7b61f750359..583903509a6 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -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, uint *cached_field_index_ptr) + bool allow_rowid, uint16 *cached_field_index_ptr) { Field *field; - uint cached_field_index= *cached_field_index_ptr; + uint16 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, - uint *cached_field_index_ptr, + uint16 *cached_field_index_ptr, bool register_tree_change, TABLE_LIST **actual_table) { Field *fld; diff --git a/sql/sql_base.h b/sql/sql_base.h index 922c61ca123..7a56d95bf2a 100644 --- a/sql/sql_base.h +++ b/sql/sql_base.h @@ -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, - uint *cached_field_index_ptr, + uint16 *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, uint *cached_field_index_ptr); + bool allow_rowid, uint16 *cached_field_index_ptr); Field * find_field_in_table_sef(TABLE *table, const char *name); Item ** find_item_in_list(Item *item, List &items, uint *counter, diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 549bd24eb69..2f317f58da6 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -3182,8 +3182,7 @@ bool JOIN::add_having_as_table_cond(JOIN_TAB *tab) DBUG_ENTER("JOIN::add_having_as_table_cond"); Item* sort_table_cond= make_cond_for_table(thd, tmp_having, used_tables, - (table_map) 0, false, - false, false); + (table_map) 0, 0, false, false); if (sort_table_cond) { if (!tab->select) @@ -3224,7 +3223,7 @@ bool JOIN::add_having_as_table_cond(JOIN_TAB *tab) QT_ORDINARY);); having= make_cond_for_table(thd, tmp_having, ~ (table_map) 0, - ~used_tables, false, false, false); + ~used_tables, 0, false, false); DBUG_EXECUTE("where", print_where(having, "having after sort", QT_ORDINARY);); } @@ -22876,7 +22875,7 @@ make_cond_for_table_from_pred(THD *thd, Item *root_cond, Item *cond, if (cond->marker == 2 || cond->eq_cmp_result() == Item::COND_OK) { - cond->set_join_tab_idx(join_tab_idx_arg); + cond->set_join_tab_idx((uint8) join_tab_idx_arg); return cond; // Not boolean op } @@ -22914,7 +22913,7 @@ make_cond_for_table_from_pred(THD *thd, Item *root_cond, Item *cond, } } cond->marker=2; - cond->set_join_tab_idx(join_tab_idx_arg); + cond->set_join_tab_idx((uint8) join_tab_idx_arg); return cond; } diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc index f83004cd2a4..6f1a21ab791 100644 --- a/sql/sql_trigger.cc +++ b/sql/sql_trigger.cc @@ -2356,9 +2356,9 @@ void Table_triggers_list::mark_fields_used(trg_event_type event) trg_field= trg_field->next_trg_field) { /* We cannot mark fields which does not present in table. */ - if (trg_field->field_idx != (uint)-1) + if (trg_field->field_idx != NO_CACHED_FIELD_INDEX) { - DBUG_PRINT("info", ("marking field: %d", trg_field->field_idx)); + DBUG_PRINT("info", ("marking field: %u", (uint) trg_field->field_idx)); if (trg_field->get_settable_routine_parameter()) bitmap_set_bit(trigger_table->write_set, trg_field->field_idx); trigger_table->mark_column_with_deps( diff --git a/sql/table.h b/sql/table.h index b29199e975a..9c87f9809ff 100644 --- a/sql/table.h +++ b/sql/table.h @@ -366,7 +366,7 @@ enum enum_vcol_update_mode /* Field visibility enums */ -enum field_visibility_t { +enum __attribute__((packed)) field_visibility_t { VISIBLE= 0, INVISIBLE_USER, /* automatically added by the server. Can be queried explicitly diff --git a/sql/unireg.cc b/sql/unireg.cc index 29348bfcec3..51dd1fb6e8c 100644 --- a/sql/unireg.cc +++ b/sql/unireg.cc @@ -869,7 +869,7 @@ static bool pack_header(THD *thd, uchar *forminfo, as auto-update field. */ if (field->real_field_type() == MYSQL_TYPE_TIMESTAMP && - MTYP_TYPENR(field->unireg_check) != Field::NONE && + field->unireg_check != Field::NONE && !time_stamp_pos) time_stamp_pos= (uint) field->offset+ (uint) data_offset + 1; length=field->pack_length; diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc index 8694a18f91f..62388c2adf6 100644 --- a/storage/innobase/handler/handler0alter.cc +++ b/storage/innobase/handler/handler0alter.cc @@ -2274,7 +2274,7 @@ innodb_instant_alter_column_allowed_reason: DBUG_RETURN(HA_ALTER_INPLACE_NOT_SUPPORTED); } - DBUG_ASSERT((MTYP_TYPENR(key_part->field->unireg_check) + DBUG_ASSERT((key_part->field->unireg_check == Field::NEXT_NUMBER) == !!(key_part->field->flags & AUTO_INCREMENT_FLAG)); @@ -2409,9 +2409,9 @@ innodb_instant_alter_column_allowed_reason: (An AUTO_INCREMENT attribute cannot be introduced to a column with ALGORITHM=INPLACE.) */ - ut_ad((MTYP_TYPENR((*af)->unireg_check) + ut_ad(((*af)->unireg_check == Field::NEXT_NUMBER) - == (MTYP_TYPENR(f->unireg_check) + == (f->unireg_check == Field::NEXT_NUMBER)); goto next_column; } @@ -8172,7 +8172,7 @@ err_exit: field = altered_table->field[i]; - DBUG_ASSERT((MTYP_TYPENR(field->unireg_check) + DBUG_ASSERT((field->unireg_check == Field::NEXT_NUMBER) == !!(field->flags & AUTO_INCREMENT_FLAG));