Commit 252c06df authored by unknown's avatar unknown

Bug #2959 UTF8 charset breaks joins with mixed column/string constant

parent 02d5e28c
...@@ -169,3 +169,28 @@ hex(s1) ...@@ -169,3 +169,28 @@ hex(s1)
drop table t1; drop table t1;
create table t1 (a text character set utf8, primary key(a(360))); create table t1 (a text character set utf8, primary key(a(360)));
ERROR 42000: Specified key was too long; max key length is 1000 bytes ERROR 42000: Specified key was too long; max key length is 1000 bytes
CREATE TABLE t1 ( a varchar(10) ) CHARACTER SET utf8;
INSERT INTO t1 VALUES ( 'test' );
SELECT a.a, b.a FROM t1 a, t1 b WHERE a.a = b.a;
a a
test test
SELECT a.a, b.a FROM t1 a, t1 b WHERE a.a = 'test' and b.a = 'test';
a a
test test
SELECT a.a, b.a FROM t1 a, t1 b WHERE a.a = b.a and a.a = 'test';
a a
test test
DROP TABLE t1;
create table t1 (a char(255) character set utf8);
insert into t1 values('b'),('b');
select * from t1 where a = 'b';
a
b
b
select * from t1 where a = 'b' and a = 'b';
a
b
b
select * from t1 where a = 'b' and a != 'b';
a
drop table t1;
...@@ -105,3 +105,22 @@ drop table t1; ...@@ -105,3 +105,22 @@ drop table t1;
# #
--error 1071 --error 1071
create table t1 (a text character set utf8, primary key(a(360))); create table t1 (a text character set utf8, primary key(a(360)));
#
# Bug 2959
# UTF8 charset breaks joins with mixed column/string constant
#
CREATE TABLE t1 ( a varchar(10) ) CHARACTER SET utf8;
INSERT INTO t1 VALUES ( 'test' );
SELECT a.a, b.a FROM t1 a, t1 b WHERE a.a = b.a;
SELECT a.a, b.a FROM t1 a, t1 b WHERE a.a = 'test' and b.a = 'test';
SELECT a.a, b.a FROM t1 a, t1 b WHERE a.a = b.a and a.a = 'test';
DROP TABLE t1;
create table t1 (a char(255) character set utf8);
insert into t1 values('b'),('b');
select * from t1 where a = 'b';
select * from t1 where a = 'b' and a = 'b';
select * from t1 where a = 'b' and a != 'b';
drop table t1;
...@@ -533,7 +533,8 @@ class Item_string :public Item ...@@ -533,7 +533,8 @@ class Item_string :public Item
bool eq(const Item *item, bool binary_cmp) const; bool eq(const Item *item, bool binary_cmp) const;
Item *new_item() Item *new_item()
{ {
return new Item_string(name, str_value.ptr(), max_length, &my_charset_bin); return new Item_string(name, str_value.ptr(),
str_value.length(), &my_charset_bin);
} }
String *const_string() { return &str_value; } String *const_string() { return &str_value; }
inline void append(char *str, uint length) { str_value.append(str, length); } inline void append(char *str, uint length) { str_value.append(str, length); }
......
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