summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2019-04-03 10:50:43 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2019-04-03 11:02:55 +0300
commit03672a0573566cdb31a5ad3a925f80d2560ebc9b (patch)
tree70f862ad3c564f9615a54abaa2348ec3f1ec561f
parentdbc716675b183dc972a40dd1320f4bdae04c1f29 (diff)
downloadmariadb-git-03672a0573566cdb31a5ad3a925f80d2560ebc9b.tar.gz
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.
-rw-r--r--storage/innobase/dict/dict0dict.cc9
-rw-r--r--storage/innobase/dict/dict0mem.cc3
-rw-r--r--storage/innobase/handler/handler0alter.cc4
-rw-r--r--storage/innobase/include/data0type.h4
-rw-r--r--storage/innobase/include/dict0dict.h8
-rw-r--r--storage/innobase/include/dict0dict.ic8
6 files changed, 13 insertions, 23 deletions
diff --git a/storage/innobase/dict/dict0dict.cc b/storage/innobase/dict/dict0dict.cc
index c747f7bebed..e5f1e0dab1d 100644
--- a/storage/innobase/dict/dict0dict.cc
+++ b/storage/innobase/dict/dict0dict.cc
@@ -3044,9 +3044,7 @@ dict_index_build_internal_clust(
/* Add to new_index non-system columns of table not yet included
there */
- ulint n_sys_cols = dict_table_get_n_sys_cols(table);
- for (i = 0; i + n_sys_cols < (ulint) table->n_cols; i++) {
-
+ for (i = 0; i + DATA_N_SYS_COLS < ulint(table->n_cols); i++) {
dict_col_t* col = dict_table_get_nth_col(table, i);
ut_ad(col->mtype != DATA_SYS);
@@ -6422,15 +6420,14 @@ dict_table_schema_check(
return(DB_TABLE_NOT_FOUND);
}
- ulint n_sys_cols = dict_table_get_n_sys_cols(table);
- if ((ulint) table->n_def - n_sys_cols != req_schema->n_cols) {
+ if (ulint(table->n_def) - DATA_N_SYS_COLS != req_schema->n_cols) {
/* the table has a different number of columns than required */
snprintf(errstr, errstr_sz,
"%s has " ULINTPF " columns but should have "
ULINTPF ".",
ut_format_name(req_schema->table_name, buf,
sizeof buf),
- table->n_def - n_sys_cols,
+ ulint(table->n_def) - DATA_N_SYS_COLS,
req_schema->n_cols);
return(DB_ERROR);
diff --git a/storage/innobase/dict/dict0mem.cc b/storage/innobase/dict/dict0mem.cc
index db62134bdef..0725eb40212 100644
--- a/storage/innobase/dict/dict0mem.cc
+++ b/storage/innobase/dict/dict0mem.cc
@@ -136,8 +136,7 @@ dict_mem_table_create(
table->name.m_name = mem_strdup(name);
table->is_system_db = dict_mem_table_is_system(table->name.m_name);
table->space = (unsigned int) space;
- table->n_t_cols = (unsigned int) (n_cols +
- dict_table_get_n_sys_cols(table));
+ table->n_t_cols = unsigned(n_cols + DATA_N_SYS_COLS);
table->n_v_cols = (unsigned int) (n_v_cols);
table->n_cols = table->n_t_cols - table->n_v_cols;
diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc
index e5559345a98..2adcaeabd5e 100644
--- a/storage/innobase/handler/handler0alter.cc
+++ b/storage/innobase/handler/handler0alter.cc
@@ -3939,7 +3939,7 @@ innobase_add_virtual_try(
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;
@@ -4173,7 +4173,7 @@ innobase_drop_virtual_try(
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)
+ ((user_table->flags & DICT_TF_COMPACT) << 31);
diff --git a/storage/innobase/include/data0type.h b/storage/innobase/include/data0type.h
index c4521d0723b..9c31bc38981 100644
--- a/storage/innobase/include/data0type.h
+++ b/storage/innobase/include/data0type.h
@@ -1,7 +1,7 @@
/*****************************************************************************
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
the terms of the GNU General Public License as published by the Free Software
@@ -183,8 +183,6 @@ be less than 256 */
for shorter VARCHARs MySQL uses only 1 byte */
#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). */
#define dict_table_is_locking_disabled(table) false
diff --git a/storage/innobase/include/dict0dict.h b/storage/innobase/include/dict0dict.h
index d843374b866..6c1f089ac44 100644
--- a/storage/innobase/include/dict0dict.h
+++ b/storage/innobase/include/dict0dict.h
@@ -879,13 +879,11 @@ dict_table_get_sys_col(
ulint sys) /*!< in: DATA_ROW_ID, ... */
MY_ATTRIBUTE((nonnull, warn_unused_result));
#else /* UNIV_DEBUG */
-#define dict_table_get_nth_col(table, pos) \
-((table)->cols + (pos))
+#define dict_table_get_nth_col(table, pos) &(table)->cols[pos]
#define dict_table_get_sys_col(table, sys) \
-((table)->cols + (table)->n_cols + (sys) \
- - (dict_table_get_n_sys_cols(table)))
+ &(table)->cols[(table)->n_cols + (sys) - DATA_N_SYS_COLS]
/* 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 */
/********************************************************************//**
Gets the given system column number of a table.
diff --git a/storage/innobase/include/dict0dict.ic b/storage/innobase/include/dict0dict.ic
index 6b081640aae..6178b40927c 100644
--- a/storage/innobase/include/dict0dict.ic
+++ b/storage/innobase/include/dict0dict.ic
@@ -475,13 +475,11 @@ dict_table_get_sys_col(
{
dict_col_t* col;
- 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);
col = dict_table_get_nth_col(table, table->n_cols
- - dict_table_get_n_sys_cols(table)
- + sys);
+ + (sys - DATA_N_SYS_COLS));
ut_ad(col->mtype == DATA_SYS);
ut_ad(col->prtype == (sys | DATA_NOT_NULL));
@@ -501,7 +499,7 @@ dict_table_get_sys_col_no(
{
ut_ad(sys < DATA_N_SYS_COLS);
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);
}
/********************************************************************//**