From 466d81709bf0d1d73dcade887bdc88ff5330739e Mon Sep 17 00:00:00 2001 From: Alexey Botchkov Date: Tue, 5 Oct 2021 12:56:11 +0400 Subject: MDEV-26768 Spider table crashes the server after the mysql_list_fields() client's call and produces weird result for SHOW FIELDS. Suppress errors in ha_spider::info() called from mysqld_show_fields() --- storage/spider/ha_spider.cc | 18 ++++++++++++------ storage/spider/mysql-test/spider/r/ha_part.result | 9 +++++++++ storage/spider/mysql-test/spider/t/ha_part.test | 7 +++++++ 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/storage/spider/ha_spider.cc b/storage/spider/ha_spider.cc index 0f222577515..7f6b4ea1958 100644 --- a/storage/spider/ha_spider.cc +++ b/storage/spider/ha_spider.cc @@ -1125,7 +1125,8 @@ THR_LOCK_DATA **ha_spider::store_lock( if ( sql_command == SQLCOM_DROP_TABLE || sql_command == SQLCOM_ALTER_TABLE || - sql_command == SQLCOM_SHOW_CREATE + sql_command == SQLCOM_SHOW_CREATE || + sql_command == SQLCOM_SHOW_FIELDS ) { if ( lock_type == TL_READ_NO_INSERT && @@ -8707,7 +8708,8 @@ int ha_spider::info( spider_param_table_init_error_interval()) { pthread_mutex_unlock(&share->sts_mutex); - if (sql_command == SQLCOM_SHOW_CREATE) + if (sql_command == SQLCOM_SHOW_CREATE || + sql_command == SQLCOM_SHOW_FIELDS) { if (thd->is_error()) { @@ -8781,7 +8783,8 @@ int ha_spider::info( share->init_error = TRUE; share->init = TRUE; } - if (sql_command == SQLCOM_SHOW_CREATE) + if (sql_command == SQLCOM_SHOW_CREATE || + sql_command == SQLCOM_SHOW_FIELDS) { if (thd->is_error()) { @@ -8844,7 +8847,8 @@ int ha_spider::info( share->init_error = TRUE; share->init = TRUE; } - if (sql_command == SQLCOM_SHOW_CREATE) + if (sql_command == SQLCOM_SHOW_CREATE || + sql_command == SQLCOM_SHOW_FIELDS) { if (thd->is_error()) { @@ -8873,7 +8877,8 @@ int ha_spider::info( if ((error_num = spider_create_sts_thread(share))) { pthread_mutex_unlock(&share->sts_mutex); - if (sql_command == SQLCOM_SHOW_CREATE) + if (sql_command == SQLCOM_SHOW_CREATE || + sql_command == SQLCOM_SHOW_FIELDS) { if (thd->is_error()) { @@ -8904,7 +8909,8 @@ int ha_spider::info( { if ((error_num = check_crd())) { - if (sql_command == SQLCOM_SHOW_CREATE) + if (sql_command == SQLCOM_SHOW_CREATE || + sql_command == SQLCOM_SHOW_FIELDS) { if (thd->is_error()) { diff --git a/storage/spider/mysql-test/spider/r/ha_part.result b/storage/spider/mysql-test/spider/r/ha_part.result index 315f37298bc..d70d62404c0 100644 --- a/storage/spider/mysql-test/spider/r/ha_part.result +++ b/storage/spider/mysql-test/spider/r/ha_part.result @@ -248,6 +248,15 @@ a b date_format(c, '%Y-%m-%d %H:%i:%s') 8 g 2011-05-05 21:33:30 9 h 2011-05-05 22:32:10 DROP TABLE ta_l2; +connection master_1; +CREATE TABLE t (c INT) PARTITION BY LIST COLUMNS (c) (PARTITION p DEFAULT ENGINE=SPIDER); +SHOW FIELDS FROM t; +Field Type Null Key Default Extra +c int(11) YES NULL +SHOW FIELDS FROM t; +Field Type Null Key Default Extra +c int(11) YES NULL +DROP TABLE t; deinit connection master_1; diff --git a/storage/spider/mysql-test/spider/t/ha_part.test b/storage/spider/mysql-test/spider/t/ha_part.test index 72ddcfd1f10..7e9d6f7715c 100644 --- a/storage/spider/mysql-test/spider/t/ha_part.test +++ b/storage/spider/mysql-test/spider/t/ha_part.test @@ -982,6 +982,13 @@ if ($HAVE_PARTITION) } } +--connection master_1 + +CREATE TABLE t (c INT) PARTITION BY LIST COLUMNS (c) (PARTITION p DEFAULT ENGINE=SPIDER); +SHOW FIELDS FROM t; +SHOW FIELDS FROM t; +DROP TABLE t; + --echo --echo deinit --disable_warnings -- cgit v1.2.1