From 1cf483aa588cf47383af49db6d7304b911ee92db Mon Sep 17 00:00:00 2001 From: Tor Didriksen Date: Wed, 4 May 2011 16:18:21 +0200 Subject: Bug#12329653 - EXPLAIN, UNION, PREPARED STATEMENT, CRASH, SQL_FULL_GROUP_BY The query was re-written *after* we had tagged it with NON_AGG_FIELD_USED. Remove the flag before continuing. mysql-test/r/explain.result: Update test case for Bug#48295. mysql-test/r/subselect.result: New test case. mysql-test/t/explain.test: Update test case for Bug#48295. mysql-test/t/subselect.test: New test case. sql/item.cc: Use accessor functions for non_agg_field_used/agg_func_used. sql/item_subselect.cc: Remove non_agg_field_used when we rewrite query '1 < some (...)' => '1 < max(...)' sql/item_sum.cc: Use accessor functions for non_agg_field_used/agg_func_used. sql/mysql_priv.h: Remove unused #defines. sql/sql_lex.cc: Initialize new member variables. sql/sql_lex.h: Replace full_group_by_flag with two boolean flags, and itroduce accessors for manipulating them. sql/sql_select.cc: Use accessor functions for non_agg_field_used/agg_func_used. --- mysql-test/t/subselect.test | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'mysql-test/t/subselect.test') diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test index 0956f91619d..b4cee13d3ac 100644 --- a/mysql-test/t/subselect.test +++ b/mysql-test/t/subselect.test @@ -3506,6 +3506,40 @@ ORDER BY outr.pk; DROP TABLE t1,t2; +--echo # +--echo # Bug#12329653 +--echo # EXPLAIN, UNION, PREPARED STATEMENT, CRASH, SQL_FULL_GROUP_BY +--echo # + +CREATE TABLE t1(a1 int); +INSERT INTO t1 VALUES (1),(2); + +SELECT @@session.sql_mode INTO @old_sql_mode; +SET SESSION sql_mode='ONLY_FULL_GROUP_BY'; + +## First a simpler query, illustrating the transformation +## '1 < some (...)' => '1 < max(...)' +SELECT 1 FROM t1 WHERE 1 < SOME (SELECT a1 FROM t1); + +## The query which made the server crash. +PREPARE stmt FROM +'SELECT 1 UNION ALL +SELECT 1 FROM t1 +ORDER BY +(SELECT 1 FROM t1 AS t1_0 + WHERE 1 < SOME (SELECT a1 FROM t1) +)' ; + +--error ER_SUBQUERY_NO_1_ROW +EXECUTE stmt ; +--error ER_SUBQUERY_NO_1_ROW +EXECUTE stmt ; + +SET SESSION sql_mode=@old_sql_mode; + +DEALLOCATE PREPARE stmt; +DROP TABLE t1; + --echo # --echo # Bug #52711: Segfault when doing EXPLAIN SELECT with --echo # union...order by (select... where...) -- cgit v1.2.1