Skip to content

Commit 3ffd5f2

Browse files
committed
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
1 parent 0ee0868 commit 3ffd5f2

File tree

3 files changed

+25
-16
lines changed

3 files changed

+25
-16
lines changed

mysql-test/suite/federated/assisted_discovery.result

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ CREATE TABLE t1 (
1313
`name` varchar(32) default 'name')
1414
DEFAULT CHARSET=latin1;
1515
connection master;
16-
CREATE TABLE t1 ENGINE=FEDERATED
17-
CONNECTION='mysql://root@127.0.0.1:SLAVE_PORT/test/t1';
16+
CREATE TABLE t1 ENGINE=FEDERATED CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/test/t1';
1817
SHOW CREATE TABLE t1;
1918
Table Create Table
2019
t1 CREATE TABLE `t1` (
@@ -38,6 +37,9 @@ id group a\\b a\\ name
3837
1 1 2 NULL foo
3938
2 1 2 NULL fee
4039
DROP TABLE t1;
40+
#
41+
# MDEV-11311 Create federated table does not work as expected
42+
#
4143
create table t1 (
4244
a bigint(20) not null auto_increment,
4345
b bigint(20) not null,
@@ -57,8 +59,7 @@ t1 CREATE TABLE `t1` (
5759
KEY `b` (`b`,`c`,`d`(255))
5860
) ENGINE=MyISAM DEFAULT CHARSET=latin1
5961
connection master;
60-
create table t1 engine=federated
61-
connection='mysql://root@127.0.0.1:SLAVE_PORT/test/t1';
62+
create table t1 engine=federated connection='mysql://root@127.0.0.1:$SLAVE_MYPORT/test/t1';
6263
show create table t1;
6364
Table Create Table
6465
t1 CREATE TABLE `t1` (
@@ -72,6 +73,12 @@ t1 CREATE TABLE `t1` (
7273
drop table t1;
7374
connection slave;
7475
drop table t1;
76+
#
77+
# MDEV-17227 Server crash in TABLE_SHARE::init_from_sql_statement_string upon table discovery with non-existent database
78+
#
79+
connection master;
80+
create table t1 engine=federated connection='mysql://root@127.0.0.1:$SLAVE_MYPORT/test/t1';
81+
ERROR HY000: Unable to connect to foreign data source: Table 'test.t1' doesn't exist
7582
connection master;
7683
DROP TABLE IF EXISTS federated.t1;
7784
DROP DATABASE IF EXISTS federated;

mysql-test/suite/federated/assisted_discovery.test

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ CREATE TABLE t1 (
1313

1414
connection master;
1515

16-
--replace_result $SLAVE_MYPORT SLAVE_PORT
17-
eval CREATE TABLE t1 ENGINE=FEDERATED
18-
CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/test/t1';
16+
evalp CREATE TABLE t1 ENGINE=FEDERATED CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/test/t1';
1917

2018
--replace_result $SLAVE_MYPORT SLAVE_PORT
2119
SHOW CREATE TABLE t1;
@@ -30,9 +28,9 @@ connection slave;
3028
SELECT * FROM t1;
3129
DROP TABLE t1;
3230

33-
#
34-
#
35-
#
31+
--echo #
32+
--echo # MDEV-11311 Create federated table does not work as expected
33+
--echo #
3634
create table t1 (
3735
a bigint(20) not null auto_increment,
3836
b bigint(20) not null,
@@ -44,15 +42,20 @@ create table t1 (
4442
show create table t1;
4543

4644
connection master;
47-
--replace_result $SLAVE_MYPORT SLAVE_PORT
48-
eval create table t1 engine=federated
49-
connection='mysql://root@127.0.0.1:$SLAVE_MYPORT/test/t1';
45+
evalp create table t1 engine=federated connection='mysql://root@127.0.0.1:$SLAVE_MYPORT/test/t1';
5046
--replace_result $SLAVE_MYPORT SLAVE_PORT
5147
show create table t1;
5248
drop table t1;
5349

5450
connection slave;
5551
drop table t1;
5652

53+
--echo #
54+
--echo # MDEV-17227 Server crash in TABLE_SHARE::init_from_sql_statement_string upon table discovery with non-existent database
55+
--echo #
56+
connection master;
57+
--error ER_CONNECT_TO_FOREIGN_DATA_SOURCE
58+
evalp create table t1 engine=federated connection='mysql://root@127.0.0.1:$SLAVE_MYPORT/test/t1';
59+
5760
source include/federated_cleanup.inc;
5861

sql/table.cc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2869,9 +2869,8 @@ int TABLE_SHARE::init_from_sql_statement_string(THD *thd, bool write,
28692869
if (unlikely(thd->is_error() || error))
28702870
{
28712871
thd->clear_error();
2872-
my_error(ER_SQL_DISCOVER_ERROR, MYF(0),
2873-
plugin_name(db_plugin)->str, db.str, table_name.str,
2874-
sql_copy);
2872+
my_error(ER_SQL_DISCOVER_ERROR, MYF(0), hton_name(hton)->str,
2873+
db.str, table_name.str, sql_copy);
28752874
DBUG_RETURN(HA_ERR_GENERIC);
28762875
}
28772876
/* Treat the table as normal table from binary logging point of view */

0 commit comments

Comments
 (0)