Debian Codegraph @

mysql-test/suite/ndbcluster/information_schema_partitions.test

raw
1 --source include/have_ndb.inc
2
3 # Test covers the different NDB specific partitioning schemes
4 # (specified as a part of NDB_TABLE option) and checks if
5 # the partition information from I_S is as expected
6 #
7 # Note: The actual partitioning of data is not checked in
8 # this test. The focus is more on creation of the partitions
9 # and checking that I_S (DD) and NDB Dictionary
10 # match in terms of their parition metadata.
11
12 # FOR_RP_BY_LDM
13
14 CREATE TABLE t1_rp_by_ldm
15 (a bigint, b bigint, c bigint, d bigint,
16 PRIMARY KEY (a,b,c,d))
17 ENGINE = NDB
18 COMMENT = "NDB_TABLE=PARTITION_BALANCE=FOR_RP_BY_LDM";
19
20 --echo
21 --echo Expected number of partitions with "FOR_RP_BY_LDM" = 8
22 --echo
23
24 SELECT TABLE_NAME, PARTITION_NAME, PARTITION_ORDINAL_POSITION, PARTITION_METHOD, NODEGROUP
25 FROM INFORMATION_SCHEMA.PARTITIONS
26 WHERE table_schema = 'test' AND table_name = 't1_rp_by_ldm'
27 ORDER BY PARTITION_ORDINAL_POSITION;
28
29 DROP TABLE t1_rp_by_ldm;
30
31 # FOR_RP_BY_NODE
32
33 CREATE TABLE t1_rp_by_node
34 (a bigint, b bigint, c bigint, d bigint,
35 PRIMARY KEY (a,b,c,d))
36 ENGINE = NDB
37 COMMENT = "NDB_TABLE=PARTITION_BALANCE=FOR_RP_BY_NODE";
38
39 --echo
40 --echo Expected number of partitions with "FOR_RP_BY_NODE"= 2
41 --echo
42
43 SELECT TABLE_NAME, PARTITION_NAME, PARTITION_ORDINAL_POSITION, PARTITION_METHOD, NODEGROUP
44 FROM INFORMATION_SCHEMA.PARTITIONS
45 WHERE table_schema = 'test' AND table_name = 't1_rp_by_node'
46 ORDER BY PARTITION_ORDINAL_POSITION;
47
48 DROP TABLE t1_rp_by_node;
49
50 # FOR_RA_BY_NODE
51
52 CREATE TABLE t1_ra_by_node
53 (a bigint, b bigint, c bigint, d bigint,
54 PRIMARY KEY (a,b,c,d))
55 ENGINE = NDB
56 COMMENT = "NDB_TABLE=PARTITION_BALANCE=FOR_RA_BY_NODE";
57
58 --echo
59 --echo Expected number of partitions with "FOR_RA_BY_NODE"= 1
60 --echo
61
62 SELECT TABLE_NAME, PARTITION_NAME, PARTITION_ORDINAL_POSITION, PARTITION_METHOD, NODEGROUP
63 FROM INFORMATION_SCHEMA.PARTITIONS
64 WHERE table_schema = 'test' AND table_name = 't1_ra_by_node'
65 ORDER BY PARTITION_ORDINAL_POSITION;
66
67 DROP TABLE t1_ra_by_node;
68
69 # FOR_RA_BY_LDM_X_3
70
71 CREATE TABLE t1_ra_by_ldm
72 (a bigint, b bigint, c bigint, d bigint,
73 PRIMARY KEY (a,b,c,d))
74 ENGINE = NDB
75 COMMENT = "NDB_TABLE=PARTITION_BALANCE=FOR_RA_BY_LDM_X_3";
76
77 --echo
78 --echo Expected number of partitions with "FOR_RA_BY_LDM_X_3" = 12
79 --echo
80
81 SELECT TABLE_NAME, PARTITION_NAME, PARTITION_ORDINAL_POSITION, PARTITION_METHOD, NODEGROUP
82 FROM INFORMATION_SCHEMA.PARTITIONS
83 WHERE table_schema = 'test' AND table_name = 't1_ra_by_ldm'
84 ORDER BY PARTITION_ORDINAL_POSITION;
85
86 # Test ALTER TABLE using the RA_BY_LDM variants
87
88 # FOR_RA_BY_LDM_X_2
89
90 ALTER TABLE t1_ra_by_ldm
91 COMMENT = "NDB_TABLE=PARTITION_BALANCE=FOR_RA_BY_LDM_X_2";
92
93 --echo
94 --echo Expected number of partitions with "FOR_RA_BY_LDM_X_2" = 8
95 --echo
96
97 SELECT TABLE_NAME, PARTITION_NAME, PARTITION_ORDINAL_POSITION, PARTITION_METHOD, NODEGROUP
98 FROM INFORMATION_SCHEMA.PARTITIONS
99 WHERE table_schema = 'test' AND table_name = 't1_ra_by_ldm'
100 ORDER BY PARTITION_ORDINAL_POSITION;
101
102 # FOR_RA_BY_LDM
103
104 ALTER TABLE t1_ra_by_ldm
105 COMMENT = "NDB_TABLE=PARTITION_BALANCE=FOR_RA_BY_LDM";
106
107 --echo
108 --echo Expected number of partitions with "FOR_RA_BY_LDM" = 4
109 --echo
110
111 SELECT TABLE_NAME, PARTITION_NAME, PARTITION_ORDINAL_POSITION, PARTITION_METHOD, NODEGROUP
112 FROM INFORMATION_SCHEMA.PARTITIONS
113 WHERE table_schema = 'test' AND table_name = 't1_ra_by_ldm'
114 ORDER BY PARTITION_ORDINAL_POSITION;
115
116 # FOR_RA_BY_LDM_X_4
117
118 ALTER TABLE t1_ra_by_ldm
119 COMMENT = "NDB_TABLE=PARTITION_BALANCE=FOR_RA_BY_LDM_X_4";
120
121 --echo
122 --echo Expected number of partitions with "FOR_RA_BY_LDM_X_4" = 16
123 --echo
124
125 SELECT TABLE_NAME, PARTITION_NAME, PARTITION_ORDINAL_POSITION, PARTITION_METHOD, NODEGROUP
126 FROM INFORMATION_SCHEMA.PARTITIONS
127 WHERE table_schema = 'test' AND table_name = 't1_ra_by_ldm'
128 ORDER BY PARTITION_ORDINAL_POSITION;
129
130 DROP TABLE t1_ra_by_ldm;
131
132 # FULLY_REPLICATED
133
134 CREATE TABLE t1_fully_replicated (
135 a char(10) NOT NULL PRIMARY KEY,
136 b int NOT NULL,
137 UNIQUE(a,b),
138 KEY(b, a))
139 ENGINE = NDB
140 COMMENT = 'NDB_TABLE=FULLY_REPLICATED=1';
141
142 --echo
143 --echo Expected number of partitions with "FULLY_REPLICATED" = 8
144 --echo
145
146 SELECT TABLE_NAME, PARTITION_NAME, PARTITION_ORDINAL_POSITION, PARTITION_METHOD, NODEGROUP
147 FROM INFORMATION_SCHEMA.PARTITIONS
148 WHERE table_schema = 'test' AND table_name = 't1_fully_replicated'
149 ORDER BY PARTITION_ORDINAL_POSITION;
150
151 DROP TABLE t1_fully_replicated;
152
153 --echo #
154 --echo # Bug#33643512 Missing check for Thd_ndb in information_schema.partitions
155 --echo # - Run I_S.partition query on new connection
156 --echo #
157 CREATE TABLE t1 (a int primary key) engine = NDB;
158
159 # Run query to cache open ha_ndbcluster instance
160 --disable_query_log ONCE
161 --disable_result_log ONCE
162 select * from information_schema.partitions
163 where (table_schema, table_name) in (select table_schema, table_name from
164 information_schema.tables where engine="ndbcluster");
165
166 # Run query in new connection
167 --connect(con1, localhost, root)
168 --connection con1
169 --disable_query_log ONCE
170 --disable_result_log ONCE
171 select * from information_schema.partitions
172 where (table_schema, table_name) in (select table_schema, table_name from
173 information_schema.tables where engine="ndbcluster");
174
175 # Disconnect
176 --disconnect con1
177 --source include/wait_until_disconnected.inc
178 --connection default
179
180 DROP TABLE t1;