diff options
author | Igor Babaev <igor@askmonty.org> | 2013-08-18 12:29:06 -0700 |
---|---|---|
committer | Igor Babaev <igor@askmonty.org> | 2013-08-18 12:29:06 -0700 |
commit | 7c85205d193dc8ecd8b2ce2796e271536f3b42b1 (patch) | |
tree | bec34ce98144ce63affeca27477ee934c41207a9 | |
parent | f0deff867a154879971560f83f62d96bb85140c0 (diff) | |
download | mariadb-git-7c85205d193dc8ecd8b2ce2796e271536f3b42b1.tar.gz |
Fixed bug mdev-4918.
The function SELECT_LEX::mark_const_derived() must take into account that
in DELETE ... RETURNING join == NULL.
-rw-r--r-- | mysql-test/r/delete_returning.result | 10 | ||||
-rw-r--r-- | mysql-test/t/delete_returning.test | 13 | ||||
-rw-r--r-- | sql/sql_lex.cc | 3 |
3 files changed, 25 insertions, 1 deletions
diff --git a/mysql-test/r/delete_returning.result b/mysql-test/r/delete_returning.result index 7cc551c23ed..fd66c3bb75d 100644 --- a/mysql-test/r/delete_returning.result +++ b/mysql-test/r/delete_returning.result @@ -233,3 +233,13 @@ DROP USER mysqltest_1@localhost; DROP VIEW v1; DROP TABLE t1,t2; 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; diff --git a/mysql-test/t/delete_returning.test b/mysql-test/t/delete_returning.test index 53c3ee23a75..3f40428e0ab 100644 --- a/mysql-test/t/delete_returning.test +++ b/mysql-test/t/delete_returning.test @@ -186,4 +186,17 @@ DROP VIEW v1; DROP TABLE t1,t2; 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 diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index fd18d2f6c52..18908abbfcd 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -4085,7 +4085,8 @@ void SELECT_LEX::increase_derived_records(ha_rows records) void SELECT_LEX::mark_const_derived(bool empty) { 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) increase_derived_records(1); |