summaryrefslogtreecommitdiff
path: root/sql/ha_innodb.cc
diff options
context:
space:
mode:
authorunknown <heikki@hundin.mysql.fi>2003-01-29 00:31:56 +0200
committerunknown <heikki@hundin.mysql.fi>2003-01-29 00:31:56 +0200
commit25aa3098be426882d6abd402ee78a0ecc665bb57 (patch)
tree5c1fcad4f8799b7c95abff987f1a9f24ee8f49cd /sql/ha_innodb.cc
parentad2c3cdf1b4b2376f2ad5871e28259237fff1b29 (diff)
downloadmariadb-git-25aa3098be426882d6abd402ee78a0ecc665bb57.tar.gz
ha_innodb.cc:
Fix a bug REPLACE INTO t SELECT ... did not work if t has an auto-inc column sql/ha_innodb.cc: Fix a bug REPLACE INTO t SELECT ... did not work if t has an auto-inc column
Diffstat (limited to 'sql/ha_innodb.cc')
-rw-r--r--sql/ha_innodb.cc16
1 files changed, 13 insertions, 3 deletions
diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc
index a25aedaa89f..fb1f99f2160 100644
--- a/sql/ha_innodb.cc
+++ b/sql/ha_innodb.cc
@@ -1733,6 +1733,7 @@ ha_innobase::write_row(
ibool incremented_auto_inc_for_stat = FALSE;
ibool incremented_auto_inc_counter = FALSE;
ibool skip_auto_inc_decr;
+ ibool success;
DBUG_ENTER("ha_innobase::write_row");
@@ -1908,9 +1909,18 @@ ha_innobase::write_row(
the counter here. */
skip_auto_inc_decr = FALSE;
- if (error == DB_DUPLICATE_KEY &&
- user_thd->lex.sql_command == SQLCOM_REPLACE)
- skip_auto_inc_decr= TRUE;
+
+ /* Note that MySQL classifies in lex.sql_command a query
+ of type REPLACE INTO ... SELECT as simply SQLCOM_QUERY.
+ We have to scan the query string if the query is actually
+ a REPLACE. */
+
+ dict_accept(user_thd->query, "REPLACE", &success);
+
+ if (error == DB_DUPLICATE_KEY && success) {
+
+ skip_auto_inc_decr= TRUE;
+ }
if (!skip_auto_inc_decr && incremented_auto_inc_counter
&& prebuilt->trx->auto_inc_lock) {