diff options
author | Sergei Golubchik <serg@mariadb.org> | 2022-11-27 17:03:29 +0100 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2023-05-02 14:25:31 +0200 |
commit | 76fd8d368d9226357d129c61834ff9ccf6cfc1fb (patch) | |
tree | 4b3d98a5ab8ede1b5154ff1bc0ee22a1152eb934 | |
parent | a6f947b92c41e7bfd141ec10f257028028ede97b (diff) | |
download | mariadb-git-bb-10.11-serg.tar.gz |
cleanup: remove vcol_info->stored_in_dbbb-10.11-serg
it was redundant, duplicating vcol_type == VCOL_GENERATED_STORED.
Note that VCOL_DEFAULT is not "stored", "stored vcol" means that after
rnd_next or index_read/etc the field value is already in the record[0]
and does not need to be calculated separately
-rw-r--r-- | sql/field.cc | 2 | ||||
-rw-r--r-- | sql/field.h | 14 | ||||
-rw-r--r-- | sql/item.h | 2 | ||||
-rw-r--r-- | sql/sql_show.cc | 4 | ||||
-rw-r--r-- | sql/sql_table.cc | 2 | ||||
-rw-r--r-- | sql/sql_yacc.yy | 8 | ||||
-rw-r--r-- | sql/table.cc | 29 | ||||
-rw-r--r-- | sql/unireg.cc | 2 | ||||
-rw-r--r-- | storage/myisam/ha_myisam.cc | 2 |
9 files changed, 28 insertions, 37 deletions
diff --git a/sql/field.cc b/sql/field.cc index 9ef8274efa2..40f9837a788 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -10652,7 +10652,7 @@ bool Column_definition::check(THD *thd) { DBUG_ASSERT(vcol_info->expr); vcol_info->set_handler(type_handler()); - if (check_expression(vcol_info, &field_name, vcol_info->stored_in_db + if (check_expression(vcol_info, &field_name, vcol_info->is_stored() ? VCOL_GENERATED_STORED : VCOL_GENERATED_VIRTUAL)) DBUG_RETURN(TRUE); } diff --git a/sql/field.h b/sql/field.h index 642456b9774..955f39ee040 100644 --- a/sql/field.h +++ b/sql/field.h @@ -586,7 +586,6 @@ private: public: /* Flag indicating that the field is physically stored in the database */ - bool stored_in_db; bool utf8; /* Already in utf8 */ bool automatic_name; bool if_not_exists; @@ -598,7 +597,7 @@ public: Virtual_column_info() :Type_handler_hybrid_field_type(&type_handler_null), vcol_type((enum_vcol_info_type)VCOL_TYPE_NONE), - in_partitioning_expr(FALSE), stored_in_db(FALSE), + in_partitioning_expr(FALSE), utf8(TRUE), automatic_name(FALSE), expr(NULL), flags(0) { name.str= NULL; @@ -627,11 +626,8 @@ public: } bool is_stored() const { - return stored_in_db; - } - void set_stored_in_db_flag(bool stored) - { - stored_in_db= stored; + /* after reading the row vcol value is already in the buffer */ + return vcol_type == VCOL_GENERATED_STORED; } bool is_in_partitioning_expr() const { @@ -1433,7 +1429,7 @@ public: null_bit= static_cast<uchar>(p_null_bit); } - bool stored_in_db() const { return !vcol_info || vcol_info->stored_in_db; } + bool stored_in_db() const { return !vcol_info || vcol_info->is_stored(); } bool check_vcol_sql_mode_dependency(THD *, vcol_init_mode mode) const; virtual sql_mode_t value_depends_on_sql_mode() const @@ -5421,7 +5417,7 @@ public: bool check(THD *thd); bool validate_check_constraint(THD *thd); - bool stored_in_db() const { return !vcol_info || vcol_info->stored_in_db; } + bool stored_in_db() const { return !vcol_info || vcol_info->is_stored(); } ha_storage_media field_storage_type() const { diff --git a/sql/item.h b/sql/item.h index 5639a622e65..9993247257e 100644 --- a/sql/item.h +++ b/sql/item.h @@ -7802,7 +7802,7 @@ bool fix_escape_item(THD *thd, Item *escape_item, String *tmp_str, inline bool Virtual_column_info::is_equal(const Virtual_column_info* vcol) const { return type_handler() == vcol->type_handler() - && stored_in_db == vcol->is_stored() + && is_stored() == vcol->is_stored() && expr->eq(vcol->expr, true); } diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 037161992ed..72e03048e46 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -2217,7 +2217,7 @@ int show_create_table_ex(THD *thd, TABLE_LIST *table_list, packet->append(STRING_WITH_LEN(" GENERATED ALWAYS AS (")); packet->append(str); packet->append(STRING_WITH_LEN(")")); - if (field->vcol_info->stored_in_db) + if (field->vcol_info->is_stored()) packet->append(STRING_WITH_LEN(" STORED")); else packet->append(STRING_WITH_LEN(" VIRTUAL")); @@ -6174,7 +6174,7 @@ static int get_schema_column_record(THD *thd, TABLE_LIST *tables, table->field[21]->set_notnull(); table->field[20]->store(STRING_WITH_LEN("ALWAYS"), cs); - if (field->vcol_info->stored_in_db) + if (field->vcol_info->is_stored()) buf.set(STRING_WITH_LEN("STORED GENERATED"), cs); else buf.set(STRING_WITH_LEN("VIRTUAL GENERATED"), cs); diff --git a/sql/sql_table.cc b/sql/sql_table.cc index a510de15027..961829cafb5 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -2602,7 +2602,7 @@ static Create_field * add_hash_field(THD * thd, List<Create_field> *create_list, cf->invisible= INVISIBLE_FULL; cf->pack_flag|= FIELDFLAG_MAYBE_NULL; cf->vcol_info= new (thd->mem_root) Virtual_column_info(); - cf->vcol_info->stored_in_db= false; + cf->vcol_info->set_vcol_type(VCOL_GENERATED_VIRTUAL); uint num= 1; LEX_CSTRING field_name; field_name.str= (char *)thd->alloc(LONG_HASH_FIELD_NAME_LENGTH); diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index c4c685d0bf2..57a4c10f7e1 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -5891,19 +5891,19 @@ opt_generated_always: vcol_opt_specifier: /* empty */ { - Lex->last_field->vcol_info->set_stored_in_db_flag(FALSE); + Lex->last_field->vcol_info->set_vcol_type(VCOL_GENERATED_VIRTUAL); } | VIRTUAL_SYM { - Lex->last_field->vcol_info->set_stored_in_db_flag(FALSE); + Lex->last_field->vcol_info->set_vcol_type(VCOL_GENERATED_VIRTUAL); } | PERSISTENT_SYM { - Lex->last_field->vcol_info->set_stored_in_db_flag(TRUE); + Lex->last_field->vcol_info->set_vcol_type(VCOL_GENERATED_STORED); } | STORED_SYM { - Lex->last_field->vcol_info->set_stored_in_db_flag(TRUE); + Lex->last_field->vcol_info->set_vcol_type(VCOL_GENERATED_STORED); } ; diff --git a/sql/table.cc b/sql/table.cc index 3c766c4ac18..b33f8eb0e3e 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -1198,7 +1198,7 @@ bool parse_vcol_defs(THD *thd, MEM_ROOT *mem_root, TABLE *table, open_table_error(table->s, OPEN_FRM_CORRUPTED, 1); goto end; } - type= (*field_ptr)->vcol_info->stored_in_db + type= (*field_ptr)->vcol_info->is_stored() ? VCOL_GENERATED_STORED : VCOL_GENERATED_VIRTUAL; expr_length= uint2korr(pos+1); if (table->s->mysql_version > 50700 && table->s->mysql_version < 100000) @@ -2459,7 +2459,6 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write, else if ((uint)vcol_screen_pos[0] != 1) goto err; bool stored= vcol_screen_pos[2] & 1; - vcol_info->stored_in_db= stored; vcol_info->set_vcol_type(stored ? VCOL_GENERATED_STORED : VCOL_GENERATED_VIRTUAL); uint vcol_expr_length= vcol_info_length - (uint)(FRM_VCOL_OLD_HEADER_SIZE(opt_interval_id)); @@ -2540,7 +2539,7 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write, uint vcol_info_length= uint2korr(vcol_screen_pos + 1); if (!vcol_info_length) // Expect non-empty expression goto err; - vcol_info->stored_in_db= vcol_screen_pos[3]; + vcol_info->set_vcol_type(vcol_screen_pos[3] ? VCOL_GENERATED_STORED : VCOL_GENERATED_VIRTUAL); vcol_info->utf8= 0; vcol_screen_pos+= vcol_info_length + MYSQL57_GCOL_HEADER_SIZE;; share->virtual_fields++; @@ -2636,7 +2635,7 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write, } #endif - if (mysql57_null_bits && vcol_info && !vcol_info->stored_in_db) + if (mysql57_null_bits && vcol_info && !vcol_info->is_stored()) { swap_variables(uchar*, null_pos, mysql57_vcol_null_pos); swap_variables(uint, null_bit_pos, mysql57_vcol_null_bit_pos); @@ -2693,7 +2692,6 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write, { reg_field->default_value= new (&share->mem_root) Virtual_column_info(); reg_field->default_value->set_vcol_type(VCOL_DEFAULT); - reg_field->default_value->stored_in_db= 1; share->default_expressions++; } @@ -2732,7 +2730,7 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write, if (vcol_info) { vcol_info->name= reg_field->field_name; - if (mysql57_null_bits && !vcol_info->stored_in_db) + if (mysql57_null_bits && !vcol_info->is_stored()) { /* MySQL 5.7 has null bits last */ swap_variables(uchar*, null_pos, mysql57_vcol_null_pos); @@ -3249,13 +3247,11 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write, break; } case VCOL_GENERATED_STORED: - vcol_info->stored_in_db= 1; DBUG_ASSERT(!reg_field->vcol_info); reg_field->vcol_info= vcol_info; share->virtual_fields++; break; case VCOL_DEFAULT: - vcol_info->stored_in_db= 1; DBUG_ASSERT(!reg_field->default_value); reg_field->default_value= vcol_info; share->default_expressions++; @@ -3909,7 +3905,6 @@ unpack_vcol_info_from_frm(THD *thd, TABLE *table, } vcol_storage.vcol_info->set_vcol_type(vcol->get_vcol_type()); - vcol_storage.vcol_info->stored_in_db= vcol->stored_in_db; vcol_storage.vcol_info->name= vcol->name; vcol_storage.vcol_info->utf8= vcol->utf8; if (!vcol_storage.vcol_info->fix_and_check_expr(thd, table)) @@ -7835,7 +7830,7 @@ bool TABLE::mark_virtual_columns_for_write(bool insert_fl tmp_vfield= *vfield_ptr; 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 || + else if (tmp_vfield->vcol_info->is_stored() || (tmp_vfield->flags & (PART_KEY_FLAG | FIELD_IN_PART_FUNC_FLAG | PART_INDIRECT_KEY_FLAG))) { @@ -7866,7 +7861,7 @@ bool TABLE::check_virtual_columns_marked_for_read() { Field *tmp_vfield= *vfield_ptr; if (bitmap_is_set(read_set, tmp_vfield->field_index) && - !tmp_vfield->vcol_info->stored_in_db) + !tmp_vfield->vcol_info->is_stored()) return TRUE; } } @@ -7893,7 +7888,7 @@ bool TABLE::check_virtual_columns_marked_for_write() { Field *tmp_vfield= *vfield_ptr; if (bitmap_is_set(write_set, tmp_vfield->field_index) && - tmp_vfield->vcol_info->stored_in_db) + tmp_vfield->vcol_info->is_stored()) return TRUE; } } @@ -8023,7 +8018,7 @@ void TABLE::remember_blob_values(String *blob_storage) for (vfield_ptr= vfield; *vfield_ptr; vfield_ptr++) { if ((*vfield_ptr)->type() == MYSQL_TYPE_BLOB && - !(*vfield_ptr)->vcol_info->stored_in_db) + !(*vfield_ptr)->vcol_info->is_stored()) { Field_blob *blob= ((Field_blob*) *vfield_ptr); memcpy((void*) blob_storage, (void*) &blob->value, sizeof(blob->value)); @@ -8046,7 +8041,7 @@ void TABLE::restore_blob_values(String *blob_storage) for (vfield_ptr= vfield; *vfield_ptr; vfield_ptr++) { if ((*vfield_ptr)->type() == MYSQL_TYPE_BLOB && - !(*vfield_ptr)->vcol_info->stored_in_db) + !(*vfield_ptr)->vcol_info->is_stored()) { Field_blob *blob= ((Field_blob*) *vfield_ptr); blob->value.free(); @@ -8833,7 +8828,7 @@ int TABLE::update_virtual_fields(handler *h, enum_vcol_update_mode update_mode) bool update= 0, swap_values= 0; switch (update_mode) { case VCOL_UPDATE_FOR_READ: - update= (!vcol_info->stored_in_db && + update= (!vcol_info->is_stored() && bitmap_is_set(read_set, vf->field_index)); swap_values= 1; break; @@ -8842,7 +8837,7 @@ int TABLE::update_virtual_fields(handler *h, enum_vcol_update_mode update_mode) update= bitmap_is_set(read_set, vf->field_index); break; case VCOL_UPDATE_FOR_REPLACE: - update= ((!vcol_info->stored_in_db && + update= ((!vcol_info->is_stored() && (vf->flags & (PART_KEY_FLAG | PART_INDIRECT_KEY_FLAG)) && bitmap_is_set(read_set, vf->field_index)) || update_all_columns); @@ -8862,7 +8857,7 @@ int TABLE::update_virtual_fields(handler *h, enum_vcol_update_mode update_mode) case VCOL_UPDATE_INDEXED: case VCOL_UPDATE_INDEXED_FOR_UPDATE: /* Read indexed fields that was not updated in VCOL_UPDATE_FOR_READ */ - update= (!vcol_info->stored_in_db && + update= (!vcol_info->is_stored() && (vf->flags & (PART_KEY_FLAG | PART_INDIRECT_KEY_FLAG)) && !bitmap_is_set(read_set, vf->field_index)); swap_values= 1; diff --git a/sql/unireg.cc b/sql/unireg.cc index e6f52cd953e..783c273f8b7 100644 --- a/sql/unireg.cc +++ b/sql/unireg.cc @@ -802,7 +802,7 @@ static bool pack_vcols(String *buf, List<Create_field> &create_fields, { if (field->vcol_info && field->vcol_info->expr) if (pack_expression(buf, field->vcol_info, field_nr, - field->vcol_info->stored_in_db + field->vcol_info->is_stored() ? VCOL_GENERATED_STORED : VCOL_GENERATED_VIRTUAL)) return 1; if (field->has_default_expression() && !field->has_default_now_unireg_check()) diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc index c0419da7e71..2a23fbd8a3c 100644 --- a/storage/myisam/ha_myisam.cc +++ b/storage/myisam/ha_myisam.cc @@ -730,7 +730,7 @@ static int compute_vcols(MI_INFO *info, uchar *record, int keynum) for (; kp < end; kp++) { Field *f= table->field[kp->fieldnr - 1]; - if (f->vcol_info && !f->vcol_info->stored_in_db) + if (f->vcol_info && !f->vcol_info->is_stored()) table->update_virtual_field(f, false); } mysql_mutex_unlock(&info->s->intern_lock); |