mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 12:02:42 +01:00
Bug#52711 Segfault when doing EXPLAIN SELECT with union...order by (select... where...)
backport from 5.1 mysql-test/r/subselect.result: backport from 5.1 mysql-test/t/subselect.test: backport from 5.1 sql/sql_select.cc: backport from 5.1
This commit is contained in:
parent
0a29baba4b
commit
50a3c55ee7
3 changed files with 40 additions and 2 deletions
|
@ -4527,4 +4527,20 @@ pk int_key
|
||||||
3 3
|
3 3
|
||||||
7 3
|
7 3
|
||||||
DROP TABLE t1,t2;
|
DROP TABLE t1,t2;
|
||||||
|
#
|
||||||
|
# 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.0 tests.
|
End of 5.0 tests.
|
||||||
|
|
|
@ -3506,5 +3506,26 @@ ORDER BY outr.pk;
|
||||||
|
|
||||||
DROP TABLE t1,t2;
|
DROP TABLE t1,t2;
|
||||||
|
|
||||||
|
--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.0 tests.
|
--echo End of 5.0 tests.
|
||||||
|
|
|
@ -501,7 +501,7 @@ JOIN::prepare(Item ***rref_pointer_array,
|
||||||
thd->lex->allow_sum_func= save_allow_sum_func;
|
thd->lex->allow_sum_func= save_allow_sum_func;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!thd->lex->view_prepare_mode)
|
if (!thd->lex->view_prepare_mode && !(select_options & SELECT_DESCRIBE))
|
||||||
{
|
{
|
||||||
Item_subselect *subselect;
|
Item_subselect *subselect;
|
||||||
/* Is it subselect? */
|
/* Is it subselect? */
|
||||||
|
@ -6861,7 +6861,8 @@ remove_const(JOIN *join,ORDER *first_order, COND *cond,
|
||||||
*simple_order=0; // Must do a temp table to sort
|
*simple_order=0; // Must do a temp table to sort
|
||||||
else if (!(order_tables & not_const_tables))
|
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);
|
order->item[0]->val_str(&order->item[0]->str_value);
|
||||||
DBUG_PRINT("info",("removing: %s", order->item[0]->full_name()));
|
DBUG_PRINT("info",("removing: %s", order->item[0]->full_name()));
|
||||||
continue; // skip const item
|
continue; // skip const item
|
||||||
|
|
Loading…
Reference in a new issue