Commit d4b2dfa9 authored by Marko Mäkelä's avatar Marko Mäkelä

Replace dict_table_get_n_sys_cols(table) with DATA_N_SYS_COLS

This could have been done as part of MDEV-11487, which removed the
support for InnoDB internal temporary tables.
parent e3d44f5d
...@@ -1236,8 +1236,7 @@ dict_table_add_system_columns( ...@@ -1236,8 +1236,7 @@ dict_table_add_system_columns(
mem_heap_t* heap) /*!< in: temporary heap */ mem_heap_t* heap) /*!< in: temporary heap */
{ {
ut_ad(table); ut_ad(table);
ut_ad(table->n_def == ut_ad(table->n_def == (table->n_cols - DATA_N_SYS_COLS));
(table->n_cols - dict_table_get_n_sys_cols(table)));
ut_ad(table->magic_n == DICT_TABLE_MAGIC_N); ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
ut_ad(!table->cached); ut_ad(!table->cached);
...@@ -3170,8 +3169,7 @@ dict_index_build_internal_clust( ...@@ -3170,8 +3169,7 @@ dict_index_build_internal_clust(
/* Add to new_index non-system columns of table not yet included /* Add to new_index non-system columns of table not yet included
there */ there */
ulint n_sys_cols = dict_table_get_n_sys_cols(table); for (i = 0; i + DATA_N_SYS_COLS < ulint(table->n_cols); i++) {
for (i = 0; i + n_sys_cols < (ulint) table->n_cols; i++) {
dict_col_t* col = dict_table_get_nth_col(table, i); dict_col_t* col = dict_table_get_nth_col(table, i);
ut_ad(col->mtype != DATA_SYS); ut_ad(col->mtype != DATA_SYS);
...@@ -6571,15 +6569,13 @@ dict_table_schema_check( ...@@ -6571,15 +6569,13 @@ dict_table_schema_check(
return(DB_TABLE_NOT_FOUND); return(DB_TABLE_NOT_FOUND);
} }
ulint n_sys_cols = dict_table_get_n_sys_cols(table); if (ulint(table->n_def - DATA_N_SYS_COLS) != req_schema->n_cols) {
if ((ulint) table->n_def - n_sys_cols != req_schema->n_cols) {
/* the table has a different number of columns than required */ /* the table has a different number of columns than required */
ut_snprintf(errstr, errstr_sz, ut_snprintf(errstr, errstr_sz,
"%s has " ULINTPF " columns but should have " "%s has %d columns but should have " ULINTPF ".",
ULINTPF ".",
ut_format_name(req_schema->table_name, ut_format_name(req_schema->table_name,
buf, sizeof(buf)), buf, sizeof(buf)),
table->n_def - n_sys_cols, table->n_def - DATA_N_SYS_COLS,
req_schema->n_cols); req_schema->n_cols);
return(DB_ERROR); return(DB_ERROR);
......
...@@ -128,8 +128,7 @@ dict_mem_table_create( ...@@ -128,8 +128,7 @@ dict_mem_table_create(
table->name.m_name = mem_strdup(name); table->name.m_name = mem_strdup(name);
table->is_system_db = dict_mem_table_is_system(table->name.m_name); table->is_system_db = dict_mem_table_is_system(table->name.m_name);
table->space = (unsigned int) space; table->space = (unsigned int) space;
table->n_t_cols = (unsigned int) (n_cols + table->n_t_cols = unsigned(n_cols + DATA_N_SYS_COLS);
dict_table_get_n_sys_cols(table));
table->n_v_cols = (unsigned int) (n_v_cols); table->n_v_cols = (unsigned int) (n_v_cols);
table->n_cols = table->n_t_cols - table->n_v_cols; table->n_cols = table->n_t_cols - table->n_v_cols;
......
...@@ -3970,17 +3970,11 @@ innobase_add_virtual_try( ...@@ -3970,17 +3970,11 @@ innobase_add_virtual_try(
} }
ulint n_col = user_table->n_cols; ulint n_col = user_table->n_cols - DATA_N_SYS_COLS;
ulint n_v_col = user_table->n_v_cols; ulint n_v_col = user_table->n_v_cols
+ ctx->num_to_add_vcol - ctx->num_to_drop_vcol;
n_v_col += ctx->num_to_add_vcol;
n_col -= dict_table_get_n_sys_cols(user_table);
n_v_col -= ctx->num_to_drop_vcol;
ulint new_n = dict_table_encode_n_col(n_col, n_v_col) ulint new_n = dict_table_encode_n_col(n_col, n_v_col)
+ ((user_table->flags & DICT_TF_COMPACT) << 31); + ((user_table->flags & DICT_TF_COMPACT) << 31);
err = innobase_update_n_virtual(user_table, new_n, trx); err = innobase_update_n_virtual(user_table, new_n, trx);
...@@ -4204,15 +4198,10 @@ innobase_drop_virtual_try( ...@@ -4204,15 +4198,10 @@ innobase_drop_virtual_try(
} }
ulint n_col = user_table->n_cols; ulint n_col = user_table->n_cols - DATA_N_SYS_COLS;
ulint n_v_col = user_table->n_v_cols; ulint n_v_col = user_table->n_v_cols - ctx->num_to_drop_vcol;
n_v_col -= ctx->num_to_drop_vcol;
n_col -= dict_table_get_n_sys_cols(user_table);
ulint new_n = dict_table_encode_n_col(n_col, n_v_col) ulint new_n = dict_table_encode_n_col(n_col, n_v_col)
+ ((user_table->flags & DICT_TF_COMPACT) << 31); + ((user_table->flags & DICT_TF_COMPACT) << 31);
err = innobase_update_n_virtual(user_table, new_n, trx); err = innobase_update_n_virtual(user_table, new_n, trx);
......
...@@ -183,8 +183,6 @@ be less than 256 */ ...@@ -183,8 +183,6 @@ be less than 256 */
for shorter VARCHARs MySQL uses only 1 byte */ for shorter VARCHARs MySQL uses only 1 byte */
#define DATA_VIRTUAL 8192U /* Virtual column */ #define DATA_VIRTUAL 8192U /* Virtual column */
/** Get the number of system columns in a table. */
#define dict_table_get_n_sys_cols(table) DATA_N_SYS_COLS
/** Check whether locking is disabled (never). */ /** Check whether locking is disabled (never). */
#define dict_table_is_locking_disabled(table) false #define dict_table_is_locking_disabled(table) false
......
...@@ -920,13 +920,12 @@ dict_table_get_sys_col( ...@@ -920,13 +920,12 @@ dict_table_get_sys_col(
ulint sys) /*!< in: DATA_ROW_ID, ... */ ulint sys) /*!< in: DATA_ROW_ID, ... */
MY_ATTRIBUTE((nonnull, warn_unused_result)); MY_ATTRIBUTE((nonnull, warn_unused_result));
#else /* UNIV_DEBUG */ #else /* UNIV_DEBUG */
#define dict_table_get_nth_col(table, pos) \ #define dict_table_get_nth_col(table, pos) \
((table)->cols + (pos)) (&(table)->cols[pos])
#define dict_table_get_sys_col(table, sys) \ #define dict_table_get_sys_col(table, sys) \
((table)->cols + (table)->n_cols + (sys) \ (&(table)->cols[(table)->n_cols + (sys) - DATA_N_SYS_COLS])
- (dict_table_get_n_sys_cols(table)))
/* Get nth virtual columns */ /* Get nth virtual columns */
#define dict_table_get_nth_v_col(table, pos) ((table)->v_cols + (pos)) #define dict_table_get_nth_v_col(table, pos) (&(table)->v_cols[pos])
#endif /* UNIV_DEBUG */ #endif /* UNIV_DEBUG */
/********************************************************************//** /********************************************************************//**
Gets the given system column number of a table. Gets the given system column number of a table.
......
...@@ -396,8 +396,8 @@ dict_table_get_n_user_cols( ...@@ -396,8 +396,8 @@ dict_table_get_n_user_cols(
const dict_table_t* table) /*!< in: table */ const dict_table_t* table) /*!< in: table */
{ {
ut_ad(table->magic_n == DICT_TABLE_MAGIC_N); ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
ut_ad(table->n_cols > DATA_N_SYS_COLS);
return(table->n_cols - dict_table_get_n_sys_cols(table)); return(table->n_cols - DATA_N_SYS_COLS);
} }
/** Gets the number of user-defined virtual and non-virtual columns in a table /** Gets the number of user-defined virtual and non-virtual columns in a table
...@@ -562,11 +562,10 @@ dict_table_get_sys_col( ...@@ -562,11 +562,10 @@ dict_table_get_sys_col(
dict_col_t* col; dict_col_t* col;
ut_ad(table); ut_ad(table);
ut_ad(sys < dict_table_get_n_sys_cols(table)); ut_ad(sys < DATA_N_SYS_COLS);
ut_ad(table->magic_n == DICT_TABLE_MAGIC_N); ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
col = dict_table_get_nth_col(table, table->n_cols col = dict_table_get_nth_col(table, table->n_cols - DATA_N_SYS_COLS
- dict_table_get_n_sys_cols(table)
+ sys); + sys);
ut_ad(col->mtype == DATA_SYS); ut_ad(col->mtype == DATA_SYS);
ut_ad(col->prtype == (sys | DATA_NOT_NULL)); ut_ad(col->prtype == (sys | DATA_NOT_NULL));
...@@ -586,10 +585,10 @@ dict_table_get_sys_col_no( ...@@ -586,10 +585,10 @@ dict_table_get_sys_col_no(
ulint sys) /*!< in: DATA_ROW_ID, ... */ ulint sys) /*!< in: DATA_ROW_ID, ... */
{ {
ut_ad(table); ut_ad(table);
ut_ad(sys < dict_table_get_n_sys_cols(table)); ut_ad(sys < DATA_N_SYS_COLS);
ut_ad(table->magic_n == DICT_TABLE_MAGIC_N); ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
return(table->n_cols - dict_table_get_n_sys_cols(table) + sys); return(table->n_cols - DATA_N_SYS_COLS + sys);
} }
/********************************************************************//** /********************************************************************//**
......
...@@ -1843,8 +1843,8 @@ row_merge_read_clustered_index( ...@@ -1843,8 +1843,8 @@ row_merge_read_clustered_index(
based on that. */ based on that. */
clust_index = dict_table_get_first_index(old_table); clust_index = dict_table_get_first_index(old_table);
const ulint old_trx_id_col = old_table->n_cols + DATA_TRX_ID const ulint old_trx_id_col = DATA_TRX_ID - DATA_N_SYS_COLS
- dict_table_get_n_sys_cols(table); + old_table->n_cols;
ut_ad(old_table->cols[old_trx_id_col].mtype == DATA_SYS); ut_ad(old_table->cols[old_trx_id_col].mtype == DATA_SYS);
ut_ad(old_table->cols[old_trx_id_col].prtype ut_ad(old_table->cols[old_trx_id_col].prtype
== (DATA_TRX_ID | DATA_NOT_NULL)); == (DATA_TRX_ID | DATA_NOT_NULL));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment