diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 18:00:34 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 18:00:34 +0000 |
commit | 3f619478f796eddbba6e39502fe941b285dd97b1 (patch) | |
tree | e2c7b5777f728320e5b5542b6213fd3591ba51e2 /mysql-test/main/binary.test | |
parent | Initial commit. (diff) | |
download | mariadb-3f619478f796eddbba6e39502fe941b285dd97b1.tar.xz mariadb-3f619478f796eddbba6e39502fe941b285dd97b1.zip |
Adding upstream version 1:10.11.6.upstream/1%10.11.6upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'mysql-test/main/binary.test')
-rw-r--r-- | mysql-test/main/binary.test | 144 |
1 files changed, 144 insertions, 0 deletions
diff --git a/mysql-test/main/binary.test b/mysql-test/main/binary.test new file mode 100644 index 00000000..ebb3d7ba --- /dev/null +++ b/mysql-test/main/binary.test @@ -0,0 +1,144 @@ +# +# test sort,min and max on binary fields +# +--disable_warnings +drop table if exists t1,t2; +--enable_warnings + +create table t1 (name char(20) not null, primary key (name)); +create table t2 (name char(20) binary not null, primary key (name)); +insert into t1 values ("å"); +insert into t1 values ("ä"); +insert into t1 values ("ö"); +insert into t2 select * from t1; + +select * from t1 order by name; +select concat("*",name,"*") from t1 order by 1; +select min(name),min(concat("*",name,"*")),max(name),max(concat("*",name,"*")) from t1; +select * from t2 order by name; +select concat("*",name,"*") from t2 order by 1; +select min(name),min(concat("*",name,"*")),max(name),max(concat("*",name,"*")) from t2; +#check after fix MDEV-29601 +--disable_service_connection +select name from t1 where name between 'Ä' and 'Ö'; +select name from t2 where name between 'ä' and 'ö'; +select name from t2 where name between 'Ä' and 'Ö'; +--enable_service_connection + +drop table t1,t2; + +# +# Test of binary and normal strings +# + +create table t1 (a char(10) not null, b char(10) binary not null,key (a), key(b)); +insert into t1 values ("hello ","hello "),("hello2 ","hello2 "); +select concat("-",a,"-",b,"-") from t1 where a="hello"; +select concat("-",a,"-",b,"-") from t1 where a="hello "; +select concat("-",a,"-",b,"-") from t1 ignore index (a) where a="hello "; +select concat("-",a,"-",b,"-") from t1 where b="hello"; +select concat("-",a,"-",b,"-") from t1 where b="hello "; +select concat("-",a,"-",b,"-") from t1 ignore index (b) where b="hello "; +# blob test +alter table t1 modify b tinytext not null, drop key b, add key (b(100)); +select concat("-",a,"-",b,"-") from t1; +select concat("-",a,"-",b,"-") from t1 where b="hello "; +select concat("-",a,"-",b,"-") from t1 ignore index (b) where b="hello "; +drop table t1; + +# +# Test of binary and NULL +# +create table t1 (b char(8)); +insert into t1 values(NULL); +select b from t1 where binary b like ''; +select b from t1 group by binary b like ''; +select b from t1 having binary b like ''; +drop table t1; + +# +# Test of binary and upper/lower +# +create table t1 (a char(3) binary, b binary(3)); +insert into t1 values ('aaa','bbb'),('AAA','BBB'); +select upper(a),upper(b) from t1; +select lower(a),lower(b) from t1; +select * from t1 where upper(a)='AAA'; +select * from t1 where lower(a)='aaa'; +select * from t1 where upper(b)='BBB'; +select * from t1 where lower(b)='bbb'; +select charset(a), charset(b), charset(binary 'ccc') from t1 limit 1; +select collation(a), collation(b), collation(binary 'ccc') from t1 limit 1; +drop table t1; + +# +# Bug5134: WHERE x = 'bar' AND x LIKE BINARY 'bar' returns wrong results +# + +create table t1( firstname char(20), lastname char(20)); +insert into t1 values ("john","doe"),("John","Doe"); +select * from t1 where firstname='john' and firstname like binary 'john'; +select * from t1 where firstname='john' and binary 'john' = firstname; +select * from t1 where firstname='john' and firstname = binary 'john'; +select * from t1 where firstname='John' and firstname like binary 'john'; +select * from t1 where firstname='john' and firstname like binary 'John'; +drop table t1; + +# +# Bug #6552 CHAR column w/o length is legal, BINARY w/o length is not +# +create table t1 (a binary); +show create table t1; +drop table t1; + +# End of 4.1 tests + +# +# Bug#16857 +# +create table t1 (col1 binary(4)); +insert into t1 values ('a'),('a '); +select hex(col1) from t1; +alter table t1 modify col1 binary(10); +select hex(col1) from t1; +insert into t1 values ('b'),('b '); +select hex(col1) from t1; +drop table t1; + +# +# Bug #29087: assertion abort for a search in a BINARY non-nullable index +# by a key with trailing spaces +# + +CREATE TABLE t1 ( + a binary(20) NOT NULL DEFAULT '\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0', + index idx(a) +); +INSERT INTO t1 SET a=unhex('1F9480179366F2BF567E1C4B964C1EF029087575'); +INSERT INTO t1 SET a=unhex('1F9480179366F2BF567E1C4B964C1EF029082020'); +INSERT INTO t1 SET a=unhex('1F9480179366F2BF567E1C4B964C1EF029080707'); + +SELECT hex(a) FROM t1 order by a; +EXPLAIN SELECT hex(a) FROM t1 order by a; + +SELECT hex(a) from t1 WHERE a=unhex('1F9480179366F2BF567E1C4B964C1EF029082020'); +EXPLAIN +SELECT hex(a) from t1 WHERE a=unhex('1F9480179366F2BF567E1C4B964C1EF029082020'); + +SELECT hex(a) from t1 WHERE a=unhex('1F9480179366F2BF567E1C4B964C1EF02908'); + +DROP TABLE t1; + +CREATE TABLE t1 ( + id numeric(20) NOT NULL, + lang varchar(8) NOT NULL, + msg varchar(32) NOT NULL, + PRIMARY KEY (id,lang) +); +INSERT INTO t1 VALUES (33, 'en', 'zzzzzzz'); +INSERT INTO t1 VALUES (31, 'en', 'xxxxxxx'); +INSERT INTO t1 VALUES (32, 'en', 'yyyyyyy'); +SELECT * FROM t1 WHERE id=32; + +DROP TABLE t1; + |