Debian Codegraph @

mysql-test/suite/federated/t/federated_bug_33962357.test

raw
1 --echo # Bug#33962357: Improve federated tables code
2
3 # Preventively fixes the code to make federated data code return errors (either 1432 or 1146)
4 # instead of crashing, if the server_cache pointer is NULL.
5 # Additional check added to test that the server does not crash if server_name parameter is NULL.
6
7 --source include/have_debug.inc
8 source suite/federated/include/federated.inc;
9
10 # connect to remote.
11 connection slave;
12 --disable_warnings
13 DROP TABLE IF EXISTS federated.t1;
14 --enable_warnings
15
16 CREATE TABLE federated.t1 (
17 a int
18 );
19 INSERT INTO federated.t1 (a) VALUES (42);
20
21 # connect to local.
22 connection master;
23
24 # TEST #1: force pointer server_cache to be NULL in tested function
25 SET @debug_save= @@GLOBAL.DEBUG;
26 SET @@GLOBAL.DEBUG='+d,bug33962357_simulate_null_cache';
27
28 --replace_result $SLAVE_MYPORT SLAVE_PORT
29 eval CREATE SERVER fedlink
30 FOREIGN DATA WRAPPER mysql
31 OPTIONS (
32 HOST '127.0.0.1',
33 PORT $SLAVE_MYPORT,
34 USER 'root',
35 PASSWORD '',
36 DATABASE 'federated');
37
38 --disable_warnings
39 DROP TABLE IF EXISTS federated.t1;
40 --enable_warnings
41
42 # only connecting through predefined server triggers get_server_by_name test function
43 --replace_result $SLAVE_MYPORT SLAVE_PORT
44 --error 1432
45 eval CREATE TABLE federated.t1 (
46 a int
47 ) ENGINE="FEDERATED"
48 CONNECTION='fedlink/t1';
49
50 # test
51 --error 1146
52 SELECT * FROM federated.t1;
53
54 # cleanup test #1
55 --disable_warnings
56 DROP TABLE IF EXISTS federated.t1;
57 --enable_warnings
58
59 # TEST #2: force server_name parameter to be NULL in tested function
60 SET @@GLOBAL.DEBUG='+d,bug33962357_simulate_null_server';
61
62 # only connecting through predefined server triggers get_server_by_name test function
63 --replace_result $SLAVE_MYPORT SLAVE_PORT
64 --error 1432
65 eval CREATE TABLE federated.t1 (
66 a int
67 ) ENGINE="FEDERATED"
68 CONNECTION='fedlink/t1';
69
70 # test
71 --error 1146
72 SELECT * FROM federated.t1;
73
74 # cleanup
75 SET GLOBAL DEBUG= @debug_save;
76 DROP SERVER fedlink;
77 source suite/federated/include/federated_cleanup.inc;