Skip to content

Commit d203a8a

Browse files
MENT-2388 MDEV-37518 Check number of fields in mysql.servers before trying to read Options
Also added a test covering MDEV-36087 This is a followup of 6f1161a
1 parent 21868be commit d203a8a

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#
2+
# MDEV-36087 MariDB 11.7.2 - /usr/sbin/mariadbd got signal 11
3+
#
4+
create server s foreign data wrapper mysql options (host "127.0.0.1", database "test", user "root", port 3306);
5+
show create server s;
6+
Server Create Server
7+
s CREATE SERVER `s` FOREIGN DATA WRAPPER mysql OPTIONS (host '127.0.0.1', database 'test', user 'root', port '3306');
8+
alter table mysql.servers drop column Options;
9+
show create server s;
10+
Server Create Server
11+
s CREATE SERVER `s` FOREIGN DATA WRAPPER mysql OPTIONS (host '127.0.0.1', database 'test', user 'root', port '3306');
12+
# restart
13+
show create server s;
14+
Server Create Server
15+
s CREATE SERVER `s` FOREIGN DATA WRAPPER mysql OPTIONS ();
16+
ALTER TABLE mysql.servers
17+
ADD Options JSON NOT NULL DEFAULT '{}' CHECK(JSON_VALID(Options));
18+
show create server s;
19+
Server Create Server
20+
s CREATE SERVER `s` FOREIGN DATA WRAPPER mysql OPTIONS ();
21+
drop server s;
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
--echo #
2+
--echo # MDEV-36087 MariDB 11.7.2 - /usr/sbin/mariadbd got signal 11
3+
--echo #
4+
5+
# This test simulates the scenario in MDEV-36087 by dropping the
6+
# column added in MDEV-34716
7+
8+
create server s foreign data wrapper mysql options (host "127.0.0.1", database "test", user "root", port 3306);
9+
show create server s;
10+
alter table mysql.servers drop column Options;
11+
show create server s;
12+
--source include/restart_mysqld.inc
13+
show create server s;
14+
ALTER TABLE mysql.servers
15+
ADD Options JSON NOT NULL DEFAULT '{}' CHECK(JSON_VALID(Options));
16+
show create server s;
17+
drop server s;

sql/sql_servers.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ get_server_from_table_to_cache(TABLE *table)
473473
server->scheme= ptr ? ptr : blank;
474474
ptr= get_field(&mem, table->field[8]);
475475
server->owner= ptr ? ptr : blank;
476-
ptr= table->field[9] ? get_field(&mem, table->field[9]) : NULL;
476+
ptr= table->s->fields > 9 ? get_field(&mem, table->field[9]) : NULL;
477477
server->option_list= NULL;
478478
if (ptr && parse_server_options_json(server, ptr))
479479
DBUG_RETURN(TRUE);

0 commit comments

Comments
 (0)