Commit 7ceb5c6c authored by unknown's avatar unknown
Browse files

A fix (bug #8942: SUBSTRING_INDEX in UPDATE causes internal loop).


sql/key.cc:
  A fix (bug #8942: SUBSTRING_INDEX in UPDATE causes internal loop).
  For "partial" key parts (e.g. key(a(20), ...) we create different
  key_part->field, see sql/table.cc; so we have to use the eq() 
  function here to compare fields.
parent c8e834e9
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -209,3 +209,10 @@ insert into t1 values (1, "t1c2-1", 10), (2, "t1c2-2", 20);
update t1 left join t2 on t1.c1 = t2.c1 set t2.c2 = "t2c2-1";
update t1 left join t2 on t1.c1 = t2.c1 set t2.c2 = "t2c2-1" where t1.c3 = 10;
drop table t1, t2;
create table t1 (a int, b char(255), key(a, b(20)));
insert into t1 values (0, '1');
update t1 set b = b + 1 where a = 0;
select * from t1;
a	b
0	2
drop table t1;
+10 −0
Original line number Diff line number Diff line
@@ -164,3 +164,13 @@ insert into t1 values (1, "t1c2-1", 10), (2, "t1c2-2", 20);
update t1 left join t2 on t1.c1 = t2.c1 set t2.c2 = "t2c2-1";
update t1 left join t2 on t1.c1 = t2.c1 set t2.c2 = "t2c2-1" where t1.c3 = 10;
drop table t1, t2;

#
# Bug #8942: a problem with update and partial key part
#

create table t1 (a int, b char(255), key(a, b(20)));
insert into t1 values (0, '1');
update t1 set b = b + 1 where a = 0;
select * from t1;
drop table t1;
+1 −1
Original line number Diff line number Diff line
@@ -265,7 +265,7 @@ bool check_if_key_used(TABLE *table, uint idx, List<Item> &fields)
    f.rewind();
    while ((field=(Item_field*) f++))
    {
      if (key_part->field == field->field)
      if (key_part->field->eq(field->field))
	return 1;
    }
  }