From 2fc5d274e875fdcc00a3ee03835f0f964e63dc49 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 5 Mar 2005 21:44:15 +0200 Subject: [PATCH 1/4] Fixing bug #8850 in such a way that when TRUNCATE is called within stored procedure, it is converted to DELETE. mysql-test/r/sp.result: A result for the test case for bug #8850 mysql-test/t/sp.test: A test case for the bug #8850 sql/sql_delete.cc: A fix for bug #8850, plus adding a missing call to mysql_init_select(), which caused mem_root corruption. sql/sql_parse.cc: A fix for the bug #8850 BitKeeper/etc/ignore: Added acinclude.m4 to the ignore list --- .bzrignore | 1 + mysql-test/r/sp.result | 21 +++++++++++++++++++++ mysql-test/t/sp.test | 24 ++++++++++++++++++++++++ sql/sql_delete.cc | 3 ++- sql/sql_parse.cc | 2 +- 5 files changed, 49 insertions(+), 2 deletions(-) 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 b4198a5f467..8a549b57189 100644 --- a/mysql-test/r/sp.result +++ b/mysql-test/r/sp.result @@ -2538,3 +2538,24 @@ drop procedure bug7992| drop table t3| drop table t1; drop table t2; +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 +| +begin; +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; +select * from t1; +a +2 +call sp1(); +select * from t1; +a +1 +drop table t1; +drop procedure sp1; diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test index cfb5de7ddd0..61287e94a6f 100644 --- a/mysql-test/t/sp.test +++ b/mysql-test/t/sp.test @@ -3073,3 +3073,27 @@ delimiter ;| drop table t1; drop table t2; +# +# 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 ;| +begin; +insert t1 values (2); +--error 1192 +call sp1(); +commit; +select * from t1; +call sp1(); +select * from t1; +drop table t1; +drop procedure sp1; 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 2f38f96c976..b093a9d94e5 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -3312,7 +3312,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)); From 50985b6783d544c6eeae9066fd6e2e1526547412 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 8 Mar 2005 13:15:36 -0600 Subject: [PATCH 2/4] changelog-5.0.xml: Add dummy changelog file. It should merge upward without conflict. --- Docs/changelog-5.0.xml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100755 Docs/changelog-5.0.xml diff --git a/Docs/changelog-5.0.xml b/Docs/changelog-5.0.xml new file mode 100755 index 00000000000..deb059716ad --- /dev/null +++ b/Docs/changelog-5.0.xml @@ -0,0 +1,18 @@ + + + + + + + Changes in release 5.0.x + + + + This is a dummy changelog file. Don't use it yet. + + + From 39c32324d65b7513df3b7232196a7ae25c488312 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 8 Mar 2005 22:44:35 +0200 Subject: [PATCH 3/4] making a better test case for bug #8850 mysql-test/r/sp.result: fixing results for new test mysql-test/t/sp.test: making a new test with autocommit set to 0 and 1. Second CALL is in autocommit mode to prove that the relevant bug (bug #8550) is fixed. --- mysql-test/r/sp.result | 3 ++- mysql-test/t/sp.test | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result index 8a549b57189..df3191911fd 100644 --- a/mysql-test/r/sp.result +++ b/mysql-test/r/sp.result @@ -2545,11 +2545,12 @@ begin truncate table t1; insert t1 values (1); rollback; end | -begin; +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 diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test index 61287e94a6f..55d0a95d36f 100644 --- a/mysql-test/t/sp.test +++ b/mysql-test/t/sp.test @@ -3087,11 +3087,12 @@ begin end | delimiter ;| -begin; +set autocommit=0; insert t1 values (2); --error 1192 call sp1(); commit; +set autocommit=1; select * from t1; call sp1(); select * from t1; From 1250899c0d9246599d34877119ba2168a539d659 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 9 Mar 2005 00:09:18 +0200 Subject: [PATCH 4/4] Fixing post-merge errors --- mysql-test/r/sp.result | 46 +++++++++++++++++------------------ mysql-test/t/sp.test | 55 +++++++++++++++++++++--------------------- 2 files changed, 49 insertions(+), 52 deletions(-) diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result index 2965c6583f2..acfc5797110 100644 --- a/mysql-test/r/sp.result +++ b/mysql-test/r/sp.result @@ -2697,30 +2697,6 @@ 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 @@ -2780,3 +2756,25 @@ a drop procedure bug8937| delete from t1| drop table t1,t2; +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; diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test index 8766c730090..14c6f2d0694 100644 --- a/mysql-test/t/sp.test +++ b/mysql-test/t/sp.test @@ -3277,34 +3277,6 @@ 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 @@ -3312,6 +3284,7 @@ drop procedure sp1; # Rolling back changes to AND/OR structure of ON and WHERE clauses in SP # +delimiter |; create table t3 ( lpitnumber int(11) default null, lrecordtype int(11) default null @@ -3387,3 +3360,29 @@ delete from t1| # practical, or create table t3, t3 etc temporarily (and drop them). delimiter ;| drop table t1,t2; + +# +# 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;