Skip to content

Commit d4b2dfa

Browse files
committed
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.
1 parent e3d44f5 commit d4b2dfa

File tree

7 files changed

+26
-46
lines changed

7 files changed

+26
-46
lines changed

storage/innobase/dict/dict0dict.cc

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1236,8 +1236,7 @@ dict_table_add_system_columns(
12361236
mem_heap_t* heap) /*!< in: temporary heap */
12371237
{
12381238
ut_ad(table);
1239-
ut_ad(table->n_def ==
1240-
(table->n_cols - dict_table_get_n_sys_cols(table)));
1239+
ut_ad(table->n_def == (table->n_cols - DATA_N_SYS_COLS));
12411240
ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
12421241
ut_ad(!table->cached);
12431242

@@ -3170,8 +3169,7 @@ dict_index_build_internal_clust(
31703169

31713170
/* Add to new_index non-system columns of table not yet included
31723171
there */
3173-
ulint n_sys_cols = dict_table_get_n_sys_cols(table);
3174-
for (i = 0; i + n_sys_cols < (ulint) table->n_cols; i++) {
3172+
for (i = 0; i + DATA_N_SYS_COLS < ulint(table->n_cols); i++) {
31753173

31763174
dict_col_t* col = dict_table_get_nth_col(table, i);
31773175
ut_ad(col->mtype != DATA_SYS);
@@ -6571,15 +6569,13 @@ dict_table_schema_check(
65716569
return(DB_TABLE_NOT_FOUND);
65726570
}
65736571

6574-
ulint n_sys_cols = dict_table_get_n_sys_cols(table);
6575-
if ((ulint) table->n_def - n_sys_cols != req_schema->n_cols) {
6572+
if (ulint(table->n_def - DATA_N_SYS_COLS) != req_schema->n_cols) {
65766573
/* the table has a different number of columns than required */
65776574
ut_snprintf(errstr, errstr_sz,
6578-
"%s has " ULINTPF " columns but should have "
6579-
ULINTPF ".",
6575+
"%s has %d columns but should have " ULINTPF ".",
65806576
ut_format_name(req_schema->table_name,
65816577
buf, sizeof(buf)),
6582-
table->n_def - n_sys_cols,
6578+
table->n_def - DATA_N_SYS_COLS,
65836579
req_schema->n_cols);
65846580

65856581
return(DB_ERROR);

storage/innobase/dict/dict0mem.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,7 @@ dict_mem_table_create(
128128
table->name.m_name = mem_strdup(name);
129129
table->is_system_db = dict_mem_table_is_system(table->name.m_name);
130130
table->space = (unsigned int) space;
131-
table->n_t_cols = (unsigned int) (n_cols +
132-
dict_table_get_n_sys_cols(table));
131+
table->n_t_cols = unsigned(n_cols + DATA_N_SYS_COLS);
133132
table->n_v_cols = (unsigned int) (n_v_cols);
134133
table->n_cols = table->n_t_cols - table->n_v_cols;
135134

storage/innobase/handler/handler0alter.cc

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3970,17 +3970,11 @@ innobase_add_virtual_try(
39703970
}
39713971

39723972

3973-
ulint n_col = user_table->n_cols;
3974-
ulint n_v_col = user_table->n_v_cols;
3975-
3976-
n_v_col += ctx->num_to_add_vcol;
3977-
3978-
n_col -= dict_table_get_n_sys_cols(user_table);
3979-
3980-
n_v_col -= ctx->num_to_drop_vcol;
3981-
3973+
ulint n_col = user_table->n_cols - DATA_N_SYS_COLS;
3974+
ulint n_v_col = user_table->n_v_cols
3975+
+ ctx->num_to_add_vcol - ctx->num_to_drop_vcol;
39823976
ulint new_n = dict_table_encode_n_col(n_col, n_v_col)
3983-
+ ((user_table->flags & DICT_TF_COMPACT) << 31);
3977+
+ ((user_table->flags & DICT_TF_COMPACT) << 31);
39843978

39853979
err = innobase_update_n_virtual(user_table, new_n, trx);
39863980

@@ -4204,15 +4198,10 @@ innobase_drop_virtual_try(
42044198
}
42054199

42064200

4207-
ulint n_col = user_table->n_cols;
4208-
ulint n_v_col = user_table->n_v_cols;
4209-
4210-
n_v_col -= ctx->num_to_drop_vcol;
4211-
4212-
n_col -= dict_table_get_n_sys_cols(user_table);
4213-
4201+
ulint n_col = user_table->n_cols - DATA_N_SYS_COLS;
4202+
ulint n_v_col = user_table->n_v_cols - ctx->num_to_drop_vcol;
42144203
ulint new_n = dict_table_encode_n_col(n_col, n_v_col)
4215-
+ ((user_table->flags & DICT_TF_COMPACT) << 31);
4204+
+ ((user_table->flags & DICT_TF_COMPACT) << 31);
42164205

42174206
err = innobase_update_n_virtual(user_table, new_n, trx);
42184207

storage/innobase/include/data0type.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,6 @@ be less than 256 */
183183
for shorter VARCHARs MySQL uses only 1 byte */
184184
#define DATA_VIRTUAL 8192U /* Virtual column */
185185

186-
/** Get the number of system columns in a table. */
187-
#define dict_table_get_n_sys_cols(table) DATA_N_SYS_COLS
188186
/** Check whether locking is disabled (never). */
189187
#define dict_table_is_locking_disabled(table) false
190188

storage/innobase/include/dict0dict.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -920,13 +920,12 @@ dict_table_get_sys_col(
920920
ulint sys) /*!< in: DATA_ROW_ID, ... */
921921
MY_ATTRIBUTE((nonnull, warn_unused_result));
922922
#else /* UNIV_DEBUG */
923-
#define dict_table_get_nth_col(table, pos) \
924-
((table)->cols + (pos))
925-
#define dict_table_get_sys_col(table, sys) \
926-
((table)->cols + (table)->n_cols + (sys) \
927-
- (dict_table_get_n_sys_cols(table)))
923+
#define dict_table_get_nth_col(table, pos) \
924+
(&(table)->cols[pos])
925+
#define dict_table_get_sys_col(table, sys) \
926+
(&(table)->cols[(table)->n_cols + (sys) - DATA_N_SYS_COLS])
928927
/* Get nth virtual columns */
929-
#define dict_table_get_nth_v_col(table, pos) ((table)->v_cols + (pos))
928+
#define dict_table_get_nth_v_col(table, pos) (&(table)->v_cols[pos])
930929
#endif /* UNIV_DEBUG */
931930
/********************************************************************//**
932931
Gets the given system column number of a table.

storage/innobase/include/dict0dict.ic

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -396,8 +396,8 @@ dict_table_get_n_user_cols(
396396
const dict_table_t* table) /*!< in: table */
397397
{
398398
ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
399-
400-
return(table->n_cols - dict_table_get_n_sys_cols(table));
399+
ut_ad(table->n_cols > DATA_N_SYS_COLS);
400+
return(table->n_cols - DATA_N_SYS_COLS);
401401
}
402402

403403
/** Gets the number of user-defined virtual and non-virtual columns in a table
@@ -562,11 +562,10 @@ dict_table_get_sys_col(
562562
dict_col_t* col;
563563

564564
ut_ad(table);
565-
ut_ad(sys < dict_table_get_n_sys_cols(table));
565+
ut_ad(sys < DATA_N_SYS_COLS);
566566
ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
567567

568-
col = dict_table_get_nth_col(table, table->n_cols
569-
- dict_table_get_n_sys_cols(table)
568+
col = dict_table_get_nth_col(table, table->n_cols - DATA_N_SYS_COLS
570569
+ sys);
571570
ut_ad(col->mtype == DATA_SYS);
572571
ut_ad(col->prtype == (sys | DATA_NOT_NULL));
@@ -586,10 +585,10 @@ dict_table_get_sys_col_no(
586585
ulint sys) /*!< in: DATA_ROW_ID, ... */
587586
{
588587
ut_ad(table);
589-
ut_ad(sys < dict_table_get_n_sys_cols(table));
588+
ut_ad(sys < DATA_N_SYS_COLS);
590589
ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
591590

592-
return(table->n_cols - dict_table_get_n_sys_cols(table) + sys);
591+
return(table->n_cols - DATA_N_SYS_COLS + sys);
593592
}
594593

595594
/********************************************************************//**

storage/innobase/row/row0merge.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1843,8 +1843,8 @@ row_merge_read_clustered_index(
18431843
based on that. */
18441844

18451845
clust_index = dict_table_get_first_index(old_table);
1846-
const ulint old_trx_id_col = old_table->n_cols + DATA_TRX_ID
1847-
- dict_table_get_n_sys_cols(table);
1846+
const ulint old_trx_id_col = DATA_TRX_ID - DATA_N_SYS_COLS
1847+
+ old_table->n_cols;
18481848
ut_ad(old_table->cols[old_trx_id_col].mtype == DATA_SYS);
18491849
ut_ad(old_table->cols[old_trx_id_col].prtype
18501850
== (DATA_TRX_ID | DATA_NOT_NULL));

0 commit comments

Comments
 (0)