Commit d27c3d88 authored by Marko Mäkelä's avatar Marko Mäkelä

Revert "ha_innobase::open(): Simplify a consistency check"

This reverts commit 71ce23cc.
parent 970e80e4
......@@ -6209,27 +6209,16 @@ ha_innobase::open(const char* name, int, uint)
ib_table = open_dict_table(name, norm_name, is_part, ignore_err);
if (NULL == ib_table) {
if (is_part) {
sql_print_error("Failed to open table %s.\n",
norm_name);
}
no_such_table:
free_share(m_share);
set_my_errno(ENOENT);
DBUG_RETURN(HA_ERR_NO_SUCH_TABLE);
}
uint n_fields = mysql_fields(table);
uint n_cols = dict_table_get_n_user_cols(ib_table)
+ dict_table_get_n_v_cols(ib_table)
- !!DICT_TF2_FLAG_IS_SET(ib_table, DICT_TF2_FTS_HAS_DOC_ID);
if (n_cols != n_fields) {
if (ib_table != NULL
&& ((!DICT_TF2_FLAG_IS_SET(ib_table, DICT_TF2_FTS_HAS_DOC_ID)
&& n_fields != dict_table_get_n_tot_u_cols(ib_table))
|| (DICT_TF2_FLAG_IS_SET(ib_table, DICT_TF2_FTS_HAS_DOC_ID)
&& (n_fields != dict_table_get_n_tot_u_cols(ib_table) - 1)))) {
ib::warn() << "Table " << norm_name << " contains "
<< n_cols << " user"
<< dict_table_get_n_tot_u_cols(ib_table) << " user"
" defined columns in InnoDB, but " << n_fields
<< " columns in MariaDB. Please check"
" INFORMATION_SCHEMA.INNODB_SYS_COLUMNS and " REFMAN
......@@ -6241,7 +6230,21 @@ ha_innobase::open(const char* name, int, uint)
ib_table->file_unreadable = true;
ib_table->corrupted = true;
dict_table_close(ib_table, FALSE, FALSE);
goto no_such_table;
ib_table = NULL;
is_part = NULL;
}
if (NULL == ib_table) {
if (is_part) {
sql_print_error("Failed to open table %s.\n",
norm_name);
}
free_share(m_share);
set_my_errno(ENOENT);
DBUG_RETURN(HA_ERR_NO_SUCH_TABLE);
}
innobase_copy_frm_flags_from_table_share(ib_table, table->s);
......
......@@ -789,6 +789,14 @@ dict_table_get_n_user_cols(
/*=======================*/
const dict_table_t* table) /*!< in: table */
MY_ATTRIBUTE((warn_unused_result));
/** Gets the number of user-defined virtual and non-virtual columns in a table
in the dictionary cache.
@param[in] table table
@return number of user-defined (e.g., not ROW_ID) columns of a table */
UNIV_INLINE
ulint
dict_table_get_n_tot_u_cols(
const dict_table_t* table);
/********************************************************************//**
Gets the number of all non-virtual columns (also system) in a table
in the dictionary cache.
......
......@@ -391,6 +391,22 @@ dict_table_get_n_user_cols(
return(table->n_cols - DATA_N_SYS_COLS);
}
/** Gets the number of user-defined virtual and non-virtual columns in a table
in the dictionary cache.
@param[in] table table
@return number of user-defined (e.g., not ROW_ID) columns of a table */
UNIV_INLINE
ulint
dict_table_get_n_tot_u_cols(
const dict_table_t* table)
{
ut_ad(table);
ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
return(dict_table_get_n_user_cols(table)
+ dict_table_get_n_v_cols(table));
}
/********************************************************************//**
Gets the number of all non-virtual columns (also system) in a table
in the dictionary cache.
......
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