summaryrefslogtreecommitdiff
path: root/sql/sql_load.cc
diff options
context:
space:
mode:
authorkroki/tomash@moonlight.intranet <>2006-10-06 13:34:07 +0400
committerkroki/tomash@moonlight.intranet <>2006-10-06 13:34:07 +0400
commitee0cebf9a7fa364df44aeb0579bdaa80d11f0125 (patch)
tree9d3af9e4d1ede2e842e8a4a18d1a01c0d66cf0ea /sql/sql_load.cc
parentacaa584c5523753cab5b3a50ed3c95672b462541 (diff)
downloadmariadb-git-ee0cebf9a7fa364df44aeb0579bdaa80d11f0125.tar.gz
BUG#21726: Incorrect result with multiple invocations of LAST_INSERT_ID.
Note: bug#21726 does not directly apply to 4.1, as it doesn't have stored procedures. However, 4.1 had some bugs that were fixed in 5.0 by the patch for bug#21726, and this patch is a backport of those fixes. Namely, in 4.1 it fixes: - LAST_INSERT_ID(expr) didn't return value of expr (4.1 specific). - LAST_INSERT_ID() could return the value generated by current statement if the call happens after the generation, like in CREATE TABLE t1 (i INT AUTO_INCREMENT PRIMARY KEY, j INT); INSERT INTO t1 VALUES (NULL, 0), (NULL, LAST_INSERT_ID()); - Redundant binary log LAST_INSERT_ID_EVENTs could be generated.
Diffstat (limited to 'sql/sql_load.cc')
-rw-r--r--sql/sql_load.cc12
1 files changed, 4 insertions, 8 deletions
diff --git a/sql/sql_load.cc b/sql/sql_load.cc
index 4e6c458cc43..48862506729 100644
--- a/sql/sql_load.cc
+++ b/sql/sql_load.cc
@@ -466,10 +466,8 @@ read_fixed_length(THD *thd,COPY_INFO &info,TABLE *table,List<Item> &fields,
if (write_record(table,&info))
DBUG_RETURN(1);
/*
- If auto_increment values are used, save the first one
- for LAST_INSERT_ID() and for the binary/update log.
- We can't use insert_id() as we don't want to touch the
- last_insert_id_used flag.
+ If auto_increment values are used, save the first one for
+ LAST_INSERT_ID() and for the binary/update log.
*/
if (!id && thd->insert_id_used)
id= thd->last_insert_id;
@@ -572,10 +570,8 @@ read_sep_field(THD *thd,COPY_INFO &info,TABLE *table,
if (write_record(table,&info))
DBUG_RETURN(1);
/*
- If auto_increment values are used, save the first one
- for LAST_INSERT_ID() and for the binary/update log.
- We can't use insert_id() as we don't want to touch the
- last_insert_id_used flag.
+ If auto_increment values are used, save the first one for
+ LAST_INSERT_ID() and for the binary/update log.
*/
if (!id && thd->insert_id_used)
id= thd->last_insert_id;