summaryrefslogtreecommitdiff
path: root/sql/sql_view.cc
diff options
context:
space:
mode:
authorgkodinov/kgeorge@magare.gmz <>2007-04-20 10:49:45 +0300
committergkodinov/kgeorge@magare.gmz <>2007-04-20 10:49:45 +0300
commit4c89a5960fbd73c684b9f8d3a07ee8d78436b732 (patch)
treef2618b562d1def306f97b055790d0a9b303eb66f /sql/sql_view.cc
parent6ad81b4e1325e727e9d218b1783f5891f7ff0405 (diff)
downloadmariadb-git-4c89a5960fbd73c684b9f8d3a07ee8d78436b732.tar.gz
Bug #27786:
When merging views into the enclosing statement the ORDER BY clause of the view is merged to the parent's ORDER BY clause. However when the VIEW is merged into an UNION branch the ORDER BY should be ignored. Use of ORDER BY for individual SELECT statements implies nothing about the order in which the rows appear in the final result because UNION by default produces unordered set of rows. Fixed by ignoring the ORDER BY clause from the merge view when expanded in an UNION branch.
Diffstat (limited to 'sql/sql_view.cc')
-rw-r--r--sql/sql_view.cc9
1 files changed, 7 insertions, 2 deletions
diff --git a/sql/sql_view.cc b/sql/sql_view.cc
index 83beec3d1be..95dec40450f 100644
--- a/sql/sql_view.cc
+++ b/sql/sql_view.cc
@@ -1263,13 +1263,18 @@ bool mysql_make_view(THD *thd, File_parser *parser, TABLE_LIST *table,
unit->slave= save_slave; // fix include_down initialisation
}
+ /*
+ We can safely ignore the VIEW's ORDER BY if we merge into union
+ branch, as order is not important there.
+ */
+ if (!table->select_lex->master_unit()->is_union())
+ table->select_lex->order_list.push_back(&lex->select_lex.order_list);
/*
This SELECT_LEX will be linked in global SELECT_LEX list
to make it processed by mysql_handle_derived(),
but it will not be included to SELECT_LEX tree, because it
will not be executed
- */
- table->select_lex->order_list.push_back(&lex->select_lex.order_list);
+ */
goto ok;
}