diff options
author | Sergei Golubchik <serg@mariadb.org> | 2021-01-10 21:51:36 +0100 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2021-01-12 10:25:04 +0100 |
commit | 3ffd5f28f04a34aadabb1966b861e6bc89f7fc73 (patch) | |
tree | 01a15495cd5f93f539f7c7319d52e16d9a5dbe21 | |
parent | 0ee086838d4b4497599d4e0822343269b682f913 (diff) | |
download | mariadb-git-3ffd5f28f04a34aadabb1966b861e6bc89f7fc73.tar.gz |
MDEV-17227 Server crash in TABLE_SHARE::init_from_sql_statement_string upon table discovery with non-existent database
* failed init_from_binary_frm_image can clear share->db_plugin,
don't use it on the error path
* cleanup the test a bit
-rw-r--r-- | mysql-test/suite/federated/assisted_discovery.result | 15 | ||||
-rw-r--r-- | mysql-test/suite/federated/assisted_discovery.test | 21 | ||||
-rw-r--r-- | sql/table.cc | 5 |
3 files changed, 25 insertions, 16 deletions
diff --git a/mysql-test/suite/federated/assisted_discovery.result b/mysql-test/suite/federated/assisted_discovery.result index 4818ff7bb02..e8d6663e9bc 100644 --- a/mysql-test/suite/federated/assisted_discovery.result +++ b/mysql-test/suite/federated/assisted_discovery.result @@ -13,8 +13,7 @@ CREATE TABLE t1 ( `name` varchar(32) default 'name') DEFAULT CHARSET=latin1; connection master; -CREATE TABLE t1 ENGINE=FEDERATED -CONNECTION='mysql://root@127.0.0.1:SLAVE_PORT/test/t1'; +CREATE TABLE t1 ENGINE=FEDERATED CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/test/t1'; SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( @@ -38,6 +37,9 @@ id group a\\b a\\ name 1 1 2 NULL foo 2 1 2 NULL fee DROP TABLE t1; +# +# MDEV-11311 Create federated table does not work as expected +# create table t1 ( a bigint(20) not null auto_increment, b bigint(20) not null, @@ -57,8 +59,7 @@ t1 CREATE TABLE `t1` ( KEY `b` (`b`,`c`,`d`(255)) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 connection master; -create table t1 engine=federated -connection='mysql://root@127.0.0.1:SLAVE_PORT/test/t1'; +create table t1 engine=federated connection='mysql://root@127.0.0.1:$SLAVE_MYPORT/test/t1'; show create table t1; Table Create Table t1 CREATE TABLE `t1` ( @@ -72,6 +73,12 @@ t1 CREATE TABLE `t1` ( drop table t1; connection slave; drop table t1; +# +# MDEV-17227 Server crash in TABLE_SHARE::init_from_sql_statement_string upon table discovery with non-existent database +# +connection master; +create table t1 engine=federated connection='mysql://root@127.0.0.1:$SLAVE_MYPORT/test/t1'; +ERROR HY000: Unable to connect to foreign data source: Table 'test.t1' doesn't exist connection master; DROP TABLE IF EXISTS federated.t1; DROP DATABASE IF EXISTS federated; diff --git a/mysql-test/suite/federated/assisted_discovery.test b/mysql-test/suite/federated/assisted_discovery.test index fa83a2a8e19..bd32878f811 100644 --- a/mysql-test/suite/federated/assisted_discovery.test +++ b/mysql-test/suite/federated/assisted_discovery.test @@ -13,9 +13,7 @@ CREATE TABLE t1 ( connection master; ---replace_result $SLAVE_MYPORT SLAVE_PORT -eval CREATE TABLE t1 ENGINE=FEDERATED - CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/test/t1'; +evalp CREATE TABLE t1 ENGINE=FEDERATED CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/test/t1'; --replace_result $SLAVE_MYPORT SLAVE_PORT SHOW CREATE TABLE t1; @@ -30,9 +28,9 @@ connection slave; SELECT * FROM t1; DROP TABLE t1; -# -# -# +--echo # +--echo # MDEV-11311 Create federated table does not work as expected +--echo # create table t1 ( a bigint(20) not null auto_increment, b bigint(20) not null, @@ -44,9 +42,7 @@ create table t1 ( show create table t1; connection master; ---replace_result $SLAVE_MYPORT SLAVE_PORT -eval create table t1 engine=federated - connection='mysql://root@127.0.0.1:$SLAVE_MYPORT/test/t1'; +evalp create table t1 engine=federated connection='mysql://root@127.0.0.1:$SLAVE_MYPORT/test/t1'; --replace_result $SLAVE_MYPORT SLAVE_PORT show create table t1; drop table t1; @@ -54,5 +50,12 @@ drop table t1; connection slave; drop table t1; +--echo # +--echo # MDEV-17227 Server crash in TABLE_SHARE::init_from_sql_statement_string upon table discovery with non-existent database +--echo # +connection master; +--error ER_CONNECT_TO_FOREIGN_DATA_SOURCE +evalp create table t1 engine=federated connection='mysql://root@127.0.0.1:$SLAVE_MYPORT/test/t1'; + source include/federated_cleanup.inc; diff --git a/sql/table.cc b/sql/table.cc index 22cf3357ac7..254e2265633 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -2869,9 +2869,8 @@ ret: if (unlikely(thd->is_error() || error)) { thd->clear_error(); - my_error(ER_SQL_DISCOVER_ERROR, MYF(0), - plugin_name(db_plugin)->str, db.str, table_name.str, - sql_copy); + my_error(ER_SQL_DISCOVER_ERROR, MYF(0), hton_name(hton)->str, + db.str, table_name.str, sql_copy); DBUG_RETURN(HA_ERR_GENERIC); } /* Treat the table as normal table from binary logging point of view */ |