summaryrefslogtreecommitdiff
path: root/mysql-test/t/sp-threads.test
diff options
context:
space:
mode:
authorunknown <dlenev@brandersnatch.localdomain>2005-06-09 01:07:52 +0400
committerunknown <dlenev@brandersnatch.localdomain>2005-06-09 01:07:52 +0400
commit4e0bbc1b6eb6716a0774a1678be24b4a2463b8c9 (patch)
tree5f8aa229b96ac3ed689847d17b87a35fd44cff21 /mysql-test/t/sp-threads.test
parent0bc3c6221cbaae56ba444e06603c4afbf11f685e (diff)
downloadmariadb-git-4e0bbc1b6eb6716a0774a1678be24b4a2463b8c9.tar.gz
Fix for bug #11158 "Can't perform multi-delete in stored procedure".
In order to make multi-delete SP friendly we need to have all table locks for the elements of main statement table list properly set at the end of parsing. Also performed small cleanup: We don't need relink_tables_for_multidelete() any longer since the only case now when TABLE_LIST::correspondent_table is non-zero are tables in auxilary table list of multi-delete and these tables are handled specially in mysql_multi_delete_prepare(). mysql-test/r/sp-threads.result: Added test case for bug #11158 "Can't perform multi-delete in stored procedure". mysql-test/t/sp-threads.test: Added test case for bug #11158 "Can't perform multi-delete in stored procedure". sql/mysql_priv.h: - Removed third argument from the declaration of multi_delete_precheck() as nowdays we calculate number of tables in multi-delete from which we are going to delete rows right at the end of statement parsing. - Introduced definition of multi_delete_set_locks_and_link_aux_tables() which is responsible for propagation of proper table locks from multi-delete's auxilary table list to the main list and binding corresponding tables in these two lists. sql/sql_base.cc: Removed relink_tables_for_multidelete() routine and its invocations. We don't need them in 5.0 since the only case now when TABLE_LIST::correspondent_table is non-zero are tables in auxilary table list of multi-delete and these tables are handled specially in mysql_multi_delete_prepare(). sql/sql_lex.h: LEX::table_count Added description of new role of this LEX member for multi-delete. Now for this statement we store number of tables from which we should delete records there. sql/sql_parse.cc: multi_delete_precheck(): Moved code which is responsible for iterating through auxilary table list and binding its elements with corresponding elements of main table list, and properly updating locks in it to separate function - multi_delete_set_locks_and_link_aux_tables(). This is because in order to make multi-delete SP friendly we need to have all locks set properly at the end of statement parsing. So we are introducing new function which will be called from parser. We also calculate number of tables from which we are going to perform deletions there and store this number for later usage in LEX::table_count. Also removed some no longer needed code. sql/sql_prepare.cc: mysql_test_multidelete(): Now multi_delete_precheck() takes only two arguments, so we don't need to pass fake third parameter. sql/sql_yacc.yy: delete: In order to make multi-delete SP friendly we need to have all table locks for the elements of main statement table list properly set at the end of parsing.
Diffstat (limited to 'mysql-test/t/sp-threads.test')
-rw-r--r--mysql-test/t/sp-threads.test26
1 files changed, 26 insertions, 0 deletions
diff --git a/mysql-test/t/sp-threads.test b/mysql-test/t/sp-threads.test
index 608ac3e2ee7..8fec5d14bc1 100644
--- a/mysql-test/t/sp-threads.test
+++ b/mysql-test/t/sp-threads.test
@@ -84,6 +84,32 @@ reap;
drop procedure bug9486;
drop table t1, t2;
+#
+# BUG#11158: Can't perform multi-delete in stored procedure
+#
+--disable_warnings
+drop procedure if exists bug11158;
+--enable_warnings
+create procedure bug11158() delete t1 from t1, t2 where t1.id = t2.id;
+create table t1 (id int, j int);
+insert into t1 values (1, 1), (2, 2);
+create table t2 (id int);
+insert into t2 values (1);
+# Procedure should work and cause proper effect (delete only first row)
+call bug11158();
+select * from t1;
+# Also let us test that we obtain only read (and thus non exclusive) lock
+# for table from which we are not going to delete rows.
+connection con2root;
+lock tables t2 read;
+connection con1root;
+call bug11158();
+connection con2root;
+unlock tables;
+connection con1root;
+# Clean-up
+drop procedure bug11158;
+drop table t1, t2;
#
# BUG#NNNN: New bug synopsis