Debian Codegraph @

mysql-test/suite/ndb_opt/index_stat_index_size.test

raw
1 --source include/have_ndb.inc
2
3 --echo #
4 --echo # Bug#28714864: Running 'analyze' on table with unsupported index length crashes the data nodes
5 --echo #
6
7 --echo #setup
8 create table t1(
9 a int auto_increment primary key,
10 b varchar(3053),
11 c varchar(3056),
12 d varchar(3072),
13 col1 varchar(762) not null,
14 col2 varchar(762) not null,
15 col3 varchar(762) not null,
16 col4 varchar(762) not null
17 ) engine ndb charset latin1;
18
19 --echo # populate enough rows to generate index stats
20 --disable_query_log
21 insert into t1 (b, c, d, col1, col2, col3, col4)
22 values (repeat('a', 3051), repeat('b', 3056), repeat('c', 3072),
23 repeat('d', 762), repeat('e', 762), repeat('f', 762), repeat('g', 762));
24 insert into t1 (b, c, d, col1, col2, col3, col4)
25 values (repeat('h', 3051), repeat('i', 3056), repeat('j', 3072),
26 repeat('k', 762), repeat('l', 762), repeat('m', 762), repeat('n', 762));
27 let $i = 5;
28 while ($i)
29 {
30 eval insert into t1 (b, c, d, col1, col2, col3, col4)
31 select b, c, d, col1, col2, col3, col4 from t1;
32 dec $i;
33 }
34 --enable_query_log
35
36 --echo # create index on b - it has the maximum key size supported by ndb index stat
37 create index idxb on t1(b); # max key size = 3056 (col size = 3053, length bytes = 2, nullmask = 1)
38
39 --echo # analyze should run fine and create statistics
40 analyze table t1;
41 drop index idxb on t1;
42
43 --echo # create index on c - it has a key size unsupported by ndb index stat
44 --echo # a warning should be returned
45 create index idxc on t1(c); # max key size = 3059 (col size = 3056, length bytes = 2, nullmask = 1)
46
47 --echo # analyze should run fine but statistics aren't created
48 analyze table t1;
49 drop index idxc on t1;
50
51 --echo # create index on d - it has the maximum key size allowed by mysql(3072)
52 --echo # but the key size is unsupported by ndb index stat
53 --echo # a warning should be returned
54 create index idxd on t1(d); # max key size = 3075 (col size = 3072, length bytes = 2, nullmask = 1)
55
56 --echo # analyze should run fine but statistics aren't created
57 analyze table t1;
58 drop index idxd on t1;
59
60 --echo # create index on col1..col4 - it has the maximum key size supported by ndb index stat
61 # max key size = 3056 (total col size = 3048[762 * 4], length bytes = 8[2 * 4], nullmask = 0)
62 create index idxcol on t1(col1, col2, col3, col4);
63
64 --echo # analyze should run fine
65 analyze table t1;
66 drop index idxcol on t1;
67
68 --echo #cleanup
69 drop table t1;