| 1 |
--source include/have_ndb.inc |
| 2 |
|
| 3 |
--disable_query_log |
| 4 |
set new=on; |
| 5 |
--enable_query_log |
| 6 |
|
| 7 |
--disable_warnings |
| 8 |
drop table if exists t1; |
| 9 |
--enable_warnings |
| 10 |
|
| 11 |
--disable_query_log |
| 12 |
sleep 1; |
| 13 |
|
| 14 |
# length 61 |
| 15 |
set @s0 = 'rggurloniukyehuxdbfkkyzlceixzrehqhvxvxbpwizzvjzpucqmzrhzxzfau'; |
| 16 |
set @s1 = 'ykyymbzqgqlcjhlhmyqelfoaaohvtbekvifukdtnvcrrjveevfakxarxexomz'; |
| 17 |
set @s2 = 'dbnfqyzgtqxalcrwtfsqabknvtfcbpoonxsjiqvmhnfikxxhcgoexlkoezvah'; |
| 18 |
|
| 19 |
set @x1 = repeat(@s0, 100); # 1d42dd9090cf78314a06665d4ea938c35cc760f4 |
| 20 |
set @x2 = repeat(@s1, 200); # 10d3c783026b310218d10b7188da96a2401648c6 |
| 21 |
set @y1 = repeat(@s2, 300); # a33549d9844092289a58ac348dd59f09fc28406a |
| 22 |
set @y2 = repeat(@s0, 400); # daa61c6de36a0526f0d47dc29d6b9de7e6d2630c |
| 23 |
set @z1 = repeat(@s1, 500); # 70fc9a7d08beebc522258bfb02000a30c77a8f1d |
| 24 |
set @z2 = repeat(@s2, 600); # 090565c580809efed3d369481a4bbb168b20713e |
| 25 |
--enable_query_log |
| 26 |
|
| 27 |
# == partition by range == |
| 28 |
|
| 29 |
create table t1 ( |
| 30 |
a int not null, |
| 31 |
b text not null, |
| 32 |
c int not null, |
| 33 |
d blob, |
| 34 |
e int not null, |
| 35 |
primary key (a, c), |
| 36 |
unique key (c, e) |
| 37 |
) |
| 38 |
engine=ndb |
| 39 |
partition by range (c) |
| 40 |
partitions 3 |
| 41 |
( partition p1 values less than (2), |
| 42 |
partition p2 values less than (3), |
| 43 |
partition p3 values less than (4)); |
| 44 |
|
| 45 |
# -- insert -- |
| 46 |
insert into t1 values (1, @x1, 1, @x2, 1); |
| 47 |
insert into t1 values (1, @y1, 2, @y2, 1); |
| 48 |
insert into t1 values (1, @z1, 3, @z2, 1); |
| 49 |
insert into t1 values (2, @x1, 1, @x2, 2); |
| 50 |
insert into t1 values (2, @y1, 2, @y2, 2); |
| 51 |
insert into t1 values (2, @z1, 3, @z2, 2); |
| 52 |
insert into t1 values (3, @x1, 1, @x2, 3); |
| 53 |
insert into t1 values (3, @y1, 2, @y2, 3); |
| 54 |
insert into t1 values (3, @z1, 3, @z2, 3); |
| 55 |
select a, c, sha1(b), sha1(d) from t1 order by a, c; |
| 56 |
|
| 57 |
# -- pk read -- |
| 58 |
select a, c, sha1(b), sha1(d) from t1 where a = 1 and c = 1; |
| 59 |
select a, c, sha1(b), sha1(d) from t1 where a = 1 and c = 2; |
| 60 |
select a, c, sha1(b), sha1(d) from t1 where a = 1 and c = 3; |
| 61 |
|
| 62 |
# -- pk update -- |
| 63 |
update t1 set b = @y1, d = @y2 where a = 2 and c = 1; |
| 64 |
update t1 set b = @z1, d = @z2 where a = 2 and c = 2; |
| 65 |
update t1 set b = @x1, d = @x2 where a = 2 and c = 3; |
| 66 |
select a, c, sha1(b), sha1(d) from t1 order by a, c; |
| 67 |
|
| 68 |
# -- hash index update -- |
| 69 |
update t1 set b = @y1, d = @y2 where c = 1 and e = 3; |
| 70 |
update t1 set b = @z1, d = @z2 where c = 2 and e = 3; |
| 71 |
update t1 set b = @x1, d = @x2 where c = 3 and e = 3; |
| 72 |
select a, c, sha1(b), sha1(d) from t1 order by a, c; |
| 73 |
|
| 74 |
# -- full scan update -- |
| 75 |
update t1 set b = @x1, d = @x2; |
| 76 |
select a, c, sha1(b), sha1(d) from t1 order by a, c; |
| 77 |
|
| 78 |
# -- range scan update |
| 79 |
update t1 set b = @x1, d = @x2 where c = 1; |
| 80 |
update t1 set b = @y1, d = @y2 where c = 2; |
| 81 |
update t1 set b = @z1, d = @z2 where c = 3; |
| 82 |
select a, c, sha1(b), sha1(d) from t1 order by a, c; |
| 83 |
|
| 84 |
# -- delete -- |
| 85 |
delete from t1 where a = 1 and c = 1; |
| 86 |
select a, c, sha1(b), sha1(d) from t1 order by a, c; |
| 87 |
delete from t1 where c = 2 and e = 2; |
| 88 |
select a, c, sha1(b), sha1(d) from t1 order by a, c; |
| 89 |
delete from t1 where c < 3; |
| 90 |
select a, c, sha1(b), sha1(d) from t1 order by a, c; |
| 91 |
delete from t1; |
| 92 |
select a, c, sha1(b), sha1(d) from t1 order by a, c; |
| 93 |
|
| 94 |
# -- clean up -- |
| 95 |
drop table t1; |
| 96 |
|
| 97 |
# == scan EQ distr key vs charset == |
| 98 |
|
| 99 |
create table t1 ( |
| 100 |
a char(4), |
| 101 |
b int, |
| 102 |
primary key (a, b) |
| 103 |
) |
| 104 |
engine=ndb |
| 105 |
character set latin1 |
| 106 |
partition by key (a) |
| 107 |
partitions 4; |
| 108 |
|
| 109 |
insert into t1 values ('aaa',1); |
| 110 |
insert into t1 values ('bbb',1); |
| 111 |
insert into t1 values ('bbb',2); |
| 112 |
|
| 113 |
# if current EQ optim was tried then some of these should fail |
| 114 |
select count(*) from t1 where a = 'aaa'; |
| 115 |
select count(*) from t1 where a = 'Aaa'; |
| 116 |
select count(*) from t1 where a = 'aAa'; |
| 117 |
select count(*) from t1 where a = 'aaA'; |
| 118 |
select count(*) from t1 where a = 'AAa'; |
| 119 |
select count(*) from t1 where a = 'AaA'; |
| 120 |
select count(*) from t1 where a = 'aAA'; |
| 121 |
select count(*) from t1 where a = 'AAA'; |
| 122 |
|
| 123 |
drop table t1; |
| 124 |
|
| 125 |
create table t1 ( |
| 126 |
a varbinary(10), |
| 127 |
b int, |
| 128 |
primary key (a, b) |
| 129 |
) |
| 130 |
engine=ndb |
| 131 |
character set latin1 |
| 132 |
partition by key (a) |
| 133 |
partitions 4; |
| 134 |
|
| 135 |
insert into t1 values ('aaa',1); |
| 136 |
insert into t1 values ('aaabbb',1); |
| 137 |
insert into t1 values ('aaabbb',2); |
| 138 |
insert into t1 values ('aaabbbccc',1); |
| 139 |
insert into t1 values ('aaabbbccc',2); |
| 140 |
insert into t1 values ('aaabbbccc',3); |
| 141 |
|
| 142 |
# the EQ optim is done for binary types |
| 143 |
select count(*) from t1 where a = 'aaa'; |
| 144 |
select count(*) from t1 where a = 'Aaa'; |
| 145 |
select count(*) from t1 where a = 'aaabbb'; |
| 146 |
select count(*) from t1 where a = 'aaaBbb'; |
| 147 |
select count(*) from t1 where a = 'aaabbbccc'; |
| 148 |
select count(*) from t1 where a = 'aaabbbCcc'; |
| 149 |
|
| 150 |
drop table t1; |