Bug #2619 ucs2 LIKE comparison fails in some cases

parent c4728c27
......@@ -104,3 +104,33 @@ a
DROP TABLE t1;
SET NAMES cp1250;
CREATE TABLE t1 (a varchar(250) NOT NULL) DEFAULT CHARACTER SET=cp1250;
INSERT INTO t1 VALUES
('Techni Tapes Sp. z o.o.'),
('Pojazdy Szynowe PESA Bydgoszcz SA Holding'),
('AKAPESTER 1 P.P.H.U.'),
('Pojazdy Szynowe PESA Bydgoszcz S A Holding'),
('PPUH PESKA-I Maria Struniarska');
select * from t1 where a like '%PESA%';
a
Pojazdy Szynowe PESA Bydgoszcz SA Holding
Pojazdy Szynowe PESA Bydgoszcz S A Holding
select * from t1 where a like '%PESA %';
a
Pojazdy Szynowe PESA Bydgoszcz SA Holding
Pojazdy Szynowe PESA Bydgoszcz S A Holding
select * from t1 where a like '%PES%';
a
Techni Tapes Sp. z o.o.
Pojazdy Szynowe PESA Bydgoszcz SA Holding
AKAPESTER 1 P.P.H.U.
Pojazdy Szynowe PESA Bydgoszcz S A Holding
PPUH PESKA-I Maria Struniarska
select * from t1 where a like '%PESKA%';
a
PPUH PESKA-I Maria Struniarska
select * from t1 where a like '%ESKA%';
a
PPUH PESKA-I Maria Struniarska
DROP TABLE t1;
......@@ -44,3 +44,22 @@ SELECT * FROM t1 WHERE a LIKE '%
SELECT * FROM t1 WHERE a LIKE '%';
DROP TABLE t1;
# Bug #2547 Strange "like" behaviour in tables with default charset=cp1250
# Test like with non-default character set using TurboBM
#
SET NAMES cp1250;
CREATE TABLE t1 (a varchar(250) NOT NULL) DEFAULT CHARACTER SET=cp1250;
INSERT INTO t1 VALUES
('Techni Tapes Sp. z o.o.'),
('Pojazdy Szynowe PESA Bydgoszcz SA Holding'),
('AKAPESTER 1 P.P.H.U.'),
('Pojazdy Szynowe PESA Bydgoszcz S A Holding'),
('PPUH PESKA-I Maria Struniarska');
select * from t1 where a like '%PESA%';
select * from t1 where a like '%PESA %';
select * from t1 where a like '%PES%';
select * from t1 where a like '%PESKA%';
select * from t1 where a like '%ESKA%';
DROP TABLE t1;
......@@ -2197,11 +2197,11 @@ void Item_func_like::turboBM_compute_suffixes(int *suff)
int f = 0;
int g = plm1;
int *const splm1 = suff + plm1;
CHARSET_INFO *cs=system_charset_info; // QQ Needs to be fixed
CHARSET_INFO *cs= cmp.cmp_collation.collation;
*splm1 = pattern_len;
if (cmp.cmp_collation.collation == &my_charset_bin)
if (cs == &my_charset_bin)
{
int i;
for (i = pattern_len - 2; i >= 0; i--)
......@@ -2299,12 +2299,12 @@ void Item_func_like::turboBM_compute_bad_character_shifts()
int *end = bmBc + alphabet_size;
int j;
const int plm1 = pattern_len - 1;
CHARSET_INFO *cs=system_charset_info; // QQ Needs to be fixed
CHARSET_INFO *cs= cmp.cmp_collation.collation;
for (i = bmBc; i < end; i++)
*i = pattern_len;
if (cmp.cmp_collation.collation == &my_charset_bin)
if (cs == &my_charset_bin)
{
for (j = 0; j < plm1; j++)
bmBc[(uint) (uchar) pattern[j]] = plm1 - j;
......@@ -2329,13 +2329,13 @@ bool Item_func_like::turboBM_matches(const char* text, int text_len) const
int shift = pattern_len;
int j = 0;
int u = 0;
CHARSET_INFO *cs= cmp.cmp_collation.collation; // QQ Needs to be fixed
CHARSET_INFO *cs= cmp.cmp_collation.collation;
const int plm1= pattern_len - 1;
const int tlmpl= text_len - pattern_len;
/* Searching */
if (cmp.cmp_collation.collation == &my_charset_bin)
if (cs == &my_charset_bin)
{
while (j <= tlmpl)
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment