Commit c7717d92 authored by Sergey Petrunya's avatar Sergey Petrunya

Automatic merge

parents f74c745a 8d8ad548
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;
#
# 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;
......@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment