Debian Codegraph @

mysql-test/suite/ndb_ddl/alter_inplace_unique_index.test

raw
1 --source connect.inc
2
3 --echo #
4 --echo # Bug#24444899 MYSQLD CRASHED WHILE DROPPING UNIQUE KEY ...
5 --echo # - test adding and using unique index of varying length
6 --echo # - test drop and using unique index of varying length
7 --echo #
8 CREATE TABLE t1 (
9 c1 int PRIMARY KEY, c2 int, c3 int, c4 int, c5 int,
10 c6 int, c7 int, c8 int, c9 int, c10 int, c11 int,
11 c12 int, c13 int, c14 int, c15 int, c16 int, c17 int,
12 c18 int, c19 int, c20 int, c21 int, c22 int, c23 int,
13 c24 int, c25 int, c26 int, c27 int, c28 int, c29 int,
14 c30 int, c31 int, c32 int, c33 int, c34 int, c35 int
15 ) engine = NDB;
16 INSERT INTO t1 VALUES
17 (1,2,3,4,5,6,7,8,9,10,
18 11,12,13,14,15,16,17,18,19,20,
19 21,22,23,24,25,26,27,28,29,30,
20 31,32,33,34,35);
21
22 --echo # Create and use unique indexes
23 let $indexes = 34;
24 let $i = 1;
25 while ($i <= $indexes) {
26
27 # Calculate first and last column
28 let $j = $i;
29 let $last = `select $j + 15`;
30 if ($last > $indexes) {
31 let $last = $indexes;
32 }
33 #echo j: $j, last: $last;
34
35 # Build column and where string
36 let $cols =;
37 let $cols_separator =;
38 let $where =;
39 let $where_separator =;
40 while ($j <= $last) {
41 let $cols = $cols$cols_separator c$j;
42 let $cols_separator =,;
43 let $where = $where $where_separator c$j=$j;
44 let $where_separator = AND;
45 inc $j;
46 }
47 #echo cols: $cols;
48 #echo where: $where;
49 eval ALTER TABLE t1 ALGORITHM=inplace, ADD UNIQUE INDEX unique$i ($cols);
50 eval SELECT c$i FROM t1 WHERE $where;
51 inc $i;
52 }
53
54 --echo # Some handcrafted use of unique indexes, also where row does not exist
55 SELECT c35 FROM t1 WHERE c2=2 AND c3=3 AND c4=4 /* not full index */;
56 SELECT c35 FROM t1
57 WHERE c19=19 AND c20=20 AND c21=21 AND c22=22 AND c23=23 AND c24=24 AND
58 c25=25 AND c26=26 AND c27=27 AND c28=28 AND c29=29 AND c30=30 AND
59 c31=31 AND c32=32 /* full unique index */;
60 SELECT c35 FROM t1
61 WHERE c19=19 AND c20=20 AND c21=21 AND c22=22 AND c23=23 AND c24=24 AND
62 c25=25 AND c26=26 AND c27=27 AND c28=28 AND c29=29 AND c30=30 AND
63 c31=31 AND c32=37 /* row does not exist */;
64 SELECT c35 FROM t1 WHERE c35=35 /* no index on this column */;
65
66 --echo # Drop and use unique indexes
67 let $i = 1;
68 while ($i <= $indexes)
69 {
70 # Calculate first and last column
71 let $j = $i;
72 let $last = `select $j + 15`;
73 if ($last > $indexes) {
74 let $last = $indexes;
75 }
76 #echo j: $j, last: $last;
77
78 # Build where string
79 let $where =;
80 let $where_separator =;
81 while ($j <= $last) {
82 let $where = $where $where_separator c$j=$j;
83 let $where_separator = AND;
84 inc $j;
85 }
86 #echo where: $where;
87 eval SELECT c$i FROM t1 WHERE $where /* read before drop */;
88 eval ALTER TABLE t1 ALGORITHM=inplace, DROP INDEX unique$i;
89 eval SELECT c$i FROM t1 WHERE $where;
90 inc $i;
91 }
92
93 DROP TABLE t1;