summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Babaev <igor@askmonty.org>2013-11-13 15:31:12 -0800
committerIgor Babaev <igor@askmonty.org>2013-11-13 15:31:12 -0800
commit222acc635b147ad591107bcdb945926f611d3781 (patch)
tree1e9efa2695b98449dc4dc92bf0a7232c8b75815a
parente4608eb3c161709df8d81dfba98ef67a4957d3ee (diff)
parentae40c7207760ea6c829a6bdbbabc1e19941f1240 (diff)
downloadmariadb-git-222acc635b147ad591107bcdb945926f611d3781.tar.gz
Merge
-rw-r--r--mysql-test/r/union.result15
-rw-r--r--mysql-test/t/union.test19
-rw-r--r--sql/sql_lex.cc2
3 files changed, 35 insertions, 1 deletions
diff --git a/mysql-test/r/union.result b/mysql-test/r/union.result
index 13941d3f84d..05dab9e2874 100644
--- a/mysql-test/r/union.result
+++ b/mysql-test/r/union.result
@@ -1724,3 +1724,18 @@ foo
1
deallocate prepare stmt1;
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
diff --git a/mysql-test/t/union.test b/mysql-test/t/union.test
index fefd67fd2f7..bb0e5610a26 100644
--- a/mysql-test/t/union.test
+++ b/mysql-test/t/union.test
@@ -1210,3 +1210,22 @@ execute stmt1;
deallocate prepare stmt1;
--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
+
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index 6f34dd23f36..e8c795e9c54 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -3534,7 +3534,7 @@ void SELECT_LEX::update_used_tables()
}
for (ORDER *order= group_list.first; order; order= order->next)
(*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)
(*order->item)->update_used_tables();