Commit 3c925ee0 authored by unknown's avatar unknown

Bug#8057

  Fix crash with LAST_INSERT_ID() in UPDATE,
  Tests included,


mysql-test/r/update.result:
  Bug#8057
    Test for bug
mysql-test/t/update.test:
  Bug#8057
    Test for bug
sql/item_func.cc:
  Bug#8057
    Don't create new Item in val_int()
parent bcb31692
...@@ -212,3 +212,10 @@ insert into t1 values (1, "t1c2-1", 10), (2, "t1c2-2", 20); ...@@ -212,3 +212,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";
update t1 left join t2 on t1.c1 = t2.c1 set t2.c2 = "t2c2-1" where t1.c3 = 10; update t1 left join t2 on t1.c1 = t2.c1 set t2.c2 = "t2c2-1" where t1.c3 = 10;
drop table t1, t2; drop table t1, t2;
create table t1 (id int not null auto_increment primary key, id_str varchar(32));
insert into t1 (id_str) values ("test");
update t1 set id_str = concat(id_str, id) where id = last_insert_id();
select * from t1;
id id_str
1 test1
drop table t1;
...@@ -170,3 +170,12 @@ insert into t1 values (1, "t1c2-1", 10), (2, "t1c2-2", 20); ...@@ -170,3 +170,12 @@ 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";
update t1 left join t2 on t1.c1 = t2.c1 set t2.c2 = "t2c2-1" where t1.c3 = 10; update t1 left join t2 on t1.c1 = t2.c1 set t2.c2 = "t2c2-1" where t1.c3 = 10;
drop table t1, t2; drop table t1, t2;
#
# Bug #8057
#
create table t1 (id int not null auto_increment primary key, id_str varchar(32));
insert into t1 (id_str) values ("test");
update t1 set id_str = concat(id_str, id) where id = last_insert_id();
select * from t1;
drop table t1;
...@@ -2284,14 +2284,10 @@ longlong Item_func_last_insert_id::val_int() ...@@ -2284,14 +2284,10 @@ longlong Item_func_last_insert_id::val_int()
longlong value=args[0]->val_int(); longlong value=args[0]->val_int();
current_thd->insert_id(value); current_thd->insert_id(value);
null_value=args[0]->null_value; null_value=args[0]->null_value;
return value;
} }
else else
{ current_thd->lex->uncacheable(UNCACHEABLE_SIDEEFFECT);
Item *it= get_system_var(current_thd, OPT_SESSION, "last_insert_id", 14, return current_thd->insert_id();
"last_insert_id()");
return it->val_int();
}
} }
/* This function is just used to test speed of different functions */ /* This function is just used to test speed of different functions */
......
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