Skip to content

Commit

Permalink
Replace dict_table_get_n_sys_cols(table) with DATA_N_SYS_COLS
Browse files Browse the repository at this point in the history
This could have been done as part of MDEV-11487, which removed the
support for InnoDB internal temporary tables.
  • Loading branch information
dr-m committed Sep 21, 2017
1 parent e3d44f5 commit d4b2dfa
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 46 deletions.
14 changes: 5 additions & 9 deletions storage/innobase/dict/dict0dict.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1236,8 +1236,7 @@ dict_table_add_system_columns(
mem_heap_t* heap) /*!< in: temporary heap */
{
ut_ad(table);
ut_ad(table->n_def ==
(table->n_cols - dict_table_get_n_sys_cols(table)));
ut_ad(table->n_def == (table->n_cols - DATA_N_SYS_COLS));
ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
ut_ad(!table->cached);

Expand Down Expand Up @@ -3170,8 +3169,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);
Expand Down Expand Up @@ -6571,15 +6569,13 @@ 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 */
ut_snprintf(errstr, errstr_sz,
"%s has " ULINTPF " columns but should have "
ULINTPF ".",
"%s has %d columns but should have " ULINTPF ".",
ut_format_name(req_schema->table_name,
buf, sizeof(buf)),
table->n_def - n_sys_cols,
table->n_def - DATA_N_SYS_COLS,
req_schema->n_cols);

return(DB_ERROR);
Expand Down
3 changes: 1 addition & 2 deletions storage/innobase/dict/dict0mem.cc
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,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;

Expand Down
25 changes: 7 additions & 18 deletions storage/innobase/handler/handler0alter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3970,17 +3970,11 @@ innobase_add_virtual_try(
}


ulint n_col = user_table->n_cols;
ulint n_v_col = user_table->n_v_cols;

n_v_col += ctx->num_to_add_vcol;

n_col -= dict_table_get_n_sys_cols(user_table);

n_v_col -= ctx->num_to_drop_vcol;

ulint n_col = user_table->n_cols - DATA_N_SYS_COLS;
ulint n_v_col = user_table->n_v_cols
+ ctx->num_to_add_vcol - ctx->num_to_drop_vcol;
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);

err = innobase_update_n_virtual(user_table, new_n, trx);

Expand Down Expand Up @@ -4204,15 +4198,10 @@ innobase_drop_virtual_try(
}


ulint n_col = user_table->n_cols;
ulint n_v_col = user_table->n_v_cols;

n_v_col -= ctx->num_to_drop_vcol;

n_col -= dict_table_get_n_sys_cols(user_table);

ulint n_col = user_table->n_cols - DATA_N_SYS_COLS;
ulint n_v_col = user_table->n_v_cols - ctx->num_to_drop_vcol;
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);

err = innobase_update_n_virtual(user_table, new_n, trx);

Expand Down
2 changes: 0 additions & 2 deletions storage/innobase/include/data0type.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
11 changes: 5 additions & 6 deletions storage/innobase/include/dict0dict.h
Original file line number Diff line number Diff line change
Expand Up @@ -920,13 +920,12 @@ 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_sys_col(table, sys) \
((table)->cols + (table)->n_cols + (sys) \
- (dict_table_get_n_sys_cols(table)))
#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) - 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.
Expand Down
13 changes: 6 additions & 7 deletions storage/innobase/include/dict0dict.ic
Original file line number Diff line number Diff line change
Expand Up @@ -396,8 +396,8 @@ dict_table_get_n_user_cols(
const dict_table_t* table) /*!< in: table */
{
ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);

return(table->n_cols - dict_table_get_n_sys_cols(table));
ut_ad(table->n_cols > DATA_N_SYS_COLS);
return(table->n_cols - DATA_N_SYS_COLS);
}

/** Gets the number of user-defined virtual and non-virtual columns in a table
Expand Down Expand Up @@ -562,11 +562,10 @@ 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)
col = dict_table_get_nth_col(table, table->n_cols - DATA_N_SYS_COLS
+ sys);
ut_ad(col->mtype == DATA_SYS);
ut_ad(col->prtype == (sys | DATA_NOT_NULL));
Expand All @@ -586,10 +585,10 @@ dict_table_get_sys_col_no(
ulint sys) /*!< in: DATA_ROW_ID, ... */
{
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);

return(table->n_cols - dict_table_get_n_sys_cols(table) + sys);
return(table->n_cols - DATA_N_SYS_COLS + sys);
}

/********************************************************************//**
Expand Down
4 changes: 2 additions & 2 deletions storage/innobase/row/row0merge.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1843,8 +1843,8 @@ row_merge_read_clustered_index(
based on that. */

clust_index = dict_table_get_first_index(old_table);
const ulint old_trx_id_col = old_table->n_cols + DATA_TRX_ID
- dict_table_get_n_sys_cols(table);
const ulint old_trx_id_col = DATA_TRX_ID - DATA_N_SYS_COLS
+ old_table->n_cols;
ut_ad(old_table->cols[old_trx_id_col].mtype == DATA_SYS);
ut_ad(old_table->cols[old_trx_id_col].prtype
== (DATA_TRX_ID | DATA_NOT_NULL));
Expand Down

0 comments on commit d4b2dfa

Please sign in to comment.