diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2017-10-06 06:53:40 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2017-10-06 06:53:40 +0300 |
commit | d27c3d887a0243781f8bb76d0c02e5bfe3669df2 (patch) | |
tree | f0a04b2ca2a3d48d676f576d2d971252e73da5e1 | |
parent | 970e80e42a8c8164619df553858a816eeb5d7567 (diff) | |
download | mariadb-git-d27c3d887a0243781f8bb76d0c02e5bfe3669df2.tar.gz |
Revert "ha_innobase::open(): Simplify a consistency check"
This reverts commit 71ce23cc93a261599522aa4c3d2f9e7fa98e2d12.
-rw-r--r-- | storage/innobase/handler/ha_innodb.cc | 41 | ||||
-rw-r--r-- | storage/innobase/include/dict0dict.h | 8 | ||||
-rw-r--r-- | storage/innobase/include/dict0dict.ic | 16 |
3 files changed, 46 insertions, 19 deletions
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 03e3db7d9c8..d6d103e55c2 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -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 @@ no_such_table: 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); diff --git a/storage/innobase/include/dict0dict.h b/storage/innobase/include/dict0dict.h index f14487f09d0..03175936f7e 100644 --- a/storage/innobase/include/dict0dict.h +++ b/storage/innobase/include/dict0dict.h @@ -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. diff --git a/storage/innobase/include/dict0dict.ic b/storage/innobase/include/dict0dict.ic index 80e406475c0..06cd2434942 100644 --- a/storage/innobase/include/dict0dict.ic +++ b/storage/innobase/include/dict0dict.ic @@ -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. |