Skip to content
Permalink
Browse files
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.
  • Loading branch information
dr-m committed Apr 3, 2019
1 parent dbc7166 commit 03672a0
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 23 deletions.
@@ -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);
@@ -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;

@@ -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);
@@ -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

@@ -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.
@@ -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);
}

/********************************************************************//**

0 comments on commit 03672a0

Please sign in to comment.