From c12a760ce9e0c99a2b943bf2de4d7278fb8fa21e Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 30 Aug 2005 12:39:20 +0300 Subject: Bug #11946: Review fixes. sql/ha_innodb.cc: Add 'value' parameter to reset_auto_increment. sql/ha_innodb.h: Add 'value' parameter to reset_auto_increment. sql/handler.h: Add 'value' parameter to reset_auto_increment. sql/mysql_priv.h: Add 'reset_auto_increment' parameter to mysql_delete. sql/sql_delete.cc: Add 'reset_auto_increment' parameter to mysql_delete, and use it instead of checking for SQLCOM_TRUNCATE. mysql_truncate: Adapt to changes in mysql_delete. sql/sql_parse.cc: mysql_execute_command: Adapt to changes in mysql_delete. --- sql/sql_delete.cc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'sql/sql_delete.cc') diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index 3e50b806897..c7fabdaf18e 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -27,7 +27,8 @@ #include "sql_trigger.h" bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, - SQL_LIST *order, ha_rows limit, ulonglong options) + SQL_LIST *order, ha_rows limit, ulonglong options, + bool reset_auto_increment) { int error; TABLE *table; @@ -230,18 +231,18 @@ 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)) + if (reset_auto_increment && (error < 0)) { /* We're really doing a truncate and need to reset the table's auto-increment counter. */ - int error2 = table->file->reset_auto_increment(); + int error2= table->file->reset_auto_increment(0); if (error2 && (error2 != HA_ERR_WRONG_COMMAND)) { table->file->print_error(error2, MYF(0)); - error = 1; + error= 1; } } @@ -828,7 +829,7 @@ bool mysql_truncate(THD *thd, TABLE_LIST *table_list, bool dont_send_ok) ha_enable_transaction(thd, FALSE); mysql_init_select(thd->lex); error= mysql_delete(thd, table_list, (COND*) 0, (SQL_LIST*) 0, - HA_POS_ERROR, LL(0)); + HA_POS_ERROR, LL(0), TRUE); ha_enable_transaction(thd, TRUE); thd->options= save_options; DBUG_RETURN(error); -- cgit v1.2.1