summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <svoj@april.(none)>2006-04-06 15:25:39 +0500
committerunknown <svoj@april.(none)>2006-04-06 15:25:39 +0500
commitb3dad934787dbdc0aba7ea6ab4559eb0e2880e25 (patch)
treec4ccd6abd70b7f3c8c85aa29ad45f614f9f99342
parent9a1d80e90ef7a176da61d7c19f9b463076e8ad0c (diff)
parentee3cf23b5ca8edf86d01dd4476d9769a8aaf49ce (diff)
downloadmariadb-git-b3dad934787dbdc0aba7ea6ab4559eb0e2880e25.tar.gz
Merge svojtovich@bk-internal.mysql.com:/home/bk/mysql-5.0
into april.(none):/home/svoj/devel/mysql/BUG14945/mysql-5.0
-rw-r--r--mysql-test/r/sp.result11
-rw-r--r--mysql-test/t/sp.test15
-rw-r--r--sql/sql_delete.cc3
-rw-r--r--sql/sql_parse.cc2
4 files changed, 28 insertions, 3 deletions
diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result
index 3e139f8cce5..dadcab76947 100644
--- a/mysql-test/r/sp.result
+++ b/mysql-test/r/sp.result
@@ -4811,6 +4811,17 @@ begin
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()|
diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test
index 9e1afa53149..1658e06d518 100644
--- a/mysql-test/t/sp.test
+++ b/mysql-test/t/sp.test
@@ -5666,6 +5666,21 @@ begin
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|
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));