diff options
author | Georgi Kodinov <Georgi.Kodinov@Oracle.com> | 2010-06-25 16:20:22 +0300 |
---|---|---|
committer | Georgi Kodinov <Georgi.Kodinov@Oracle.com> | 2010-06-25 16:20:22 +0300 |
commit | 2b2e09086cf2b2fcbe32b2555ef51d52481487da (patch) | |
tree | 28538bb1c31b321181e20d14b1b17dba7b28b452 | |
parent | 700f8add127dbb6f566e95ea1dd682c054d75c9c (diff) | |
parent | a8ae3cd6e9bf1713ec9508e7639f936c0b97316a (diff) | |
download | mariadb-git-2b2e09086cf2b2fcbe32b2555ef51d52481487da.tar.gz |
merge
-rw-r--r-- | mysql-test/r/subselect.result | 17 | ||||
-rw-r--r-- | mysql-test/t/subselect.test | 25 | ||||
-rw-r--r-- | sql/sql_select.cc | 3 |
3 files changed, 44 insertions, 1 deletions
diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result index d767e741c4d..47a89897daf 100644 --- a/mysql-test/r/subselect.result +++ b/mysql-test/r/subselect.result @@ -4717,3 +4717,20 @@ t1_id total_amount DROP TABLE t3; DROP TABLE t2; DROP TABLE t1; +# +# Bug #52711: Segfault when doing EXPLAIN SELECT with +# union...order by (select... where...) +# +CREATE TABLE t1 (a VARCHAR(10), FULLTEXT KEY a (a)); +INSERT INTO t1 VALUES (1),(2); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1),(2); +# Should not crash +EXPLAIN +SELECT * FROM t2 UNION SELECT * FROM t2 +ORDER BY (SELECT * FROM t1 WHERE MATCH(a) AGAINST ('+abc' IN BOOLEAN MODE)); +# Should not crash +SELECT * FROM t2 UNION SELECT * FROM t2 +ORDER BY (SELECT * FROM t1 WHERE MATCH(a) AGAINST ('+abc' IN BOOLEAN MODE)); +DROP TABLE t1,t2; +End of 5.1 tests diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test index c58faf60010..1f471b46c4e 100644 --- a/mysql-test/t/subselect.test +++ b/mysql-test/t/subselect.test @@ -3701,3 +3701,28 @@ GROUP BY DROP TABLE t3; DROP TABLE t2; DROP TABLE t1; + + +--echo # +--echo # Bug #52711: Segfault when doing EXPLAIN SELECT with +--echo # union...order by (select... where...) +--echo # + +CREATE TABLE t1 (a VARCHAR(10), FULLTEXT KEY a (a)); +INSERT INTO t1 VALUES (1),(2); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1),(2); + +--echo # Should not crash +--disable_result_log +EXPLAIN +SELECT * FROM t2 UNION SELECT * FROM t2 + ORDER BY (SELECT * FROM t1 WHERE MATCH(a) AGAINST ('+abc' IN BOOLEAN MODE)); + +--echo # Should not crash +SELECT * FROM t2 UNION SELECT * FROM t2 + ORDER BY (SELECT * FROM t1 WHERE MATCH(a) AGAINST ('+abc' IN BOOLEAN MODE)); +DROP TABLE t1,t2; +--enable_result_log + +--echo End of 5.1 tests diff --git a/sql/sql_select.cc b/sql/sql_select.cc index c9cca2e601f..b61f7d1eb37 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -7238,7 +7238,8 @@ remove_const(JOIN *join,ORDER *first_order, COND *cond, *simple_order=0; // Must do a temp table to sort else if (!(order_tables & not_const_tables)) { - if (order->item[0]->with_subselect) + if (order->item[0]->with_subselect && + !(join->select_lex->options & SELECT_DESCRIBE)) order->item[0]->val_str(&order->item[0]->str_value); DBUG_PRINT("info",("removing: %s", order->item[0]->full_name())); continue; // skip const item |