Debian Codegraph @

mysql-test/suite/ndb/t/ndb_fully_replicated.test

raw
1 -- source include/have_ndb.inc
2
3 #
4 # Create fully replicated table with non default partition balance
5 #
6 CREATE TABLE t1 (
7 a char(10) NOT NULL primary key,
8 b int not null,
9 unique (a,b),
10 key(b, a)
11 ) comment='NDB_TABLE=FULLY_REPLICATED=1,PARTITION_BALANCE=FOR_RP_BY_NODE' ENGINE=ndbcluster;
12 drop table t1;
13
14 CREATE TABLE t1 (
15 a char(10) NOT NULL primary key,
16 b int not null,
17 unique (a,b),
18 key(b, a)
19 ) comment='NDB_TABLE=FULLY_REPLICATED=1,PARTITION_BALANCE=FOR_RP_BY_LDM' ENGINE=ndbcluster;
20 drop table t1;
21
22 #
23 # Create a normal table with primary key
24 # use char PK for consistent hashing
25 #
26 CREATE TABLE t1 (
27 a char(10) NOT NULL primary key,
28 b int not null,
29 unique (a,b),
30 key(b, a)
31 ) comment='NDB_TABLE=FULLY_REPLICATED=1' ENGINE=ndbcluster;
32 show create table t1;
33 --let $ndb_describe_table= t1
34 --source suite/ndb/include/ndb_describe_table.inc
35
36 insert into t1 values
37 ('1',1), ('2',2), ('3',3), ('4',4),
38 ('5',5), ('6',6), ('7',7), ('8',8);
39
40 --sorted_result
41 select * from t1;
42
43 #
44 # Check single row lookups, these should always be local reads
45 #
46 create temporary table counters_at_startup
47 select counter_name, sum(val) as val
48 from ndbinfo.counters
49 group by counter_name;
50
51 select * from t1 where a = '1';
52 select * from t1 where a = '2';
53 select * from t1 where a = '3';
54
55 #
56 # Compare counters, this should be only local reads
57 #
58 select s1.counter_name, s2.val - s1.val as diff
59 from counters_at_startup s1,
60 (select counter_name, sum(val) as val
61 from ndbinfo.counters
62 group by counter_name) s2
63 where s1.counter_name = s2.counter_name
64 and ( s1.counter_name = 'LOCAL_READS' or s1.counter_name = 'READS' )
65 order by 1;
66 drop table counters_at_startup;
67
68 #
69 # alters...
70 #
71 alter table t1 algorithm=inplace, reorganize partition;
72 --error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
73 alter table t1 algorithm=inplace, add partition partitions 1;
74 --error ER_CANT_CREATE_TABLE
75 alter table t1 algorithm=copy, add partition partitions 1;
76 alter table t1 algorithm=inplace, add column c int column_format dynamic;
77 show create table t1;
78 --let $ndb_describe_table= t1
79 --source suite/ndb/include/ndb_describe_table.inc
80
81 --error ER_ILLEGAL_HA_CREATE_OPTION
82 alter table t1 algorithm=copy, comment='NDB_TABLE=';
83
84 alter table t1 algorithm=copy, comment='NDB_TABLE=READ_BACKUP=1';
85 show create table t1;
86 --let $ndb_describe_table= t1
87 --source suite/ndb/include/ndb_describe_table.inc
88
89 alter table t1 algorithm=copy, comment='NDB_TABLE=FULLY_REPLICATED=1';
90 show create table t1;
91 --let $ndb_describe_table= t1
92 --source suite/ndb/include/ndb_describe_table.inc
93
94 alter table t1 algorithm=copy, comment='comment text';
95 --let $ndb_describe_table= t1
96 --source suite/ndb/include/ndb_describe_table.inc
97 show create table t1;
98
99 drop table t1;
100
101 ###
102 #
103 # illegal alter tables
104 #
105 create table t1 (
106 x int primary key,
107 y blob,
108 z int,
109 unique key (z)
110 ) engine=ndbcluster;
111
112 --error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
113 alter table t1 algorithm=inplace, comment="NDB_TABLE=FULLY_REPLICATED=1";
114 alter table t1 algorithm=copy, comment="NDB_TABLE=FULLY_REPLICATED=1";
115
116 --error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
117 alter table t1 algorithm=inplace, comment="NDB_TABLE=PARTITION_BALANCE=FOR_RA_BY_LDM";
118
119 --error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
120 alter table t1 algorithm=inplace, comment="NDB_TABLE=READ_BACKUP=0";
121
122 drop table t1;
123
124 ###
125 #
126 # illegal creates
127 #
128
129 --error ER_CANT_CREATE_TABLE
130 CREATE TABLE t2 (
131 a char(10) NOT NULL primary key,
132 b int not null,
133 unique (a,b),
134 key(b, a)
135 ) comment='NDB_TABLE=FULLY_REPLICATED=1'
136 ENGINE=ndbcluster
137 partition by key() partitions 2;
138 show warnings;
139
140 --error ER_ILLEGAL_HA_CREATE_OPTION
141 CREATE TABLE t2 (
142 a char(10) NOT NULL primary key,
143 b int not null,
144 unique (a,b),
145 key(b, a)
146 ) comment='NDB_TABLE=FULLY_REPLICATED=1,READ_BACKUP=0' ENGINE=ndbcluster;
147
148 set session new = 1;
149 --error ER_CANT_CREATE_TABLE
150 create table t2 (
151 a char(10) NOT NULL,
152 b int not null primary key,
153 unique (a,b),
154 key(b, a)
155 )
156 ENGINE=ndbcluster
157 comment='NDB_TABLE=FULLY_REPLICATED=1'
158 PARTITION BY HASH(b);
159
160 create table t1 (
161 a char(10) NOT NULL primary key,
162 b int not null)
163 ENGINE=ndbcluster;
164 alter table t1 algorithm=copy, comment='NDB_TABLE=FULLY_REPLICATED=1,PARTITION_BALANCE=FOR_RA_BY_LDM';
165 drop table t1;