|
| 1 | + |
| 2 | +Testing spider sysvar and table params / options, including default values and overriding mechanisms |
| 3 | + |
| 4 | +for master_1 |
| 5 | +for child2 |
| 6 | +for child3 |
| 7 | +SET @old_spider_read_only_mode = @@session.spider_read_only_mode; |
| 8 | +CREATE SERVER srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); |
| 9 | +# Cases where table params/options are not set |
| 10 | +set session spider_read_only_mode = default; |
| 11 | +create table t2 (c int); |
| 12 | +create table t1 (c int) ENGINE=Spider COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2"'; |
| 13 | +/* 1 */ insert into t1 values (42); |
| 14 | +drop table t1, t2; |
| 15 | +set session spider_read_only_mode = 1; |
| 16 | +create table t2 (c int); |
| 17 | +create table t1 (c int) ENGINE=Spider COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2"'; |
| 18 | +/* 2 */ insert into t1 values (42); |
| 19 | +ERROR HY000: Table 'test.t1' is read only |
| 20 | +drop table t1, t2; |
| 21 | +set session spider_read_only_mode = -1; |
| 22 | +Warnings: |
| 23 | +Warning 138 The option value -1 (fallback to default) is deprecated and will be removed in a future release |
| 24 | +create table t2 (c int); |
| 25 | +create table t1 (c int) ENGINE=Spider COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2"'; |
| 26 | +/* 3 */ insert into t1 values (42); |
| 27 | +drop table t1, t2; |
| 28 | +# Cases where table params are set |
| 29 | +SET session spider_read_only_mode = default; |
| 30 | +create table t2 (c int); |
| 31 | +create table t1 (c int) ENGINE=Spider COMMENT='read_only_mode "1", WRAPPER "mysql", srv "srv",TABLE "t2"'; |
| 32 | +/* 4 */ insert into t1 values (42); |
| 33 | +ERROR HY000: Table 'test.t1' is read only |
| 34 | +drop table t1, t2; |
| 35 | +set session spider_read_only_mode = 1; |
| 36 | +create table t2 (c int); |
| 37 | +create table t1 (c int) ENGINE=Spider COMMENT='read_only_mode "0", WRAPPER "mysql", srv "srv",TABLE "t2"'; |
| 38 | +/* 5 */ insert into t1 values (42); |
| 39 | +drop table t1, t2; |
| 40 | +SET session spider_read_only_mode = -1; |
| 41 | +Warnings: |
| 42 | +Warning 138 The option value -1 (fallback to default) is deprecated and will be removed in a future release |
| 43 | +create table t2 (c int); |
| 44 | +create table t1 (c int) ENGINE=Spider COMMENT='read_only_mode "1", WRAPPER "mysql", srv "",TABLE "t2"'; |
| 45 | +/* 6 */ insert into t1 values (42); |
| 46 | +ERROR HY000: Table 'test.t1' is read only |
| 47 | +drop table t1, t2; |
| 48 | +# Cases where table options are set |
| 49 | +SET session spider_read_only_mode = default; |
| 50 | +create table t2 (c int); |
| 51 | +create table t1 (c int) ENGINE=Spider REMOTE_SERVER=srv REMOTE_TABLE=t2 READ_ONLY=1 WRAPPER=mysql; |
| 52 | +/* 7 */ insert into t1 values (42); |
| 53 | +ERROR HY000: Table 'test.t1' is read only |
| 54 | +drop table t1, t2; |
| 55 | +set session spider_read_only_mode = 1; |
| 56 | +create table t2 (c int); |
| 57 | +create table t1 (c int) ENGINE=Spider READ_ONLY=0 REMOTE_SERVER=srv REMOTE_TABLE=t2 WRAPPER=mysql; |
| 58 | +/* 8 */ insert into t1 values (42); |
| 59 | +drop table t1, t2; |
| 60 | +SET session spider_read_only_mode = -1; |
| 61 | +Warnings: |
| 62 | +Warning 138 The option value -1 (fallback to default) is deprecated and will be removed in a future release |
| 63 | +create table t2 (c int); |
| 64 | +create table t1 (c int) ENGINE=Spider READ_ONLY=1 REMOTE_SERVER=srv REMOTE_TABLE=t2 WRAPPER=mysql; |
| 65 | +/* 9 */ insert into t1 values (42); |
| 66 | +ERROR HY000: Table 'test.t1' is read only |
| 67 | +drop table t1, t2; |
| 68 | +SET session spider_read_only_mode = 0; |
| 69 | +create table t2 (c int); |
| 70 | +create table t1 (c int) ENGINE=Spider READ_ONLY=default REMOTE_SERVER=srv REMOTE_TABLE=t2 WRAPPER=mysql; |
| 71 | +/* 10 */ insert into t1 values (42); |
| 72 | +drop table t1, t2; |
| 73 | +SET session spider_read_only_mode = 1; |
| 74 | +create table t2 (c int); |
| 75 | +create table t1 (c int) ENGINE=Spider READ_ONLY=default REMOTE_SERVER=srv REMOTE_TABLE=t2 WRAPPER=mysql; |
| 76 | +/* 11 */ insert into t1 values (42); |
| 77 | +ERROR HY000: Table 'test.t1' is read only |
| 78 | +drop table t1, t2; |
| 79 | +SET session spider_read_only_mode = -1; |
| 80 | +Warnings: |
| 81 | +Warning 138 The option value -1 (fallback to default) is deprecated and will be removed in a future release |
| 82 | +create table t2 (c int); |
| 83 | +create table t1 (c int) ENGINE=Spider READ_ONLY=default REMOTE_SERVER=srv REMOTE_TABLE=t2 WRAPPER=mysql; |
| 84 | +/* 12 */ insert into t1 values (42); |
| 85 | +drop table t1, t2; |
| 86 | +drop server srv; |
| 87 | +SET session spider_read_only_mode = @old_spider_read_only_mode; |
| 88 | +for master_1 |
| 89 | +for child2 |
| 90 | +for child3 |
| 91 | +# |
| 92 | +# End of test sysvar_params |
| 93 | +# |
0 commit comments