From: Date: April 6 2006 12:19pm Subject: bk commit into 5.0 tree (svoj:1.2120) BUG#14945 List-Archive: http://lists.mysql.com/commits/4549 X-Bug: 14945 Message-Id: <20060406101908.EE94D19B0@april.pils.ru> Below is the list of changes that have just been committed into a local 5.0 repository of svoj. When svoj does a push these changes will be propagated to the main repository and, within 24 hours after the push, to the public repository. For information on how to access the public repository see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html ChangeSet 1.2120 06/04/06 15:19:01 svoj@april.(none) +4 -0 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). sql/sql_parse.cc 1.537 06/04/06 15:18:57 svoj@april.(none) +1 -1 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_delete.cc 1.173 06/04/06 15:18:57 svoj@april.(none) +1 -2 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). mysql-test/t/sp.test 1.182 06/04/06 15:18:57 svoj@april.(none) +15 -0 Test case for BUG#14945. mysql-test/r/sp.result 1.194 06/04/06 15:18:57 svoj@april.(none) +11 -0 Test case for BUG#14945. # This is a BitKeeper patch. What follows are the unified diffs for the # set of deltas contained in the patch. The rest of the patch, the part # that BitKeeper cares about, is below these diffs. # User: svoj # Host: april.(none) # Root: /home/svoj/devel/mysql/BUG14945/mysql-5.0 --- 1.172/sql/sql_delete.cc 2006-03-08 13:17:03 +04:00 +++ 1.173/sql/sql_delete.cc 2006-04-06 15:18:57 +05:00 @@ -842,8 +842,7 @@ 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); --- 1.536/sql/sql_parse.cc 2006-03-15 21:15:42 +04:00 +++ 1.537/sql/sql_parse.cc 2006-04-06 15:18:57 +05:00 @@ -3350,7 +3350,7 @@ 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)); --- 1.193/mysql-test/r/sp.result 2006-03-28 17:18:44 +05:00 +++ 1.194/mysql-test/r/sp.result 2006-04-06 15:18:57 +05:00 @@ -4811,6 +4811,17 @@ declare x int; select id from t1 order by x; end| +drop procedure if exists bug14945| +create table t3 (id int not null auto_increment primary key)| +create procedure bug14945() deterministic truncate t3| +insert into t3 values (null)| +call bug14945()| +insert into t3 values (null)| +select * from t3| +id +1 +drop table t3| +drop procedure bug14945| create procedure bug16474_2(x int) select id from t1 order by x| call bug16474_1()| --- 1.181/mysql-test/t/sp.test 2006-03-28 17:17:15 +05:00 +++ 1.182/mysql-test/t/sp.test 2006-04-06 15:18:57 +05:00 @@ -5666,6 +5666,21 @@ select id from t1 order by x; end| +# +# BUG#14945: Truncate table doesn't reset the auto_increment counter +# +--disable_warnings +drop procedure if exists bug14945| +--enable_warnings +create table t3 (id int not null auto_increment primary key)| +create procedure bug14945() deterministic truncate t3| +insert into t3 values (null)| +call bug14945()| +insert into t3 values (null)| +select * from t3| +drop table t3| +drop procedure bug14945| + # This does NOT order by column index; variable is an expression. create procedure bug16474_2(x int) select id from t1 order by x|