mariadb/mysql-test/main/servers.result
Yuchen Pei fca8864d5b
MDEV-36230 Fix SERVER port field bound check
The Port field in the system table mysql.servers has type INT(4),
which translates to Field_long.

During parsing it is parsed as ulong_num

The various bound checks check for lower bound but not upper bound. So
we fix that.
2025-06-06 16:40:54 +10:00

79 lines
3.4 KiB
Text

set sql_mode="";
#
# MDEV-4594 - CREATE SERVER crashes embedded
#
CREATE SERVER s1 FOREIGN DATA WRAPPER mysql OPTIONS(HOST 'localhost');
SELECT * FROM mysql.servers;
Server_name Host Db Username Password Port Socket Wrapper Owner
s1 localhost 3306 mysql
DROP SERVER s1;
CREATE SERVER s1 FOREIGN DATA WRAPPER foo OPTIONS(USER 'bar');
SELECT * FROM mysql.servers;
Server_name Host Db Username Password Port Socket Wrapper Owner
s1 bar 0 foo
DROP SERVER s1;
CREATE SERVER s1 FOREIGN DATA WRAPPER mysql OPTIONS(USER 'bar');
ERROR HY000: Can't create federated table. Foreign data src error: either HOST or SOCKET must be set
CREATE SERVER s1 FOREIGN DATA WRAPPER mysql OPTIONS(HOST 'bar');
SELECT * FROM mysql.servers;
Server_name Host Db Username Password Port Socket Wrapper Owner
s1 bar 3306 mysql
DROP SERVER s1;
CREATE SERVER s1 FOREIGN DATA WRAPPER mysql OPTIONS(SOCKET 'bar');
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;
#
# MDEV-33783 CREATE SERVER segfaults on wrong mysql.servers
#
create server s1 foreign data wrapper foo options(user 'a');
alter server s1 options(host 'server.example.org');
rename table mysql.servers to mysql.servers_save;
create table mysql.servers (x int);
alter server s1 options(host 'server.example.org');
ERROR HY000: The foreign server name you are trying to reference does not exist. Data source error: s1
create server s2 foreign data wrapper foo options(user 'a');
ERROR HY000: Can't read record in system table
drop table mysql.servers;
rename table mysql.servers_save to mysql.servers;
drop server s1;
#
# MDEV-35641 foreign server "disappears" after ALTERing the servers system table to use innodb and FLUSH PRIVILEGES
#
CREATE SERVER s1 FOREIGN DATA WRAPPER mysql OPTIONS (HOST '127.0.0.1');
ALTER TABLE mysql.servers ENGINE=innodb;
FLUSH PRIVILEGES;
drop server s1;
#
# MDEV-36230 SIGSEGV in store_server_fields on CREATE SERVER
#
CREATE SERVER s FOREIGN DATA WRAPPER mysql OPTIONS (HOST'',PORT 4294967295);
select * from mysql.servers;
Server_name Host Db Username Password Port Socket Wrapper Owner
s 3306 mysql
drop server s;
CREATE SERVER s FOREIGN DATA WRAPPER mysql OPTIONS (HOST'',PORT 2147483647);
select * from mysql.servers;
Server_name Host Db Username Password Port Socket Wrapper Owner
s 2147483647 mysql
drop server s;
CREATE SERVER s FOREIGN DATA WRAPPER mysql OPTIONS (HOST'',PORT 2147483648);
select * from mysql.servers;
Server_name Host Db Username Password Port Socket Wrapper Owner
s 3306 mysql
drop server s;
CREATE SERVER s FOREIGN DATA WRAPPER mysql OPTIONS (HOST'',PORT 18446744073709551615);
select * from mysql.servers;
Server_name Host Db Username Password Port Socket Wrapper Owner
s 3306 mysql
drop server s;
CREATE SERVER s FOREIGN DATA WRAPPER mysql OPTIONS (HOST'',PORT -5);
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '-5)' at line 1
select * from mysql.servers;
Server_name Host Db Username Password Port Socket Wrapper Owner