diff options
author | unknown <svoj@april.(none)> | 2006-04-06 15:19:01 +0500 |
---|---|---|
committer | unknown <svoj@april.(none)> | 2006-04-06 15:19:01 +0500 |
commit | ee3cf23b5ca8edf86d01dd4476d9769a8aaf49ce (patch) | |
tree | 03df9bcbdcaf7e9d48482604e706d38dc3aa5635 /sql | |
parent | 66ac19e2cf721ae9f02f5045376bdbbb9f1597c5 (diff) | |
download | mariadb-git-ee3cf23b5ca8edf86d01dd4476d9769a8aaf49ce.tar.gz |
Fix for bug#14945 "Truncate table doesn't reset the auto_increment
counter".
When TRUNCATE TABLE was called within an stored procedure the
auto_increment counter was not reset to 0 even if straight
TRUNCATE for this table did this.
This fix makes TRUNCATE in stored procedures to be handled exactly
in the same way as straight TRUNCATE. We achieve this by rolling
back the fix for bug 8850, which is no longer needed since stored
procedures don't require prelocked mode anymore (and TRUNCATE is
not allowed in stored functions or triggers).
mysql-test/r/sp.result:
Test case for BUG#14945.
mysql-test/t/sp.test:
Test case for BUG#14945.
sql/sql_delete.cc:
Handle TRUNCATE in stored procedures exactly in the same way as straight
TRUNCATE (i.e. without falling back to DELETE if possible). We achieve
this by rolling back the fix for bug 8850, which is no longer relevant
since stored procedures don't require prelocked mode anymore
(and TRUNCATE is not allowed in stored functions or triggers).
sql/sql_parse.cc:
Handle TRUNCATE in stored procedures exactly in the same way as straight
TRUNCATE (i.e. without falling back to DELETE if possible). We achieve
this by rolling back the fix for bug 8850, which is no longer relevant
since stored procedures don't require prelocked mode anymore
(and TRUNCATE is not allowed in stored functions or triggers).
Diffstat (limited to 'sql')
-rw-r--r-- | sql/sql_delete.cc | 3 | ||||
-rw-r--r-- | sql/sql_parse.cc | 2 |
2 files changed, 2 insertions, 3 deletions
diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index 56dbd423b69..37c4f9a3256 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -842,8 +842,7 @@ bool mysql_truncate(THD *thd, TABLE_LIST *table_list, bool dont_send_ok) table_list->db, table_list->table_name); DBUG_RETURN(TRUE); } - if (!ha_check_storage_engine_flag(table_type, HTON_CAN_RECREATE) - || thd->lex->sphead) + if (!ha_check_storage_engine_flag(table_type, HTON_CAN_RECREATE)) goto trunc_by_del; if (lock_and_wait_for_table_name(thd, table_list)) DBUG_RETURN(TRUE); diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index f9d04fc873e..2f589f48c57 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -3350,7 +3350,7 @@ end_with_restore_list: Don't allow this within a transaction because we want to use re-generate table */ - if ((thd->locked_tables && !lex->sphead) || thd->active_transaction()) + if (thd->locked_tables || thd->active_transaction()) { my_message(ER_LOCK_OR_ACTIVE_TRANSACTION, ER(ER_LOCK_OR_ACTIVE_TRANSACTION), MYF(0)); |