[Commits] 32818f5e57d: MDEV-18791 Wrong error upon creating Aria table with long index on BLOB
revision-id: 32818f5e57ddb262dff8b2e72ed612748d29d3d0 (mariadb-10.4.5-25-g32818f5e57d) parent(s): 8b545d3d41416772203cb98f06243873a4f0d8f7 author: Sachin committer: Sachin timestamp: 2019-06-02 13:05:54 +0530 message: MDEV-18791 Wrong error upon creating Aria table with long index on BLOB Create a Create_table_error_handler to mask ER_KEY_BASED_ON_GENERATED_VIRTUAL_COLUMN error. --- mysql-test/main/long_unique_bugs.result | 2 ++ mysql-test/main/long_unique_bugs.test | 6 ++++++ sql/handler.cc | 9 +++++++++ sql/share/errmsg-utf8.txt | 2 ++ sql/sql_class.cc | 25 +++++++++++++++++++++++++ sql/sql_class.h | 24 ++++++++++++++++++++++++ 6 files changed, 68 insertions(+) diff --git a/mysql-test/main/long_unique_bugs.result b/mysql-test/main/long_unique_bugs.result index 33496c4e20d..4a65cc69ced 100644 --- a/mysql-test/main/long_unique_bugs.result +++ b/mysql-test/main/long_unique_bugs.result @@ -265,3 +265,5 @@ ERROR 40001: Deadlock found when trying to get lock; try restarting transaction disconnect con1; connection default; DROP TABLE t1, t2; +CREATE TABLE t1 (a TEXT, UNIQUE(a)) ENGINE=Aria; +ERROR HY000: Aria Storage engine does not support long unique keys diff --git a/mysql-test/main/long_unique_bugs.test b/mysql-test/main/long_unique_bugs.test index dc78f6c7067..ce76211184d 100644 --- a/mysql-test/main/long_unique_bugs.test +++ b/mysql-test/main/long_unique_bugs.test @@ -317,3 +317,9 @@ INSERT IGNORE INTO t1 VALUES (4, 1)/*4*/; --disconnect con1 --connection default DROP TABLE t1, t2; + +# +# MDEV-18791 Wrong error upon creating Aria table with long index on BLOB +# +--error ER_NO_LONG_UNIQUE_ENGINE_SUPPORT +CREATE TABLE t1 (a TEXT, UNIQUE(a)) ENGINE=Aria; diff --git a/sql/handler.cc b/sql/handler.cc index 124f5c8e9ce..b5303fbf67e 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -5135,6 +5135,7 @@ int ha_create_table(THD *thd, const char *path, TABLE_SHARE share; bool temp_table __attribute__((unused)) = create_info->options & (HA_LEX_CREATE_TMP_TABLE | HA_CREATE_TMP_ALTER); + Create_table_error_handler err_handler; DBUG_ENTER("ha_create_table"); init_tmp_table_share(thd, &share, db, 0, table_name, path); @@ -5170,12 +5171,20 @@ int ha_create_table(THD *thd, const char *path, name= get_canonical_filename(table.file, share.path.str, name_buff); + thd->push_internal_handler(&err_handler); error= table.file->ha_create(name, &table, create_info); + thd->pop_internal_handler(); if (unlikely(error)) { if (!thd->is_error()) + { + if (err_handler.safely_trapped_errors()) + { + my_error(ER_NO_LONG_UNIQUE_ENGINE_SUPPORT, MYF(0), hton_name(table.file->ht)->str); + } my_error(ER_CANT_CREATE_TABLE, MYF(0), db, table_name, error); + } table.file->print_error(error, MYF(ME_WARNING)); PSI_CALL_drop_table_share(temp_table, share.db.str, (uint)share.db.length, share.table_name.str, (uint)share.table_name.length); diff --git a/sql/share/errmsg-utf8.txt b/sql/share/errmsg-utf8.txt index c64f60f3562..3fb53ad55e6 100644 --- a/sql/share/errmsg-utf8.txt +++ b/sql/share/errmsg-utf8.txt @@ -7931,3 +7931,5 @@ ER_PERIOD_CONSTRAINT_DROP eng "Can't DROP CONSTRAINT `%s`. Use DROP PERIOD `%s` for this" ER_TOO_LONG_KEYPART 42000 S1009 eng "Specified key part was too long; max key part length is %u bytes" +ER_NO_LONG_UNIQUE_ENGINE_SUPPORT + eng "%s Storage engine does not support long unique keys" diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 94e2b518fa4..4cd3c49cd41 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -563,6 +563,31 @@ bool Drop_table_error_handler::handle_condition(THD *thd, sql_errno == ER_TRG_NO_DEFINER); } +/** + Implementation of Create_table_error_handler::handle_condition(). + The reason in having this implementation is to silence technical low-level + error during CREATE TABLE operation. Currently we don't want to expose + the following warnings during DROP TABLE: + - When using long unique on ARIA storage engine show long unique not + avaliable in ARIA instead of ER_KEY_BASED_ON_GENERATED_VIRTUAL_COLUMN + @return TRUE if the condition is handled. +*/ +bool Create_table_error_handler::handle_condition(THD *thd, + uint sql_errno, + const char* sqlstate, + Sql_condition::enum_warning_level *level, + const char* msg, + Sql_condition ** cond_hdl) +{ + *cond_hdl= NULL; + if (sql_errno == ER_KEY_BASED_ON_GENERATED_VIRTUAL_COLUMN) + { + m_handled_error++; + return true; + } + return false; +} + /** Handle an error from MDL_context::upgrade_lock() and mysql_lock_tables(). diff --git a/sql/sql_class.h b/sql/sql_class.h index dd9cfbbd1c4..c5c3058cc06 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -1808,6 +1808,30 @@ class Drop_table_error_handler : public Internal_error_handler private: }; +/** + This class is an internal error handler implementation for + CREATE TABLE statements. The thing is that there may be error during + execution of these statements, which should not be exposed to the user. + This class is intended to silence such error. +*/ + +class Create_table_error_handler : public Internal_error_handler +{ +public: + Create_table_error_handler(): m_handled_error(0) {} + +public: + bool handle_condition(THD *thd, + uint sql_errno, + const char* sqlstate, + Sql_condition::enum_warning_level *level, + const char* msg, + Sql_condition ** cond_hdl); + bool safely_trapped_errors(){return m_handled_error > 0;} +private: + int m_handled_error; +}; + /** Internal error handler to process an error from MDL_context::upgrade_lock()
participants (1)
-
sachin.setiya@mariadb.com