Skip to content

Commit 03672a0

Browse files
committed
MDEV-11487: Remove dict_table_get_n_sys_cols()
In MariaDB, InnoDB tables will always contain DATA_N_SYS_COLS = 3 columns, 2 or 3 of which are present in the clustered index. We remove the predicate that was added in MySQL 5.7 as part of WL#7682.
1 parent dbc7166 commit 03672a0

File tree

6 files changed

+13
-23
lines changed

6 files changed

+13
-23
lines changed

storage/innobase/dict/dict0dict.cc

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3044,9 +3044,7 @@ dict_index_build_internal_clust(
30443044

30453045
/* Add to new_index non-system columns of table not yet included
30463046
there */
3047-
ulint n_sys_cols = dict_table_get_n_sys_cols(table);
3048-
for (i = 0; i + n_sys_cols < (ulint) table->n_cols; i++) {
3049-
3047+
for (i = 0; i + DATA_N_SYS_COLS < ulint(table->n_cols); i++) {
30503048
dict_col_t* col = dict_table_get_nth_col(table, i);
30513049
ut_ad(col->mtype != DATA_SYS);
30523050

@@ -6422,15 +6420,14 @@ dict_table_schema_check(
64226420
return(DB_TABLE_NOT_FOUND);
64236421
}
64246422

6425-
ulint n_sys_cols = dict_table_get_n_sys_cols(table);
6426-
if ((ulint) table->n_def - n_sys_cols != req_schema->n_cols) {
6423+
if (ulint(table->n_def) - DATA_N_SYS_COLS != req_schema->n_cols) {
64276424
/* the table has a different number of columns than required */
64286425
snprintf(errstr, errstr_sz,
64296426
"%s has " ULINTPF " columns but should have "
64306427
ULINTPF ".",
64316428
ut_format_name(req_schema->table_name, buf,
64326429
sizeof buf),
6433-
table->n_def - n_sys_cols,
6430+
ulint(table->n_def) - DATA_N_SYS_COLS,
64346431
req_schema->n_cols);
64356432

64366433
return(DB_ERROR);

storage/innobase/dict/dict0mem.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,7 @@ dict_mem_table_create(
136136
table->name.m_name = mem_strdup(name);
137137
table->is_system_db = dict_mem_table_is_system(table->name.m_name);
138138
table->space = (unsigned int) space;
139-
table->n_t_cols = (unsigned int) (n_cols +
140-
dict_table_get_n_sys_cols(table));
139+
table->n_t_cols = unsigned(n_cols + DATA_N_SYS_COLS);
141140
table->n_v_cols = (unsigned int) (n_v_cols);
142141
table->n_cols = table->n_t_cols - table->n_v_cols;
143142

storage/innobase/handler/handler0alter.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3939,7 +3939,7 @@ innobase_add_virtual_try(
39393939

39403940
n_v_col += ctx->num_to_add_vcol;
39413941

3942-
n_col -= dict_table_get_n_sys_cols(user_table);
3942+
n_col -= DATA_N_SYS_COLS;
39433943

39443944
n_v_col -= ctx->num_to_drop_vcol;
39453945

@@ -4173,7 +4173,7 @@ innobase_drop_virtual_try(
41734173

41744174
n_v_col -= ctx->num_to_drop_vcol;
41754175

4176-
n_col -= dict_table_get_n_sys_cols(user_table);
4176+
n_col -= DATA_N_SYS_COLS;
41774177

41784178
ulint new_n = dict_table_encode_n_col(n_col, n_v_col)
41794179
+ ((user_table->flags & DICT_TF_COMPACT) << 31);

storage/innobase/include/data0type.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*****************************************************************************
22
33
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved.
4-
Copyright (c) 2017, 2018, MariaDB Corporation.
4+
Copyright (c) 2017, 2019, MariaDB Corporation.
55
66
This program is free software; you can redistribute it and/or modify it under
77
the terms of the GNU General Public License as published by the Free Software
@@ -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: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -879,13 +879,11 @@ dict_table_get_sys_col(
879879
ulint sys) /*!< in: DATA_ROW_ID, ... */
880880
MY_ATTRIBUTE((nonnull, warn_unused_result));
881881
#else /* UNIV_DEBUG */
882-
#define dict_table_get_nth_col(table, pos) \
883-
((table)->cols + (pos))
882+
#define dict_table_get_nth_col(table, pos) &(table)->cols[pos]
884883
#define dict_table_get_sys_col(table, sys) \
885-
((table)->cols + (table)->n_cols + (sys) \
886-
- (dict_table_get_n_sys_cols(table)))
884+
&(table)->cols[(table)->n_cols + (sys) - DATA_N_SYS_COLS]
887885
/* Get nth virtual columns */
888-
#define dict_table_get_nth_v_col(table, pos) ((table)->v_cols + (pos))
886+
#define dict_table_get_nth_v_col(table, pos) &(table)->v_cols[pos]
889887
#endif /* UNIV_DEBUG */
890888
/********************************************************************//**
891889
Gets the given system column number of a table.

storage/innobase/include/dict0dict.ic

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -475,13 +475,11 @@ dict_table_get_sys_col(
475475
{
476476
dict_col_t* col;
477477

478-
ut_ad(table);
479-
ut_ad(sys < dict_table_get_n_sys_cols(table));
478+
ut_ad(sys < DATA_N_SYS_COLS);
480479
ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
481480

482481
col = dict_table_get_nth_col(table, table->n_cols
483-
- dict_table_get_n_sys_cols(table)
484-
+ sys);
482+
+ (sys - DATA_N_SYS_COLS));
485483
ut_ad(col->mtype == DATA_SYS);
486484
ut_ad(col->prtype == (sys | DATA_NOT_NULL));
487485

@@ -501,7 +499,7 @@ dict_table_get_sys_col_no(
501499
{
502500
ut_ad(sys < DATA_N_SYS_COLS);
503501
ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
504-
return(table->n_cols - dict_table_get_n_sys_cols(table) + sys);
502+
return table->n_cols + (sys - DATA_N_SYS_COLS);
505503
}
506504

507505
/********************************************************************//**

0 commit comments

Comments
 (0)