Skip to content
Permalink
Browse files
MDEV-13335 UTF8 escape wildcard LIKE match has different behavior in …
…different collations

The fix for MDEV-17064 addressed this problem. Adding tests only.
  • Loading branch information
abarkov committed Apr 28, 2019
1 parent d3534d5 commit eb9b03a
Show file tree
Hide file tree
Showing 21 changed files with 228 additions and 0 deletions.
@@ -16,3 +16,9 @@ select c1 as c1u from t1 where c1 like 'ab\_def';
# should return ab_def
select c1 as c2h from t1 where c1 like 'ab#_def' escape '#';
drop table t1;

#
# MDEV-13335 UTF8 escape wildcard LIKE match has different behavior in different collations
#
SELECT @@collation_connection;
SELECT '\%b' LIKE '%\%';
@@ -220,6 +220,12 @@ select c1 as c2h from t1 where c1 like 'ab#_def' escape '#';
c2h
ab_def
drop table t1;
SELECT @@collation_connection;
@@collation_connection
big5_chinese_ci
SELECT '\%b' LIKE '%\%';
'\%b' LIKE '%\%'
0
CREATE TABLE t1 AS
SELECT 10 AS a, REPEAT('a',20) AS b, REPEAT('a',8) AS c, REPEAT('a',8) AS d;
ALTER TABLE t1 ADD PRIMARY KEY(a), ADD KEY(b);
@@ -447,6 +453,12 @@ select c1 as c2h from t1 where c1 like 'ab#_def' escape '#';
c2h
ab_def
drop table t1;
SELECT @@collation_connection;
@@collation_connection
big5_bin
SELECT '\%b' LIKE '%\%';
'\%b' LIKE '%\%'
0
CREATE TABLE t1 AS
SELECT 10 AS a, REPEAT('a',20) AS b, REPEAT('a',8) AS c, REPEAT('a',8) AS d;
ALTER TABLE t1 ADD PRIMARY KEY(a), ADD KEY(b);
@@ -220,6 +220,12 @@ select c1 as c2h from t1 where c1 like 'ab#_def' escape '#';
c2h
ab_def
drop table t1;
SELECT @@collation_connection;
@@collation_connection
euckr_korean_ci
SELECT '\%b' LIKE '%\%';
'\%b' LIKE '%\%'
0
CREATE TABLE t1 AS
SELECT 10 AS a, REPEAT('a',20) AS b, REPEAT('a',8) AS c, REPEAT('a',8) AS d;
ALTER TABLE t1 ADD PRIMARY KEY(a), ADD KEY(b);
@@ -367,6 +373,12 @@ select c1 as c2h from t1 where c1 like 'ab#_def' escape '#';
c2h
ab_def
drop table t1;
SELECT @@collation_connection;
@@collation_connection
euckr_bin
SELECT '\%b' LIKE '%\%';
'\%b' LIKE '%\%'
0
CREATE TABLE t1 AS
SELECT 10 AS a, REPEAT('a',20) AS b, REPEAT('a',8) AS c, REPEAT('a',8) AS d;
ALTER TABLE t1 ADD PRIMARY KEY(a), ADD KEY(b);
@@ -220,6 +220,12 @@ select c1 as c2h from t1 where c1 like 'ab#_def' escape '#';
c2h
ab_def
drop table t1;
SELECT @@collation_connection;
@@collation_connection
gb2312_chinese_ci
SELECT '\%b' LIKE '%\%';
'\%b' LIKE '%\%'
0
CREATE TABLE t1 AS
SELECT 10 AS a, REPEAT('a',20) AS b, REPEAT('a',8) AS c, REPEAT('a',8) AS d;
ALTER TABLE t1 ADD PRIMARY KEY(a), ADD KEY(b);
@@ -448,6 +454,12 @@ select c1 as c2h from t1 where c1 like 'ab#_def' escape '#';
c2h
ab_def
drop table t1;
SELECT @@collation_connection;
@@collation_connection
gb2312_bin
SELECT '\%b' LIKE '%\%';
'\%b' LIKE '%\%'
0
CREATE TABLE t1 AS
SELECT 10 AS a, REPEAT('a',20) AS b, REPEAT('a',8) AS c, REPEAT('a',8) AS d;
ALTER TABLE t1 ADD PRIMARY KEY(a), ADD KEY(b);
@@ -220,6 +220,12 @@ select c1 as c2h from t1 where c1 like 'ab#_def' escape '#';
c2h
ab_def
drop table t1;
SELECT @@collation_connection;
@@collation_connection
gbk_chinese_ci
SELECT '\%b' LIKE '%\%';
'\%b' LIKE '%\%'
0
CREATE TABLE t1 AS
SELECT 10 AS a, REPEAT('a',20) AS b, REPEAT('a',8) AS c, REPEAT('a',8) AS d;
ALTER TABLE t1 ADD PRIMARY KEY(a), ADD KEY(b);
@@ -448,6 +454,12 @@ select c1 as c2h from t1 where c1 like 'ab#_def' escape '#';
c2h
ab_def
drop table t1;
SELECT @@collation_connection;
@@collation_connection
gbk_bin
SELECT '\%b' LIKE '%\%';
'\%b' LIKE '%\%'
0
CREATE TABLE t1 AS
SELECT 10 AS a, REPEAT('a',20) AS b, REPEAT('a',8) AS c, REPEAT('a',8) AS d;
ALTER TABLE t1 ADD PRIMARY KEY(a), ADD KEY(b);
@@ -506,6 +506,12 @@ select c1 as c2h from t1 where c1 like 'ab#_def' escape '#';
c2h
ab_def
drop table t1;
SELECT @@collation_connection;
@@collation_connection
latin1_swedish_ci
SELECT '\%b' LIKE '%\%';
'\%b' LIKE '%\%'
0
#
# MDEV-4842 STR_TO_DATE does not work with UCS2/UTF16/UTF32
#
@@ -621,6 +627,12 @@ select c1 as c2h from t1 where c1 like 'ab#_def' escape '#';
c2h
ab_def
drop table t1;
SELECT @@collation_connection;
@@collation_connection
latin1_bin
SELECT '\%b' LIKE '%\%';
'\%b' LIKE '%\%'
0
CREATE TABLE �a (a int);
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '�a (a int)' at line 1
SELECT '�a' as str;
@@ -189,6 +189,12 @@ select c1 as c2h from t1 where c1 like 'ab#_def' escape '#';
c2h
ab_def
drop table t1;
SELECT @@collation_connection;
@@collation_connection
sjis_japanese_ci
SELECT '\%b' LIKE '%\%';
'�_%b' LIKE '%�_%'
0
CREATE TABLE t1 AS
SELECT 10 AS a, REPEAT('a',20) AS b, REPEAT('a',8) AS c, REPEAT('a',8) AS d;
ALTER TABLE t1 ADD PRIMARY KEY(a), ADD KEY(b);
@@ -355,6 +361,12 @@ select c1 as c2h from t1 where c1 like 'ab#_def' escape '#';
c2h
ab_def
drop table t1;
SELECT @@collation_connection;
@@collation_connection
sjis_bin
SELECT '\%b' LIKE '%\%';
'�_%b' LIKE '%�_%'
0
CREATE TABLE t1 AS
SELECT 10 AS a, REPEAT('a',20) AS b, REPEAT('a',8) AS c, REPEAT('a',8) AS d;
ALTER TABLE t1 ADD PRIMARY KEY(a), ADD KEY(b);
@@ -3033,6 +3033,12 @@ select c1 as c2h from t1 where c1 like 'ab#_def' escape '#';
c2h
ab_def
drop table t1;
SELECT @@collation_connection;
@@collation_connection
tis620_thai_ci
SELECT '\%b' LIKE '%\%';
'\%b' LIKE '%\%'
0
drop table if exists t1;
create table t1 select repeat('a',10) as c1;
delete from t1;
@@ -3331,6 +3337,12 @@ select c1 as c2h from t1 where c1 like 'ab#_def' escape '#';
c2h
ab_def
drop table t1;
SELECT @@collation_connection;
@@collation_connection
tis620_bin
SELECT '\%b' LIKE '%\%';
'\%b' LIKE '%\%'
0
#
# MDEV-7149 Constant condition propagation erroneously applied for LIKE
#
@@ -6233,6 +6233,12 @@ select c1 as c2h from t1 where c1 like 'ab#_def' escape '#';
c2h
ab_def
drop table t1;
SELECT @@collation_connection;
@@collation_connection
utf8_unicode_ci
SELECT '\%b' LIKE '%\%';
'\%b' LIKE '%\%'
0
"BEGIN ctype_german.inc"
drop table if exists t1;
create table t1 as select repeat(' ', 64) as s1;
@@ -839,6 +839,12 @@ select c1 as c2h from t1 where c1 like 'ab#_def' escape '#';
c2h
ab_def
drop table t1;
SELECT @@collation_connection;
@@collation_connection
ucs2_general_ci
SELECT '\%b' LIKE '%\%';
'\%b' LIKE '%\%'
0
"BEGIN ctype_german.inc"
drop table if exists t1;
create table t1 as select repeat(' ', 64) as s1;
@@ -1100,6 +1106,12 @@ select c1 as c2h from t1 where c1 like 'ab#_def' escape '#';
c2h
ab_def
drop table t1;
SELECT @@collation_connection;
@@collation_connection
ucs2_bin
SELECT '\%b' LIKE '%\%';
'\%b' LIKE '%\%'
0
CREATE TABLE t1 AS
SELECT 10 AS a, REPEAT('a',20) AS b, REPEAT('a',8) AS c, REPEAT('a',8) AS d;
ALTER TABLE t1 ADD PRIMARY KEY(a), ADD KEY(b);
@@ -2327,6 +2327,12 @@ select c1 as c2h from t1 where c1 like 'ab#_def' escape '#';
c2h
ab_def
drop table t1;
SELECT @@collation_connection;
@@collation_connection
ujis_japanese_ci
SELECT '\%b' LIKE '%\%';
'\%b' LIKE '%\%'
0
CREATE TABLE t1 AS
SELECT 10 AS a, REPEAT('a',20) AS b, REPEAT('a',8) AS c, REPEAT('a',8) AS d;
ALTER TABLE t1 ADD PRIMARY KEY(a), ADD KEY(b);
@@ -2474,6 +2480,12 @@ select c1 as c2h from t1 where c1 like 'ab#_def' escape '#';
c2h
ab_def
drop table t1;
SELECT @@collation_connection;
@@collation_connection
ujis_bin
SELECT '\%b' LIKE '%\%';
'\%b' LIKE '%\%'
0
CREATE TABLE t1 AS
SELECT 10 AS a, REPEAT('a',20) AS b, REPEAT('a',8) AS c, REPEAT('a',8) AS d;
ALTER TABLE t1 ADD PRIMARY KEY(a), ADD KEY(b);
@@ -669,6 +669,12 @@ select c1 as c2h from t1 where c1 like 'ab#_def' escape '#';
c2h
ab_def
drop table t1;
SELECT @@collation_connection;
@@collation_connection
utf16_general_ci
SELECT '\%b' LIKE '%\%';
'\%b' LIKE '%\%'
0
SET NAMES latin1;
SET collation_connection='utf16_bin';
create table t1 select repeat('a',4000) a;
@@ -806,6 +812,12 @@ select c1 as c2h from t1 where c1 like 'ab#_def' escape '#';
c2h
ab_def
drop table t1;
SELECT @@collation_connection;
@@collation_connection
utf16_bin
SELECT '\%b' LIKE '%\%';
'\%b' LIKE '%\%'
0
select hex(substr(_utf16 0x00e400e50068,1));
hex(substr(_utf16 0x00e400e50068,1))
00E400E50068
@@ -2952,6 +2952,12 @@ select c1 as c2h from t1 where c1 like 'ab#_def' escape '#';
c2h
ab_def
drop table t1;
SELECT @@collation_connection;
@@collation_connection
utf16_unicode_ci
SELECT '\%b' LIKE '%\%';
'\%b' LIKE '%\%'
0
"BEGIN ctype_german.inc"
drop table if exists t1;
create table t1 as select repeat(' ', 64) as s1;
@@ -713,6 +713,12 @@ select c1 as c2h from t1 where c1 like 'ab#_def' escape '#';
c2h
ab_def
drop table t1;
SELECT @@collation_connection;
@@collation_connection
utf16le_general_ci
SELECT '\%b' LIKE '%\%';
'\%b' LIKE '%\%'
0
SET NAMES utf8, collation_connection='utf16le_bin';
create table t1 select repeat('a',4000) a;
delete from t1;
@@ -849,6 +855,12 @@ select c1 as c2h from t1 where c1 like 'ab#_def' escape '#';
c2h
ab_def
drop table t1;
SELECT @@collation_connection;
@@collation_connection
utf16le_bin
SELECT '\%b' LIKE '%\%';
'\%b' LIKE '%\%'
0
#
# Bug#10344 Some string functions fail for UCS2
#
@@ -668,6 +668,12 @@ select c1 as c2h from t1 where c1 like 'ab#_def' escape '#';
c2h
ab_def
drop table t1;
SELECT @@collation_connection;
@@collation_connection
utf32_general_ci
SELECT '\%b' LIKE '%\%';
'\%b' LIKE '%\%'
0
SET NAMES latin1;
SET collation_connection='utf32_bin';
create table t1 select repeat('a',4000) a;
@@ -805,6 +811,12 @@ select c1 as c2h from t1 where c1 like 'ab#_def' escape '#';
c2h
ab_def
drop table t1;
SELECT @@collation_connection;
@@collation_connection
utf32_bin
SELECT '\%b' LIKE '%\%';
'\%b' LIKE '%\%'
0
select hex(substr(_utf32 0x000000e4000000e500000068,1));
hex(substr(_utf32 0x000000e4000000e500000068,1))
000000E4000000E500000068
@@ -2952,6 +2952,12 @@ select c1 as c2h from t1 where c1 like 'ab#_def' escape '#';
c2h
ab_def
drop table t1;
SELECT @@collation_connection;
@@collation_connection
utf32_unicode_ci
SELECT '\%b' LIKE '%\%';
'\%b' LIKE '%\%'
0
"BEGIN ctype_german.inc"
drop table if exists t1;
create table t1 as select repeat(' ', 64) as s1;
@@ -1032,6 +1032,12 @@ select c1 as c2h from t1 where c1 like 'ab#_def' escape '#';
c2h
ab_def
drop table t1;
SELECT @@collation_connection;
@@collation_connection
utf8_general_ci
SELECT '\%b' LIKE '%\%';
'\%b' LIKE '%\%'
0
"BEGIN ctype_german.inc"
drop table if exists t1;
create table t1 as select repeat(' ', 64) as s1;
@@ -1263,6 +1269,12 @@ select c1 as c2h from t1 where c1 like 'ab#_def' escape '#';
c2h
ab_def
drop table t1;
SELECT @@collation_connection;
@@collation_connection
utf8_bin
SELECT '\%b' LIKE '%\%';
'\%b' LIKE '%\%'
0
CREATE TABLE t1 (
user varchar(255) NOT NULL default ''
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

0 comments on commit eb9b03a

Please sign in to comment.