1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392
|
--source include/have_ndb.inc
#
# Minimal NDB charset test.
#
# pk - binary
create table t1 (
a char(3) character set latin1 collate latin1_bin primary key
) engine=ndb;
# ok
insert into t1 values('aAa');
insert into t1 values('aaa');
insert into t1 values('AAA');
# 3
select * from t1 order by a;
# 1
select * from t1 where a = 'aAa';
# 1
select * from t1 where a = 'aaa';
# 0
select * from t1 where a = 'AaA';
# 1
select * from t1 where a = 'AAA';
drop table t1;
# pk - case insensitive
create table t1 (
a char(3) character set latin1 collate latin1_swedish_ci primary key
) engine=ndb;
# ok
insert into t1 values('aAa');
# fail
--error ER_DUP_ENTRY
insert into t1 values('aaa');
--error ER_DUP_ENTRY
insert into t1 values('AAA');
# 1
select * from t1 order by a;
# 1
select * from t1 where a = 'aAa';
# 1
select * from t1 where a = 'aaa';
# 1
select * from t1 where a = 'AaA';
# 1
select * from t1 where a = 'AAA';
drop table t1;
# pk - varchar
create table t1 (
a varchar(20) character set latin1 collate latin1_swedish_ci primary key
) engine=ndb;
#
insert into t1 values ('A'),('b '),('C '),('d '),('E'),('f');
-- error ER_DUP_ENTRY
insert into t1 values('b');
-- error ER_DUP_ENTRY
insert into t1 values('a ');
#
select a,length(a) from t1 order by a;
select a,length(a) from t1 order by a desc;
select * from t1 where a = 'a';
select * from t1 where a = 'a ';
select * from t1 where a = 'd';
drop table t1;
# unique hash index - binary
create table t1 (
p int primary key,
a char(3) character set latin1 collate latin1_bin not null,
unique key(a)
) engine=ndb;
# ok
insert into t1 values(1, 'aAa');
insert into t1 values(2, 'aaa');
insert into t1 values(3, 'AAA');
# 3
select * from t1 order by p;
# 1
select * from t1 where a = 'aAa';
# 1
select * from t1 where a = 'aaa';
# 0
select * from t1 where a = 'AaA';
# 1
select * from t1 where a = 'AAA';
drop table t1;
# unique hash index - case insensitive
create table t1 (
p int primary key,
a char(3) character set latin1 collate latin1_swedish_ci not null,
unique key(a)
) engine=ndb;
# ok
insert into t1 values(1, 'aAa');
# fail
--error ER_DUP_ENTRY
insert into t1 values(2, 'aaa');
--error ER_DUP_ENTRY
insert into t1 values(3, 'AAA');
# 1
select * from t1 order by p;
# 1
select * from t1 where a = 'aAa';
# 1
select * from t1 where a = 'aaa';
# 1
select * from t1 where a = 'AaA';
# 1
select * from t1 where a = 'AAA';
drop table t1;
# unique hash index - varchar
create table t1 (
p int primary key,
a varchar(20) character set latin1 collate latin1_swedish_ci not null,
unique key(a)
) engine=ndb;
#
insert into t1 values (1,'A'),(2,'b '),(3,'C '),(4,'d '),(5,'E'),(6,'f');
-- error ER_DUP_ENTRY
insert into t1 values(99,'b');
-- error ER_DUP_ENTRY
insert into t1 values(99,'a ');
#
select a,length(a) from t1 order by a;
select a,length(a) from t1 order by a desc;
select * from t1 where a = 'a';
select * from t1 where a = 'a ';
select * from t1 where a = 'd';
drop table t1;
# ordered index - binary
create table t1 (
p int primary key,
a char(3) character set latin1 collate latin1_bin not null,
index(a)
) engine=ndb;
# ok
insert into t1 values(1, 'aAa');
insert into t1 values(2, 'aaa');
insert into t1 values(3, 'AAA');
insert into t1 values(4, 'aAa');
insert into t1 values(5, 'aaa');
insert into t1 values(6, 'AAA');
# 6
select * from t1 order by p;
# plan too flaky
#--replace_column 10 # 11 #
#explain select * from t1 where a = 'zZz' order by p;
# 2
select * from t1 where a = 'aAa' order by p;
# 2
select * from t1 where a = 'aaa' order by p;
# 0
select * from t1 where a = 'AaA' order by p;
# 2
select * from t1 where a = 'AAA' order by p;
drop table t1;
# ordered index - case insensitive
create table t1 (
p int primary key,
a char(3) character set latin1 collate latin1_swedish_ci not null,
index(a)
) engine=ndb;
# ok
insert into t1 values(1, 'aAa');
insert into t1 values(2, 'aaa');
insert into t1 values(3, 'AAA');
insert into t1 values(4, 'aAa');
insert into t1 values(5, 'aaa');
insert into t1 values(6, 'AAA');
# 6
select * from t1 order by p;
# plan too flaky
#--replace_column 10 # 11 #
#explain select * from t1 where a = 'zZz' order by p;
# 6
select * from t1 where a = 'aAa' order by p;
# 6
select * from t1 where a = 'aaa' order by p;
# 6
select * from t1 where a = 'AaA' order by p;
# 6
select * from t1 where a = 'AAA' order by p;
drop table t1;
# ordered index - varchar
create table t1 (
p int primary key,
a varchar(20) character set latin1 collate latin1_swedish_ci not null,
index(a, p)
) engine=ndb;
#
insert into t1 values (1,'A'),(2,'b '),(3,'C '),(4,'d '),(5,'E'),(6,'f');
insert into t1 values (7,'a'),(8,'B '),(9,'c '),(10,'D'),(11,'e'),(12,'F ');
select p,a,length(a) from t1 order by a, p;
select * from t1 where a = 'a ' order by a desc, p desc;
select * from t1 where a >= 'D' order by a, p;
select * from t1 where a < 'D' order by a, p;
#
select count(*) from t1 x, t1 y, t1 z where x.a = y.a and y.a = z.a;
drop table t1;
# minimal multi-byte test
# removed by jonas as this requires a configure --with-extra-charsets
#create table t1 (
# a char(5) character set ucs2,
# b varchar(7) character set utf8,
# primary key(a, b)
#) engine=ndb;
#
#insert into t1 values
# ('a','A '),('B ','b'),('c','C '),('D','d'),('e ','E'),('F','f '),
# ('A','b '),('b ','C'),('C','d '),('d','E'),('E ','f'),
# ('a','C '),('B ','d'),('c','E '),('D','f');
#-- error ER_DUP_ENTRY
#insert into t1 values('d','f');
#
#select a,b,length(a),length(b) from t1 order by a,b limit 3;
#select a,b,length(a),length(b) from t1 order by a desc, b desc limit 3;
#select a,b,length(a),length(b) from t1 where a='c' and b='c';
#drop table t1;
# bug#14007
create table t1 (
a char(10) primary key
) engine=ndbcluster default charset=latin1;
insert into t1 values ('aaabb');
select * from t1;
replace into t1 set a = 'AAABB';
select * from t1;
replace into t1 set a = 'aAaBb';
select * from t1;
replace into t1 set a = 'aaabb';
select * from t1;
drop table t1;
# bug#33158 NDB table name problem(sensitive/insensitive)
# Check that tables with same letters, but different case
# don't conflict
create table t1(a int) engine = ndbcluster;
if (`SELECT @@lower_case_table_names = 0`)
{
create table T1(a int) engine = ndbcluster;
drop table T1;
}
if (`SELECT @@lower_case_table_names <> 0`)
{
--echo create table T1(a int) engine = ndbcluster;
--echo drop table T1;
}
drop table t1;
# End of 4.1 tests
# Start of 8.0 tests
# Bug #27477829 UNICODE 9.0 COLLATIONS INCORRECTLY DETECT DUPLICATES
# Truncation of the xfrm'ed normalized string caused false
# detection of duplicates.
create table t1 (
c1 varchar(10) collate utf8mb4_0900_as_cs,
primary key(c1)
) engine = ndbcluster;
#Inserting short string was OK.
insert into t1 values('ABC_x'), ('ABC_X');
# However, longer strings were truncated when transformed into
# a normalized form. Thus false duplicates were detected.
insert into t1 values('ABCDEF_x'), ('ABCDEF_X');
insert into t1 values('ABCDEFGH_x'), ('ABCDEFGH_X');
--sorted_result
select * from t1;
drop table t1;
####################################
# Bug#27515000 ERROR 743: CHARSET UTF8MB4_JA_0900_AS_CS_KS IS NOT SUPPORTED
#
# The above character set could not be used in any kind
# of index or key. Below test cases should pass after fix.
create table t1 (
c1 varchar(10) collate utf8mb4_ja_0900_as_cs_ks,
primary key(c1)
) engine = ndbcluster;
drop table t1;
create table t1 (
c1 varchar(10) collate utf8mb4_ja_0900_as_cs_ks,
primary key using hash(c1)
) engine = ndbcluster;
drop table t1;
create table t1 (
c1 varchar(10) collate utf8mb4_ja_0900_as_cs_ks,
unique key(c1)
) engine = ndbcluster;
drop table t1;
create table t1 (
c1 varchar(10) not null collate utf8mb4_ja_0900_as_cs_ks,
unique key using hash(c1)
) engine = ndbcluster;
drop table t1;
create table t1 (
c1 varchar(10) collate utf8mb4_ja_0900_as_cs_ks,
key(c1)
) engine = ndbcluster;
drop table t1;
####################################
# Bug#29322313 ANGSTROM AND A-RING NOT EQUAL WITH CHAR(N) COLUMN AND UTF8MB4_0900_AI_CI
#
# NO_PAD collations did not ignore trailing spaces as supposed to
# when hashing and comparing fix character columns.
# Insert two strings being binary different, but compares equal
# Require 2'nd insert to fail.
create table t (
ck char(1) collate utf8mb4_0900_ai_ci primary key
) engine=ndb;
insert into t values (_utf16 X'212B');
--error ER_DUP_ENTRY
insert into t values (_utf16 X'00C5');
select count(*) from t;
drop table t;
create table t (
ck char(10) collate utf8mb4_0900_ai_ci primary key
) engine=ndb;
insert into t values (_utf16 X'212B');
--error ER_DUP_ENTRY
insert into t values (_utf16 X'00C5');
select count(*) from t;
drop table t;
create table t (
ck varchar(1) collate utf8mb4_0900_ai_ci primary key
) engine=ndb;
insert into t values (_utf16 X'212B');
--error ER_DUP_ENTRY
insert into t values (_utf16 X'00C5');
select count(*) from t;
drop table t;
create table t (
ck varchar(10) collate utf8mb4_0900_ai_ci primary key
) engine=ndb;
insert into t values (_utf16 X'212B');
--error ER_DUP_ENTRY
insert into t values (_utf16 X'00C5');
select count(*) from t;
drop table t;
# End of 8.0 tests
|