1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

When unifying arguments for comparion, binary strings won character strings,

and comparison was done binary. Now, a binary string wins a character sting 
taking in account their derivation. That means a character field wins a
binary literal and comparison is done according to the character field
collation, not binary.
This commit is contained in:
bar@bar.mysql.r18.ru
2003-06-27 16:08:52 +05:00
parent d31de69795
commit b528745dce
3 changed files with 24 additions and 22 deletions

View File

@ -215,21 +215,21 @@ drop table t1;
create table t1 (word varchar(255) not null, word2 varchar(255) not null, index(word));
insert into t1 (word) values ('ss'),(0xDF),(0xE4),('ae');
update t1 set word2=word;
select word, word=0xdf as t from t1 having t > 0;
select word, word=binary 0xdf as t from t1 having t > 0;
word t
<EFBFBD> 1
select word, word=cast(0xdf AS CHAR) as t from t1 having t > 0;
word t
ss 1
<EFBFBD> 1
select * from t1 where word=0xDF;
select * from t1 where word=binary 0xDF;
word word2
<EFBFBD> <09>
select * from t1 where word=CAST(0xDF as CHAR);
word word2
ss ss
<EFBFBD> <09>
select * from t1 where word2=0xDF;
select * from t1 where word2=binary 0xDF;
word word2
<EFBFBD> <09>
select * from t1 where word2=CAST(0xDF as CHAR);
@ -244,7 +244,7 @@ select * from t1 where word= 0xe4 or word=CAST(0xe4 as CHAR);
word word2
<EFBFBD> <09>
ae ae
select * from t1 where word between 0xDF and 0xDF;
select * from t1 where word between binary 0xDF and binary 0xDF;
word word2
<EFBFBD> <09>
select * from t1 where word between CAST(0xDF AS CHAR) and CAST(0xDF AS CHAR);
@ -257,7 +257,7 @@ ae ae
select * from t1 where word like 'AE';
word word2
ae ae
select * from t1 where word like 0xDF;
select * from t1 where word like binary 0xDF;
word word2
<EFBFBD> <09>
select * from t1 where word like CAST(0xDF as CHAR);

View File

@ -52,21 +52,24 @@ drop table t1;
# Test bug report #152 (problem with index on latin1_de)
#
#
# The below checks both binary and character comparisons.
#
create table t1 (word varchar(255) not null, word2 varchar(255) not null, index(word));
insert into t1 (word) values ('ss'),(0xDF),(0xE4),('ae');
update t1 set word2=word;
select word, word=0xdf as t from t1 having t > 0;
select word, word=binary 0xdf as t from t1 having t > 0;
select word, word=cast(0xdf AS CHAR) as t from t1 having t > 0;
select * from t1 where word=0xDF;
select * from t1 where word=binary 0xDF;
select * from t1 where word=CAST(0xDF as CHAR);
select * from t1 where word2=0xDF;
select * from t1 where word2=binary 0xDF;
select * from t1 where word2=CAST(0xDF as CHAR);
select * from t1 where word='ae';
select * from t1 where word= 0xe4 or word=CAST(0xe4 as CHAR);
select * from t1 where word between 0xDF and 0xDF;
select * from t1 where word between binary 0xDF and binary 0xDF;
select * from t1 where word between CAST(0xDF AS CHAR) and CAST(0xDF AS CHAR);
select * from t1 where word like 'ae';
select * from t1 where word like 'AE';
select * from t1 where word like 0xDF;
select * from t1 where word like binary 0xDF;
select * from t1 where word like CAST(0xDF as CHAR);
drop table t1;