Commit 1d5f6a00 authored by Aleksey Midenkov's avatar Aleksey Midenkov

MDEV-21049 Segfault in create federatedx table with empty hostname

Use my_localhost instead of NULL for share->hostname.
parent 0076dce2
......@@ -2283,6 +2283,22 @@ connection default;
connection master;
CREATE TABLE t1 (a INT) ENGINE=FEDERATED CONNECTION='mysql://@127.0.0.1:SLAVE_PORT/federated/t1';
ERROR HY000: Can't create federated table. Foreign data src error: database: 'federated' username: '' hostname: '127.0.0.1'
#
# MDEV-21049 Segfault in create federatedx table with empty hostname
#
connection master;
CREATE TABLE federated.t1 (x int) ENGINE=FEDERATED
CONNECTION='mysql://root@:SLAVE_PORT/federated/t1';
ERROR HY000: Can't create federated table. Foreign data src error: database: 'federated' username: 'root' hostname: 'localhost'
connection slave;
CREATE TABLE federated.t1(x int);
connection master;
CREATE TABLE federated.t1 (x int) ENGINE=FEDERATED
CONNECTION='mysql://root@:SLAVE_PORT/federated/t1';
DROP TABLE federated.t1;
connection slave;
DROP TABLE federated.t1;
connection default;
connection master;
DROP TABLE IF EXISTS federated.t1;
DROP DATABASE IF EXISTS federated;
......
......@@ -2010,4 +2010,25 @@ connection master;
--error ER_CANT_CREATE_FEDERATED_TABLE
eval CREATE TABLE t1 (a INT) ENGINE=FEDERATED CONNECTION='mysql://@127.0.0.1:$SLAVE_MYPORT/federated/t1';
--echo #
--echo # MDEV-21049 Segfault in create federatedx table with empty hostname
--echo #
connection master;
--replace_result $SLAVE_MYPORT SLAVE_PORT
--error ER_CANT_CREATE_FEDERATED_TABLE
eval CREATE TABLE federated.t1 (x int) ENGINE=FEDERATED
CONNECTION='mysql://root@:$SLAVE_MYPORT/federated/t1';
connection slave;
CREATE TABLE federated.t1(x int);
connection master;
--replace_result $SLAVE_MYPORT SLAVE_PORT
eval CREATE TABLE federated.t1 (x int) ENGINE=FEDERATED
CONNECTION='mysql://root@:$SLAVE_MYPORT/federated/t1';
DROP TABLE federated.t1;
connection slave;
DROP TABLE federated.t1;
connection default;
source include/federated_cleanup.inc;
......@@ -798,12 +798,12 @@ static int parse_url(MEM_ROOT *mem_root, FEDERATEDX_SHARE *share,
goto error;
if (share->hostname[0] == '\0')
share->hostname= NULL;
share->hostname= strdup_root(mem_root, my_localhost);
}
if (!share->port)
{
if (!share->hostname || strcmp(share->hostname, my_localhost) == 0)
if (0 == strcmp(share->hostname, my_localhost))
share->socket= (char *) MYSQL_UNIX_ADDR;
else
share->port= MYSQL_PORT;
......@@ -3385,8 +3385,7 @@ int ha_federatedx::create(const char *name, TABLE *table_arg,
goto error;
/* loopback socket connections hang due to LOCK_open mutex */
if ((!tmp_share.hostname || !strcmp(tmp_share.hostname,my_localhost)) &&
!tmp_share.port)
if (0 == strcmp(tmp_share.hostname, my_localhost) && !tmp_share.port)
goto error;
/*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment