summaryrefslogtreecommitdiff
path: root/sql/sql_update.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_update.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_update.cc')
-rw-r--r--sql/sql_update.cc4
1 files changed, 2 insertions, 2 deletions
diff --git a/sql/sql_update.cc b/sql/sql_update.cc
index af4ba8025f9..51643fc611d 100644
--- a/sql/sql_update.cc
+++ b/sql/sql_update.cc
@@ -408,7 +408,7 @@ int mysql_update(THD *thd,
(ulong) thd->cuted_fields);
send_ok(thd,
(thd->client_capabilities & CLIENT_FOUND_ROWS) ? found : updated,
- thd->insert_id_used ? thd->insert_id() : 0L,buff);
+ thd->insert_id_used ? thd->last_insert_id : 0L,buff);
DBUG_PRINT("info",("%d records updated",updated));
}
thd->count_cuted_fields= CHECK_FIELD_IGNORE; /* calc cuted fields */
@@ -1318,6 +1318,6 @@ bool multi_update::send_eof()
(ulong) thd->cuted_fields);
::send_ok(thd,
(thd->client_capabilities & CLIENT_FOUND_ROWS) ? found : updated,
- thd->insert_id_used ? thd->insert_id() : 0L,buff);
+ thd->insert_id_used ? thd->last_insert_id : 0L,buff);
return 0;
}