diff --git a/storage/innobase/dict/dict0mem.cc b/storage/innobase/dict/dict0mem.cc index ef7589f6892..b988affac5b 100644 --- a/storage/innobase/dict/dict0mem.cc +++ b/storage/innobase/dict/dict0mem.cc @@ -305,12 +305,10 @@ dict_mem_table_add_col( dict_mem_fill_column_struct(col, i, mtype, prtype, len); if (prtype & DATA_VERS_ROW_START) { - ut_ad(table->flags2 & DICT_TF2_VERSIONED - && !(prtype & DATA_VERS_ROW_END)); + ut_ad(!(prtype & DATA_VERS_ROW_END)); table->vers_row_start = i; } else if (prtype & DATA_VERS_ROW_END) { - ut_ad(table->flags2 & DICT_TF2_VERSIONED - && !(prtype & DATA_VERS_ROW_START)); + ut_ad(!(prtype & DATA_VERS_ROW_START)); table->vers_row_end = i; } } diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index be294bd3e36..7d1124cbd00 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -8870,9 +8870,8 @@ calc_row_difference( n_changed++; if (!prebuilt->upd_node->versioned && - DICT_TF2_FLAG_IS_SET(prebuilt->table, DICT_TF2_VERSIONED) && - !(field->flags & VERS_OPTIMIZED_UPDATE_FLAG)) - { + prebuilt->table->with_versioning() && + !(field->flags & VERS_OPTIMIZED_UPDATE_FLAG)) { prebuilt->upd_node->versioned = true; } @@ -8982,9 +8981,8 @@ calc_row_difference( ++n_changed; if (!prebuilt->upd_node->versioned && - DICT_TF2_FLAG_IS_SET(prebuilt->table, DICT_TF2_VERSIONED) && - !(field->flags & VERS_OPTIMIZED_UPDATE_FLAG)) - { + prebuilt->table->with_versioning() && + !(field->flags & VERS_OPTIMIZED_UPDATE_FLAG)) { prebuilt->upd_node->versioned = true; } } else { @@ -11400,7 +11398,7 @@ create_table_info_t::create_table_def() ulint vers_row_start = 0; ulint vers_row_end = 0; - if (m_flags2 & DICT_TF2_VERSIONED) { + if (m_form->versioned()) { if (i == m_form->s->row_start_field) { vers_row_start = DATA_VERS_ROW_START; } else if (i == m_form->s->row_end_field) { @@ -12522,10 +12520,6 @@ index_bad: DBUG_EXECUTE_IF("innodb_test_wrong_fts_aux_table_name", m_flags2 &= ~DICT_TF2_FTS_AUX_HEX_NAME;); - if (m_create_info->options & HA_VERSIONED_TABLE) { - m_flags2 |= DICT_TF2_VERSIONED; - } - DBUG_RETURN(true); } diff --git a/storage/innobase/include/dict0mem.h b/storage/innobase/include/dict0mem.h index 87564f58db4..891998d79c1 100644 --- a/storage/innobase/include/dict0mem.h +++ b/storage/innobase/include/dict0mem.h @@ -245,7 +245,7 @@ ROW_FORMAT=REDUNDANT. InnoDB engines do not check these flags for unknown bits in order to protect backward incompatibility. */ /* @{ */ /** Total number of bits in table->flags2. */ -#define DICT_TF2_BITS 8 +#define DICT_TF2_BITS 7 #define DICT_TF2_UNUSED_BIT_MASK (~0U << DICT_TF2_BITS) #define DICT_TF2_BIT_MASK ~DICT_TF2_UNUSED_BIT_MASK @@ -273,9 +273,6 @@ use its own tablespace instead of the system tablespace. */ index tables) of a FTS table are in HEX format. */ #define DICT_TF2_FTS_AUX_HEX_NAME 64U -/** System Versioning bit. */ -#define DICT_TF2_VERSIONED 128U - /* @} */ #define DICT_TF2_FLAG_SET(table, flag) \ @@ -1492,6 +1489,8 @@ struct dict_table_t { /** Add the table definition to the data dictionary cache */ void add_to_cache(); + bool with_versioning() const { return vers_row_start || vers_row_end; } + /** Id of the table. */ table_id_t id; diff --git a/storage/innobase/row/row0ins.cc b/storage/innobase/row/row0ins.cc index 3ac7eba3d37..87157255835 100644 --- a/storage/innobase/row/row0ins.cc +++ b/storage/innobase/row/row0ins.cc @@ -1705,9 +1705,8 @@ row_ins_check_foreign_constraint( } /* System Versioning: if sys_trx_end != Inf, we suppress the foreign key check */ - if (DICT_TF2_FLAG_IS_SET(table, DICT_TF2_VERSIONED) && - dfield_get_type(field)->prtype & DATA_VERS_ROW_END) - { + if (table->with_versioning() && + dfield_get_type(field)->prtype & DATA_VERS_ROW_END) { byte* data = static_cast(dfield_get_data(field)); ut_ad(data); trx_id_t end_trx_id = mach_read_from_8(data); @@ -1842,7 +1841,7 @@ row_ins_check_foreign_constraint( cmp = cmp_dtuple_rec(entry, rec, offsets); if (cmp == 0) { - if (DICT_TF2_FLAG_IS_SET(check_table, DICT_TF2_VERSIONED)) { + if (check_table->with_versioning()) { trx_id_t end_trx_id = 0; if (dict_index_is_clust(check_index)) { diff --git a/storage/innobase/row/row0merge.cc b/storage/innobase/row/row0merge.cc index 393a00f83c3..08bc78e54b4 100644 --- a/storage/innobase/row/row0merge.cc +++ b/storage/innobase/row/row0merge.cc @@ -2241,8 +2241,7 @@ end_of_index: < dict_table_get_n_user_cols(new_table)); bool historical_row = false; - if (DICT_TF2_FLAG_IS_SET( - new_table, DICT_TF2_VERSIONED)) { + if (new_table->with_versioning()) { const dfield_t *dfield = dtuple_get_nth_field( row, new_table->vers_row_end); const byte *data = static_cast( @@ -2304,10 +2303,8 @@ end_of_index: } } - if (DICT_TF2_FLAG_IS_SET(old_table, DICT_TF2_VERSIONED)) { - if (DICT_TF2_FLAG_IS_SET(new_table, - DICT_TF2_VERSIONED) && - !drop_historical) { + if (old_table->with_versioning()) { + if (new_table->with_versioning() && !drop_historical) { dfield_t *end = dtuple_get_nth_field( row, new_table->vers_row_end); byte *data = static_cast( @@ -2333,8 +2330,7 @@ end_of_index: if (mach_read_from_8(sys_trx_end) != TRX_ID_MAX) continue; } - } else if (DICT_TF2_FLAG_IS_SET( - new_table, DICT_TF2_VERSIONED)) { + } else if (new_table->with_versioning()) { void *sys_trx_start = mem_heap_alloc(row_heap, 8); void *sys_trx_end = mem_heap_alloc(row_heap, 8); mach_write_to_8(sys_trx_start, trx->id); diff --git a/storage/innobase/row/row0mysql.cc b/storage/innobase/row/row0mysql.cc index 29fabd9a1ad..0a4151a2b22 100644 --- a/storage/innobase/row/row0mysql.cc +++ b/storage/innobase/row/row0mysql.cc @@ -1569,7 +1569,7 @@ error_exit: node->duplicate = NULL; - if (DICT_TF2_FLAG_IS_SET(node->table, DICT_TF2_VERSIONED)) { + if (node->table->with_versioning()) { trx->vtq_notify_on_commit = true; } @@ -2127,8 +2127,8 @@ run_again: node->cascade_upd_nodes = cascade_upd_nodes; cascade_upd_nodes->pop_front(); thr->fk_cascade_depth++; - vers_set_fields = DICT_TF2_FLAG_IS_SET(node->table, DICT_TF2_VERSIONED) - && (node->is_delete || node->versioned); + vers_set_fields = node->table->with_versioning() && + (node->is_delete || node->versioned); goto run_again; } @@ -2208,11 +2208,11 @@ run_again: prebuilt->table->stat_modified_counter++; } - if (DICT_TF2_FLAG_IS_SET(node->table, DICT_TF2_VERSIONED) && - (node->versioned || node->vers_delete || - // TODO: imrove this check (check if we touch only - // unversioned fields in foreigh table - node->foreign)) { + if (node->table->with_versioning() && + (node->versioned || node->vers_delete || + // TODO: imrove this check (check if we touch only + // unversioned fields in foreigh table) + node->foreign)) { trx->vtq_notify_on_commit = true; }