Commit 7c85205d authored by Igor Babaev's avatar Igor Babaev

Fixed bug mdev-4918.

The function SELECT_LEX::mark_const_derived() must take into account that
in DELETE ... RETURNING join == NULL.
parent f0deff86
...@@ -233,3 +233,13 @@ DROP USER mysqltest_1@localhost; ...@@ -233,3 +233,13 @@ DROP USER mysqltest_1@localhost;
DROP VIEW v1; DROP VIEW v1;
DROP TABLE t1,t2; DROP TABLE t1,t2;
DROP TABLE t1c,t2c; DROP TABLE t1c,t2c;
#
# Bug mdev-4918: DELETE ... RETURNING subquery with more than 1 row
#
CREATE TABLE t1 (i1 int);
INSERT INTO t1 VALUES (1),(2);
CREATE TABLE t2 (i2 int);
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;
...@@ -186,4 +186,17 @@ DROP VIEW v1; ...@@ -186,4 +186,17 @@ DROP VIEW v1;
DROP TABLE t1,t2; DROP TABLE t1,t2;
DROP TABLE t1c,t2c; DROP TABLE t1c,t2c;
--echo #
--echo # Bug mdev-4918: DELETE ... RETURNING subquery with more than 1 row
--echo #
CREATE TABLE t1 (i1 int);
INSERT INTO t1 VALUES (1),(2);
CREATE TABLE t2 (i2 int);
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
...@@ -4085,7 +4085,8 @@ void SELECT_LEX::increase_derived_records(ha_rows records) ...@@ -4085,7 +4085,8 @@ void SELECT_LEX::increase_derived_records(ha_rows records)
void SELECT_LEX::mark_const_derived(bool empty) void SELECT_LEX::mark_const_derived(bool empty)
{ {
TABLE_LIST *derived= master_unit()->derived; TABLE_LIST *derived= master_unit()->derived;
if (!join->thd->lex->describe && derived) /* join == NULL in DELETE ... RETURNING */
if (!(join && join->thd->lex->describe) && derived)
{ {
if (!empty) if (!empty)
increase_derived_records(1); increase_derived_records(1);
......
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