mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
Fixed that multibyte charsets didn't honor multibyte
sequence boundaries in functions LIKE and LOCATE in the case of "binary" collation. Comparison was done like if the strings were just a binary strings without character set assumption.
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
drop table if exists t1;
|
||||
set names ujis;
|
||||
create table t1 (c text character set ujis);
|
||||
insert into t1 values (0xa4a2),(0xa4a3);
|
||||
select hex(left(c,1)) from t1 group by c;
|
||||
@ -6,3 +7,60 @@ hex(left(c,1))
|
||||
A4A2
|
||||
A4A3
|
||||
drop table t1;
|
||||
select locate(0xa2a1,0xa1a2a1a3);
|
||||
locate(0xa2a1,0xa1a2a1a3)
|
||||
2
|
||||
select locate(_ujis 0xa2a1,_ujis 0xa1a2a1a3);
|
||||
locate(_ujis 0xa2a1,_ujis 0xa1a2a1a3)
|
||||
0
|
||||
select locate(_ujis 0xa2a1,_ujis 0xa1a2a1a3 collate ujis_bin);
|
||||
locate(_ujis 0xa2a1,_ujis 0xa1a2a1a3 collate ujis_bin)
|
||||
0
|
||||
select locate('he','hello');
|
||||
locate('he','hello')
|
||||
1
|
||||
select locate('he','hello',2);
|
||||
locate('he','hello',2)
|
||||
0
|
||||
select locate('lo','hello',2);
|
||||
locate('lo','hello',2)
|
||||
4
|
||||
select locate('HE','hello');
|
||||
locate('HE','hello')
|
||||
1
|
||||
select locate('HE','hello',2);
|
||||
locate('HE','hello',2)
|
||||
0
|
||||
select locate('LO','hello',2);
|
||||
locate('LO','hello',2)
|
||||
4
|
||||
select locate('HE','hello' collate ujis_bin);
|
||||
locate('HE','hello' collate ujis_bin)
|
||||
0
|
||||
select locate('HE','hello' collate ujis_bin,2);
|
||||
locate('HE','hello' collate ujis_bin,2)
|
||||
0
|
||||
select locate('LO','hello' collate ujis_bin,2);
|
||||
locate('LO','hello' collate ujis_bin,2)
|
||||
0
|
||||
select locate(_ujis 0xa1a3,_ujis 0xa1a2a1a3);
|
||||
locate(_ujis 0xa1a3,_ujis 0xa1a2a1a3)
|
||||
2
|
||||
select 0xa1a2a1a3 like concat(_binary'%',0xa2a1,_binary'%');
|
||||
0xa1a2a1a3 like concat(_binary'%',0xa2a1,_binary'%')
|
||||
1
|
||||
select _ujis 0xa1a2a1a3 like concat(_ujis'%',_ujis 0xa2a1, _ujis'%');
|
||||
_ujis 0xa1a2a1a3 like concat(_ujis'%',_ujis 0xa2a1, _ujis'%')
|
||||
0
|
||||
select _ujis 0xa1a2a1a3 like concat(_ujis'%',_ujis 0xa2a1, _ujis'%') collate ujis_bin;
|
||||
_ujis 0xa1a2a1a3 like concat(_ujis'%',_ujis 0xa2a1, _ujis'%') collate ujis_bin
|
||||
0
|
||||
select 'a' like 'a';
|
||||
'a' like 'a'
|
||||
1
|
||||
select 'A' like 'a';
|
||||
'A' like 'a'
|
||||
1
|
||||
select 'A' like 'a' collate ujis_bin;
|
||||
'A' like 'a' collate ujis_bin
|
||||
0
|
||||
|
@ -1,2 +1,2 @@
|
||||
Collation Charset Id Default Compiled Sortlen
|
||||
ujis_japanese_ci ujis 12 Yes Yes 0
|
||||
ujis_japanese_ci ujis 12 Yes Yes 1
|
||||
|
@ -7,6 +7,8 @@
|
||||
drop table if exists t1;
|
||||
--enable_warnings
|
||||
|
||||
set names ujis;
|
||||
|
||||
#
|
||||
# Test problem with LEFT()
|
||||
#
|
||||
@ -15,3 +17,27 @@ create table t1 (c text character set ujis);
|
||||
insert into t1 values (0xa4a2),(0xa4a3);
|
||||
select hex(left(c,1)) from t1 group by c;
|
||||
drop table t1;
|
||||
|
||||
#
|
||||
#
|
||||
#
|
||||
select locate(0xa2a1,0xa1a2a1a3);
|
||||
select locate(_ujis 0xa2a1,_ujis 0xa1a2a1a3);
|
||||
select locate(_ujis 0xa2a1,_ujis 0xa1a2a1a3 collate ujis_bin);
|
||||
select locate('he','hello');
|
||||
select locate('he','hello',2);
|
||||
select locate('lo','hello',2);
|
||||
select locate('HE','hello');
|
||||
select locate('HE','hello',2);
|
||||
select locate('LO','hello',2);
|
||||
select locate('HE','hello' collate ujis_bin);
|
||||
select locate('HE','hello' collate ujis_bin,2);
|
||||
select locate('LO','hello' collate ujis_bin,2);
|
||||
select locate(_ujis 0xa1a3,_ujis 0xa1a2a1a3);
|
||||
|
||||
select 0xa1a2a1a3 like concat(_binary'%',0xa2a1,_binary'%');
|
||||
select _ujis 0xa1a2a1a3 like concat(_ujis'%',_ujis 0xa2a1, _ujis'%');
|
||||
select _ujis 0xa1a2a1a3 like concat(_ujis'%',_ujis 0xa2a1, _ujis'%') collate ujis_bin;
|
||||
select 'a' like 'a';
|
||||
select 'A' like 'a';
|
||||
select 'A' like 'a' collate ujis_bin;
|
||||
|
Reference in New Issue
Block a user