mariadb/mysql-test/main/servers.test
2025-10-09 16:57:55 +03:00

162 lines
5.3 KiB
Text

# Generic tests for servers (do not require FEDERATED)
set sql_mode="";
--echo #
--echo # MDEV-4594 - CREATE SERVER crashes embedded
--echo #
CREATE SERVER s1 FOREIGN DATA WRAPPER mysql OPTIONS(HOST 'localhost');
SELECT * FROM mysql.servers;
DROP SERVER s1;
CREATE SERVER s1 FOREIGN DATA WRAPPER foo OPTIONS(USER 'bar');
SELECT * FROM mysql.servers;
DROP SERVER s1;
--error ER_CANT_CREATE_FEDERATED_TABLE
CREATE SERVER s1 FOREIGN DATA WRAPPER mysql OPTIONS(USER 'bar');
CREATE SERVER s1 FOREIGN DATA WRAPPER mysql OPTIONS(HOST 'bar');
SELECT * FROM mysql.servers;
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;
--echo #
--echo # MDEV-33783 CREATE SERVER segfaults on wrong mysql.servers
--echo #
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);
--error ER_CANNOT_LOAD_FROM_TABLE_V2
alter server s1 options(host 'server.example.org');
--error ER_CANNOT_LOAD_FROM_TABLE_V2
drop server s1;
--error ER_CANNOT_LOAD_FROM_TABLE_V2
create server s2 foreign data wrapper foo options(user 'a');
drop table mysql.servers;
rename table mysql.servers_save to mysql.servers;
flush privileges;
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;
--echo #
--echo # MDEV-34716 - Arbitrary OPTIONS for CREATE SERVER
--echo # MDEV-15696 - SHOW CREATE SERVER
--echo #
create server srv foreign data wrapper mysql options
(host "localhost", port 12345, wait_what "it's all good");
show create server srv;
create or replace server srv foreign data wrapper Foo options
(host "somewhere.else", port 54321, wait_what "it's all good", foo 'bar');
show create server srv;
alter server srv options (socket "sock", port 123, foo "", bar ')"{');
show create server srv;
alter server srv options (socket "sock", port 123, bar "quux");
show create server srv;
create or replace server srv foreign data wrapper foo options
(host "localhost", port "12345");
--error ER_PARSE_ERROR
create or replace server srv foreign data wrapper mysql options
(host "localhost", port "bar321");
--error ER_PARSE_ERROR
create or replace server srv foreign data wrapper mysql options
(host "localhost", port "123bar");
create or replace server srv foreign data wrapper mysql options
(host "localhost", port "0");
--error ER_FOREIGN_SERVER_DOESNT_EXIST
show create server nonexist;
drop server srv;
--echo #
--echo # MDEV-35557 SIGSEGV in get_server_from_table_to_cache | servers_load, UBSAN null pointer passed as argument 1, which is declared to never be null
--echo #
--source include/have_innodb.inc
CREATE SERVER s1 FOREIGN DATA WRAPPER mysql OPTIONS (HOST '127.0.0.1');
ALTER TABLE mysql.servers ENGINE=InnoDB;
FLUSH PRIVILEGES;
ALTER TABLE mysql.servers ENGINE=Aria;
FLUSH PRIVILEGES;
drop server s1;
--echo #
--echo # MDEV-35622 SEGV, ASAN use-after-poison when reading system table with less than expected number of columns
--echo # MDEV-37777 upgrade from MySQL 5.7 regression, mysql.servers invalid structure
--echo #
--echo # no crash:
rename table mysql.servers to mysql.servers_save;
create table mysql.servers like mysql.servers_save;
alter table mysql.servers drop column owner,drop column options;
insert into mysql.servers values(0,0,0,0,0,0,0,0);
--error 0,ER_CANNOT_LOAD_FROM_TABLE_V2
flush privileges;
drop table mysql.servers;
--echo # w/o PK
create table mysql.servers like mysql.servers_save;
alter table mysql.servers drop primary key;
insert into mysql.servers values(0,0,0,0,0,0,0,0,0,0);
--error ER_CANNOT_LOAD_FROM_TABLE_V2
flush privileges;
drop table mysql.servers;
--echo # upgrade is ok
create table mysql.servers like mysql.servers_save;
alter table mysql.servers drop column Options;
--error ER_CANNOT_LOAD_FROM_TABLE_V2
create server s1 foreign data wrapper mysql options (host '127.0.0.1');
flush privileges;
insert into mysql.servers values('s1',0,0,0,0,0,0,0,0);
flush privileges;
drop server s1;
drop table mysql.servers;
--echo # MySQL 5.7 (MDEV-37777)
create table mysql.servers like mysql.servers_save;
alter table mysql.servers modify Host char(64) not null, modify Owner char(64) not null;
create server s1 foreign data wrapper mysql options (host '127.0.0.1');
flush privileges;
drop server s1;
drop table mysql.servers;
rename table mysql.servers_save to mysql.servers;
--echo # plugin
create table mysql.plugin_save like mysql.plugin;
alter table mysql.plugin drop column dl;
--error ER_CANNOT_LOAD_FROM_TABLE_V2
install soname "ha_example";
--error ER_CANNOT_LOAD_FROM_TABLE_V2
uninstall soname "ha_example";
drop table mysql.plugin;
create table mysql.plugin like mysql.plugin_save;
alter table mysql.plugin drop primary key;
--error ER_CANNOT_LOAD_FROM_TABLE_V2
install soname "ha_example";
--error ER_CANNOT_LOAD_FROM_TABLE_V2
uninstall soname "ha_example";
drop table mysql.plugin;
rename table mysql.plugin_save to mysql.plugin;
--echo # End of 10.11 tests