summaryrefslogtreecommitdiff
path: root/sql/sql_parse.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/sql_parse.cc')
-rw-r--r--sql/sql_parse.cc17
1 files changed, 17 insertions, 0 deletions
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 5e58ceb9621..f7eed09c789 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -6932,11 +6932,28 @@ mysql_new_select(LEX *lex, bool move_down)
}
else
{
+ bool const outer_most= (lex->current_select->master_unit() == &lex->unit);
+ if (outer_most && lex->result)
+ {
+ my_error(ER_WRONG_USAGE, MYF(0), "UNION", "INTO");
+ DBUG_RETURN(TRUE);
+ }
+ if (lex->proc_list.elements!=0)
+ {
+ my_error(ER_WRONG_USAGE, MYF(0), "UNION",
+ "SELECT ... PROCEDURE ANALYSE()");
+ DBUG_RETURN(TRUE);
+ }
if (lex->current_select->order_list.first && !lex->current_select->braces)
{
my_error(ER_WRONG_USAGE, MYF(0), "UNION", "ORDER BY");
DBUG_RETURN(1);
}
+ if (lex->current_select->explicit_limit && !lex->current_select->braces)
+ {
+ my_error(ER_WRONG_USAGE, MYF(0), "UNION", "LIMIT");
+ DBUG_RETURN(1);
+ }
select_lex->include_neighbour(lex->current_select);
SELECT_LEX_UNIT *unit= select_lex->master_unit();
if (!unit->fake_select_lex && unit->add_fake_select_lex(lex->thd))