Commit 03672a05 authored by Marko Mäkelä's avatar Marko Mäkelä

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.
parent dbc71667
...@@ -3044,9 +3044,7 @@ dict_index_build_internal_clust( ...@@ -3044,9 +3044,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);
...@@ -6422,15 +6420,14 @@ dict_table_schema_check( ...@@ -6422,15 +6420,14 @@ 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 */
snprintf(errstr, errstr_sz, snprintf(errstr, errstr_sz,
"%s has " ULINTPF " columns but should have " "%s has " ULINTPF " columns but should have "
ULINTPF ".", ULINTPF ".",
ut_format_name(req_schema->table_name, buf, ut_format_name(req_schema->table_name, buf,
sizeof buf), sizeof buf),
table->n_def - n_sys_cols, ulint(table->n_def) - DATA_N_SYS_COLS,
req_schema->n_cols); req_schema->n_cols);
return(DB_ERROR); return(DB_ERROR);
......
...@@ -136,8 +136,7 @@ dict_mem_table_create( ...@@ -136,8 +136,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;
......
...@@ -3939,7 +3939,7 @@ innobase_add_virtual_try( ...@@ -3939,7 +3939,7 @@ innobase_add_virtual_try(
n_v_col += ctx->num_to_add_vcol; n_v_col += ctx->num_to_add_vcol;
n_col -= dict_table_get_n_sys_cols(user_table); n_col -= DATA_N_SYS_COLS;
n_v_col -= ctx->num_to_drop_vcol; n_v_col -= ctx->num_to_drop_vcol;
...@@ -4173,7 +4173,7 @@ innobase_drop_virtual_try( ...@@ -4173,7 +4173,7 @@ innobase_drop_virtual_try(
n_v_col -= ctx->num_to_drop_vcol; n_v_col -= ctx->num_to_drop_vcol;
n_col -= dict_table_get_n_sys_cols(user_table); n_col -= DATA_N_SYS_COLS;
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);
......
/***************************************************************************** /*****************************************************************************
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2017, 2018, MariaDB Corporation. Copyright (c) 2017, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software the terms of the GNU General Public License as published by the Free Software
...@@ -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
......
...@@ -879,13 +879,11 @@ dict_table_get_sys_col( ...@@ -879,13 +879,11 @@ 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.
......
...@@ -475,13 +475,11 @@ dict_table_get_sys_col( ...@@ -475,13 +475,11 @@ dict_table_get_sys_col(
{ {
dict_col_t* col; dict_col_t* col;
ut_ad(table); ut_ad(sys < DATA_N_SYS_COLS);
ut_ad(sys < 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);
col = dict_table_get_nth_col(table, table->n_cols col = dict_table_get_nth_col(table, table->n_cols
- dict_table_get_n_sys_cols(table) + (sys - DATA_N_SYS_COLS));
+ 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));
...@@ -501,7 +499,7 @@ dict_table_get_sys_col_no( ...@@ -501,7 +499,7 @@ dict_table_get_sys_col_no(
{ {
ut_ad(sys < DATA_N_SYS_COLS); 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 + (sys - DATA_N_SYS_COLS);
} }
/********************************************************************//** /********************************************************************//**
......
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