diff options
author | Sergei Golubchik <serg@mariadb.org> | 2015-10-06 12:07:58 +0200 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2015-10-06 19:09:38 +0200 |
commit | 0b88441127d92a6c184dbc34109ed539b53a2d59 (patch) | |
tree | ef5b9a9c403d903e16a7f9ac5056f140425fb1b8 | |
parent | dce289aabcfb0047c3d459bcac340472f0da7cba (diff) | |
download | mariadb-git-MDEV-8909.tar.gz |
wipMDEV-8909
-rw-r--r-- | mysql-test/r/parser.result | 16 | ||||
-rw-r--r-- | mysql-test/t/parser.test | 14 | ||||
-rw-r--r-- | sql/sql_yacc.yy | 47 |
3 files changed, 32 insertions, 45 deletions
diff --git a/mysql-test/r/parser.result b/mysql-test/r/parser.result index 48ea8128194..996b814d738 100644 --- a/mysql-test/r/parser.result +++ b/mysql-test/r/parser.result @@ -821,49 +821,49 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp SELECT (SELECT 1 FROM t1 ORDER BY 1 UNION SELECT 1 FROM t1); ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'UNION SELECT 1 FROM t1)' at line 1 SELECT 1 FROM (SELECT 1 FROM t1 ORDER BY 1 UNION SELECT 1 FROM t1) a; -ERROR HY000: Incorrect usage of UNION and ORDER BY +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'UNION SELECT 1 FROM t1) a' at line 1 SELECT 1 FROM t1 LIMIT 1 UNION SELECT 1 FROM t1; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'UNION SELECT 1 FROM t1' at line 1 SELECT (SELECT 1 FROM t1 LIMIT 1 UNION SELECT 1 FROM t1); ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'UNION SELECT 1 FROM t1)' at line 1 SELECT 1 FROM (SELECT 1 FROM t1 LIMIT 1 UNION SELECT 1 FROM t1) a; -ERROR HY000: Incorrect usage of UNION and LIMIT +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'UNION SELECT 1 FROM t1) a' at line 1 SELECT 1 FROM t1 ORDER BY 1 LIMIT 1 UNION SELECT 1 FROM t1; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'UNION SELECT 1 FROM t1' at line 1 SELECT (SELECT 1 FROM t1 ORDER BY 1 LIMIT 1 UNION SELECT 1 FROM t1); ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'UNION SELECT 1 FROM t1)' at line 1 SELECT 1 FROM (SELECT 1 FROM t1 ORDER BY 1 LIMIT 1 UNION SELECT 1 FROM t1) a; -ERROR HY000: Incorrect usage of UNION and ORDER BY +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'UNION SELECT 1 FROM t1) a' at line 1 SELECT 1 FROM t1 LIMIT 1 ORDER BY 1 UNION SELECT 1 FROM t1; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'ORDER BY 1 UNION SELECT 1 FROM t1' at line 1 SELECT (SELECT 1 FROM t1 LIMIT 1 ORDER BY 1 UNION SELECT 1 FROM t1); ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'ORDER BY 1 UNION SELECT 1 FROM t1)' at line 1 SELECT 1 FROM (SELECT 1 FROM t1 LIMIT 1 ORDER BY 1 UNION SELECT 1 FROM t1) a; -ERROR HY000: Incorrect usage of UNION and ORDER BY +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'ORDER BY 1 UNION SELECT 1 FROM t1) a' at line 1 SELECT 1 FROM t1 ORDER BY 1 UNION SELECT 1 FROM t1 ORDER BY 1; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'UNION SELECT 1 FROM t1 ORDER BY 1' at line 1 SELECT (SELECT 1 FROM t1 ORDER BY 1 UNION SELECT 1 FROM t1 ORDER BY 1); ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'UNION SELECT 1 FROM t1 ORDER BY 1)' at line 1 SELECT 1 FROM (SELECT 1 FROM t1 ORDER BY 1 UNION SELECT 1 FROM t1 ORDER BY 1) a; -ERROR HY000: Incorrect usage of UNION and ORDER BY +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'UNION SELECT 1 FROM t1 ORDER BY 1) a' at line 1 SELECT 1 FROM t1 LIMIT 1 UNION SELECT 1 FROM t1 LIMIT 1; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'UNION SELECT 1 FROM t1 LIMIT 1' at line 1 SELECT (SELECT 1 FROM t1 LIMIT 1 UNION SELECT 1 FROM t1 LIMIT 1); ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'UNION SELECT 1 FROM t1 LIMIT 1)' at line 1 SELECT 1 FROM (SELECT 1 FROM t1 LIMIT 1 UNION SELECT 1 FROM t1 LIMIT 1) a; -ERROR HY000: Incorrect usage of UNION and LIMIT +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'UNION SELECT 1 FROM t1 LIMIT 1) a' at line 1 SELECT 1 FROM t1 LIMIT 1 UNION SELECT 1 FROM t1 ORDER BY 1; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'UNION SELECT 1 FROM t1 ORDER BY 1' at line 1 SELECT (SELECT 1 FROM t1 LIMIT 1 UNION SELECT 1 FROM t1 ORDER BY 1); ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'UNION SELECT 1 FROM t1 ORDER BY 1)' at line 1 SELECT 1 FROM (SELECT 1 FROM t1 LIMIT 1 UNION SELECT 1 FROM t1 ORDER BY 1) a; -ERROR HY000: Incorrect usage of UNION and LIMIT +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'UNION SELECT 1 FROM t1 ORDER BY 1) a' at line 1 SELECT 1 FROM t1 ORDER BY 1 UNION SELECT 1 FROM t1 LIMIT 1; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'UNION SELECT 1 FROM t1 LIMIT 1' at line 1 SELECT (SELECT 1 FROM t1 ORDER BY 1 UNION SELECT 1 FROM t1 LIMIT 1); ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'UNION SELECT 1 FROM t1 LIMIT 1)' at line 1 SELECT 1 FROM (SELECT 1 FROM t1 ORDER BY 1 UNION SELECT 1 FROM t1 LIMIT 1) a; -ERROR HY000: Incorrect usage of UNION and ORDER BY +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'UNION SELECT 1 FROM t1 LIMIT 1) a' at line 1 DROP TABLE t1; # # MDEV-8380: Subquery parse error diff --git a/mysql-test/t/parser.test b/mysql-test/t/parser.test index 3f9266c3363..5786b936694 100644 --- a/mysql-test/t/parser.test +++ b/mysql-test/t/parser.test @@ -951,7 +951,7 @@ let $q=SELECT 1 FROM t1 ORDER BY 1 UNION SELECT 1 FROM t1; eval $q; --error ER_PARSE_ERROR eval SELECT ($q); ---error ER_WRONG_USAGE +--error ER_PARSE_ERROR eval SELECT 1 FROM ($q) a; let $q=SELECT 1 FROM t1 LIMIT 1 UNION SELECT 1 FROM t1; @@ -959,7 +959,7 @@ let $q=SELECT 1 FROM t1 LIMIT 1 UNION SELECT 1 FROM t1; eval $q; --error ER_PARSE_ERROR eval SELECT ($q); ---error ER_WRONG_USAGE +--error ER_PARSE_ERROR eval SELECT 1 FROM ($q) a; let $q=SELECT 1 FROM t1 ORDER BY 1 LIMIT 1 UNION SELECT 1 FROM t1; @@ -967,7 +967,7 @@ let $q=SELECT 1 FROM t1 ORDER BY 1 LIMIT 1 UNION SELECT 1 FROM t1; eval $q; --error ER_PARSE_ERROR eval SELECT ($q); ---error ER_WRONG_USAGE +--error ER_PARSE_ERROR eval SELECT 1 FROM ($q) a; let $q=SELECT 1 FROM t1 LIMIT 1 ORDER BY 1 UNION SELECT 1 FROM t1; @@ -983,7 +983,7 @@ let $q=SELECT 1 FROM t1 ORDER BY 1 UNION SELECT 1 FROM t1 ORDER BY 1; eval $q; --error ER_PARSE_ERROR eval SELECT ($q); ---error ER_WRONG_USAGE +--error ER_PARSE_ERROR eval SELECT 1 FROM ($q) a; let $q=SELECT 1 FROM t1 LIMIT 1 UNION SELECT 1 FROM t1 LIMIT 1; @@ -991,7 +991,7 @@ let $q=SELECT 1 FROM t1 LIMIT 1 UNION SELECT 1 FROM t1 LIMIT 1; eval $q; --error ER_PARSE_ERROR eval SELECT ($q); ---error ER_WRONG_USAGE +--error ER_PARSE_ERROR eval SELECT 1 FROM ($q) a; let $q=SELECT 1 FROM t1 LIMIT 1 UNION SELECT 1 FROM t1 ORDER BY 1; @@ -999,7 +999,7 @@ let $q=SELECT 1 FROM t1 LIMIT 1 UNION SELECT 1 FROM t1 ORDER BY 1; eval $q; --error ER_PARSE_ERROR eval SELECT ($q); ---error ER_WRONG_USAGE +--error ER_PARSE_ERROR eval SELECT 1 FROM ($q) a; let $q=SELECT 1 FROM t1 ORDER BY 1 UNION SELECT 1 FROM t1 LIMIT 1; @@ -1007,7 +1007,7 @@ let $q=SELECT 1 FROM t1 ORDER BY 1 UNION SELECT 1 FROM t1 LIMIT 1; eval $q; --error ER_PARSE_ERROR eval SELECT ($q); ---error ER_WRONG_USAGE +--error ER_PARSE_ERROR eval SELECT 1 FROM ($q) a; DROP TABLE t1; diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index ab45f94e490..6342b8f501d 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -990,10 +990,10 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); %parse-param { THD *thd } %lex-param { THD *thd } /* - Currently there are 154 shift/reduce conflicts. + Currently there are 152 shift/reduce conflicts. We should not introduce new conflicts any more. */ -%expect 154 +%expect 152 /* Comments for TOKENS. @@ -10831,7 +10831,11 @@ table_factor: mysql_new_select(lex, 1)) MYSQL_YYABORT; } - select_part2_derived + select_options_and_item_list + opt_from_clause + opt_where_clause + opt_group_clause + opt_having_clause { LEX *lex= Lex; SELECT_LEX *sel= lex->current_select; @@ -10857,17 +10861,16 @@ table_factor: <table subquery> ::= <subquery> <subquery> ::= <left paren> <query expression> <right paren> <query expression> ::= [ <with clause> ] <query expression body> - - For the time being we use the non-standard rule - select_derived_union which is a compromise between the standard - and our parser. Possibly this rule could be replaced by our - query_expression_body. */ - | '(' get_select_lex select_derived_union ')' opt_table_alias + | '(' get_select_lex select_derived_union + opt_order_clause + opt_limit_clause + opt_select_lock_type + ')' opt_table_alias { /* Use $2 instead of Lex->current_select as derived table will alter value of Lex->current_select. */ - if (!($3 || $5) && $2->embedding && + if (!($3 || $8) && $2->embedding && !$2->embedding->nested_join->join_list.elements) { /* we have a derived table ($3 == NULL) but no alias, @@ -10889,7 +10892,7 @@ table_factor: if (ti == NULL) MYSQL_YYABORT; if (!($$= sel->add_table_to_list(lex->thd, - ti, $5, 0, + ti, $8, 0, TL_READ, MDL_SHARED_READ))) MYSQL_YYABORT; @@ -10897,7 +10900,7 @@ table_factor: lex->pop_context(); lex->nest_level--; } - else if ($5 != NULL) + else if ($8 != NULL) { /* Tables with or without joins within parentheses cannot @@ -10935,10 +10938,7 @@ table_factor: subqueries have their own union rules. */ select_derived_union: - select_derived opt_order_or_limit - { - MYSQL_YYABORT_UNLESS(!$1 || !$2); - } + select_derived | select_derived_union UNION_SYM union_option @@ -10958,18 +10958,6 @@ select_derived_union: } ; -/* The equivalent of select_part2 for nested queries. */ -select_part2_derived: - select_options_and_item_list - opt_from_clause - opt_where_clause - opt_group_clause - opt_having_clause - opt_order_clause - opt_limit_clause - opt_select_lock_type - ; - /* handle contents of parentheses in join expression */ select_derived: get_select_lex @@ -15826,13 +15814,12 @@ union_option: query_specification: SELECT_SYM - select_part2 + select_part2_union_ready { MYSQL_YYABORT_UNLESS(!Lex->current_select->set_braces(0)); $$= Lex->current_select->master_unit()->first_select(); } | '(' select_paren ')' - opt_order_or_limit { $$= Lex->current_select->master_unit()->first_select(); } |