diff options
author | unknown <sanja@askmonty.org> | 2011-07-21 23:37:40 +0300 |
---|---|---|
committer | unknown <sanja@askmonty.org> | 2011-07-21 23:37:40 +0300 |
commit | 813aaac51d2aaf0c582cbcd869fd48b948b90d66 (patch) | |
tree | dd0723f7e841410ec714d4e52510f807ceddf754 /sql/sql_view.cc | |
parent | c86ffc23ee737b258dc006669ccfb3600e6f4c2e (diff) | |
download | mariadb-git-813aaac51d2aaf0c582cbcd869fd48b948b90d66.tar.gz |
Fix for LP BUG#806071
In case of two views with subqueries it is dificult to decide about order of injected ORDER BY clauses.
A simple solution is just prohibit ORDER BY injection if there is other order by.
mysql-test/r/view.result:
New test added, old test changed.
mysql-test/t/view.test:
New test aded.
sql/share/errmsg.txt:
new warning added.
sql/sql_view.cc:
Inject ORDER BY only if there is no other one.
Warning about ignoring ORDER BY in this case for EXPLAIN EXTENDED.
Diffstat (limited to 'sql/sql_view.cc')
-rw-r--r-- | sql/sql_view.cc | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/sql/sql_view.cc b/sql/sql_view.cc index 89ccfd10a45..535cc30e3e8 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -1483,8 +1483,22 @@ bool mysql_make_view(THD *thd, File_parser *parser, TABLE_LIST *table, 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()) + if (!table->select_lex->master_unit()->is_union() && + table->select_lex->order_list.elements == 0) table->select_lex->order_list.push_back(&lex->select_lex.order_list); + else + { + if (old_lex->sql_command == SQLCOM_SELECT && + (old_lex->describe & DESCRIBE_EXTENDED) && + lex->select_lex.order_list.elements && + !table->select_lex->master_unit()->is_union()) + { + push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_NOTE, + ER_VIEW_ORDERBY_IGNORED, + ER(ER_VIEW_ORDERBY_IGNORED), + table->db, table->table_name); + } + } /* This SELECT_LEX will be linked in global SELECT_LEX list to make it processed by mysql_handle_derived(), |