Commit 4feb58e8 authored by Yuchen Pei's avatar Yuchen Pei Committed by Sergei Golubchik

MDEV-34716 Fix mysql.servers socket max length too short

The limit of socket length on unix according to libc is 108, see
sockaddr_un::sun_path, but in the table it is a string of max length
64, which results in truncation of socket and failure to connect by
plugins using servers such as spider.
parent b200cf78
......@@ -6,7 +6,7 @@
mysql.time_zone_transition 3719776009
-mysql.plugin 1587119305
+mysql.plugin 2184891911
mysql.servers 2079085450
mysql.servers 2180549486
-mysql.func 3241572444
+mysql.func 310494789
mysql.innodb_table_stats 1972297402
......@@ -17,7 +17,7 @@
mysql.roles_mapping 2510045525
mysql.time_zone_transition 3719776009
-mysql.plugin 1587119305
+mysql.plugin 2184891911
+mysql.plugin 2180549486
mysql.servers 2079085450
-mysql.func 3241572444
+mysql.func 310494789
......
......@@ -1865,7 +1865,7 @@ Table Checksum
mysql.roles_mapping 2510045525
mysql.time_zone_transition 3719776009
mysql.plugin 1587119305
mysql.servers 2079085450
mysql.servers 2180549486
mysql.func 3241572444
mysql.innodb_table_stats 1972297402
mysql.table_stats 1911089388
......@@ -1900,7 +1900,7 @@ Table Checksum
mysql.roles_mapping 2510045525
mysql.time_zone_transition 3719776009
mysql.plugin 1587119305
mysql.servers 2079085450
mysql.servers 2180549486
mysql.func 3241572444
mysql.innodb_table_stats 1972297402
mysql.table_stats 1911089388
......
......@@ -24,3 +24,8 @@ SELECT * FROM mysql.servers;
Server_name Host Db Username Password Port Socket Wrapper Owner
s1 3306 bar mysql
DROP SERVER s1;
CREATE SERVER s1 FOREIGN DATA WRAPPER mysql OPTIONS(SOCKET '/tmp/1234567890_1234567890_1234567890_1234567890_1234567890_1234567890.sock');
SELECT Socket FROM mysql.servers where Server_name = 's1';
Socket
/tmp/1234567890_1234567890_1234567890_1234567890_1234567890_1234567890.sock
DROP SERVER s1;
......@@ -22,3 +22,7 @@ DROP SERVER s1;
CREATE SERVER s1 FOREIGN DATA WRAPPER mysql OPTIONS(SOCKET 'bar');
SELECT * FROM mysql.servers;
DROP SERVER s1;
CREATE SERVER s1 FOREIGN DATA WRAPPER mysql OPTIONS(SOCKET '/tmp/1234567890_1234567890_1234567890_1234567890_1234567890_1234567890.sock');
SELECT Socket FROM mysql.servers where Server_name = 's1';
DROP SERVER s1;
......@@ -130,7 +130,7 @@ servers CREATE TABLE `servers` (
`Username` char(128) NOT NULL DEFAULT '',
`Password` char(64) NOT NULL DEFAULT '',
`Port` int(4) NOT NULL DEFAULT 0,
`Socket` char(64) NOT NULL DEFAULT '',
`Socket` char(108) NOT NULL DEFAULT '',
`Wrapper` char(64) NOT NULL DEFAULT '',
`Owner` varchar(512) NOT NULL DEFAULT '',
PRIMARY KEY (`Server_name`)
......
......@@ -168,7 +168,7 @@ servers CREATE TABLE `servers` (
`Username` char(128) NOT NULL DEFAULT '',
`Password` char(64) NOT NULL DEFAULT '',
`Port` int(4) NOT NULL DEFAULT 0,
`Socket` char(64) NOT NULL DEFAULT '',
`Socket` char(108) NOT NULL DEFAULT '',
`Wrapper` char(64) NOT NULL DEFAULT '',
`Owner` varchar(512) NOT NULL DEFAULT '',
PRIMARY KEY (`Server_name`)
......
......@@ -172,7 +172,7 @@ servers CREATE TABLE `servers` (
`Username` char(128) NOT NULL DEFAULT '',
`Password` char(64) NOT NULL DEFAULT '',
`Port` int(4) NOT NULL DEFAULT 0,
`Socket` char(64) NOT NULL DEFAULT '',
`Socket` char(108) NOT NULL DEFAULT '',
`Wrapper` char(64) NOT NULL DEFAULT '',
`Owner` varchar(512) NOT NULL DEFAULT '',
PRIMARY KEY (`Server_name`)
......
......@@ -152,7 +152,7 @@ servers CREATE TABLE `servers` (
`Username` char(128) NOT NULL DEFAULT '',
`Password` char(64) NOT NULL DEFAULT '',
`Port` int(4) NOT NULL DEFAULT 0,
`Socket` char(64) NOT NULL DEFAULT '',
`Socket` char(108) NOT NULL DEFAULT '',
`Wrapper` char(64) NOT NULL DEFAULT '',
`Owner` varchar(512) NOT NULL DEFAULT '',
PRIMARY KEY (`Server_name`)
......
......@@ -173,7 +173,7 @@ servers CREATE TABLE `servers` (
`Username` char(128) NOT NULL DEFAULT '',
`Password` char(64) NOT NULL DEFAULT '',
`Port` int(4) NOT NULL DEFAULT 0,
`Socket` char(64) NOT NULL DEFAULT '',
`Socket` char(108) NOT NULL DEFAULT '',
`Wrapper` char(64) NOT NULL DEFAULT '',
`Owner` varchar(512) NOT NULL DEFAULT '',
PRIMARY KEY (`Server_name`)
......
......@@ -164,7 +164,7 @@ def mysql servers Owner 9 '' NO varchar 512 1536 NULL NULL NULL utf8mb3 utf8mb3_
def mysql servers Password 5 '' NO char 64 192 NULL NULL NULL utf8mb3 utf8mb3_general_ci char(64) select,insert,update,references NEVER NULL NO NO
def mysql servers Port 6 0 NO int NULL NULL 10 0 NULL NULL NULL int(4) select,insert,update,references NEVER NULL NO NO
def mysql servers Server_name 1 '' NO char 64 192 NULL NULL NULL utf8mb3 utf8mb3_general_ci char(64) PRI select,insert,update,references NEVER NULL NO NO
def mysql servers Socket 7 '' NO char 64 192 NULL NULL NULL utf8mb3 utf8mb3_general_ci char(64) select,insert,update,references NEVER NULL NO NO
def mysql servers Socket 7 '' NO char 108 324 NULL NULL NULL utf8mb3 utf8mb3_general_ci char(108) select,insert,update,references NEVER NULL NO NO
def mysql servers Username 4 '' NO char 128 384 NULL NULL NULL utf8mb3 utf8mb3_general_ci char(128) select,insert,update,references NEVER NULL NO NO
def mysql servers Wrapper 8 '' NO char 64 192 NULL NULL NULL utf8mb3 utf8mb3_general_ci char(64) select,insert,update,references NEVER NULL NO NO
def mysql slow_log db 7 NULL NO varchar 512 1536 NULL NULL NULL utf8mb3 utf8mb3_general_ci varchar(512) select,insert,update,references NEVER NULL NO NO
......@@ -492,7 +492,7 @@ NULL mysql proxies_priv Timestamp timestamp NULL NULL NULL NULL timestamp
3.0000 mysql servers Username char 128 384 utf8mb3 utf8mb3_general_ci char(128)
3.0000 mysql servers Password char 64 192 utf8mb3 utf8mb3_general_ci char(64)
NULL mysql servers Port int NULL NULL NULL NULL int(4)
3.0000 mysql servers Socket char 64 192 utf8mb3 utf8mb3_general_ci char(64)
3.0000 mysql servers Socket char 108 324 utf8mb3 utf8mb3_general_ci char(108)
3.0000 mysql servers Wrapper char 64 192 utf8mb3 utf8mb3_general_ci char(64)
3.0000 mysql servers Owner varchar 512 1536 utf8mb3 utf8mb3_general_ci varchar(512)
NULL mysql slow_log start_time timestamp NULL NULL NULL NULL timestamp(6)
......
......@@ -150,7 +150,7 @@ def mysql servers Owner 9 '' NO varchar 512 1536 NULL NULL NULL utf8mb3 utf8mb3_
def mysql servers Password 5 '' NO char 64 192 NULL NULL NULL utf8mb3 utf8mb3_general_ci char(64) NEVER NULL NO NO
def mysql servers Port 6 0 NO int NULL NULL 10 0 NULL NULL NULL int(4) NEVER NULL NO NO
def mysql servers Server_name 1 '' NO char 64 192 NULL NULL NULL utf8mb3 utf8mb3_general_ci char(64) PRI NEVER NULL NO NO
def mysql servers Socket 7 '' NO char 64 192 NULL NULL NULL utf8mb3 utf8mb3_general_ci char(64) NEVER NULL NO NO
def mysql servers Socket 7 '' NO char 108 324 NULL NULL NULL utf8mb3 utf8mb3_general_ci char(64) NEVER NULL NO NO
def mysql servers Username 4 '' NO char 128 384 NULL NULL NULL utf8mb3 utf8mb3_general_ci char(128) NEVER NULL NO NO
def mysql servers Wrapper 8 '' NO char 64 192 NULL NULL NULL utf8mb3 utf8mb3_general_ci char(64) NEVER NULL NO NO
def mysql slow_log db 7 NULL NO varchar 512 1536 NULL NULL NULL utf8mb3 utf8mb3_general_ci varchar(512) NEVER NULL NO NO
......@@ -475,7 +475,7 @@ NULL mysql proxies_priv Timestamp timestamp NULL NULL NULL NULL timestamp
3.0000 mysql servers Username char 128 384 utf8mb3 utf8mb3_general_ci char(128)
3.0000 mysql servers Password char 64 192 utf8mb3 utf8mb3_general_ci char(64)
NULL mysql servers Port int NULL NULL NULL NULL int(4)
3.0000 mysql servers Socket char 64 192 utf8mb3 utf8mb3_general_ci char(64)
3.0000 mysql servers Socket char 108 324 utf8mb3 utf8mb3_general_ci char(64)
3.0000 mysql servers Wrapper char 64 192 utf8mb3 utf8mb3_general_ci char(64)
3.0000 mysql servers Owner varchar 512 1536 utf8mb3 utf8mb3_general_ci varchar(512)
NULL mysql slow_log start_time timestamp NULL NULL NULL NULL timestamp(6)
......
......@@ -109,7 +109,7 @@ CREATE TABLE IF NOT EXISTS func ( name char(64) binary DEFAULT '' NOT NULL, ret
CREATE TABLE IF NOT EXISTS plugin ( name varchar(64) DEFAULT '' NOT NULL, dl varchar(128) DEFAULT '' NOT NULL, PRIMARY KEY (name) ) engine=Aria transactional=1 CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci comment='MySQL plugins';
CREATE TABLE IF NOT EXISTS servers ( Server_name char(64) NOT NULL DEFAULT '', Host varchar(2048) NOT NULL DEFAULT '', Db char(64) NOT NULL DEFAULT '', Username char(128) NOT NULL DEFAULT '', Password char(64) NOT NULL DEFAULT '', Port INT(4) NOT NULL DEFAULT '0', Socket char(64) NOT NULL DEFAULT '', Wrapper char(64) NOT NULL DEFAULT '', Owner varchar(512) NOT NULL DEFAULT '', PRIMARY KEY (Server_name)) engine=Aria transactional=1 CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci comment='MySQL Foreign Servers table';
CREATE TABLE IF NOT EXISTS servers ( Server_name char(64) NOT NULL DEFAULT '', Host varchar(2048) NOT NULL DEFAULT '', Db char(64) NOT NULL DEFAULT '', Username char(128) NOT NULL DEFAULT '', Password char(64) NOT NULL DEFAULT '', Port INT(4) NOT NULL DEFAULT '0', Socket char(108) NOT NULL DEFAULT '', Wrapper char(64) NOT NULL DEFAULT '', Owner varchar(512) NOT NULL DEFAULT '', PRIMARY KEY (Server_name)) engine=Aria transactional=1 CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci comment='MySQL Foreign Servers table';
CREATE TABLE IF NOT EXISTS tables_priv ( Host char(255) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(128) binary DEFAULT '' NOT NULL, Table_name char(64) binary DEFAULT '' NOT NULL, Grantor varchar(384) DEFAULT '' NOT NULL, Timestamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter','Create View','Show view','Trigger','Delete versioning rows') COLLATE utf8mb3_general_ci DEFAULT '' NOT NULL, Column_priv set('Select','Insert','Update','References') COLLATE utf8mb3_general_ci DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name), KEY Grantor (Grantor) ) engine=Aria transactional=1 CHARACTER SET utf8mb3 COLLATE utf8mb3_bin comment='Table privileges';
......
......@@ -897,3 +897,7 @@ DELIMITER ;
ALTER TABLE servers
MODIFY Host varchar(2048) NOT NULL DEFAULT '',
MODIFY Owner varchar(512) NOT NULL DEFAULT '';
# MDEV-34716 Fix mysql.servers socket max length too short
ALTER TABLE servers
MODIFY Socket char(108) NOT NULL DEFAULT '';
for master_1
for child2
for child3
set spider_same_server_link= 1;
CREATE SERVER srv FOREIGN DATA WRAPPER mysql
OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
select Socket from mysql.servers where Server_name = "srv";
Socket
/tmp/1234567890_1234567890_1234567890_1234567890_1234567890_1234567890.sock
create table t2 (c int);
alter SERVER srv OPTIONS (DATABASE 'test');
create table t1 (c int) ENGINE=Spider
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2"';
Warnings:
Warning 138 Spider table params in COMMENT or CONNECTION strings have been deprecated and will be removed in a future release. Please use table options instead.
insert into t1 values (1), (2), (3);
select * from t1;
c
1
2
3
select * from t2;
c
1
2
3
drop table t1, t2;
drop server srv;
for master_1
for child2
for child3
[mysqld.1.1]
socket= /tmp/1234567890_1234567890_1234567890_1234567890_1234567890_1234567890.sock
[ENV]
MASTER_1_MYSOCK= @mysqld.1.1.socket
--disable_query_log
--disable_result_log
--source test_init.inc
--enable_result_log
--enable_query_log
set spider_same_server_link= 1;
# Test long socket length
evalp CREATE SERVER srv FOREIGN DATA WRAPPER mysql
OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
select Socket from mysql.servers where Server_name = "srv";
create table t2 (c int);
# triggers a table read into the server object
alter SERVER srv OPTIONS (DATABASE 'test');
create table t1 (c int) ENGINE=Spider
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2"';
insert into t1 values (1), (2), (3);
select * from t1;
select * from t2;
drop table t1, t2;
drop server srv;
--disable_query_log
--disable_result_log
--source test_deinit.inc
--enable_result_log
--enable_query_log
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