mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 12:02:42 +01:00
Fix bug #11398 Bug in field_conv() results in wrong result of join with index
When copying varchar fields with field_conv() it's not taken into account that length_bytes of source and destination fields may be different. This results in saving wrong data in field and making wrong key later. Added check so if fields are varchar and have different length_bytes they are not copied by memcpy(). sql/field_conv.cc: Fix bug #11398 Bug in field_conv() results in wrong result of join with index mysql-test/t/select.test: Test case for bug #11398 Bug in field_conv() results in wrong result of join with index mysql-test/r/select.result: Test case for bug #11398 Bug in field_conv() results in wrong result of join with index
This commit is contained in:
parent
219c84faba
commit
06ebdbb785
3 changed files with 23 additions and 1 deletions
|
@ -2739,3 +2739,12 @@ DROP TABLE t1,t2;
|
|||
select x'10' + 0, X'10' + 0, b'10' + 0, B'10' + 0;
|
||||
x'10' + 0 X'10' + 0 b'10' + 0 B'10' + 0
|
||||
16 16 2 2
|
||||
create table t1 (f1 varchar(6) default NULL, f2 int(6) primary key not null);
|
||||
create table t2 (f3 varchar(5) not null, f4 varchar(5) not null, UNIQUE KEY UKEY (f3,f4));
|
||||
insert into t1 values (" 2", 2);
|
||||
insert into t2 values (" 2", " one "),(" 2", " two ");
|
||||
select * from t1 left join t2 on f1 = f3;
|
||||
f1 f2 f3 f4
|
||||
2 2 2 one
|
||||
2 2 2 two
|
||||
drop table t1,t2;
|
||||
|
|
|
@ -2350,3 +2350,13 @@ DROP TABLE t1,t2;
|
|||
#
|
||||
|
||||
select x'10' + 0, X'10' + 0, b'10' + 0, B'10' + 0;
|
||||
|
||||
#
|
||||
# Bug #11398 Bug in field_conv() results in wrong result of join with index
|
||||
#
|
||||
create table t1 (f1 varchar(6) default NULL, f2 int(6) primary key not null);
|
||||
create table t2 (f3 varchar(5) not null, f4 varchar(5) not null, UNIQUE KEY UKEY (f3,f4));
|
||||
insert into t1 values (" 2", 2);
|
||||
insert into t2 values (" 2", " one "),(" 2", " two ");
|
||||
select * from t1 left join t2 on f1 = f3;
|
||||
drop table t1,t2;
|
||||
|
|
|
@ -640,7 +640,10 @@ void field_conv(Field *to,Field *from)
|
|||
(!(to->table->in_use->variables.sql_mode &
|
||||
(MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE | MODE_INVALID_DATES)) ||
|
||||
to->type() != FIELD_TYPE_DATE &&
|
||||
to->type() != FIELD_TYPE_DATETIME))
|
||||
to->type() != FIELD_TYPE_DATETIME) &&
|
||||
(from->real_type() != MYSQL_TYPE_VARCHAR ||
|
||||
((Field_varstring*)from)->length_bytes ==
|
||||
((Field_varstring*)to)->length_bytes))
|
||||
{ // Identical fields
|
||||
#ifdef HAVE_purify
|
||||
/* This may happen if one does 'UPDATE ... SET x=x' */
|
||||
|
|
Loading…
Reference in a new issue