[Commits] Rev 3682: MDEV-4919: Packets out of order on a SELECT after calling a procedure with DELETE .. RETURNING in file:///data0/psergey/dev2/10.0-base/

Sergey Petrunya psergey at askmonty.org
Wed Aug 21 12:51:22 EEST 2013


At file:///data0/psergey/dev2/10.0-base/

------------------------------------------------------------
revno: 3682
revision-id: psergey at askmonty.org-20130821095121-xfdgdft1264b046p
parent: timour at askmonty.org-20130821075108-33rptvhha6vfjzd8
committer: Sergey Petrunya <psergey at askmonty.org>
branch nick: 10.0-base
timestamp: Wed 2013-08-21 13:51:21 +0400
message:
  MDEV-4919: Packets out of order on a SELECT after calling a procedure with DELETE .. RETURNING
  - Let sp_get_flags_for_command() set sp_head::MULTI_RESULTS for DELETE ... RETURNING, 
    like it does for all statements that return a resultset.
=== modified file 'mysql-test/r/delete_returning.result'
--- a/mysql-test/r/delete_returning.result	2013-08-18 19:29:06 +0000
+++ b/mysql-test/r/delete_returning.result	2013-08-21 09:51:21 +0000
@@ -1,3 +1,6 @@
+drop table if exists t1,t2;
+drop view if exists v1;
+drop procedure if exists p1;
 CREATE TABLE t1 (a int, b varchar(32));
 INSERT INTO t1 VALUES
 (7,'ggggggg'), (1,'a'), (3,'ccc'),
@@ -243,3 +246,22 @@ INSERT INTO t2 VALUES (1),(2);
 DELETE FROM t1 ORDER BY i1 RETURNING ( SELECT i2 FROM t2 );
 ERROR 21000: Subquery returns more than 1 row
 DROP TABLE t1,t2;
+#
+# MDEV-4919: Packets out of order on a SELECT after calling a procedure with DELETE .. RETURNING
+#
+CREATE TABLE t1 (i INT);
+INSERT INTO t1 VALUES (1),(2);
+CREATE PROCEDURE p1 (a INT) 
+BEGIN
+DELETE FROM t1 WHERE i = a RETURNING *;
+INSERT INTO t1 VALUES (a);
+END |
+CALL p1(1);
+i
+1
+SELECT * FROM t1;
+i
+1
+2
+DROP PROCEDURE p1;
+DROP TABLE t1;

=== modified file 'mysql-test/t/delete_returning.test'
--- a/mysql-test/t/delete_returning.test	2013-08-18 19:29:06 +0000
+++ b/mysql-test/t/delete_returning.test	2013-08-21 09:51:21 +0000
@@ -1,6 +1,11 @@
 #
 #  Tests for DELETE FROM <table> ... RETURNING <expr>,...
 # 
+--disable_warnings
+drop table if exists t1,t2;
+drop view if exists v1;
+drop procedure if exists p1;
+--enable_warnings
 
 CREATE TABLE t1 (a int, b varchar(32));
 INSERT INTO t1 VALUES
@@ -199,4 +204,23 @@ INSERT INTO t2 VALUES (1),(2);
 --error ER_SUBQUERY_NO_1_ROW
 DELETE FROM t1 ORDER BY i1 RETURNING ( SELECT i2 FROM t2 );
 
-DROP TABLE t1,t2;
\ No newline at end of file
+DROP TABLE t1,t2;
+
+--echo #
+--echo # MDEV-4919: Packets out of order on a SELECT after calling a procedure with DELETE .. RETURNING
+--echo #
+CREATE TABLE t1 (i INT);
+INSERT INTO t1 VALUES (1),(2);
+--delimiter |
+CREATE PROCEDURE p1 (a INT) 
+BEGIN
+  DELETE FROM t1 WHERE i = a RETURNING *;
+  INSERT INTO t1 VALUES (a);
+END |
+--delimiter ;
+
+CALL p1(1);
+SELECT * FROM t1;
+DROP PROCEDURE p1;
+DROP TABLE t1;
+

=== modified file 'sql/sp_head.cc'
--- a/sql/sp_head.cc	2013-06-07 08:10:45 +0000
+++ b/sql/sp_head.cc	2013-08-21 09:51:21 +0000
@@ -312,6 +312,17 @@ sp_get_flags_for_command(LEX *lex)
   case SQLCOM_UNINSTALL_PLUGIN:
     flags= sp_head::HAS_COMMIT_OR_ROLLBACK;
     break;
+  case SQLCOM_DELETE:
+  {
+    if (lex->select_lex.item_list.is_empty())
+      flags= 0;
+    else
+    {
+      /* This is DELETE ... RETURNING ...  */
+      flags= sp_head::MULTI_RESULTS; 
+    }
+    break;
+  }
   default:
     flags= 0;
     break;



More information about the commits mailing list