Commit 4af5e597 authored by unknown's avatar unknown

Bugs#20392: INSERT_ID session variable has weird value

sys_var_insert_id returned LAST_INSERT_ID instead of INSERT_ID.


mysql-test/r/variables.result:
  Adding test case
mysql-test/t/variables.test:
  Adding test case
sql/set_var.cc:
  Fixed that sys_var_insert_id returned last_indert_id instead of insert_id.
parent 95d04277
...@@ -421,6 +421,18 @@ set tmp_table_size=100; ...@@ -421,6 +421,18 @@ set tmp_table_size=100;
set tx_isolation="READ-COMMITTED"; set tx_isolation="READ-COMMITTED";
set wait_timeout=100; set wait_timeout=100;
set log_warnings=1; set log_warnings=1;
select @@session.insert_id;
@@session.insert_id
1
set @save_insert_id=@@session.insert_id;
set session insert_id=20;
select @@session.insert_id;
@@session.insert_id
20
set @@session.insert_id=@save_insert_id;
select @@session.insert_id;
@@session.insert_id
1
create table t1 (a int not null auto_increment, primary key(a)); create table t1 (a int not null auto_increment, primary key(a));
create table t2 (a int not null auto_increment, primary key(a)); create table t2 (a int not null auto_increment, primary key(a));
insert into t1 values(null),(null),(null); insert into t1 values(null),(null),(null);
......
...@@ -301,6 +301,16 @@ set tx_isolation="READ-COMMITTED"; ...@@ -301,6 +301,16 @@ set tx_isolation="READ-COMMITTED";
set wait_timeout=100; set wait_timeout=100;
set log_warnings=1; set log_warnings=1;
#
# Bugs: #20392: INSERT_ID session variable has weird value
#
select @@session.insert_id;
set @save_insert_id=@@session.insert_id;
set session insert_id=20;
select @@session.insert_id;
set @@session.insert_id=@save_insert_id;
select @@session.insert_id;
# #
# key buffer # key buffer
# #
......
...@@ -2578,7 +2578,7 @@ bool sys_var_insert_id::update(THD *thd, set_var *var) ...@@ -2578,7 +2578,7 @@ bool sys_var_insert_id::update(THD *thd, set_var *var)
byte *sys_var_insert_id::value_ptr(THD *thd, enum_var_type type, byte *sys_var_insert_id::value_ptr(THD *thd, enum_var_type type,
LEX_STRING *base) LEX_STRING *base)
{ {
return (byte*) &thd->current_insert_id; return (byte*) &thd->next_insert_id;
} }
......
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