summaryrefslogtreecommitdiff
path: root/sql/sql_delete.cc
diff options
context:
space:
mode:
authorosku@127.(none) <>2005-08-29 09:06:43 +0300
committerosku@127.(none) <>2005-08-29 09:06:43 +0300
commitcaf74b7cdd5e4b59d3e18263e44eba36c8413e2c (patch)
treefa562597c08dce3de422d77cf8e36b5e768b8b2f /sql/sql_delete.cc
parentc019e40ff0b05bc7233fbfbd4a8ce37a4673664b (diff)
parentce22788bdd220c27b76022ecabc36e59b99053f8 (diff)
downloadmariadb-git-caf74b7cdd5e4b59d3e18263e44eba36c8413e2c.tar.gz
Merge osalerma@bk-internal.mysql.com:/home/bk/mysql-5.0
into 127.(none):/home/osku/mysql-5.0
Diffstat (limited to 'sql/sql_delete.cc')
-rw-r--r--sql/sql_delete.cc22
1 files changed, 22 insertions, 0 deletions
diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc
index 4ec5b43f8e7..3e50b806897 100644
--- a/sql/sql_delete.cc
+++ b/sql/sql_delete.cc
@@ -100,6 +100,13 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
free_underlaid_joins(thd, select_lex);
thd->row_count_func= 0;
send_ok(thd,0L);
+
+ /*
+ We don't need to call reset_auto_increment in this case, because
+ mysql_truncate always gives a NULL conds argument, hence we never
+ get here.
+ */
+
DBUG_RETURN(0); // Nothing to delete
}
@@ -223,6 +230,21 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
if (options & OPTION_QUICK)
(void) table->file->extra(HA_EXTRA_NORMAL);
+ if ((error < 0) && (thd->lex->sql_command == SQLCOM_TRUNCATE))
+ {
+ /*
+ We're really doing a truncate and need to reset the table's
+ auto-increment counter.
+ */
+ int error2 = table->file->reset_auto_increment();
+
+ if (error2 && (error2 != HA_ERR_WRONG_COMMAND))
+ {
+ table->file->print_error(error2, MYF(0));
+ error = 1;
+ }
+ }
+
cleanup:
/*
Invalidate the table in the query cache if something changed. This must