From b5ae1327f73af7e893bf6415a74d633739fa903b Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Thu, 25 Feb 2010 16:57:15 +0200 Subject: Backport of the fix for bug #49552 to 5.0-bugteam --- mysql-test/r/delete.result | 12 ++++++++++++ mysql-test/t/delete.test | 15 +++++++++++++++ sql/sql_parse.cc | 4 ++-- 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/delete.result b/mysql-test/r/delete.result index a682d90fbf7..d3cf69279fd 100644 --- a/mysql-test/r/delete.result +++ b/mysql-test/r/delete.result @@ -241,4 +241,16 @@ DELETE FROM t1 ORDER BY (f1(10)) LIMIT 1; ERROR 42000: Incorrect number of arguments for FUNCTION test.f1; expected 0, got 1 DROP TABLE t1; DROP FUNCTION f1; +# +# Bug #49552 : sql_buffer_result cause crash + not found records +# in multitable delete/subquery +# +CREATE TABLE t1(a INT); +INSERT INTO t1 VALUES (1),(2),(3); +SET SESSION SQL_BUFFER_RESULT=1; +DELETE t1 FROM (SELECT SUM(a) a FROM t1) x,t1; +SET SESSION SQL_BUFFER_RESULT=DEFAULT; +SELECT * FROM t1; +a +DROP TABLE t1; End of 5.0 tests diff --git a/mysql-test/t/delete.test b/mysql-test/t/delete.test index ec70587c9d1..d9091c92a52 100644 --- a/mysql-test/t/delete.test +++ b/mysql-test/t/delete.test @@ -247,4 +247,19 @@ DELETE FROM t1 ORDER BY (f1(10)) LIMIT 1; DROP TABLE t1; DROP FUNCTION f1; + +--echo # +--echo # Bug #49552 : sql_buffer_result cause crash + not found records +--echo # in multitable delete/subquery +--echo # + +CREATE TABLE t1(a INT); +INSERT INTO t1 VALUES (1),(2),(3); +SET SESSION SQL_BUFFER_RESULT=1; +DELETE t1 FROM (SELECT SUM(a) a FROM t1) x,t1; + +SET SESSION SQL_BUFFER_RESULT=DEFAULT; +SELECT * FROM t1; +DROP TABLE t1; + --echo End of 5.0 tests diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 61c2d70a563..64d6888d772 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -4009,9 +4009,9 @@ end_with_restore_list: select_lex->where, 0, (ORDER *)NULL, (ORDER *)NULL, (Item *)NULL, (ORDER *)NULL, - select_lex->options | thd->options | + (select_lex->options | thd->options | SELECT_NO_JOIN_CACHE | SELECT_NO_UNLOCK | - OPTION_SETUP_TABLES_DONE, + OPTION_SETUP_TABLES_DONE) & ~OPTION_BUFFER_RESULT, del_result, unit, select_lex); res|= thd->net.report_error; if (unlikely(res)) -- cgit v1.2.1