diff --git a/.bzrignore b/.bzrignore index 81b5139a7d3..302ea948459 100644 --- a/.bzrignore +++ b/.bzrignore @@ -1105,3 +1105,4 @@ vio/test-ssl vio/test-sslclient vio/test-sslserver vio/viotest-ssl +acinclude.m4 diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result index a04e178263b..2965c6583f2 100644 --- a/mysql-test/r/sp.result +++ b/mysql-test/r/sp.result @@ -2697,6 +2697,30 @@ call bug7992()| call bug7992()| drop procedure bug7992| drop table t3| +drop table t2; +drop table t1; +drop procedure if exists sp1; +create table t1 (a int) engine=innodb| +create procedure sp1 () +begin +truncate table t1; insert t1 values (1); rollback; +end +| +set autocommit=0; +insert t1 values (2); +call sp1(); +ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction +commit; +set autocommit=1; +select * from t1; +a +2 +call sp1(); +select * from t1; +a +1 +drop table t1; +drop procedure sp1; create table t3 ( lpitnumber int(11) default null, lrecordtype int(11) default null diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test index c120e7e94b7..8766c730090 100644 --- a/mysql-test/t/sp.test +++ b/mysql-test/t/sp.test @@ -3276,7 +3276,35 @@ call bug7992()| call bug7992()| drop procedure bug7992| drop table t3| +delimiter ;| +drop table t2; +drop table t1; +# +# BUG#8850 +# +--disable_warnings +drop procedure if exists sp1; +--enable_warnings +delimiter |; +create table t1 (a int) engine=innodb| +create procedure sp1 () +begin + truncate table t1; insert t1 values (1); rollback; +end +| +delimiter ;| +set autocommit=0; +insert t1 values (2); +--error 1192 +call sp1(); +commit; +set autocommit=1; +select * from t1; +call sp1(); +select * from t1; +drop table t1; +drop procedure sp1; # # BUG#8849: problem with insert statement with table alias's diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index eddc6741be6..d49d654cb87 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -749,11 +749,12 @@ 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_supports_generate(table_type)) + if (!ha_supports_generate(table_type) || thd->lex->sphead) { /* Probably InnoDB table */ table_list->lock_type= TL_WRITE; ha_enable_transaction(thd, FALSE); + mysql_init_select(thd->lex); error= mysql_delete(thd, table_list, (COND*) 0, (SQL_LIST*) 0, HA_POS_ERROR, 0); ha_enable_transaction(thd, TRUE); diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index f328d31161a..81391dc920f 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -3191,7 +3191,7 @@ unsent_create_error: Don't allow this within a transaction because we want to use re-generate table */ - if (thd->locked_tables || thd->active_transaction()) + if ((thd->locked_tables && !lex->sphead) || thd->active_transaction()) { my_message(ER_LOCK_OR_ACTIVE_TRANSACTION, ER(ER_LOCK_OR_ACTIVE_TRANSACTION), MYF(0));