diff options
author | Alexander Barkov <bar@mariadb.com> | 2019-08-14 20:27:00 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mariadb.com> | 2019-08-14 20:27:00 +0400 |
commit | afe6eb499d7d5d9b4ba9de5746e78b43f25e31a4 (patch) | |
tree | 8755d77c5aca99ddc5bafc874e5f550be85e6f45 /sql | |
parent | e86010f909fb6b8c4ffd9d6df92991ac079e67e7 (diff) | |
download | mariadb-git-afe6eb499d7d5d9b4ba9de5746e78b43f25e31a4.tar.gz |
Revert "MDEV-20342 Turn Field::flags from a member to a method"
This reverts commit e86010f909fb6b8c4ffd9d6df92991ac079e67e7.
Reverting on Monty's request, as this change makes merging
things from 10.5 to 10.2 much harder.
Diffstat (limited to 'sql')
41 files changed, 384 insertions, 427 deletions
diff --git a/sql/field.cc b/sql/field.cc index a9132e52031..746f418415c 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -1258,11 +1258,11 @@ int Field::store_hex_hybrid(const char *str, size_t length) if (length > 8) { - nr= is_unsigned() ? ULONGLONG_MAX : LONGLONG_MAX; + nr= flags & UNSIGNED_FLAG ? ULONGLONG_MAX : LONGLONG_MAX; goto warn; } nr= (ulonglong) longlong_from_hex_hybrid(str, length); - if (length == 8 && !is_unsigned() && nr > LONGLONG_MAX) + if ((length == 8) && !(flags & UNSIGNED_FLAG) && (nr > LONGLONG_MAX)) { nr= LONGLONG_MAX; goto warn; @@ -1384,7 +1384,7 @@ error: bool Field::make_empty_rec_store_default_value(THD *thd, Item *item) { - DBUG_ASSERT(!(flags() & BLOB_FLAG)); + DBUG_ASSERT(!(flags & BLOB_FLAG)); int res= item->save_in_field(this, true); return res != 0 && res != 3; } @@ -1402,9 +1402,9 @@ Field_num::Field_num(uchar *ptr_arg,uint32 len_arg, uchar *null_ptr_arg, dec(dec_arg),zerofill(zero_arg),unsigned_flag(unsigned_arg) { if (zerofill) - add_flags(ZEROFILL_FLAG); + flags|=ZEROFILL_FLAG; if (unsigned_flag) - add_flags(UNSIGNED_FLAG); + flags|=UNSIGNED_FLAG; } @@ -1725,8 +1725,7 @@ 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) - :Column_cached_flags(null_ptr_arg ? 0 : NOT_NULL_FLAG), - ptr(ptr_arg), invisible(VISIBLE), + :ptr(ptr_arg), invisible(VISIBLE), 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), @@ -1736,6 +1735,7 @@ Field::Field(uchar *ptr_arg,uint32 length_arg,uchar *null_ptr_arg, read_stats(NULL), collected_stats(0), vcol_info(0), check_constraint(0), default_value(0) { + flags=null_ptr ? 0: NOT_NULL_FLAG; comment.str= (char*) ""; comment.length=0; field_index= 0; @@ -1988,7 +1988,7 @@ void Field::make_send_field(Send_field *field) field->col_name= field_name; field->length=field_length; field->set_handler(type_handler()); - field->flags= table->maybe_null ? (flags() & ~NOT_NULL_FLAG) : flags(); + field->flags=table->maybe_null ? (flags & ~NOT_NULL_FLAG) : flags; field->decimals= 0; } @@ -2086,7 +2086,7 @@ my_decimal* Field_int::val_decimal(my_decimal *decimal_value) bool Field_int::get_date(MYSQL_TIME *ltime,date_mode_t fuzzydate) { DBUG_ASSERT(marked_for_read()); - Longlong_hybrid nr(val_int(), is_unsigned()); + Longlong_hybrid nr(val_int(), (flags & UNSIGNED_FLAG)); return int_to_datetime_with_warn(get_thd(), nr, ltime, fuzzydate, table->s, field_name.str); } @@ -2143,7 +2143,7 @@ Field_str::Field_str(uchar *ptr_arg,uint32 len_arg, uchar *null_ptr_arg, { m_collation= collation; if (collation.collation->state & MY_CS_BINSORT) - add_flags(BINARY_FLAG); + flags|=BINARY_FLAG; } @@ -2242,7 +2242,7 @@ uint Field::fill_cache_field(CACHE_FIELD *copy) copy->str= ptr; copy->length= pack_length_in_rec(); copy->field= this; - if (flags() & BLOB_FLAG) + if (flags & BLOB_FLAG) { copy->type= CACHE_BLOB; copy->length-= portable_sizeof_char_ptr; @@ -2311,7 +2311,7 @@ Field *Field::make_new_field(MEM_ROOT *root, TABLE *new_table, return 0; if (tmp->table->maybe_null) - tmp->clear_flags(NOT_NULL_FLAG); + tmp->flags&= ~NOT_NULL_FLAG; tmp->table= new_table; tmp->key_start.init(0); tmp->part_of_key.init(0); @@ -2321,10 +2321,10 @@ Field *Field::make_new_field(MEM_ROOT *root, TABLE *new_table, Try not to reset it, or explain why it needs to be reset. */ tmp->unireg_check= Field::NONE; - tmp->mask_flags(NOT_NULL_FLAG | UNSIGNED_FLAG | - ZEROFILL_FLAG | BINARY_FLAG | - VERS_SYS_START_FLAG | VERS_SYS_END_FLAG | - VERS_UPDATE_UNVERSIONED_FLAG); + tmp->flags&= (NOT_NULL_FLAG | BLOB_FLAG | UNSIGNED_FLAG | + ZEROFILL_FLAG | BINARY_FLAG | ENUM_FLAG | SET_FLAG | + VERS_SYS_START_FLAG | VERS_SYS_END_FLAG | + VERS_UPDATE_UNVERSIONED_FLAG); tmp->reset_fields(); tmp->invisible= VISIBLE; return tmp; @@ -2368,9 +2368,9 @@ Field *Field::create_tmp_field(MEM_ROOT *mem_root, TABLE *new_table, if ((new_field= make_new_field(mem_root, new_table, new_table == table))) { new_field->init_for_tmp_table(this, new_table); - new_field->add_flags(cached_flags() & NO_DEFAULT_VALUE_FLAG); + new_field->flags|= flags & NO_DEFAULT_VALUE_FLAG; if (maybe_null_arg) - new_field->clear_flags(NOT_NULL_FLAG); // Because of outer join + new_field->flags&= ~NOT_NULL_FLAG; // Because of outer join } return new_field; } @@ -3117,7 +3117,7 @@ Field *Field_decimal::make_new_field(MEM_ROOT *root, TABLE *new_table, Field *field= new (root) Field_new_decimal(NULL, field_length, maybe_null() ? (uchar*) "" : 0, 0, NONE, &field_name, - dec, is_zerofill(), + dec, flags & ZEROFILL_FLAG, unsigned_flag); if (field) field->init_for_make_new_field(new_table, orig_table); @@ -3493,9 +3493,10 @@ bool Field_new_decimal::compatible_field_size(uint field_metadata, bool Field_new_decimal::is_equal(const Column_definition &new_field) const { return ((new_field.type_handler() == type_handler()) && - (new_field.is_unsigned() == is_unsigned()) && - ((new_field.flags() & AUTO_INCREMENT_FLAG) <= - (uint) (flags() & AUTO_INCREMENT_FLAG)) && + ((new_field.flags & UNSIGNED_FLAG) == + (uint) (flags & UNSIGNED_FLAG)) && + ((new_field.flags & AUTO_INCREMENT_FLAG) <= + (uint) (flags & AUTO_INCREMENT_FLAG)) && (new_field.length == max_display_length()) && (new_field.decimals == dec)); } @@ -3560,7 +3561,7 @@ Field_new_decimal::unpack(uchar* to, const uchar *from, const uchar *from_end, Item *Field_new_decimal::get_equal_const_item(THD *thd, const Context &ctx, Item *const_item) { - if (is_zerofill()) + if (flags & ZEROFILL_FLAG) return Field_num::get_equal_zerofill_const_item(thd, ctx, const_item); switch (ctx.subst_constraint()) { case IDENTITY_SUBST: @@ -4845,7 +4846,7 @@ bool Field_real::get_date(MYSQL_TIME *ltime,date_mode_t fuzzydate) Item *Field_real::get_equal_const_item(THD *thd, const Context &ctx, Item *const_item) { - if (is_zerofill()) + if (flags & ZEROFILL_FLAG) return Field_num::get_equal_zerofill_const_item(thd, ctx, const_item); switch (ctx.subst_constraint()) { case IDENTITY_SUBST: @@ -4999,16 +5000,16 @@ Field_timestamp::Field_timestamp(uchar *ptr_arg, uint32 len_arg, unireg_check_arg, field_name_arg) { /* For 4.0 MYD and 4.0 InnoDB compatibility */ - add_flags(UNSIGNED_FLAG); + flags|= UNSIGNED_FLAG; if (unireg_check != NONE) { /* We mark the flag with TIMESTAMP_FLAG to indicate to the client that this field will be automaticly updated on insert. */ - add_flags(TIMESTAMP_FLAG); + flags|= TIMESTAMP_FLAG; if (unireg_check != TIMESTAMP_DN_FIELD) - add_flags(ON_UPDATE_NOW_FLAG); + flags|= ON_UPDATE_NOW_FLAG; } } @@ -8168,6 +8169,7 @@ Field_blob::Field_blob(uchar *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg, packlength(blob_pack_length) { DBUG_ASSERT(blob_pack_length <= 4); // Only pack lengths 1-4 supported currently + flags|= BLOB_FLAG; share->blob_fields++; /* TODO: why do not fill table->s->blob_field array here? */ } @@ -8235,7 +8237,7 @@ int Field_blob::store(const char *from,size_t length,CHARSET_INFO *cs) if (table && table->blob_storage) // GROUP_CONCAT with ORDER BY | DISTINCT { - DBUG_ASSERT(!f_is_hex_escape(flags())); + DBUG_ASSERT(!f_is_hex_escape(flags)); DBUG_ASSERT(field_charset() == cs); DBUG_ASSERT(length <= max_data_length()); @@ -8283,7 +8285,7 @@ int Field_blob::store(const char *from,size_t length,CHARSET_INFO *cs) goto oom_error; tmp= const_cast<char*>(value.ptr()); - if (f_is_hex_escape(flags())) + if (f_is_hex_escape(flags)) { copy_length= my_copy_with_hex_escaping(field_charset(), tmp, new_length, @@ -8687,7 +8689,7 @@ void Field_blob::make_send_field(Send_field *field) bool Field_blob::make_empty_rec_store_default_value(THD *thd, Item *item) { - DBUG_ASSERT(flags() & BLOB_FLAG); + DBUG_ASSERT(flags & BLOB_FLAG); int res= item->save_in_field(this, true); DBUG_ASSERT(res != 3); // Field_blob never returns 3 if (res) @@ -9226,9 +9228,8 @@ bool Field_num::eq_def(const Field *field) const bool Field_num::is_equal(const Column_definition &new_field) const { - if ((new_field.is_unsigned() != is_unsigned()) || - ((new_field.flags() & AUTO_INCREMENT_FLAG) > - (flags() & AUTO_INCREMENT_FLAG))) + if (((new_field.flags & UNSIGNED_FLAG) != (flags & UNSIGNED_FLAG)) || + ((new_field.flags & AUTO_INCREMENT_FLAG) > (flags & AUTO_INCREMENT_FLAG))) return false; const Type_handler *th= type_handler(), *new_th = new_field.type_handler(); @@ -9327,7 +9328,7 @@ Field_bit::Field_bit(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg, DBUG_ENTER("Field_bit::Field_bit"); DBUG_PRINT("enter", ("ptr_arg: %p, null_ptr_arg: %p, len_arg: %u, bit_len: %u, bytes_in_rec: %u", ptr_arg, null_ptr_arg, len_arg, bit_len, bytes_in_rec)); - add_flags(UNSIGNED_FLAG); + flags|= UNSIGNED_FLAG; /* Ensure that Field::eq() can distinguish between two different bit fields. (two bit fields that are not null, may have same ptr and null_ptr) @@ -9845,7 +9846,7 @@ Field_bit_as_char::Field_bit_as_char(uchar *ptr_arg, uint32 len_arg, :Field_bit(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, 0, 0, unireg_check_arg, field_name_arg) { - add_flags(UNSIGNED_FLAG); + flags|= UNSIGNED_FLAG; bit_len= 0; bytes_in_rec= (len_arg + 7) / 8; } @@ -10070,7 +10071,7 @@ void Column_definition::create_length_to_internal_length_bit() void Column_definition::create_length_to_internal_length_newdecimal() { DBUG_ASSERT(length < UINT_MAX32); - uint prec= get_decimal_precision((uint)length, decimals, is_unsigned()); + uint prec= get_decimal_precision((uint)length, decimals, flags & UNSIGNED_FLAG); key_length= pack_length= my_decimal_get_binary_size(prec, decimals); } @@ -10177,7 +10178,7 @@ bool Column_definition::fix_attributes_decimal() return true; } length= my_decimal_precision_to_length((uint) length, decimals, - is_unsigned()); + flags & UNSIGNED_FLAG); pack_length= my_decimal_get_binary_size((uint) length, decimals); return false; } @@ -10241,7 +10242,7 @@ bool Column_definition::check(THD *thd) if (def_expr->type() == Item::NULL_ITEM) { default_value= 0; - if ((flags() & (NOT_NULL_FLAG | AUTO_INCREMENT_FLAG)) == NOT_NULL_FLAG) + if ((flags & (NOT_NULL_FLAG | AUTO_INCREMENT_FLAG)) == NOT_NULL_FLAG) { my_error(ER_INVALID_DEFAULT, MYF(0), field_name.str); DBUG_RETURN(1); @@ -10250,7 +10251,7 @@ bool Column_definition::check(THD *thd) } } - if (default_value && (flags() & AUTO_INCREMENT_FLAG)) + if (default_value && (flags & AUTO_INCREMENT_FLAG)) { my_error(ER_INVALID_DEFAULT, MYF(0), field_name.str); DBUG_RETURN(1); @@ -10284,7 +10285,7 @@ bool Column_definition::check(THD *thd) unireg_check= unireg_check == Field::NONE ? Field::TIMESTAMP_UN_FIELD : Field::TIMESTAMP_DNUN_FIELD; } - else if (flags() & AUTO_INCREMENT_FLAG) + else if (flags & AUTO_INCREMENT_FLAG) unireg_check= Field::NEXT_NUMBER; if (type_handler()->Column_definition_fix_attributes(this)) @@ -10299,7 +10300,7 @@ bool Column_definition::check(THD *thd) We need to do this check here and in mysql_create_prepare_table() as sp_head::fill_field_definition() calls this function. */ - if (!default_value && unireg_check == Field::NONE && (flags() & NOT_NULL_FLAG)) + if (!default_value && unireg_check == Field::NONE && (flags & NOT_NULL_FLAG)) { /* TIMESTAMP columns get implicit DEFAULT value when @@ -10308,12 +10309,12 @@ bool Column_definition::check(THD *thd) if ((opt_explicit_defaults_for_timestamp || !is_timestamp_type()) && !vers_sys_field()) { - add_flags(NO_DEFAULT_VALUE_FLAG); + flags|= NO_DEFAULT_VALUE_FLAG; } } - if ((flags() & AUTO_INCREMENT_FLAG) && + if ((flags & AUTO_INCREMENT_FLAG) && !type_handler()->type_can_have_auto_increment_attribute()) { my_error(ER_WRONG_FIELD_SPEC, MYF(0), field_name.str); @@ -10417,11 +10418,11 @@ Column_definition_attributes::Column_definition_attributes(const Field *field) Column_definition::Column_definition(THD *thd, Field *old_field, Field *orig_field) - :Column_cached_flags(*old_field), - Column_definition_attributes(old_field) + :Column_definition_attributes(old_field) { on_update= NULL; field_name= old_field->field_name; + flags= old_field->flags; pack_length=old_field->pack_length(); key_length= old_field->key_length(); set_handler(old_field->type_handler()); @@ -10469,7 +10470,7 @@ Column_definition::Column_definition(THD *thd, Field *old_field, - The column didn't have a default expression */ - if (!(flags() & (NO_DEFAULT_VALUE_FLAG | BLOB_FLAG)) && + if (!(flags & (NO_DEFAULT_VALUE_FLAG | BLOB_FLAG)) && old_field->ptr != NULL && orig_field != NULL) { if (orig_field->unireg_check != Field::NEXT_NUMBER) @@ -10511,7 +10512,7 @@ Column_definition::redefine_stage1_common(const Column_definition *dup_field, key_length= dup_field->key_length; decimals= dup_field->decimals; unireg_check= dup_field->unireg_check; - set_flags(dup_field->cached_flags()); + flags= dup_field->flags; interval= dup_field->interval; vcol_info= dup_field->vcol_info; invisible= dup_field->invisible; @@ -10586,7 +10587,7 @@ bool Column_definition::has_default_expression() { return (default_value && (!default_value->expr->basic_const_item() || - (flags() & BLOB_FLAG))); + (flags & BLOB_FLAG))); } @@ -10870,7 +10871,7 @@ bool Field::save_in_field_default_value(bool view_error_processing) { THD *thd= table->in_use; - if (unlikely(flags() & NO_DEFAULT_VALUE_FLAG && + if (unlikely(flags & NO_DEFAULT_VALUE_FLAG && real_type() != MYSQL_TYPE_ENUM)) { if (reset()) diff --git a/sql/field.h b/sql/field.h index e9747e74a10..24a8a617657 100644 --- a/sql/field.h +++ b/sql/field.h @@ -633,95 +633,7 @@ public: inline void print(String*); }; - - -class Column_cached_flags -{ - uint32 m_flags; - static uint32 type_handler_implied_flags() - { - return ENUM_FLAG | SET_FLAG | BLOB_FLAG; - } - static bool is_valid(uint32 flags) - { - return (flags & type_handler_implied_flags()) == 0; - } -public: - Column_cached_flags(uint32 flags) - :m_flags(flags) - { - DBUG_ASSERT(is_valid(m_flags)); - } - void set_flags(uint32 flags) - { - m_flags= flags; - DBUG_ASSERT(is_valid(m_flags)); - } - void add_flags(uint32 flags) - { - m_flags|= flags; - DBUG_ASSERT(is_valid(m_flags)); - } - void clear_flags(uint32 flags) { m_flags&= ~flags; } - void mask_flags(uint32 flags) { m_flags&= flags; } - void swap_flags(Column_cached_flags *other) - { - DBUG_ASSERT(is_valid(m_flags)); - DBUG_ASSERT(is_valid(other->m_flags)); - swap_variables(uint32, m_flags, other->m_flags); - } - - uint32 cached_flags() const { return m_flags; } - - bool is_zerofill() const - { - return m_flags & ZEROFILL_FLAG; - } - - bool has_update_default_function() const - { - return m_flags & ON_UPDATE_NOW_FLAG; - } - - ha_storage_media field_storage_type() const - { - return (ha_storage_media) - ((m_flags >> FIELD_FLAGS_STORAGE_MEDIA) & 3); - } - - void set_storage_type(ha_storage_media storage_type_arg) - { - DBUG_ASSERT(field_storage_type() == HA_SM_DEFAULT); - m_flags |= static_cast<uint32>(storage_type_arg) << - FIELD_FLAGS_STORAGE_MEDIA; - } - - column_format_type column_format() const - { - return (column_format_type) - ((m_flags >> FIELD_FLAGS_COLUMN_FORMAT) & 3); - } - - void set_column_format(column_format_type column_format_arg) - { - DBUG_ASSERT(column_format() == COLUMN_FORMAT_TYPE_DEFAULT); - m_flags |= static_cast<uint32>(column_format_arg) << - FIELD_FLAGS_COLUMN_FORMAT; - } - - bool vers_sys_field() const - { - return m_flags & (VERS_SYS_START_FLAG | VERS_SYS_END_FLAG); - } - - bool vers_update_unversioned() const - { - return m_flags & VERS_UPDATE_UNVERSIONED_FLAG; - } -}; - - -class Field: public Value_source, public Column_cached_flags +class Field: public Value_source { Field(const Item &); /* Prevent use of these */ void operator=(Field &); @@ -813,6 +725,7 @@ public: utype unireg_check; 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 /** @@ -877,15 +790,8 @@ public: return Type_std_attributes(type_numeric_attributes(), dtcollation()); } - uint32 flags() const - { - return Column_cached_flags::cached_flags() | type_handler()->flags(); - } + bool is_unsigned() const { return flags & UNSIGNED_FLAG; } - bool is_unsigned() const - { - return cached_flags() & UNSIGNED_FLAG; - } /** Convenience definition of a copy function returned by Field::get_copy_func() @@ -1104,6 +1010,10 @@ public: } virtual int set_default(); + bool has_update_default_function() const + { + return flags & ON_UPDATE_NOW_FLAG; + } bool has_default_now_unireg_check() const { return unireg_check == TIMESTAMP_DN_FIELD @@ -1670,6 +1580,42 @@ public: return field_length / charset()->mbmaxlen; } + ha_storage_media field_storage_type() const + { + return (ha_storage_media) + ((flags >> FIELD_FLAGS_STORAGE_MEDIA) & 3); + } + + void set_storage_type(ha_storage_media storage_type_arg) + { + DBUG_ASSERT(field_storage_type() == HA_SM_DEFAULT); + flags |= static_cast<uint32>(storage_type_arg) << + FIELD_FLAGS_STORAGE_MEDIA; + } + + column_format_type column_format() const + { + return (column_format_type) + ((flags >> FIELD_FLAGS_COLUMN_FORMAT) & 3); + } + + void set_column_format(column_format_type column_format_arg) + { + DBUG_ASSERT(column_format() == COLUMN_FORMAT_TYPE_DEFAULT); + flags |= static_cast<uint32>(column_format_arg) << + FIELD_FLAGS_COLUMN_FORMAT; + } + + bool vers_sys_field() const + { + return flags & (VERS_SYS_START_FLAG | VERS_SYS_END_FLAG); + } + + bool vers_update_unversioned() const + { + return flags & VERS_UPDATE_UNVERSIONED_FLAG; + } + /* Validate a non-null field value stored in the given record according to the current thread settings, e.g. sql_mode. @@ -1886,7 +1832,7 @@ public: } Item *get_equal_const_item(THD *thd, const Context &ctx, Item *const_item) { - return is_zerofill() ? + return (flags & ZEROFILL_FLAG) ? get_equal_zerofill_const_item(thd, ctx, const_item) : const_item; } @@ -1904,7 +1850,7 @@ public: } int save_in_field(Field *to) { - return to->store(val_int(), is_unsigned()); + return to->store(val_int(), MY_TEST(flags & UNSIGNED_FLAG)); } bool is_equal(const Column_definition &new_field) const; uint row_pack_length() const { return pack_length(); } @@ -1976,7 +1922,7 @@ public: my_decimal *val_decimal(my_decimal *); bool val_bool() { return val_real() != 0e0; } virtual bool str_needs_quotes() { return TRUE; } - bool eq_cmp_as_binary() { return MY_TEST(flags() & BINARY_FLAG); } + bool eq_cmp_as_binary() { return MY_TEST(flags & BINARY_FLAG); } virtual uint length_size() const { return 0; } double pos_in_interval(Field *min, Field *max) { @@ -2832,7 +2778,7 @@ public: const LEX_CSTRING *field_name_arg) :Field(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, unireg_check_arg, field_name_arg) - { add_flags(BINARY_FLAG); } + { flags|= BINARY_FLAG; } int store_hex_hybrid(const char *str, size_t length) { return store(str, length, &my_charset_bin); @@ -3471,7 +3417,7 @@ public: { if (unireg_check == TIMESTAMP_UN_FIELD || unireg_check == TIMESTAMP_DNUN_FIELD) - add_flags(ON_UPDATE_NOW_FLAG); + flags|= ON_UPDATE_NOW_FLAG; } const Type_handler *type_handler() const { return &type_handler_datetime; } enum ha_base_keytype key_type() const { return HA_KEYTYPE_ULONGLONG; } @@ -4009,13 +3955,16 @@ public: :Field_longstr((uchar*) 0, len_arg, maybe_null_arg ? (uchar*) "": 0, 0, NONE, field_name_arg, collation), packlength(4) - { } + { + flags|= BLOB_FLAG; + } Field_blob(uint32 len_arg,bool maybe_null_arg, const LEX_CSTRING *field_name_arg, const DTCollation &collation, bool set_packlength) :Field_longstr((uchar*) 0,len_arg, maybe_null_arg ? (uchar*) "": 0, 0, NONE, field_name_arg, collation) { + flags|= BLOB_FLAG; packlength= set_packlength ? number_storage_requirement(len_arg) : 4; } Field_blob(uint32 packlength_arg) @@ -4072,7 +4021,7 @@ public: if (from->type() == MYSQL_TYPE_BIT) return do_field_int; */ - if (!(from->flags() & BLOB_FLAG) || from->charset() != charset() || + if (!(from->flags & BLOB_FLAG) || from->charset() != charset() || !from->compression_method() != !compression_method()) return do_conv_blob; if (from->pack_length() != Field_blob::pack_length()) @@ -4311,7 +4260,9 @@ public: :Field_str(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, unireg_check_arg, field_name_arg, collation), packlength(packlength_arg),typelib(typelib_arg) - { } + { + flags|=ENUM_FLAG; + } Field *make_new_field(MEM_ROOT *root, TABLE *new_table, bool keep_type); const Type_handler *type_handler() const { return &type_handler_enum; } enum ha_base_keytype key_type() const; @@ -4347,7 +4298,7 @@ public: bool memcpy_field_possible(const Field *from) const { return false; } void make_empty_rec_reset(THD *thd) { - if (flags() & NOT_NULL_FLAG) + if (flags & NOT_NULL_FLAG) { set_notnull(); store((longlong) 1, true); @@ -4418,7 +4369,9 @@ public: packlength_arg, typelib_arg, collation), empty_set_string("", 0, collation.collation) - { } + { + flags=(flags & ~ENUM_FLAG) | SET_FLAG; + } void make_empty_rec_reset(THD *thd) { Field::make_empty_rec_reset(thd); @@ -4708,7 +4661,6 @@ public: */ class Column_definition: public Sql_alloc, public Type_handler_hybrid_field_type, - public Column_cached_flags, public Column_definition_attributes { /** @@ -4770,8 +4722,7 @@ public: for most of the types, or of bytes for BLOBs or numeric types. */ uint32 char_length; - uint decimals, pack_length, key_length; - + uint decimals, flags, pack_length, key_length; List<String> interval_list; engine_option_value *option_list; @@ -4792,11 +4743,10 @@ public: Column_definition() :Type_handler_hybrid_field_type(&type_handler_null), - Column_cached_flags(0), compression_method_ptr(0), comment(null_clex_str), on_update(NULL), invisible(VISIBLE), char_length(0), decimals(0), - pack_length(0), key_length(0), + flags(0), pack_length(0), key_length(0), option_list(NULL), vcol_info(0), default_value(0), check_constraint(0), versioning(VERSIONING_NOT_SET), period(NULL) @@ -4830,6 +4780,10 @@ public: length*= charset->mbmaxlen; key_length= pack_length; } + bool vers_sys_field() const + { + return flags & (VERS_SYS_START_FLAG | VERS_SYS_END_FLAG); + } void create_length_to_internal_length_bit(); void create_length_to_internal_length_newdecimal(); @@ -4893,15 +4847,7 @@ public: bool prepare_stage2_typelib(const char *type_name, uint field_flags, uint *dup_val_count); uint pack_flag_numeric(uint dec) const; - uint32 flags() const - { - return cached_flags() | type_handler()->flags(); - } - bool is_unsigned() const - { - return cached_flags() & UNSIGNED_FLAG; - } - uint sign_length() const { return is_unsigned() ? 0 : 1; } + uint sign_length() const { return flags & UNSIGNED_FLAG ? 0 : 1; } bool check_length(uint mysql_errno, uint max_allowed_length) const; bool fix_attributes_real(uint default_length); bool fix_attributes_int(uint default_length); @@ -4914,6 +4860,18 @@ public: bool stored_in_db() const { return !vcol_info || vcol_info->stored_in_db; } + ha_storage_media field_storage_type() const + { + return (ha_storage_media) + ((flags >> FIELD_FLAGS_STORAGE_MEDIA) & 3); + } + + column_format_type column_format() const + { + return (column_format_type) + ((flags >> FIELD_FLAGS_COLUMN_FORMAT) & 3); + } + bool has_default_function() const { return unireg_check != Field::NONE; @@ -4925,7 +4883,7 @@ public: { return Column_definition_attributes::make_field(share, mem_root, addr, type_handler(), - field_name_arg, flags()); + field_name_arg, flags); } Field *make_field(TABLE_SHARE *share, MEM_ROOT *mem_root, const LEX_CSTRING *field_name_arg) const @@ -4948,7 +4906,7 @@ public: length= other.length; char_length= other.char_length; decimals= other.decimals; - set_flags(other.cached_flags()); + flags= other.flags; pack_length= other.pack_length; key_length= other.key_length; unireg_check= other.unireg_check; @@ -5210,7 +5168,7 @@ public: org_col_name(field->field_name), length(field->field_length), flags(field->table->maybe_null ? - (field->flags() & ~NOT_NULL_FLAG) : field->flags()), + (field->flags & ~NOT_NULL_FLAG) : field->flags), decimals(field->decimals()) { normalize(); diff --git a/sql/field_conv.cc b/sql/field_conv.cc index 7fa6ecc4428..bcd4c5fbb38 100644 --- a/sql/field_conv.cc +++ b/sql/field_conv.cc @@ -400,7 +400,8 @@ static void do_field_varbinary_pre50(Copy_field *copy) void Field::do_field_int(Copy_field *copy) { longlong value= copy->from_field->val_int(); - copy->to_field->store(value, copy->from_field->is_unsigned()); + copy->to_field->store(value, + MY_TEST(copy->from_field->flags & UNSIGNED_FLAG)); } void Field::do_field_real(Copy_field *copy) @@ -715,7 +716,7 @@ void Copy_field::set(Field *to,Field *from,bool save) else do_copy=0; - if ((to->flags() & BLOB_FLAG) && save) + if ((to->flags & BLOB_FLAG) && save) do_copy2= do_save_blob; else do_copy2= to->get_copy_func(from); diff --git a/sql/filesort.cc b/sql/filesort.cc index d92ee34aa1a..3f4291cfb1f 100644 --- a/sql/filesort.cc +++ b/sql/filesort.cc @@ -2007,7 +2007,7 @@ bool filesort_use_addons(TABLE *table, uint sortlength, { if (!bitmap_is_set(table->read_set, field->field_index)) continue; - if (field->flags() & BLOB_FLAG) + if (field->flags & BLOB_FLAG) return false; (*length)+= field->max_packed_col_length(field->pack_length()); if (field->maybe_null()) diff --git a/sql/handler.cc b/sql/handler.cc index cd6ebe6495e..3e54d4a19d0 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -3259,7 +3259,7 @@ int handler::update_auto_increment() 1). Ignore negative values. */ - if ((longlong) nr > 0 || table->next_number_field->is_unsigned()) + if ((longlong) nr > 0 || (table->next_number_field->flags & UNSIGNED_FLAG)) adjust_next_insert_id_after_explicit_value(nr); insert_id_for_cur_row= 0; // didn't generate anything DBUG_RETURN(0); @@ -7262,11 +7262,11 @@ bool Vers_parse_info::is_end(const char *name) const } bool Vers_parse_info::is_start(const Create_field &f) const { - return f.flags() & VERS_SYS_START_FLAG; + return f.flags & VERS_SYS_START_FLAG; } bool Vers_parse_info::is_end(const Create_field &f) const { - return f.flags() & VERS_SYS_END_FLAG; + return f.flags & VERS_SYS_END_FLAG; } static Create_field *vers_init_sys_field(THD *thd, const char *field_name, int flags, bool integer) @@ -7278,13 +7278,13 @@ static Create_field *vers_init_sys_field(THD *thd, const char *field_name, int f f->field_name.str= field_name; f->field_name.length= strlen(field_name); f->charset= system_charset_info; - f->set_flags(flags | NOT_NULL_FLAG); + f->flags= flags | NOT_NULL_FLAG; if (integer) { DBUG_ASSERT(0); // Not implemented yet f->set_handler(&type_handler_vers_trx_id); f->length= MY_INT64_NUM_DECIMAL_DIGITS - 1; - f->add_flags(UNSIGNED_FLAG); + f->flags|= UNSIGNED_FLAG; } else { @@ -7370,7 +7370,7 @@ bool Table_scope_and_contents_source_st::vers_fix_system_fields( !(alter_info->flags & ALTER_ADD_SYSTEM_VERSIONING)) || f->versioning == Column_definition::WITHOUT_VERSIONING) { - f->add_flags(VERS_UPDATE_UNVERSIONED_FLAG); + f->flags|= VERS_UPDATE_UNVERSIONED_FLAG; } } // while (Create_field *f= it++) @@ -7460,7 +7460,7 @@ bool Vers_parse_info::fix_alter_info(THD *thd, Alter_info *alter_info, List_iterator_fast<Create_field> it(alter_info->create_list); while (Create_field *f= it++) { - if (f->change.length && f->flags() & VERS_SYSTEM_FIELD) + if (f->change.length && f->flags & VERS_SYSTEM_FIELD) { my_error(ER_VERS_ALTER_SYSTEM_FIELD, MYF(0), f->field_name.str); return true; @@ -7502,7 +7502,7 @@ bool Vers_parse_info::fix_alter_info(THD *thd, Alter_info *alter_info, while (Create_field *f= it++) { if (f->versioning == Column_definition::WITHOUT_VERSIONING) - f->add_flags(VERS_UPDATE_UNVERSIONED_FLAG); + f->flags|= VERS_UPDATE_UNVERSIONED_FLAG; if (f->change.str && (start.streq(f->change) || end.streq(f->change))) { @@ -7545,7 +7545,7 @@ Vers_parse_info::fix_create_like(Alter_info &alter_info, HA_CREATE_INFO &create_ int remove= 2; while (remove && (f= it++)) { - if (f->flags() & VERS_SYSTEM_FIELD) + if (f->flags & VERS_SYSTEM_FIELD) { it.remove(); remove--; @@ -7561,13 +7561,13 @@ Vers_parse_info::fix_create_like(Alter_info &alter_info, HA_CREATE_INFO &create_ while ((f= it++)) { - if (f->flags() & VERS_SYS_START_FLAG) + if (f->flags & VERS_SYS_START_FLAG) { f_start= f; if (f_end) break; } - else if (f->flags() & VERS_SYS_END_FLAG) + else if (f->flags & VERS_SYS_END_FLAG) { f_end= f; if (f_start) @@ -7643,7 +7643,7 @@ static bool is_some_bigint(const Create_field *f) static bool is_versioning_bigint(const Create_field *f) { - return is_some_bigint(f) && f->is_unsigned() && + return is_some_bigint(f) && f->flags & UNSIGNED_FLAG && f->length == MY_INT64_NUM_DECIMAL_DIGITS - 1; } @@ -7674,9 +7674,9 @@ bool Vers_parse_info::check_sys_fields(const Lex_table_name &table_name, List_iterator<Create_field> it(alter_info->create_list); while (Create_field *f= it++) { - if (!row_start && f->flags() & VERS_SYS_START_FLAG) + if (!row_start && f->flags & VERS_SYS_START_FLAG) row_start= f; - else if (!row_end && f->flags() & VERS_SYS_END_FLAG) + else if (!row_end && f->flags & VERS_SYS_END_FLAG) row_end= f; } @@ -7725,7 +7725,7 @@ bool Table_period_info::check_field(const Create_field* f, my_error(ER_WRONG_FIELD_SPEC, MYF(0), f->field_name.str); res= true; } - else if (f->vcol_info || f->flags() & VERS_SYSTEM_FIELD) + else if (f->vcol_info || f->flags & VERS_SYSTEM_FIELD) { my_error(ER_PERIOD_FIELD_WRONG_ATTRIBUTES, MYF(0), f->field_name.str, "GENERATED ALWAYS AS"); @@ -7808,7 +7808,7 @@ Table_scope_and_contents_source_st::fix_period_fields(THD *thd, if (period.start.streq(f->field_name) || period.end.streq(f->field_name)) { f->period= &period_info; - f->add_flags(NOT_NULL_FLAG); + f->flags|= NOT_NULL_FLAG; } } return false; diff --git a/sql/item.cc b/sql/item.cc index 65f826feb4a..162e82c57ea 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -908,7 +908,7 @@ bool Item_field::register_field_in_write_map(void *arg) bool Item_field::check_field_expression_processor(void *arg) { Field *org_field= (Field*) arg; - if (field->flags() & NO_DEFAULT_VALUE_FLAG) + if (field->flags & NO_DEFAULT_VALUE_FLAG) return 0; if ((field->default_value && field->default_value->flags) || field->vcol_info) { @@ -9161,7 +9161,7 @@ bool Item_default_value::fix_fields(THD *thd, Item **items) } field_arg= (Item_field *)real_arg; - if ((field_arg->field->flags() & NO_DEFAULT_VALUE_FLAG)) + if ((field_arg->field->flags & NO_DEFAULT_VALUE_FLAG)) { my_error(ER_NO_DEFAULT_FOR_FIELD, MYF(0), field_arg->field->field_name.str); diff --git a/sql/item_buff.cc b/sql/item_buff.cc index 71aaf63f01a..81949bcdae0 100644 --- a/sql/item_buff.cc +++ b/sql/item_buff.cc @@ -39,7 +39,7 @@ Cached_item *new_Cached_item(THD *thd, Item *item, bool pass_through_ref) { if (pass_through_ref && item->real_item()->type() == Item::FIELD_ITEM && - !(((Item_field *) (item->real_item()))->field->flags() & BLOB_FLAG)) + !(((Item_field *) (item->real_item()))->field->flags & BLOB_FLAG)) { Item_field *real_item= (Item_field *) item->real_item(); Field *cached_field= real_item->field; diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index a07fbeebc36..02fc7719fbc 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -357,7 +357,7 @@ static bool convert_const_to_int(THD *thd, Item_field *field_item, if (0 == field_cmp) { Item *tmp= new (thd->mem_root) Item_int_with_ref(thd, field->val_int(), *item, - field->is_unsigned()); + MY_TEST(field->flags & UNSIGNED_FLAG)); if (tmp) thd->change_item_tree(item, tmp); result= 1; // Item was replaced diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index a9d421e4d7d..34c957cba19 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -2563,7 +2563,7 @@ public: { Field *field=((Item_field*) args[0]->real_item())->field; - if ((field->flags() & NOT_NULL_FLAG) && + if ((field->flags & NOT_NULL_FLAG) && field->type_handler()->cond_notnull_field_isnull_to_field_eq_zero()) return true; } diff --git a/sql/item_sum.cc b/sql/item_sum.cc index b41c0589826..87f3e1d3345 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -1303,7 +1303,7 @@ Field *Item_sum_min_max::create_tmp_field(MEM_ROOT *root, Field *field= ((Item_field*) args[0])->field; if ((field= field->create_tmp_field(root, table, true))) { - DBUG_ASSERT((field->flags() & NOT_NULL_FLAG) == 0); + DBUG_ASSERT((field->flags & NOT_NULL_FLAG) == 0); field->field_name= name; } DBUG_RETURN(field); diff --git a/sql/log.cc b/sql/log.cc index fe1206e35df..78c1debcb4d 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -783,7 +783,7 @@ bool Log_to_csv_event_handler:: A positive return value in store() means truncation. Still logging a message in the log in this case. */ - table->field[5]->add_flags(FIELDFLAG_HEX_ESCAPE); + table->field[5]->flags|= FIELDFLAG_HEX_ESCAPE; if (table->field[5]->store(sql_text, sql_text_len, client_cs) < 0) goto err; diff --git a/sql/opt_range.cc b/sql/opt_range.cc index dc8336e733b..f4bd76e4695 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -3083,7 +3083,7 @@ bool create_key_parts_for_pseudo_indexes(RANGE_OPT_PARAM *param, uint16 max_key_part_length= (uint16) table->file->max_key_part_length(); key_part->key= keys; key_part->part= 0; - if (field->flags() & BLOB_FLAG) + if (field->flags & BLOB_FLAG) key_part->length= max_key_part_length; else { @@ -15815,7 +15815,7 @@ static void print_key_value(String *out, const KEY_PART_INFO *key_part, { field= key_part->field; store_length= key_part->store_length; - if (field->flags() & BLOB_FLAG) + if (field->flags & BLOB_FLAG) { // Byte 0 of a nullable key is the null-byte. If set, key is NULL. if (field->real_maybe_null() && *key) diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc index dd17b5d1c0e..f00d0ed019d 100644 --- a/sql/opt_subselect.cc +++ b/sql/opt_subselect.cc @@ -4392,7 +4392,7 @@ SJ_TMP_TABLE::create_sj_weedout_tmp_table(THD *thd) field->part_of_key.clear_all(); field->part_of_sortkey.clear_all(); field->unireg_check= Field::NONE; - field->set_flags(NOT_NULL_FLAG | BINARY_FLAG | NO_DEFAULT_VALUE_FLAG); + field->flags= (NOT_NULL_FLAG | BINARY_FLAG | NO_DEFAULT_VALUE_FLAG); field->reset_fields(); field->init(table); field->orig_table= NULL; diff --git a/sql/opt_sum.cc b/sql/opt_sum.cc index 884dd089c52..0a3c30a176d 100644 --- a/sql/opt_sum.cc +++ b/sql/opt_sum.cc @@ -904,7 +904,7 @@ static bool find_key_for_maxmin(bool max_fl, TABLE_REF *ref, Field* field, COND *cond, uint *range_fl, uint *prefix_len) { - if (!(field->flags() & PART_KEY_FLAG)) + if (!(field->flags & PART_KEY_FLAG)) return FALSE; // Not key field DBUG_ENTER("find_key_for_maxmin"); @@ -937,7 +937,7 @@ static bool find_key_for_maxmin(bool max_fl, TABLE_REF *ref, /* Check whether the index component is partial */ Field *part_field= table->field[part->fieldnr-1]; - if ((part_field->flags() & BLOB_FLAG) || + if ((part_field->flags & BLOB_FLAG) || part->length < part_field->key_length()) break; diff --git a/sql/partition_info.cc b/sql/partition_info.cc index 8f353299f4a..66216493de8 100644 --- a/sql/partition_info.cc +++ b/sql/partition_info.cc @@ -902,7 +902,7 @@ bool partition_info::vers_setup_expression(THD * thd, uint32 alter_add) part_field_list.push_back(row_end->field_name.str, thd->mem_root); DBUG_ASSERT(part_field_list.elements == 1); // needed in handle_list_of_fields() - row_end->add_flags(GET_FIXED_FIELDS_FLAG); + row_end->flags|= GET_FIXED_FIELDS_FLAG; } if (alter_add) diff --git a/sql/rpl_record.cc b/sql/rpl_record.cc index 62d17ab6ac1..5a4b9516690 100644 --- a/sql/rpl_record.cc +++ b/sql/rpl_record.cc @@ -482,7 +482,7 @@ int prepare_record(TABLE *const table, const uint skip, const bool check) for (Field **field_ptr= table->field+skip; *field_ptr; ++field_ptr) { Field *const f= *field_ptr; - if ((f->flags() & NO_DEFAULT_VALUE_FLAG) && + if ((f->flags & NO_DEFAULT_VALUE_FLAG) && (f->real_type() != MYSQL_TYPE_ENUM)) { THD *thd= f->table->in_use; diff --git a/sql/rpl_record_old.cc b/sql/rpl_record_old.cc index 2711ad83a3b..496e781d2eb 100644 --- a/sql/rpl_record_old.cc +++ b/sql/rpl_record_old.cc @@ -177,11 +177,11 @@ unpack_row_old(rpl_group_info *rgi, uint32 const mask= NOT_NULL_FLAG | NO_DEFAULT_VALUE_FLAG; DBUG_PRINT("debug", ("flags = 0x%x, mask = 0x%x, flags & mask = 0x%x", - (*field_ptr)->flags(), mask, - (*field_ptr)->flags() & mask)); + (*field_ptr)->flags, mask, + (*field_ptr)->flags & mask)); if (event_type == WRITE_ROWS_EVENT && - ((*field_ptr)->flags() & mask) == mask) + ((*field_ptr)->flags & mask) == mask) { rgi->rli->report(ERROR_LEVEL, ER_NO_DEFAULT_FOR_FIELD, NULL, "Field `%s` of table `%s`.`%s` " diff --git a/sql/rpl_utility_server.cc b/sql/rpl_utility_server.cc index 565aaa9f07f..4abcd9d6e1e 100644 --- a/sql/rpl_utility_server.cc +++ b/sql/rpl_utility_server.cc @@ -1044,7 +1044,7 @@ public: " maybe_null: %d, unsigned_flag: %d, pack_length: %u", handler->name().ptr(), target_field->field_name.str, tmp->field_length, tmp->decimals(), TRUE, - tmp->flags(), tmp->pack_length())); + tmp->flags, tmp->pack_length())); return false; } }; diff --git a/sql/sp_rcontext.cc b/sql/sp_rcontext.cc index 918fa014ae3..17b4c83b7bc 100644 --- a/sql/sp_rcontext.cc +++ b/sql/sp_rcontext.cc @@ -256,7 +256,7 @@ bool Qualified_column_ident::resolve_type_ref(THD *thd, Column_definition *def) m_column.length, src))) { *def= Column_definition(thd, src, NULL/*No defaults,no constraints*/); - def->clear_flags(NOT_NULL_FLAG); + def->flags&= (uint) ~NOT_NULL_FLAG; rc= def->sp_prepare_create_field(thd, thd->mem_root); } } @@ -323,7 +323,7 @@ bool Table_ident::resolve_table_rowtype_ref(THD *thd, (rc= !(def= new (thd->mem_root) Spvar_definition(thd, *src)))) break; src[0]->field_name.str= tmp.str; // Restore field name, just in case. - def->clear_flags(NOT_NULL_FLAG); + def->flags&= (uint) ~NOT_NULL_FLAG; if ((rc= def->sp_prepare_create_field(thd, thd->mem_root))) break; defs.push_back(def, thd->mem_root); diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 84b41e94fc9..5f39f514b59 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -5723,7 +5723,7 @@ static void update_field_dependencies(THD *thd, Field *field, TABLE *table) table->used_fields++; } if (table->get_fields_in_item_tree) - field->add_flags(GET_FIXED_FIELDS_FLAG); + field->flags|= GET_FIXED_FIELDS_FLAG; DBUG_VOID_RETURN; } @@ -8603,7 +8603,7 @@ static bool not_null_fields_have_null_values(TABLE *table) if (ff != of) { // copy after-update flags to of, copy before-update flags to ff - ff->swap_flags(of); + swap_variables(uint32, of->flags, ff->flags); if (ff->is_real_null()) { ff->set_notnull(); // for next row WHERE condition in UPDATE diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 1c48f027e70..9078396a575 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -6708,7 +6708,7 @@ void THD::binlog_prepare_row_images(TABLE *table) { Field *field= (*ptr); if ((field->type() == MYSQL_TYPE_BLOB) && - !(field->flags() & PRI_KEY_FLAG)) + !(field->flags & PRI_KEY_FLAG)) bitmap_clear_bit(&table->tmp_set, field->field_index); } break; diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 22373e232f0..7d399464e4c 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -317,8 +317,7 @@ static int check_insert_fields(THD *thd, TABLE_LIST *table_list, static bool has_no_default_value(THD *thd, Field *field, TABLE_LIST *table_list) { - if ((field->flags() & NO_DEFAULT_VALUE_FLAG) && - field->real_type() != MYSQL_TYPE_ENUM) + if ((field->flags & NO_DEFAULT_VALUE_FLAG) && field->real_type() != MYSQL_TYPE_ENUM) { bool view= false; if (table_list) @@ -3228,7 +3227,7 @@ static void unlink_blobs(TABLE *table) { for (Field **ptr=table->field ; *ptr ; ptr++) { - if ((*ptr)->flags() & BLOB_FLAG) + if ((*ptr)->flags & BLOB_FLAG) ((Field_blob *) (*ptr))->clear_temporary(); } } @@ -3239,7 +3238,7 @@ static void free_delayed_insert_blobs(TABLE *table) { for (Field **ptr=table->field ; *ptr ; ptr++) { - if ((*ptr)->flags() & BLOB_FLAG) + if ((*ptr)->flags & BLOB_FLAG) ((Field_blob *) *ptr)->free(); } } @@ -3251,7 +3250,7 @@ static void set_delayed_insert_blobs(TABLE *table) { for (Field **ptr=table->field ; *ptr ; ptr++) { - if ((*ptr)->flags() & BLOB_FLAG) + if ((*ptr)->flags & BLOB_FLAG) { Field_blob *blob= ((Field_blob *) *ptr); uchar *data= blob->get_ptr(); @@ -4238,7 +4237,7 @@ TABLE *select_create::create_table_from_items(THD *thd, List<Item> *items, DBUG_RETURN(NULL); if (item->maybe_null) - cr_field->clear_flags(NOT_NULL_FLAG); + cr_field->flags &= ~NOT_NULL_FLAG; alter_info->create_list.push_back(cr_field, thd->mem_root); } diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index d9de954f8e2..15d83b15ac9 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -8820,7 +8820,7 @@ bool LEX::last_field_generated_always_as_row_start_or_end(Lex_ident *p, last_field->field_name.str); return true; } - last_field->add_flags(flag | NOT_NULL_FLAG); + last_field->flags|= (flag | NOT_NULL_FLAG); DBUG_ASSERT(p); *p= last_field->field_name; return false; diff --git a/sql/sql_load.cc b/sql/sql_load.cc index ce12879de65..3fa6e095f10 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -283,7 +283,7 @@ static bool write_execute_load_query_log_event(THD *, const sql_exchange*, const bool Load_data_param::add_outvar_field(THD *thd, const Field *field) { - if (field->flags() & BLOB_FLAG) + if (field->flags & BLOB_FLAG) { m_use_blobs= true; m_fixed_length+= 256; // Will be extended if needed diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index 0f86ec7680e..e24a8962dcd 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -340,10 +340,10 @@ static bool set_up_field_array(THD *thd, TABLE *table, ptr= table->field; while ((field= *(ptr++))) { - if (field->flags() & GET_FIXED_FIELDS_FLAG) + if (field->flags & GET_FIXED_FIELDS_FLAG) { if (table->versioned(VERS_TRX_ID) - && unlikely(field->flags() & VERS_SYSTEM_FIELD)) + && unlikely(field->flags & VERS_SYSTEM_FIELD)) { my_error(ER_VERS_TRX_PART_HISTORIC_ROW_NOT_SUPPORTED, MYF(0)); DBUG_RETURN(TRUE); @@ -377,10 +377,10 @@ static bool set_up_field_array(THD *thd, TABLE *table, ptr= table->field; while ((field= *(ptr++))) { - if (field->flags() & GET_FIXED_FIELDS_FLAG) + if (field->flags & GET_FIXED_FIELDS_FLAG) { - field->clear_flags(GET_FIXED_FIELDS_FLAG); - field->add_flags(FIELD_IN_PART_FUNC_FLAG); + field->flags&= ~GET_FIXED_FIELDS_FLAG; + field->flags|= FIELD_IN_PART_FUNC_FLAG; if (likely(!result)) { if (!is_sub_part && part_info->column_list) @@ -424,7 +424,7 @@ static bool set_up_field_array(THD *thd, TABLE *table, performance reasons. */ - if (unlikely(field->flags() & BLOB_FLAG)) + if (unlikely(field->flags & BLOB_FLAG)) { my_error(ER_BLOB_FIELD_IN_PART_FUNC_ERROR, MYF(0)); result= TRUE; @@ -489,7 +489,7 @@ static bool create_full_part_field_array(THD *thd, TABLE *table, ptr= table->field; while ((field= *(ptr++))) { - if (field->flags() & FIELD_IN_PART_FUNC_FLAG) + if (field->flags & FIELD_IN_PART_FUNC_FLAG) num_part_fields++; } size_field_array= (num_part_fields+1)*sizeof(Field*); @@ -503,7 +503,7 @@ static bool create_full_part_field_array(THD *thd, TABLE *table, ptr= table->field; while ((field= *(ptr++))) { - if (field->flags() & FIELD_IN_PART_FUNC_FLAG) + if (field->flags & FIELD_IN_PART_FUNC_FLAG) field_array[num_part_fields++]= field; } field_array[num_part_fields]=0; @@ -571,7 +571,7 @@ static void clear_indicator_in_key_fields(KEY *key_info) KEY_PART_INFO *key_part; uint key_parts= key_info->user_defined_key_parts, i; for (i= 0, key_part=key_info->key_part; i < key_parts; i++, key_part++) - key_part->field->clear_flags(GET_FIXED_FIELDS_FLAG); + key_part->field->flags&= (~GET_FIXED_FIELDS_FLAG); } @@ -591,7 +591,7 @@ static void set_indicator_in_key_fields(KEY *key_info) KEY_PART_INFO *key_part; uint key_parts= key_info->user_defined_key_parts, i; for (i= 0, key_part=key_info->key_part; i < key_parts; i++, key_part++) - key_part->field->add_flags(GET_FIXED_FIELDS_FLAG); + key_part->field->flags|= GET_FIXED_FIELDS_FLAG; } @@ -624,7 +624,7 @@ static void check_fields_in_PF(Field **ptr, bool *all_fields, do { /* Check if the field of the PF is part of the current key investigated */ - if ((*ptr)->flags() & GET_FIXED_FIELDS_FLAG) + if ((*ptr)->flags & GET_FIXED_FIELDS_FLAG) *some_fields= TRUE; else *all_fields= FALSE; @@ -651,7 +651,7 @@ static void clear_field_flag(TABLE *table) DBUG_ENTER("clear_field_flag"); for (ptr= table->field; *ptr; ptr++) - (*ptr)->clear_flags(GET_FIXED_FIELDS_FLAG); + (*ptr)->flags&= (~GET_FIXED_FIELDS_FLAG); DBUG_VOID_RETURN; } @@ -695,7 +695,7 @@ static bool handle_list_of_fields(THD *thd, List_iterator<const char> it, is_list_empty= FALSE; field= find_field_in_table_sef(table, field_name); if (likely(field != 0)) - field->add_flags(GET_FIXED_FIELDS_FLAG); + field->flags|= GET_FIXED_FIELDS_FLAG; else { my_error(ER_FIELD_NOT_FOUND_PART_ERROR, MYF(0)); @@ -716,7 +716,7 @@ static bool handle_list_of_fields(THD *thd, List_iterator<const char> it, for (i= 0; i < num_key_parts; i++) { Field *field= table->key_info[primary_key].key_part[i].field; - field->add_flags(GET_FIXED_FIELDS_FLAG); + field->flags|= GET_FIXED_FIELDS_FLAG; } } else @@ -3889,10 +3889,10 @@ static bool set_PF_fields_in_key(KEY *key_info, uint key_length) if (key_length < key_part->length) break; key_length-= key_part->length; - if (key_part->field->flags() & FIELD_IN_PART_FUNC_FLAG) + if (key_part->field->flags & FIELD_IN_PART_FUNC_FLAG) { found_part_field= TRUE; - key_part->field->add_flags(GET_FIXED_FIELDS_FLAG); + key_part->field->flags|= GET_FIXED_FIELDS_FLAG; } } DBUG_RETURN(found_part_field); @@ -3919,7 +3919,7 @@ static bool check_part_func_bound(Field **ptr) for (; *ptr; ptr++) { - if (!((*ptr)->flags() & GET_FIXED_FIELDS_FLAG)) + if (!((*ptr)->flags & GET_FIXED_FIELDS_FLAG)) { result= FALSE; break; @@ -8565,7 +8565,7 @@ static uint32 get_next_partition_via_walking(PARTITION_ITERATOR *part_iter) while (part_iter->field_vals.cur != part_iter->field_vals.end) { longlong dummy; - field->store(part_iter->field_vals.cur++, field->is_unsigned()); + field->store(part_iter->field_vals.cur++, field->flags & UNSIGNED_FLAG); if ((part_iter->part_info->is_sub_partitioned() && !part_iter->part_info->get_part_partition_id(part_iter->part_info, &part_id, &dummy)) || @@ -8589,7 +8589,7 @@ static uint32 get_next_subpartition_via_walking(PARTITION_ITERATOR *part_iter) part_iter->field_vals.cur= part_iter->field_vals.start; return NOT_A_PARTITION_ID; } - field->store(part_iter->field_vals.cur++, field->is_unsigned()); + field->store(part_iter->field_vals.cur++, field->flags & UNSIGNED_FLAG); if (part_iter->part_info->get_subpartition_id(part_iter->part_info, &res)) return NOT_A_PARTITION_ID; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 79b0a2ead97..3977dd9017b 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -5791,11 +5791,11 @@ add_key_field(JOIN *join, !(field->table->pos_in_table_list->is_materialized_derived() && field->table->is_created())) || (field->table->pos_in_table_list->is_materialized_derived() && - !field->table->is_created() && !(field->flags() & BLOB_FLAG)))) + !field->table->is_created() && !(field->flags & BLOB_FLAG)))) { optimize= KEY_OPTIMIZE_EQ; } - else if (!(field->flags() & PART_KEY_FLAG)) + else if (!(field->flags & PART_KEY_FLAG)) { // Don't remove column IS NULL on a LEFT JOIN table if (eq_func && (*value)->type() == Item::NULL_ITEM && @@ -5851,7 +5851,7 @@ add_key_field(JOIN *join, Field BETWEEN ... Field IN ... */ - if (field->flags() & PART_KEY_FLAG) + if (field->flags & PART_KEY_FLAG) stat[0].key_dependent|=used_tables; bool is_const=1; @@ -9523,7 +9523,7 @@ void JOIN_TAB::calc_used_field_length(bool max_fl) { if (bitmap_is_set(read_set, field->field_index)) { - uint flags= field->flags(); + uint flags=field->flags; fields++; rec_length+=field->pack_length(); if (flags & BLOB_FLAG) @@ -17257,7 +17257,7 @@ Item_func_isnull::remove_eq_conds(THD *thd, Item::cond_result *cond_value, { Field *field= ((Item_field*) real_item)->field; - if ((field->flags() & NOT_NULL_FLAG) && + if ((field->flags & NOT_NULL_FLAG) && field->type_handler()->cond_notnull_field_isnull_to_field_eq_zero()) { /* fix to replace 'NULL' dates with '0' (shreeve@uci.edu) */ @@ -17326,7 +17326,7 @@ Item_func_isnull::remove_eq_conds(THD *thd, Item::cond_result *cond_value, if (top_level_arg) // "auto_increment_column IS NULL" is the only condition { - if (field->flags() & AUTO_INCREMENT_FLAG && !field->table->maybe_null && + if (field->flags & AUTO_INCREMENT_FLAG && !field->table->maybe_null && (thd->variables.option_bits & OPTION_AUTO_IS_NULL) && (thd->first_successful_insert_id_in_prev_stmt > 0 && thd->substitute_null_with_insert_id)) @@ -17886,17 +17886,17 @@ void Create_tmp_table::add_field(TABLE *table, Field *field, uint fieldnr, bool if (force_not_null_cols) { - field->add_flags(NOT_NULL_FLAG); + field->flags|= NOT_NULL_FLAG; field->null_ptr= NULL; } - if (!(field->flags() & NOT_NULL_FLAG)) + if (!(field->flags & NOT_NULL_FLAG)) m_null_count++; table->s->reclength+= field->pack_length(); // Assign it here, before update_data_type_statistics() changes m_blob_count - if (field->flags() & BLOB_FLAG) + if (field->flags & BLOB_FLAG) table->s->blob_field[m_blob_count]= fieldnr; table->field[fieldnr]= field; @@ -18176,7 +18176,7 @@ bool Create_tmp_table::add_fields(THD *thd, add_field(table, new_field, fieldnr++, param->force_not_null_cols); - if (!(new_field->flags() & NOT_NULL_FLAG)) + if (!(new_field->flags & NOT_NULL_FLAG)) { /* new_field->maybe_null() is still false, it will be @@ -18256,7 +18256,7 @@ bool Create_tmp_table::add_fields(THD *thd, if (item->marker == 4 && item->maybe_null) { m_group_null_items++; - new_field->add_flags(GROUP_FLAG); + new_field->flags|= GROUP_FLAG; } } if (!--m_hidden_field_count) @@ -18412,7 +18412,7 @@ bool Create_tmp_table::finalize(THD *thd, uint length; bzero((uchar*) recinfo,sizeof(*recinfo)); - if (!(field->flags() & NOT_NULL_FLAG)) + if (!(field->flags & NOT_NULL_FLAG)) { recinfo->null_bit= (uint8)1 << (m_null_count & 7); recinfo->null_pos= m_null_count/8; @@ -18680,7 +18680,7 @@ bool Create_tmp_table::finalize(THD *thd, i++, reg_field++, m_key_part_info++) { m_key_part_info->field= *reg_field; - (*reg_field)->add_flags(PART_KEY_FLAG); + (*reg_field)->flags |= PART_KEY_FLAG; if (m_key_part_info == keyinfo->key_part) (*reg_field)->key_start.set_bit(0); m_key_part_info->null_bit= (*reg_field)->null_bit; @@ -18898,7 +18898,7 @@ void Virtual_tmp_table::setup_field_pointers() for (Field **cur_ptr= field; *cur_ptr; ++cur_ptr) { Field *cur_field= *cur_ptr; - if ((cur_field->flags() & NOT_NULL_FLAG)) + if ((cur_field->flags & NOT_NULL_FLAG)) cur_field->move_field(field_pos); else { @@ -19138,7 +19138,7 @@ bool create_internal_tmp_table(TABLE *table, KEY *keyinfo, seg->language= field->charset()->number; seg->length= keyinfo->key_part[i].length; seg->start= keyinfo->key_part[i].offset; - if (field->flags() & BLOB_FLAG) + if (field->flags & BLOB_FLAG) { seg->type= ((keyinfo->key_part[i].key_type & FIELDFLAG_BINARY) ? @@ -19156,7 +19156,7 @@ bool create_internal_tmp_table(TABLE *table, KEY *keyinfo, keyinfo->key_part[i].length > 32) seg->flag|= HA_SPACE_PACK; } - if (!(field->flags() & NOT_NULL_FLAG)) + if (!(field->flags & NOT_NULL_FLAG)) { seg->null_bit= field->null_bit; seg->null_pos= (uint) (field->null_ptr - (uchar*) table->record[0]); @@ -19333,7 +19333,7 @@ bool create_internal_tmp_table(TABLE *table, KEY *keyinfo, seg->language= field->charset()->number; seg->length= keyinfo->key_part[i].length; seg->start= keyinfo->key_part[i].offset; - if (field->flags() & BLOB_FLAG) + if (field->flags & BLOB_FLAG) { seg->type= ((keyinfo->key_part[i].key_type & FIELDFLAG_BINARY) ? @@ -19350,7 +19350,7 @@ bool create_internal_tmp_table(TABLE *table, KEY *keyinfo, keyinfo->key_part[i].length > 4) seg->flag|= HA_SPACE_PACK; } - if (!(field->flags() & NOT_NULL_FLAG)) + if (!(field->flags & NOT_NULL_FLAG)) { seg->null_bit= field->null_bit; seg->null_pos= (uint) (field->null_ptr - (uchar*) table->record[0]); @@ -23529,7 +23529,7 @@ static bool copy_blobs(Field **ptr) { for (; *ptr ; ptr++) { - if ((*ptr)->flags() & BLOB_FLAG) + if ((*ptr)->flags & BLOB_FLAG) if (((Field_blob *) (*ptr))->copy()) return 1; // Error } @@ -23540,7 +23540,7 @@ static void free_blobs(Field **ptr) { for (; *ptr ; ptr++) { - if ((*ptr)->flags() & BLOB_FLAG) + if ((*ptr)->flags & BLOB_FLAG) ((Field_blob *) (*ptr))->free(); } } @@ -24788,7 +24788,7 @@ setup_copy_fields(THD *thd, TMP_TABLE_PARAM *param, item->name= ref->name; } pos= item; - if (item->field->flags() & BLOB_FLAG) + if (item->field->flags & BLOB_FLAG) { if (!(pos= new (thd->mem_root) Item_copy_string(thd, pos))) goto err; diff --git a/sql/sql_select.h b/sql/sql_select.h index bef8ad3c712..40a9ed303f7 100644 --- a/sql/sql_select.h +++ b/sql/sql_select.h @@ -2191,9 +2191,9 @@ public: new_field->init(this); field[s->fields]= new_field; s->reclength+= new_field->pack_length(); - if (!(new_field->flags() & NOT_NULL_FLAG)) + if (!(new_field->flags & NOT_NULL_FLAG)) s->null_fields++; - if (new_field->flags() & BLOB_FLAG) + if (new_field->flags & BLOB_FLAG) { // Note, s->blob_fields was incremented in Field_blob::Field_blob DBUG_ASSERT(s->blob_fields); diff --git a/sql/sql_sequence.cc b/sql/sql_sequence.cc index 2e0029afd33..4e8624d6360 100644 --- a/sql/sql_sequence.cc +++ b/sql/sql_sequence.cc @@ -209,7 +209,7 @@ bool check_sequence_fields(LEX *lex, List<Create_field> *fields) Field_definition *field_def= &sequence_structure[field_no]; if (my_strcasecmp(system_charset_info, field_def->field_name, field->field_name.str) || - field->flags() != field_def->flags || + field->flags != field_def->flags || field->type_handler() != field_def->type_handler) { reason= field->field_name.str; @@ -253,7 +253,7 @@ bool prepare_sequence_fields(THD *thd, List<Create_field> *fields) new_field->length= field_info->length; new_field->char_length= field_info->length; new_field->comment= field_info->comment; - new_field->set_flags(field_info->flags); + new_field->flags= field_info->flags; if (unlikely(fields->push_back(new_field))) DBUG_RETURN(TRUE); /* purify inspected */ } diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 943cb31b6cb..34c0e0abc6c 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -1686,7 +1686,7 @@ static bool get_field_default_value(THD *thd, Field *field, String *def_value, enum enum_field_types field_type= field->type(); has_default= (field->default_value || - (!(field->flags() & NO_DEFAULT_VALUE_FLAG) && + (!(field->flags & NO_DEFAULT_VALUE_FLAG) && !field->vers_sys_field() && field->unireg_check != Field::NEXT_NUMBER)); @@ -2107,7 +2107,7 @@ int show_create_table(THD *thd, TABLE_LIST *table_list, String *packet, for (ptr=table->field ; (field= *ptr); ptr++) { - uint flags = field->flags(); + uint flags = field->flags; if (field->invisible > INVISIBLE_USER) continue; @@ -2161,11 +2161,11 @@ int show_create_table(THD *thd, TABLE_LIST *table_list, String *packet, } else { - if (field->flags() & VERS_SYS_START_FLAG) + if (field->flags & VERS_SYS_START_FLAG) { packet->append(STRING_WITH_LEN(" GENERATED ALWAYS AS ROW START")); } - else if (field->flags() & VERS_SYS_END_FLAG) + else if (field->flags & VERS_SYS_END_FLAG) { packet->append(STRING_WITH_LEN(" GENERATED ALWAYS AS ROW END")); } @@ -5901,13 +5901,13 @@ static int get_schema_column_record(THD *thd, TABLE_LIST *tables, table->field[5]->store(type.ptr(), type.length(), cs); table->field[5]->set_notnull(); } - pos=(uchar*) ((field->flags() & NOT_NULL_FLAG) ? "NO" : "YES"); + pos=(uchar*) ((field->flags & NOT_NULL_FLAG) ? "NO" : "YES"); table->field[6]->store((const char*) pos, strlen((const char*) pos), cs); store_column_type(table, field, cs, 7); - pos=(uchar*) ((field->flags() & PRI_KEY_FLAG) ? "PRI" : - (field->flags() & UNIQUE_KEY_FLAG) ? "UNI" : - (field->flags() & MULTIPLE_KEY_FLAG) ? "MUL":""); + pos=(uchar*) ((field->flags & PRI_KEY_FLAG) ? "PRI" : + (field->flags & UNIQUE_KEY_FLAG) ? "UNI" : + (field->flags & MULTIPLE_KEY_FLAG) ? "MUL":""); table->field[16]->store((const char*) pos, strlen((const char*) pos), cs); @@ -5930,9 +5930,9 @@ static int get_schema_column_record(THD *thd, TABLE_LIST *tables, else buf.set(STRING_WITH_LEN("VIRTUAL GENERATED"), cs); } - else if (field->flags() & VERS_SYSTEM_FIELD) + else if (field->flags & VERS_SYSTEM_FIELD) { - if (field->flags() & VERS_SYS_START_FLAG) + if (field->flags & VERS_SYS_START_FLAG) { table->field[21]->store(STRING_WITH_LEN("ROW START"), cs); buf.set(STRING_WITH_LEN("STORED GENERATED"), cs); @@ -6596,7 +6596,7 @@ static int get_schema_stat_record(THD *thd, TABLE_LIST *tables, key_part->field->charset()->mbmaxlen, TRUE); table->field[10]->set_notnull(); } - uint flags= key_part->field ? key_part->field->flags() : 0; + uint flags= key_part->field ? key_part->field->flags : 0; const char *pos=(char*) ((flags & NOT_NULL_FLAG) ? "" : "YES"); table->field[12]->store(pos, strlen(pos), cs); if (!show_table->s->keys_in_use.is_set(i)) diff --git a/sql/sql_statistics.cc b/sql/sql_statistics.cc index 633f0f99a75..8c170b7df52 100644 --- a/sql/sql_statistics.cc +++ b/sql/sql_statistics.cc @@ -2483,7 +2483,7 @@ void Column_statistics_collected::init(THD *thd, Field *table_field) column_total_length= 0; if (is_single_pk_col) count_distinct= NULL; - if (table_field->flags() & BLOB_FLAG) + if (table_field->flags & BLOB_FLAG) count_distinct= NULL; else { diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 50688aea172..bdf1d043e71 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -2926,8 +2926,8 @@ bool Column_definition::prepare_stage2_typelib(const char *type_name, uint Column_definition::pack_flag_numeric(uint dec) const { return (FIELDFLAG_NUMBER | - (is_unsigned() ? 0 : FIELDFLAG_DECIMAL) | - (is_zerofill() ? FIELDFLAG_ZEROFILL : 0) | + (flags & UNSIGNED_FLAG ? 0 : FIELDFLAG_DECIMAL) | + (flags & ZEROFILL_FLAG ? FIELDFLAG_ZEROFILL : 0) | (dec << FIELDFLAG_DEC_SHIFT)); } @@ -2965,10 +2965,10 @@ bool Column_definition::prepare_stage2(handler *file, if (type_handler()->Column_definition_prepare_stage2(this, file, table_flags)) DBUG_RETURN(true); - if (!(flags() & NOT_NULL_FLAG) || + if (!(flags & NOT_NULL_FLAG) || (vcol_info)) /* Make virtual columns allow NULL values */ pack_flag|= FIELDFLAG_MAYBE_NULL; - if (flags() & NO_DEFAULT_VALUE_FLAG) + if (flags & NO_DEFAULT_VALUE_FLAG) pack_flag|= FIELDFLAG_NO_DEFAULT; DBUG_RETURN(false); } @@ -3029,12 +3029,12 @@ void promote_first_timestamp_column(List<Create_field> *column_definitions) column_definition->unireg_check == Field::TIMESTAMP_OLD_FIELD) // Legacy { DBUG_PRINT("info", ("field-ptr:%p", column_definition->field)); - if ((column_definition->flags() & NOT_NULL_FLAG) != 0 && // NOT NULL, + if ((column_definition->flags & NOT_NULL_FLAG) != 0 && // NOT NULL, column_definition->default_value == NULL && // no constant default, column_definition->unireg_check == Field::NONE && // no function default column_definition->vcol_info == NULL && column_definition->period == NULL && - !(column_definition->flags() & VERS_SYSTEM_FIELD)) // column isn't generated + !(column_definition->flags & VERS_SYSTEM_FIELD)) // column isn't generated { DBUG_PRINT("info", ("First TIMESTAMP column '%s' was promoted to " "DEFAULT CURRENT_TIMESTAMP ON UPDATE " @@ -3176,7 +3176,7 @@ bool Column_definition::prepare_stage1_string(THD *thd, But not for blobs, as they will be stored as SQL expressions, not written down into the record image. */ - if (!(flags() & BLOB_FLAG) && default_value && + if (!(flags & BLOB_FLAG) && default_value && default_value->expr->basic_const_item() && charset != default_value->expr->collation.collation) { @@ -3235,7 +3235,7 @@ bool Column_definition::prepare_stage1_check_typelib_default() bool not_found; if (def == NULL) /* SQL "NULL" maps to NULL */ { - not_found= flags() & NOT_NULL_FLAG; + not_found= flags & NOT_NULL_FLAG; } else { @@ -3332,7 +3332,7 @@ static Create_field * add_hash_field(THD * thd, List<Create_field> *create_list, { List_iterator<Create_field> it(*create_list); Create_field *dup_field, *cf= new (thd->mem_root) Create_field(); - cf->add_flags(UNSIGNED_FLAG | LONG_UNIQUE_HASH_FIELD); + cf->flags|= UNSIGNED_FLAG | LONG_UNIQUE_HASH_FIELD; cf->decimals= 0; cf->length= cf->char_length= cf->pack_length= HA_HASH_FIELD_LENGTH; cf->invisible= INVISIBLE_FULL; @@ -3418,7 +3418,7 @@ key_add_part_check_null(const handler *file, KEY *key_info, const Column_definition *sql_field, const Key_part_spec *column) { - if (!(sql_field->flags() & NOT_NULL_FLAG)) + if (!(sql_field->flags & NOT_NULL_FLAG)) { key_info->flags|= HA_NULL_PART_KEY; if (!(file->ha_table_flags() & HA_NULL_IN_KEY)) @@ -3541,13 +3541,13 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info, sql_field->length= sql_field->char_length; /* Set field charset. */ sql_field->charset= get_sql_field_charset(sql_field, create_info); - if ((sql_field->flags() & BINCMP_FLAG) && + if ((sql_field->flags & BINCMP_FLAG) && !(sql_field->charset= find_bin_collation(sql_field->charset))) DBUG_RETURN(true); /* Virtual fields are always NULL */ if (sql_field->vcol_info) - sql_field->clear_flags(NOT_NULL_FLAG); + sql_field->flags&= ~NOT_NULL_FLAG; if (sql_field->prepare_stage1(thd, thd->mem_root, file, file->ha_table_flags())) @@ -3557,7 +3557,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info, file->ha_table_flags() & HA_CAN_BIT_FIELD) total_uneven_bit_length+= sql_field->length & 7; - if (!(sql_field->flags() & NOT_NULL_FLAG)) + if (!(sql_field->flags & NOT_NULL_FLAG)) null_fields++; if (check_column_name(sql_field->field_name.str)) @@ -3600,7 +3600,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info, dup_field->flags as flags. If we've incremented null_fields because of sql_field->flags, decrement it back. */ - if (!(sql_field->flags() & NOT_NULL_FLAG)) + if (!(sql_field->flags & NOT_NULL_FLAG)) null_fields--; if (sql_field->redefine_stage1(dup_field, file, create_info)) @@ -3613,7 +3613,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info, } } /* Don't pack rows in old tables if the user has requested this */ - if ((sql_field->flags() & BLOB_FLAG) || + if ((sql_field->flags & BLOB_FLAG) || (sql_field->real_field_type() == MYSQL_TYPE_VARCHAR && create_info->row_type != ROW_TYPE_FIXED)) (*db_options)|= HA_OPTION_PACK_RECORD; @@ -3647,7 +3647,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info, */ if (sql_field->stored_in_db()) record_offset+= sql_field->pack_length; - if (sql_field->flags() & VERS_SYSTEM_FIELD) + if (sql_field->flags & VERS_SYSTEM_FIELD) continue; } /* Update virtual fields' offset and give error if @@ -3949,7 +3949,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info, DBUG_RETURN(TRUE); } if (sql_field->invisible > INVISIBLE_USER && - !(sql_field->flags() & VERS_SYSTEM_FIELD) && + !(sql_field->flags & VERS_SYSTEM_FIELD) && !key->invisible && DBUG_EVALUATE_IF("test_invisible_index", 0, 1)) { my_error(ER_KEY_COLUMN_DOES_NOT_EXITS, MYF(0), column->field_name.str); @@ -3991,7 +3991,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info, *sql_field) || sql_field->check_vcol_for_key(thd)) DBUG_RETURN(TRUE); - if (!(sql_field->flags() & NOT_NULL_FLAG)) + if (!(sql_field->flags & NOT_NULL_FLAG)) { my_message(ER_SPATIAL_CANT_HAVE_NULL, ER_THD(thd, ER_SPATIAL_CANT_HAVE_NULL), MYF(0)); @@ -4009,10 +4009,10 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info, *sql_field, file)) DBUG_RETURN(TRUE); - if (!(sql_field->flags() & NOT_NULL_FLAG)) + if (!(sql_field->flags & NOT_NULL_FLAG)) { /* Implicitly set primary key fields to NOT NULL for ISO conf. */ - sql_field->add_flags(NOT_NULL_FLAG); + sql_field->flags|= NOT_NULL_FLAG; sql_field->pack_flag&= ~FIELDFLAG_MAYBE_NULL; null_fields--; } @@ -4105,7 +4105,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info, else if (!(file->ha_table_flags() & HA_NO_PREFIX_CHAR_KEYS)) key_part_length= column->length; } - else if (key_part_length == 0 && (sql_field->flags() & NOT_NULL_FLAG) && + else if (key_part_length == 0 && (sql_field->flags & NOT_NULL_FLAG) && !is_hash_field_needed) { my_error(ER_WRONG_KEY_COLUMN, MYF(0), file->table_type(), @@ -4234,7 +4234,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info, null_fields++; else { - hash_fld->add_flags(NOT_NULL_FLAG); + hash_fld->flags|= NOT_NULL_FLAG; hash_fld->pack_flag&= ~FIELDFLAG_MAYBE_NULL; } } @@ -4286,12 +4286,12 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info, */ if (!sql_field->default_value && !sql_field->has_default_function() && - (sql_field->flags() & NOT_NULL_FLAG) && + (sql_field->flags & NOT_NULL_FLAG) && (!sql_field->is_timestamp_type() || opt_explicit_defaults_for_timestamp)&& !sql_field->vers_sys_field()) { - sql_field->add_flags(NO_DEFAULT_VALUE_FLAG); + sql_field->flags|= NO_DEFAULT_VALUE_FLAG; sql_field->pack_flag|= FIELDFLAG_NO_DEFAULT; } @@ -4299,7 +4299,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info, !sql_field->default_value && !sql_field->vcol_info && sql_field->is_timestamp_type() && !opt_explicit_defaults_for_timestamp && - (sql_field->flags() & NOT_NULL_FLAG) && + (sql_field->flags & NOT_NULL_FLAG) && (type == Field::NONE || type == Field::TIMESTAMP_UN_FIELD)) { /* @@ -4320,8 +4320,8 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info, DBUG_RETURN(TRUE); } if (sql_field->invisible == INVISIBLE_USER && - sql_field->flags() & NOT_NULL_FLAG && - sql_field->flags() & NO_DEFAULT_VALUE_FLAG) + sql_field->flags & NOT_NULL_FLAG && + sql_field->flags & NO_DEFAULT_VALUE_FLAG) { my_error(ER_INVISIBLE_NOT_NULL_WITHOUT_DEFAULT, MYF(0), sql_field->field_name.str); @@ -4479,7 +4479,7 @@ bool Column_definition::prepare_blob_field(THD *thd) { DBUG_ENTER("Column_definition::prepare_blob_field"); - if (length > MAX_FIELD_VARCHARLENGTH && !(flags() & BLOB_FLAG)) + if (length > MAX_FIELD_VARCHARLENGTH && !(flags & BLOB_FLAG)) { /* Convert long VARCHAR columns to TEXT or BLOB */ char warn_buff[MYSQL_ERRMSG_SIZE]; @@ -4491,6 +4491,7 @@ bool Column_definition::prepare_blob_field(THD *thd) DBUG_RETURN(1); } set_handler(&type_handler_blob); + flags|= BLOB_FLAG; my_snprintf(warn_buff, sizeof(warn_buff), ER_THD(thd, ER_AUTO_CONVERT), field_name.str, (charset == &my_charset_bin) ? "VARBINARY" : "VARCHAR", @@ -4499,7 +4500,7 @@ bool Column_definition::prepare_blob_field(THD *thd) warn_buff); } - if ((flags() & BLOB_FLAG) && length) + if ((flags & BLOB_FLAG) && length) { if (real_field_type() == FIELD_TYPE_BLOB || real_field_type() == FIELD_TYPE_TINY_BLOB || @@ -6759,7 +6760,7 @@ static bool fill_alter_inplace_info(THD *thd, TABLE *table, bool varchar, { /* Clear marker for renamed or dropped field which we are going to set later. */ - field->clear_flags(FIELD_IS_RENAMED | FIELD_IS_DROPPED); + field->flags&= ~(FIELD_IS_RENAMED | FIELD_IS_DROPPED); /* Use transformed info to evaluate flags for storage engine. */ uint new_field_index= 0, new_field_stored_index= 0; @@ -6859,7 +6860,7 @@ static bool fill_alter_inplace_info(THD *thd, TABLE *table, bool varchar, } if (field->vcol_info->is_in_partitioning_expr() || - field->flags() & PART_KEY_FLAG) + field->flags & PART_KEY_FLAG) { if (value_changes) ha_alter_info->handler_flags|= ALTER_COLUMN_VCOL; @@ -6875,17 +6876,17 @@ static bool fill_alter_inplace_info(THD *thd, TABLE *table, bool varchar, if (lex_string_cmp(system_charset_info, &field->field_name, &new_field->field_name)) { - field->add_flags(FIELD_IS_RENAMED); + field->flags|= FIELD_IS_RENAMED; ha_alter_info->handler_flags|= ALTER_COLUMN_NAME; rename_column_in_stat_tables(thd, table, field, new_field->field_name.str); } /* Check that NULL behavior is same for old and new fields */ - if ((new_field->flags() & NOT_NULL_FLAG) != - (uint) (field->flags() & NOT_NULL_FLAG)) + if ((new_field->flags & NOT_NULL_FLAG) != + (uint) (field->flags & NOT_NULL_FLAG)) { - if (new_field->flags() & NOT_NULL_FLAG) + if (new_field->flags & NOT_NULL_FLAG) ha_alter_info->handler_flags|= ALTER_COLUMN_NOT_NULLABLE; else ha_alter_info->handler_flags|= ALTER_COLUMN_NULLABLE; @@ -6929,7 +6930,7 @@ static bool fill_alter_inplace_info(THD *thd, TABLE *table, bool varchar, else { // Field is not present in new version of table and therefore was dropped. - field->add_flags(FIELD_IS_DROPPED); + field->flags|= FIELD_IS_DROPPED; if (field->stored_in_db()) ha_alter_info->handler_flags|= ALTER_DROP_STORED_COLUMN; else @@ -7181,7 +7182,7 @@ static void update_altered_table(const Alter_inplace_info &ha_alter_info, for fields which participate in new indexes. */ for (field_idx= 0; field_idx < altered_table->s->fields; ++field_idx) - altered_table->field[field_idx]->clear_flags(FIELD_IN_ADD_INDEX); + altered_table->field[field_idx]->flags&= ~FIELD_IN_ADD_INDEX; /* Go through array of newly added indexes and mark fields @@ -7195,7 +7196,7 @@ static void update_altered_table(const Alter_inplace_info &ha_alter_info, end= key->key_part + key->user_defined_key_parts; for (key_part= key->key_part; key_part < end; key_part++) - altered_table->field[key_part->fieldnr]->add_flags(FIELD_IN_ADD_INDEX); + altered_table->field[key_part->fieldnr]->flags|= FIELD_IN_ADD_INDEX; } } @@ -7267,8 +7268,8 @@ bool mysql_compare_tables(TABLE *table, Create_field *tmp_new_field= tmp_new_field_it++; /* Check that NULL behavior is the same. */ - if ((tmp_new_field->flags() & NOT_NULL_FLAG) != - (uint) (field->flags() & NOT_NULL_FLAG)) + if ((tmp_new_field->flags & NOT_NULL_FLAG) != + (uint) (field->flags & NOT_NULL_FLAG)) DBUG_RETURN(false); /* @@ -7280,7 +7281,7 @@ bool mysql_compare_tables(TABLE *table, */ if (create_info->row_type == ROW_TYPE_DYNAMIC || create_info->row_type == ROW_TYPE_PAGE || - (tmp_new_field->flags() & BLOB_FLAG) || + (tmp_new_field->flags & BLOB_FLAG) || (tmp_new_field->real_field_type() == MYSQL_TYPE_VARCHAR && create_info->row_type != ROW_TYPE_FIXED)) create_info->table_options|= HA_OPTION_PACK_RECORD; @@ -8051,7 +8052,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table, 3. unless it's a system versioning column (but see below). */ if (drop && field->invisible < INVISIBLE_SYSTEM && - !(field->flags() & VERS_SYSTEM_FIELD && + !(field->flags & VERS_SYSTEM_FIELD && !(alter_info->flags & ALTER_DROP_SYSTEM_VERSIONING))) { /* Reset auto_increment value if it was dropped */ @@ -8063,7 +8064,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table, } if (table->s->tmp_table == NO_TMP_TABLE) (void) delete_statistics_for_column(thd, table, field); - dropped_sys_vers_fields|= field->flags(); + dropped_sys_vers_fields|= field->flags; drop_it.remove(); dropped_fields= &table->tmp_set; bitmap_set_bit(dropped_fields, field->field_index); @@ -8072,7 +8073,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table, /* invisible versioning column is dropped automatically on DROP SYSTEM VERSIONING */ if (!drop && field->invisible >= INVISIBLE_SYSTEM && - field->flags() & VERS_SYSTEM_FIELD && + field->flags & VERS_SYSTEM_FIELD && alter_info->flags & ALTER_DROP_SYSTEM_VERSIONING) { if (table->s->tmp_table == NO_TMP_TABLE) @@ -8134,7 +8135,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table, } } else if (alter_info->flags & ALTER_DROP_SYSTEM_VERSIONING && - field->flags() & VERS_SYSTEM_FIELD && + field->flags & VERS_SYSTEM_FIELD && field->invisible < INVISIBLE_SYSTEM) { StringBuffer<NAME_LEN*3> tmp; @@ -8143,19 +8144,19 @@ mysql_prepare_alter_table(THD *thd, TABLE *table, goto err; } else if (drop && field->invisible < INVISIBLE_SYSTEM && - field->flags() & VERS_SYSTEM_FIELD && + field->flags & VERS_SYSTEM_FIELD && !(alter_info->flags & ALTER_DROP_SYSTEM_VERSIONING)) { /* "dropping" a versioning field only hides it from the user */ def= new (thd->mem_root) Create_field(thd, field, field); def->invisible= INVISIBLE_SYSTEM; alter_info->flags|= ALTER_CHANGE_COLUMN; - if (field->flags() & VERS_SYS_START_FLAG) + if (field->flags & VERS_SYS_START_FLAG) create_info->vers_info.as_row.start= def->field_name= Vers_parse_info::default_start; else create_info->vers_info.as_row.end= def->field_name= Vers_parse_info::default_end; new_create_list.push_back(def, thd->mem_root); - dropped_sys_vers_fields|= field->flags(); + dropped_sys_vers_fields|= field->flags; drop_it.remove(); } else @@ -8177,9 +8178,9 @@ mysql_prepare_alter_table(THD *thd, TABLE *table, if (alter) { if ((def->default_value= alter->default_value)) - def->clear_flags(NO_DEFAULT_VALUE_FLAG); + def->flags&= ~NO_DEFAULT_VALUE_FLAG; else - def->add_flags(NO_DEFAULT_VALUE_FLAG); + def->flags|= NO_DEFAULT_VALUE_FLAG; alter_it.remove(); } } @@ -8232,13 +8233,13 @@ mysql_prepare_alter_table(THD *thd, TABLE *table, flag to allow ALTER TABLE only if the table to be altered is empty. */ if (!alter_ctx->implicit_default_value_error_field && - !(~def->flags() & (NO_DEFAULT_VALUE_FLAG | NOT_NULL_FLAG)) && + !(~def->flags & (NO_DEFAULT_VALUE_FLAG | NOT_NULL_FLAG)) && def->type_handler()->validate_implicit_default_value(thd, *def)) { alter_ctx->implicit_default_value_error_field= def; alter_ctx->error_if_not_empty= TRUE; } - if (def->flags() & VERS_SYSTEM_FIELD && + if (def->flags & VERS_SYSTEM_FIELD && !(alter_info->flags & ALTER_ADD_SYSTEM_VERSIONING)) { my_error(ER_VERS_NOT_VERSIONED, MYF(0), table->s->table_name.str); @@ -8305,9 +8306,9 @@ mysql_prepare_alter_table(THD *thd, TABLE *table, if (alter) { if ((def->default_value= alter->default_value)) // Use new default - def->clear_flags(NO_DEFAULT_VALUE_FLAG); + def->flags&= ~NO_DEFAULT_VALUE_FLAG; else - def->add_flags(NO_DEFAULT_VALUE_FLAG); + def->flags|= NO_DEFAULT_VALUE_FLAG; alter_it.remove(); } } @@ -8400,7 +8401,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table, if (table->s->primary_key == i) modified_primary_key= TRUE; delete_index_stat= TRUE; - if (!(kfield->flags() & VERS_SYSTEM_FIELD)) + if (!(kfield->flags & VERS_SYSTEM_FIELD)) dropped_key_part= key_part_name; continue; // Field is removed } @@ -8796,8 +8797,8 @@ fk_check_column_changes(THD *thd, Alter_info *alter_info, } if ((old_field->is_equal(*new_field) == IS_EQUAL_NO) || - ((new_field->flags() & NOT_NULL_FLAG) && - !(old_field->flags() & NOT_NULL_FLAG))) + ((new_field->flags & NOT_NULL_FLAG) && + !(old_field->flags & NOT_NULL_FLAG))) { if (!(thd->variables.option_bits & OPTION_NO_FOREIGN_KEY_CHECKS)) { @@ -10811,7 +10812,7 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to, { const char *err_msg= ER_THD(thd, ER_DUP_ENTRY_WITH_KEY_NAME); if (key_nr == 0 && to->s->keys > 0 && - (to->key_info[0].key_part[0].field->flags() & + (to->key_info[0].key_part[0].field->flags & AUTO_INCREMENT_FLAG)) err_msg= ER_THD(thd, ER_DUP_ENTRY_AUTOINCREMENT_CASE); print_keydup_error(to, diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc index 4fa28ca896c..64bf24aa4fc 100644 --- a/sql/sql_trigger.cc +++ b/sql/sql_trigger.cc @@ -1239,7 +1239,7 @@ bool Table_triggers_list::prepare_record_accessors(TABLE *table) table == (*fld)->table))) return 1; - f->set_flags((*fld)->cached_flags()); + f->flags= (*fld)->flags; f->invisible= (*fld)->invisible; f->null_ptr= null_ptr; f->null_bit= null_bit; diff --git a/sql/sql_type.cc b/sql/sql_type.cc index 8eae70a3918..f9a16e72f0f 100644 --- a/sql/sql_type.cc +++ b/sql/sql_type.cc @@ -2533,6 +2533,7 @@ bool Type_handler_string:: bool Type_handler_blob_common:: Column_definition_fix_attributes(Column_definition *def) const { + def->flags|= BLOB_FLAG; return def->check_length(ER_TOO_BIG_DISPLAYWIDTH, MAX_FIELD_BLOBLENGTH); } @@ -2542,7 +2543,7 @@ bool Type_handler_year:: { if (!def->length || def->length != 2) def->length= 4; // Default length - def->add_flags(ZEROFILL_FLAG | UNSIGNED_FLAG); + def->flags|= ZEROFILL_FLAG | UNSIGNED_FLAG; return false; } @@ -2562,7 +2563,7 @@ bool Type_handler_double:: bool Type_handler_timestamp_common:: Column_definition_fix_attributes(Column_definition *def) const { - def->add_flags(UNSIGNED_FLAG); + def->flags|= UNSIGNED_FLAG; return def->fix_attributes_temporal_with_time(MAX_DATETIME_WIDTH); } @@ -2623,7 +2624,7 @@ void Type_handler_typelib:: Column_definition *def, const Field *field) const { - DBUG_ASSERT(def->flags() & (ENUM_FLAG | SET_FLAG)); + DBUG_ASSERT(def->flags & (ENUM_FLAG | SET_FLAG)); def->interval= field->get_typelib(); } diff --git a/sql/sql_type.h b/sql/sql_type.h index 70128d67a95..a696ada93df 100644 --- a/sql/sql_type.h +++ b/sql/sql_type.h @@ -3313,7 +3313,6 @@ public: virtual const Name name() const= 0; virtual const Name version() const { return m_version_default; } virtual const Name &default_value() const= 0; - virtual uint32 flags() const { return 0; } virtual enum_field_types field_type() const= 0; virtual enum_field_types real_field_type() const { return field_type(); } /** @@ -6443,7 +6442,6 @@ class Type_handler_blob_common: public Type_handler_longstr { public: virtual ~Type_handler_blob_common() { } - uint32 flags() const override { return BLOB_FLAG; } virtual uint length_bytes() const= 0; Field *make_conversion_table_field(MEM_ROOT *root, TABLE *table, uint metadata, @@ -6650,7 +6648,6 @@ class Type_handler_enum: public Type_handler_typelib public: virtual ~Type_handler_enum() {} const Name name() const override { return m_name_enum; } - uint32 flags() const override { return ENUM_FLAG; } enum_field_types real_field_type() const override { return MYSQL_TYPE_ENUM; } enum_field_types traditional_merge_field_type() const override { @@ -6691,7 +6688,6 @@ class Type_handler_set: public Type_handler_typelib public: virtual ~Type_handler_set() {} const Name name() const override { return m_name_set; } - uint32 flags() const override { return SET_FLAG; } enum_field_types real_field_type() const override { return MYSQL_TYPE_SET; } enum_field_types traditional_merge_field_type() const override { diff --git a/sql/sql_type_geom.cc b/sql/sql_type_geom.cc index 2bce7987c13..9bd8e3935b8 100644 --- a/sql/sql_type_geom.cc +++ b/sql/sql_type_geom.cc @@ -228,6 +228,7 @@ Field *Type_handler_geometry::make_conversion_table_field(MEM_ROOT *root, bool Type_handler_geometry:: Column_definition_fix_attributes(Column_definition *def) const { + def->flags|= BLOB_FLAG; return false; } diff --git a/sql/sql_type_geom.h b/sql/sql_type_geom.h index cebd809f29e..699b5280611 100644 --- a/sql/sql_type_geom.h +++ b/sql/sql_type_geom.h @@ -43,7 +43,6 @@ public: public: virtual ~Type_handler_geometry() {} const Name name() const override { return m_name_geometry; } - uint32 flags() const override { return BLOB_FLAG; } enum_field_types field_type() const override { return MYSQL_TYPE_GEOMETRY; } bool is_param_long_data_type() const override { return true; } uint32 max_display_length_for_field(const Conv_source &src) const override; diff --git a/sql/sql_union.cc b/sql/sql_union.cc index b0b98fbf8bd..41f4234c13d 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -377,7 +377,7 @@ select_unit::create_result_table(THD *thd_arg, List<Item> *column_types, table->keys_in_use_for_query.clear_all(); for (uint i=0; i < table->s->fields; i++) - table->field[i]->clear_flags(PART_KEY_FLAG | PART_INDIRECT_KEY_FLAG); + table->field[i]->flags &= ~(PART_KEY_FLAG | PART_INDIRECT_KEY_FLAG); if (create_table) { @@ -413,7 +413,7 @@ select_union_recursive::create_result_table(THD *thd_arg, incr_table->keys_in_use_for_query.clear_all(); for (uint i=0; i < table->s->fields; i++) - incr_table->field[i]->clear_flags(PART_KEY_FLAG | PART_INDIRECT_KEY_FLAG); + incr_table->field[i]->flags &= ~(PART_KEY_FLAG | PART_INDIRECT_KEY_FLAG); TABLE *rec_table= 0; if (! (rec_table= create_tmp_table(thd_arg, &tmp_table_param, *column_types, @@ -424,7 +424,7 @@ select_union_recursive::create_result_table(THD *thd_arg, rec_table->keys_in_use_for_query.clear_all(); for (uint i=0; i < table->s->fields; i++) - rec_table->field[i]->clear_flags(PART_KEY_FLAG | PART_INDIRECT_KEY_FLAG); + rec_table->field[i]->flags &= ~(PART_KEY_FLAG | PART_INDIRECT_KEY_FLAG); if (rec_tables.push_back(rec_table)) return true; diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index f593a4002e7..8fce24bfc3e 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -666,7 +666,7 @@ bool LEX::set_bincmp(CHARSET_INFO *cs, bool bin) if (!charset) { charset= cs; - last_field->add_flags(bin ? BINCMP_FLAG : 0); + last_field->flags|= bin ? BINCMP_FLAG : 0; return false; } @@ -6648,9 +6648,9 @@ field_spec: lex->alter_info.create_list.push_back($$, thd->mem_root); $$->create_if_not_exists= Lex->check_exists; - if ($$->flags() & PRI_KEY_FLAG) + if ($$->flags & PRI_KEY_FLAG) lex->add_key_to_list(&$1, Key::PRIMARY, lex->check_exists); - else if ($$->flags() & UNIQUE_KEY_FLAG) + else if ($$->flags & UNIQUE_KEY_FLAG) lex->add_key_to_list(&$1, Key::UNIQUE, lex->check_exists); } ; @@ -6661,8 +6661,8 @@ field_type_or_serial: | SERIAL_SYM { Lex->last_field->set_handler(&type_handler_longlong); - Lex->last_field->add_flags(AUTO_INCREMENT_FLAG | NOT_NULL_FLAG | - UNSIGNED_FLAG | UNIQUE_KEY_FLAG); + Lex->last_field->flags|= AUTO_INCREMENT_FLAG | NOT_NULL_FLAG + | UNSIGNED_FLAG | UNIQUE_KEY_FLAG; } opt_serial_attribute ; @@ -6695,7 +6695,7 @@ field_def: | opt_generated_always AS virtual_column_func { Lex->last_field->vcol_info= $3; - Lex->last_field->clear_flags(NOT_NULL_FLAG); // undo automatic NOT NULL for timestamps + Lex->last_field->flags&= ~NOT_NULL_FLAG; // undo automatic NOT NULL for timestamps } vcol_opt_specifier vcol_opt_attribute | opt_generated_always AS ROW_SYM START_SYM opt_asrow_attribute @@ -6748,13 +6748,13 @@ vcol_attribute: UNIQUE_SYM { LEX *lex=Lex; - lex->last_field->add_flags(UNIQUE_KEY_FLAG); + lex->last_field->flags|= UNIQUE_KEY_FLAG; lex->alter_info.flags|= ALTER_ADD_INDEX; } | UNIQUE_SYM KEY_SYM { LEX *lex=Lex; - lex->last_field->add_flags(UNIQUE_KEY_FLAG); + lex->last_field->flags|= UNIQUE_KEY_FLAG; lex->alter_info.flags|= ALTER_ADD_INDEX; } | COMMENT_SYM TEXT_STRING_sys { Lex->last_field->comment= $2; } @@ -6976,7 +6976,7 @@ field_type_temporal: Unless --explicit-defaults-for-timestamp is given. */ if (!opt_explicit_defaults_for_timestamp) - Lex->last_field->add_flags(NOT_NULL_FLAG); + Lex->last_field->flags|= NOT_NULL_FLAG; $$.set(opt_mysql56_temporal_format ? static_cast<const Type_handler*>(&type_handler_timestamp2): static_cast<const Type_handler*>(&type_handler_timestamp), @@ -7121,10 +7121,10 @@ precision: field_options: /* empty */ {} | SIGNED_SYM {} - | UNSIGNED { Lex->last_field->add_flags(UNSIGNED_FLAG);} - | ZEROFILL { Lex->last_field->add_flags(UNSIGNED_FLAG | ZEROFILL_FLAG); } - | UNSIGNED ZEROFILL { Lex->last_field->add_flags(UNSIGNED_FLAG | ZEROFILL_FLAG); } - | ZEROFILL UNSIGNED { Lex->last_field->add_flags(UNSIGNED_FLAG | ZEROFILL_FLAG); } + | UNSIGNED { Lex->last_field->flags|= UNSIGNED_FLAG;} + | ZEROFILL { Lex->last_field->flags|= UNSIGNED_FLAG | ZEROFILL_FLAG; } + | UNSIGNED ZEROFILL { Lex->last_field->flags|= UNSIGNED_FLAG | ZEROFILL_FLAG; } + | ZEROFILL UNSIGNED { Lex->last_field->flags|= UNSIGNED_FLAG | ZEROFILL_FLAG; } ; field_length: @@ -7155,7 +7155,7 @@ attribute_list: ; attribute: - NULL_SYM { Lex->last_field->clear_flags(NOT_NULL_FLAG); } + NULL_SYM { Lex->last_field->flags&= ~ NOT_NULL_FLAG; } | DEFAULT column_default_expr { Lex->last_field->default_value= $2; } | ON UPDATE_SYM NOW_SYM opt_default_time_precision { @@ -7164,11 +7164,11 @@ attribute: MYSQL_YYABORT; Lex->last_field->on_update= item; } - | AUTO_INC { Lex->last_field->add_flags(AUTO_INCREMENT_FLAG | NOT_NULL_FLAG); } + | AUTO_INC { Lex->last_field->flags|= AUTO_INCREMENT_FLAG | NOT_NULL_FLAG; } | SERIAL_SYM DEFAULT VALUE_SYM { LEX *lex=Lex; - lex->last_field->add_flags(AUTO_INCREMENT_FLAG | NOT_NULL_FLAG | UNIQUE_KEY_FLAG); + lex->last_field->flags|= AUTO_INCREMENT_FLAG | NOT_NULL_FLAG | UNIQUE_KEY_FLAG; lex->alter_info.flags|= ALTER_ADD_INDEX; } | COLLATE_SYM collation_name @@ -7219,12 +7219,12 @@ compressed_deprecated_column_attribute: asrow_attribute: not NULL_SYM { - Lex->last_field->add_flags(NOT_NULL_FLAG); + Lex->last_field->flags|= NOT_NULL_FLAG; } | opt_primary KEY_SYM { LEX *lex=Lex; - lex->last_field->add_flags(PRI_KEY_FLAG | NOT_NULL_FLAG); + lex->last_field->flags|= PRI_KEY_FLAG | NOT_NULL_FLAG; lex->alter_info.flags|= ALTER_ADD_INDEX; } | vcol_attribute diff --git a/sql/sql_yacc_ora.yy b/sql/sql_yacc_ora.yy index eb691db00c2..290e13e16a0 100644 --- a/sql/sql_yacc_ora.yy +++ b/sql/sql_yacc_ora.yy @@ -6647,9 +6647,9 @@ field_spec: lex->alter_info.create_list.push_back($$, thd->mem_root); $$->create_if_not_exists= Lex->check_exists; - if ($$->flags() & PRI_KEY_FLAG) + if ($$->flags & PRI_KEY_FLAG) lex->add_key_to_list(&$1, Key::PRIMARY, lex->check_exists); - else if ($$->flags() & UNIQUE_KEY_FLAG) + else if ($$->flags & UNIQUE_KEY_FLAG) lex->add_key_to_list(&$1, Key::UNIQUE, lex->check_exists); } ; @@ -6660,8 +6660,8 @@ field_type_or_serial: | SERIAL_SYM { Lex->last_field->set_handler(&type_handler_longlong); - Lex->last_field->add_flags(AUTO_INCREMENT_FLAG | NOT_NULL_FLAG | - UNSIGNED_FLAG | UNIQUE_KEY_FLAG); + Lex->last_field->flags|= AUTO_INCREMENT_FLAG | NOT_NULL_FLAG + | UNSIGNED_FLAG | UNIQUE_KEY_FLAG; } opt_serial_attribute ; @@ -6694,7 +6694,7 @@ field_def: | opt_generated_always AS virtual_column_func { Lex->last_field->vcol_info= $3; - Lex->last_field->clear_flags(NOT_NULL_FLAG); // undo automatic NOT NULL for timestamps + Lex->last_field->flags&= ~NOT_NULL_FLAG; // undo automatic NOT NULL for timestamps } vcol_opt_specifier vcol_opt_attribute | opt_generated_always AS ROW_SYM START_SYM opt_asrow_attribute @@ -6747,13 +6747,13 @@ vcol_attribute: UNIQUE_SYM { LEX *lex=Lex; - lex->last_field->add_flags(UNIQUE_KEY_FLAG); + lex->last_field->flags|= UNIQUE_KEY_FLAG; lex->alter_info.flags|= ALTER_ADD_INDEX; } | UNIQUE_SYM KEY_SYM { LEX *lex=Lex; - lex->last_field->add_flags(UNIQUE_KEY_FLAG); + lex->last_field->flags|= UNIQUE_KEY_FLAG; lex->alter_info.flags|= ALTER_ADD_INDEX; } | COMMENT_SYM TEXT_STRING_sys { Lex->last_field->comment= $2; } @@ -7027,7 +7027,7 @@ field_type_temporal: Unless --explicit-defaults-for-timestamp is given. */ if (!opt_explicit_defaults_for_timestamp) - Lex->last_field->add_flags(NOT_NULL_FLAG); + Lex->last_field->flags|= NOT_NULL_FLAG; $$.set(opt_mysql56_temporal_format ? static_cast<const Type_handler*>(&type_handler_timestamp2): static_cast<const Type_handler*>(&type_handler_timestamp), @@ -7172,10 +7172,10 @@ precision: field_options: /* empty */ {} | SIGNED_SYM {} - | UNSIGNED { Lex->last_field->add_flags(UNSIGNED_FLAG);} - | ZEROFILL { Lex->last_field->add_flags(UNSIGNED_FLAG | ZEROFILL_FLAG); } - | UNSIGNED ZEROFILL { Lex->last_field->add_flags(UNSIGNED_FLAG | ZEROFILL_FLAG); } - | ZEROFILL UNSIGNED { Lex->last_field->add_flags(UNSIGNED_FLAG | ZEROFILL_FLAG); } + | UNSIGNED { Lex->last_field->flags|= UNSIGNED_FLAG;} + | ZEROFILL { Lex->last_field->flags|= UNSIGNED_FLAG | ZEROFILL_FLAG; } + | UNSIGNED ZEROFILL { Lex->last_field->flags|= UNSIGNED_FLAG | ZEROFILL_FLAG; } + | ZEROFILL UNSIGNED { Lex->last_field->flags|= UNSIGNED_FLAG | ZEROFILL_FLAG; } ; field_length: @@ -7233,7 +7233,7 @@ attribute_list: ; attribute: - NULL_SYM { Lex->last_field->clear_flags(NOT_NULL_FLAG); } + NULL_SYM { Lex->last_field->flags&= ~ NOT_NULL_FLAG; } | DEFAULT column_default_expr { Lex->last_field->default_value= $2; } | ON UPDATE_SYM NOW_SYM opt_default_time_precision { @@ -7242,11 +7242,11 @@ attribute: MYSQL_YYABORT; Lex->last_field->on_update= item; } - | AUTO_INC { Lex->last_field->add_flags(AUTO_INCREMENT_FLAG | NOT_NULL_FLAG); } + | AUTO_INC { Lex->last_field->flags|= AUTO_INCREMENT_FLAG | NOT_NULL_FLAG; } | SERIAL_SYM DEFAULT VALUE_SYM { LEX *lex=Lex; - lex->last_field->add_flags(AUTO_INCREMENT_FLAG | NOT_NULL_FLAG | UNIQUE_KEY_FLAG); + lex->last_field->flags|= AUTO_INCREMENT_FLAG | NOT_NULL_FLAG | UNIQUE_KEY_FLAG; lex->alter_info.flags|= ALTER_ADD_INDEX; } | COLLATE_SYM collation_name @@ -7297,12 +7297,12 @@ compressed_deprecated_column_attribute: asrow_attribute: not NULL_SYM { - Lex->last_field->add_flags(NOT_NULL_FLAG); + Lex->last_field->flags|= NOT_NULL_FLAG; } | opt_primary KEY_SYM { LEX *lex=Lex; - lex->last_field->add_flags(PRI_KEY_FLAG | NOT_NULL_FLAG); + lex->last_field->flags|= PRI_KEY_FLAG | NOT_NULL_FLAG; lex->alter_info.flags|= ALTER_ADD_INDEX; } | vcol_attribute diff --git a/sql/table.cc b/sql/table.cc index d1252b3afc1..6951b21c53d 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -1180,7 +1180,7 @@ bool parse_vcol_defs(THD *thd, MEM_ROOT *mem_root, TABLE *table, for (field_ptr= table->field; *field_ptr; field_ptr++) { Field *field= *field_ptr; - if (field->flags() & LONG_UNIQUE_HASH_FIELD) + if (field->flags & LONG_UNIQUE_HASH_FIELD) { List<Item> *field_list= new (mem_root) List<Item>(); Item *list_item; @@ -2457,12 +2457,12 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write, reg_field->field_index= i; reg_field->comment=comment; reg_field->vcol_info= vcol_info; - reg_field->add_flags(flags); + reg_field->flags|= flags; if (extra2.field_flags.str) { uchar flags= *extra2.field_flags.str++; if (flags & VERS_OPTIMIZED_UPDATE) - reg_field->add_flags(VERS_UPDATE_UNVERSIONED_FLAG); + reg_field->flags|= VERS_UPDATE_UNVERSIONED_FLAG; reg_field->invisible= f_visibility(flags); } @@ -2480,7 +2480,7 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write, null_bit_pos-= 8; } } - if (!(reg_field->flags() & NOT_NULL_FLAG)) + if (!(reg_field->flags & NOT_NULL_FLAG)) { if (!(null_bit_pos= (null_bit_pos + 1) & 7)) null_pos++; @@ -2498,7 +2498,7 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write, } if (f_no_default(attr.pack_flag)) - reg_field->add_flags(NO_DEFAULT_VALUE_FLAG); + reg_field->flags|= NO_DEFAULT_VALUE_FLAG; if (reg_field->unireg_check == Field::NEXT_NUMBER) share->found_next_number_field= field_ptr; @@ -2555,7 +2555,7 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write, hash_keypart->offset= offset; hash_keypart->fieldnr= hash_field_used_no + 1; hash_field= share->field[hash_field_used_no]; - hash_field->add_flags(LONG_UNIQUE_HASH_FIELD);//Used in parse_vcol_defs + hash_field->flags|= LONG_UNIQUE_HASH_FIELD;//Used in parse_vcol_defs keyinfo->flags|= HA_NOSAME; share->virtual_fields++; share->stored_fields--; @@ -2773,14 +2773,14 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write, keyinfo->key_length+= key_part_length_bytes; if (i == 0 && key != primary_key) - field->add_flags((((keyinfo->flags & HA_NOSAME || + field->flags |= (((keyinfo->flags & HA_NOSAME || keyinfo->algorithm == HA_KEY_ALG_LONG_HASH) && (keyinfo->user_defined_key_parts == 1)) ? - UNIQUE_KEY_FLAG : MULTIPLE_KEY_FLAG)); + UNIQUE_KEY_FLAG : MULTIPLE_KEY_FLAG); if (i == 0) field->key_start.set_bit(key); if (field->key_length() == key_part->length && - !(field->flags() & BLOB_FLAG) && + !(field->flags & BLOB_FLAG) && keyinfo->algorithm != HA_KEY_ALG_LONG_HASH) { if (handler_file->index_flags(key, i, 0) & HA_KEYREAD_ONLY) @@ -2796,10 +2796,10 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write, if (!(key_part->key_part_flag & HA_REVERSE_SORT) && usable_parts == i) usable_parts++; // For FILESORT - field->add_flags(PART_KEY_FLAG); + field->flags|= PART_KEY_FLAG; if (key == primary_key) { - field->add_flags(PRI_KEY_FLAG); + field->flags|= PRI_KEY_FLAG; /* If this field is part of the primary key and all keys contains the primary key, then we can use any key to find this column @@ -2807,7 +2807,7 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write, if (ha_option & HA_PRIMARY_KEY_IN_READ_INDEX) { if (field->key_length() == key_part->length && - !(field->flags() & BLOB_FLAG)) + !(field->flags & BLOB_FLAG)) field->part_of_key= share->keys_in_use; if (field->part_of_sortkey.is_set(key)) field->part_of_sortkey= share->keys_in_use; @@ -2964,7 +2964,7 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write, reg_field->vcol_info= vcol_info; share->virtual_fields++; share->stored_fields--; - if (reg_field->flags() & BLOB_FLAG) + if (reg_field->flags & BLOB_FLAG) share->virtual_not_stored_blob_fields++; /* Correct stored_rec_length as non stored fields are last */ recpos= (uint) (reg_field->ptr - record); @@ -3017,7 +3017,7 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write, &share->next_number_key_offset, &share->next_number_keypart)) < 0) goto err; // Wrong field definition - reg_field->add_flags(AUTO_INCREMENT_FLAG); + reg_field->flags |= AUTO_INCREMENT_FLAG; } if (share->blob_fields) @@ -3032,7 +3032,7 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write, goto err; for (k=0, ptr= share->field ; *ptr ; ptr++, k++) { - if ((*ptr)->flags() & BLOB_FLAG) + if ((*ptr)->flags & BLOB_FLAG) (*save++)= k; } } @@ -3523,15 +3523,15 @@ static bool check_vcol_forward_refs(Field *field, Virtual_column_info *vcol, bool check_constraint) { bool res; - uint32 flags= field->cached_flags(); + uint32 flags= field->flags; if (check_constraint) { /* Check constraints can refer it itself */ - field->add_flags(NO_DEFAULT_VALUE_FLAG); + field->flags|= NO_DEFAULT_VALUE_FLAG; } res= (vcol && vcol->expr->walk(&Item::check_field_expression_processor, 0, field)); - field->set_flags(flags); + field->flags= flags; return res; } @@ -3813,7 +3813,7 @@ enum open_frm_error open_table_from_share(THD *thd, TABLE_SHARE *share, { Field *field= key_part->field= outparam->field[key_part->fieldnr - 1]; if (field->key_length() != key_part->length && - !(field->flags() & BLOB_FLAG)) + !(field->flags & BLOB_FLAG)) { /* We are using only a prefix of the column as a key: @@ -4029,8 +4029,8 @@ partititon_err: // copy PART_INDIRECT_KEY_FLAG that was set meanwhile by *some* thread for (uint i= 0 ; i < share->fields ; i++) { - if (share->field[i]->flags() & PART_INDIRECT_KEY_FLAG) - outparam->field[i]->add_flags(PART_INDIRECT_KEY_FLAG); + if (share->field[i]->flags & PART_INDIRECT_KEY_FLAG) + outparam->field[i]->flags|= PART_INDIRECT_KEY_FLAG; } } @@ -6959,7 +6959,7 @@ void TABLE::mark_columns_needed_for_delete() Field **reg_field; for (reg_field= field ; *reg_field ; reg_field++) { - if ((*reg_field)->flags() & (PART_KEY_FLAG | PART_INDIRECT_KEY_FLAG)) + if ((*reg_field)->flags & (PART_KEY_FLAG | PART_INDIRECT_KEY_FLAG)) mark_column_with_deps(*reg_field); } need_signal= true; @@ -7212,7 +7212,7 @@ void TABLE::mark_columns_per_binlog_row_image() If set in the AI, then the blob is really needed, there is nothing we can do about it. */ - if ((my_field->flags() & PRI_KEY_FLAG) || + if ((my_field->flags & PRI_KEY_FLAG) || (my_field->type() != MYSQL_TYPE_BLOB)) { bitmap_set_bit(read_set, my_field->field_index); @@ -7285,8 +7285,8 @@ bool TABLE::mark_virtual_columns_for_write(bool insert_fl if (bitmap_is_set(write_set, tmp_vfield->field_index)) bitmap_updated|= mark_virtual_column_with_deps(tmp_vfield); else if (tmp_vfield->vcol_info->stored_in_db || - (tmp_vfield->flags() & (PART_KEY_FLAG | FIELD_IN_PART_FUNC_FLAG | - PART_INDIRECT_KEY_FLAG))) + (tmp_vfield->flags & (PART_KEY_FLAG | FIELD_IN_PART_FUNC_FLAG | + PART_INDIRECT_KEY_FLAG))) { bitmap_set_bit(write_set, tmp_vfield->field_index); mark_virtual_column_with_deps(tmp_vfield); @@ -7396,7 +7396,7 @@ void TABLE::mark_columns_used_by_virtual_fields(void) { for (vfield_ptr= vfield; *vfield_ptr; vfield_ptr++) { - if ((*vfield_ptr)->flags() & PART_KEY_FLAG) + if ((*vfield_ptr)->flags & PART_KEY_FLAG) (*vfield_ptr)->vcol_info->expr->walk(&Item::add_field_to_set_processor, 1, this); } @@ -7404,7 +7404,7 @@ void TABLE::mark_columns_used_by_virtual_fields(void) { if (bitmap_is_set(&tmp_set, i)) { - s->field[i]->add_flags(PART_INDIRECT_KEY_FLAG); + s->field[i]->flags|= PART_INDIRECT_KEY_FLAG; v_keys= TABLE_SHARE::V_KEYS; } } @@ -7723,7 +7723,7 @@ bool TABLE::add_tmp_key(uint key, uint key_parts, (*reg_field)->part_of_key.set_bit(key); create_key_part_by_field(key_part_info, *reg_field, fld_idx+1); keyinfo->key_length += key_part_info->store_length; - (*reg_field)->add_flags(PART_KEY_FLAG); + (*reg_field)->flags|= PART_KEY_FLAG; key_start= FALSE; key_part_info++; } @@ -8274,10 +8274,10 @@ int TABLE::update_virtual_fields(handler *h, enum_vcol_update_mode update_mode) break; case VCOL_UPDATE_FOR_REPLACE: update= ((!vcol_info->stored_in_db && - (vf->flags() & (PART_KEY_FLAG | PART_INDIRECT_KEY_FLAG)) && + (vf->flags & (PART_KEY_FLAG | PART_INDIRECT_KEY_FLAG)) && bitmap_is_set(read_set, vf->field_index)) || update_all_columns); - if (update && (vf->flags() & BLOB_FLAG)) + if (update && (vf->flags & BLOB_FLAG)) { /* The row has been read into record[1] and Field_blob::value @@ -8294,7 +8294,7 @@ int TABLE::update_virtual_fields(handler *h, enum_vcol_update_mode update_mode) case VCOL_UPDATE_INDEXED_FOR_UPDATE: /* Read indexed fields that was not updated in VCOL_UPDATE_FOR_READ */ update= (!vcol_info->stored_in_db && - (vf->flags() & (PART_KEY_FLAG | PART_INDIRECT_KEY_FLAG)) && + (vf->flags & (PART_KEY_FLAG | PART_INDIRECT_KEY_FLAG)) && !bitmap_is_set(read_set, vf->field_index)); swap_values= 1; break; @@ -8310,7 +8310,7 @@ int TABLE::update_virtual_fields(handler *h, enum_vcol_update_mode update_mode) DBUG_RESTORE_WRITE_SET(vf); DBUG_PRINT("info", ("field '%s' - updated error: %d", vf->field_name.str, field_error)); - if (swap_values && (vf->flags() & BLOB_FLAG)) + if (swap_values && (vf->flags & BLOB_FLAG)) { /* Remember the read value to allow other update_virtual_field() calls @@ -8393,7 +8393,7 @@ int TABLE::update_default_fields(bool update_command, bool ignore_errors) if (!update_command) { if (field->default_value && - (field->default_value->flags || field->flags() & BLOB_FLAG)) + (field->default_value->flags || field->flags & BLOB_FLAG)) res|= (field->default_value->expr->save_in_field(field, 0) < 0); } else @@ -8622,7 +8622,7 @@ bool TABLE::validate_default_values_of_unset_fields(THD *thd) const for (Field **fld= field; *fld; fld++) { if (!bitmap_is_set(write_set, (*fld)->field_index) && - !((*fld)->flags() & NO_DEFAULT_VALUE_FLAG)) + !((*fld)->flags & NO_DEFAULT_VALUE_FLAG)) { if (!(*fld)->is_null_in_record(s->default_values) && (*fld)->validate_value_in_record_with_warn(thd, s->default_values) && @@ -9096,7 +9096,7 @@ int fields_in_hash_keyinfo(KEY *keyinfo) void setup_keyinfo_hash(KEY *key_info) { DBUG_ASSERT(key_info->algorithm == HA_KEY_ALG_LONG_HASH); - DBUG_ASSERT(key_info->key_part->field->flags() & LONG_UNIQUE_HASH_FIELD); + DBUG_ASSERT(key_info->key_part->field->flags & LONG_UNIQUE_HASH_FIELD); uint no_of_keyparts= fields_in_hash_keyinfo(key_info); key_info->key_part-= no_of_keyparts; key_info->user_defined_key_parts= key_info->usable_key_parts= @@ -9111,8 +9111,8 @@ void setup_keyinfo_hash(KEY *key_info) void re_setup_keyinfo_hash(KEY *key_info) { DBUG_ASSERT(key_info->algorithm == HA_KEY_ALG_LONG_HASH); - DBUG_ASSERT(!(key_info->key_part->field->flags() & LONG_UNIQUE_HASH_FIELD)); - while(!(key_info->key_part->field->flags() & LONG_UNIQUE_HASH_FIELD)) + DBUG_ASSERT(!(key_info->key_part->field->flags & LONG_UNIQUE_HASH_FIELD)); + while(!(key_info->key_part->field->flags & LONG_UNIQUE_HASH_FIELD)) key_info->key_part++; key_info->user_defined_key_parts= key_info->usable_key_parts= key_info->ext_key_parts= 1; @@ -9468,7 +9468,7 @@ bool TR_table::check(bool error) } if (table->field[FLD_ISO_LEVEL]->type() != MYSQL_TYPE_STRING || - !(table->field[FLD_ISO_LEVEL]->flags() & ENUM_FLAG)) + !(table->field[FLD_ISO_LEVEL]->flags & ENUM_FLAG)) { wrong_enum: WARN_SCHEMA("Wrong field %d type (expected ENUM('READ-UNCOMMITTED', " @@ -9615,7 +9615,7 @@ bool TABLE::export_structure(THD *thd, Row_definition_list *defs) Spvar_definition *def= new (thd->mem_root) Spvar_definition(thd, *src); if (!def) return true; - def->clear_flags(NOT_NULL_FLAG); + def->flags&= (uint) ~NOT_NULL_FLAG; if ((def->sp_prepare_create_field(thd, thd->mem_root)) || (defs->push_back(def, thd->mem_root))) return true; diff --git a/sql/unireg.cc b/sql/unireg.cc index 6761172ff93..7130b3e5d8a 100644 --- a/sql/unireg.cc +++ b/sql/unireg.cc @@ -104,7 +104,7 @@ static uchar *extra2_write_field_properties(uchar *pos, while (Create_field *cf= it++) { uchar flags= cf->invisible; - if (cf->flags() & VERS_UPDATE_UNVERSIONED_FLAG) + if (cf->flags & VERS_UPDATE_UNVERSIONED_FLAG) flags|= VERS_OPTIMIZED_UPDATE; *pos++= flags; } @@ -141,7 +141,7 @@ bool has_extra2_field_flags(List<Create_field> &create_fields) { if (f->invisible) return true; - if (f->flags() & VERS_UPDATE_UNVERSIONED_FLAG) + if (f->flags & VERS_UPDATE_UNVERSIONED_FLAG) return true; } return false; @@ -1147,7 +1147,7 @@ static bool make_empty_rec(THD *thd, uchar *buff, uint table_options, Field *regfield= tmp.make_field(&share, thd->mem_root, &addr, field->type_handler(), &field->field_name, - field->flags()); + field->flags); if (!regfield) { error= true; @@ -1157,7 +1157,7 @@ static bool make_empty_rec(THD *thd, uchar *buff, uint table_options, /* save_in_field() will access regfield->table->in_use */ regfield->init(&table); - if (!(field->flags() & NOT_NULL_FLAG)) + if (!(field->flags & NOT_NULL_FLAG)) { *regfield->null_ptr|= regfield->null_bit; null_count++; |