Commit ae40c720 authored by Igor Babaev's avatar Igor Babaev

Fixed bug mdev-5091.

The function SELECT_LEX::update_used_tables should process all
ORDER BY lists in any subselect of a union.
parent 441192bf
...@@ -1724,3 +1724,18 @@ foo ...@@ -1724,3 +1724,18 @@ foo
1 1
deallocate prepare stmt1; deallocate prepare stmt1;
End of 5.1 tests End of 5.1 tests
#
# mdev-5091: Asseirtion failure for UNION with ORDER BY
# in one of selects
#
CREATE TABLE t1 (i int, c char(1)) ENGINE=MyISAM;
INSERT INTO t1 VALUES (6,'b');
CREATE VIEW v1 AS SELECT * FROM t1;
( SELECT i FROM v1 GROUP BY i ORDER BY CONCAT( c, c ) LIMIT 1 )
UNION
( SELECT i FROM t1 );
i
6
DROP VIEW v1;
DROP TABLE t1;
End of 5.3 tests
...@@ -1210,3 +1210,22 @@ execute stmt1; ...@@ -1210,3 +1210,22 @@ execute stmt1;
deallocate prepare stmt1; deallocate prepare stmt1;
--echo End of 5.1 tests --echo End of 5.1 tests
--echo #
--echo # mdev-5091: Asseirtion failure for UNION with ORDER BY
--echo # in one of selects
--echo #
CREATE TABLE t1 (i int, c char(1)) ENGINE=MyISAM;
INSERT INTO t1 VALUES (6,'b');
CREATE VIEW v1 AS SELECT * FROM t1;
( SELECT i FROM v1 GROUP BY i ORDER BY CONCAT( c, c ) LIMIT 1 )
UNION
( SELECT i FROM t1 );
DROP VIEW v1;
DROP TABLE t1;
--echo End of 5.3 tests
...@@ -3534,7 +3534,7 @@ void SELECT_LEX::update_used_tables() ...@@ -3534,7 +3534,7 @@ void SELECT_LEX::update_used_tables()
} }
for (ORDER *order= group_list.first; order; order= order->next) for (ORDER *order= group_list.first; order; order= order->next)
(*order->item)->update_used_tables(); (*order->item)->update_used_tables();
if (!master_unit()->is_union()) if (master_unit()->global_parameters != this)
{ {
for (ORDER *order= order_list.first; order; order= order->next) for (ORDER *order= order_list.first; order; order= order->next)
(*order->item)->update_used_tables(); (*order->item)->update_used_tables();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment