diff options
author | Sergei Golubchik <sergii@pisem.net> | 2013-07-18 16:46:57 +0200 |
---|---|---|
committer | Sergei Golubchik <sergii@pisem.net> | 2013-07-18 16:46:57 +0200 |
commit | 5f6380adde2dac3f32b40339b9b702c0135eb7d6 (patch) | |
tree | 31068acc0b39c208d35d524688a5985831af0447 /sql/sql_yacc.yy | |
parent | 8a23ae088dc38f591efeab9eccdef5eb9094add9 (diff) | |
parent | 97e640b9ae83e07b444fceede6b0524256c7a3cc (diff) | |
download | mariadb-git-5f6380adde2dac3f32b40339b9b702c0135eb7d6.tar.gz |
10.0-base merge
Diffstat (limited to 'sql/sql_yacc.yy')
-rw-r--r-- | sql/sql_yacc.yy | 108 |
1 files changed, 85 insertions, 23 deletions
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 0dc8ed7037e..da8750a7ba4 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -892,6 +892,7 @@ static bool sp_create_assignment_instr(THD *thd, bool no_lookahead) Diag_condition_item_name diag_condition_item_name; DYNCALL_CREATE_DEF *dyncol_def; List<DYNCALL_CREATE_DEF> *dyncol_def_list; + bool is_not_empty; } %{ @@ -900,10 +901,10 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); %pure_parser /* We have threads */ /* - Currently there are 167 shift/reduce conflicts. + Currently there are 189 shift/reduce conflicts. We should not introduce new conflicts any more. */ -%expect 167 +%expect 189 /* Comments for TOKENS. @@ -1758,7 +1759,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); precision subselect_start opt_and charset subselect_end select_var_list select_var_list_init help field_length opt_field_length - opt_extended_describe + opt_extended_describe shutdown prepare prepare_src execute deallocate statement sp_suid sp_c_chistics sp_a_chistics sp_chistic sp_c_chistic xa @@ -1797,7 +1798,7 @@ END_OF_INPUT %type <lex> sp_cursor_stmt %type <spname> sp_name %type <index_hint> index_hint_type -%type <num> index_hint_clause +%type <num> index_hint_clause normal_join inner_join %type <filetype> data_or_xml %type <NONE> signal_stmt resignal_stmt @@ -1808,7 +1809,7 @@ END_OF_INPUT ',' '!' '{' '}' '&' '|' AND_SYM OR_SYM OR_OR_SYM BETWEEN_SYM CASE_SYM THEN_SYM WHEN_SYM DIV_SYM MOD_SYM OR2_SYM AND_AND_SYM DELETE_SYM -%type <num> normal_join inner_join +%type <is_not_empty> opt_union_order_or_limit %% @@ -1936,6 +1937,7 @@ statement: | set | signal_stmt | show + | shutdown | slave | start | truncate @@ -5504,7 +5506,7 @@ storage_engines: plugin_ref plugin= ha_resolve_by_name(YYTHD, &$1); if (plugin) - $$= plugin_data(plugin, handlerton*); + $$= plugin_hton(plugin); else { if (YYTHD->variables.sql_mode & MODE_NO_ENGINE_SUBSTITUTION) @@ -5526,7 +5528,7 @@ known_storage_engines: { plugin_ref plugin; if ((plugin= ha_resolve_by_name(YYTHD, &$1))) - $$= plugin_data(plugin, handlerton*); + $$= plugin_hton(plugin); else { my_error(ER_UNKNOWN_STORAGE_ENGINE, MYF(0), $1.str); @@ -9767,6 +9769,7 @@ sum_expr: if ($$ == NULL) MYSQL_YYABORT; $5->empty(); + sel->gorder_list.empty(); } ; @@ -9836,18 +9839,27 @@ opt_gconcat_separator: opt_gorder_clause: /* empty */ + | ORDER_SYM BY { - Select->gorder_list = NULL; - } - | order_clause - { - SELECT_LEX *select= Select; - select->gorder_list= new (YYTHD->mem_root) - SQL_I_List<ORDER>(select->order_list); - if (select->gorder_list == NULL) + LEX *lex= Lex; + SELECT_LEX *sel= lex->current_select; + if (sel->linkage != GLOBAL_OPTIONS_TYPE && + sel->olap != UNSPECIFIED_OLAP_TYPE && + (sel->linkage != UNION_TYPE || sel->braces)) + { + my_error(ER_WRONG_USAGE, MYF(0), + "CUBE/ROLLUP", "ORDER BY"); MYSQL_YYABORT; - select->order_list.empty(); + } } + gorder_list; + ; + +gorder_list: + gorder_list ',' order_ident order_dir + { if (add_gorder_to_list(YYTHD, $3,(bool) $4)) MYSQL_YYABORT; } + | order_ident order_dir + { if (add_gorder_to_list(YYTHD, $1,(bool) $2)) MYSQL_YYABORT; } ; in_sum_expr: @@ -9980,7 +9992,10 @@ table_ref: { LEX *lex= Lex; if (!($$= lex->current_select->nest_last_join(lex->thd))) + { + my_parse_error(ER(ER_SYNTAX_ERROR)); MYSQL_YYABORT; + } } ; @@ -10245,12 +10260,16 @@ table_factor: lex->pop_context(); lex->nest_level--; } - else if (($3->select_lex && + /*else if (($3->select_lex && $3->select_lex->master_unit()->is_union() && ($3->select_lex->master_unit()->first_select() == - $3->select_lex || !$3->lifted)) || $5) + $3->select_lex || !$3->lifted)) || $5)*/ + else if ($5 != NULL) { - /* simple nested joins cannot have aliases or unions */ + /* + Tables with or without joins within parentheses cannot + have aliases, and we ruled out derived tables above. + */ my_parse_error(ER(ER_SYNTAX_ERROR)); MYSQL_YYABORT; } @@ -10263,8 +10282,34 @@ table_factor: } ; +/* + This rule accepts just about anything. The reason is that we have + empty-producing rules in the beginning of rules, in this case + subselect_start. This forces bison to take a decision which rules to + reduce by long before it has seen any tokens. This approach ties us + to a very limited class of parseable languages, and unfortunately + SQL is not one of them. The chosen 'solution' was this rule, which + produces just about anything, even complete bogus statements, for + instance ( table UNION SELECT 1 ). + Fortunately, we know that the semantic value returned by + select_derived is NULL if it contained a derived table, and a pointer to + the base table's TABLE_LIST if it was a base table. So in the rule + regarding union's, we throw a parse error manually and pretend it + was bison that did it. + + Also worth noting is that this rule concerns query expressions in + the from clause only. Top level select statements and other types of + subqueries have their own union rules. +*/ select_derived_union: select_derived opt_union_order_or_limit + { + if ($1 && $2) + { + my_parse_error(ER(ER_SYNTAX_ERROR)); + MYSQL_YYABORT; + } + } | select_derived_union UNION_SYM union_option @@ -10281,6 +10326,13 @@ select_derived_union: Lex->pop_context(); } opt_union_order_or_limit + { + if ($1 != NULL) + { + my_parse_error(ER(ER_SYNTAX_ERROR)); + MYSQL_YYABORT; + } + } ; /* The equivalent of select_init2 for nested queries. */ @@ -11754,7 +11806,9 @@ show: bzero((char*) &lex->create_info,sizeof(lex->create_info)); } show_param - {} + { + Select->parsing_place= NO_MATTER; + } ; show_param: @@ -12167,7 +12221,10 @@ describe: if (prepare_schema_table(YYTHD, lex, $2, SCH_COLUMNS)) MYSQL_YYABORT; } - opt_describe_column {} + opt_describe_column + { + Select->parsing_place= NO_MATTER; + } | describe_command opt_extended_describe { Lex->describe|= DESCRIBE_NORMAL; } select @@ -12422,6 +12479,11 @@ kill_expr: } ; + +shutdown: + SHUTDOWN { Lex->sql_command= SQLCOM_SHUTDOWN; } + ; + /* change database */ use: @@ -14993,8 +15055,8 @@ union_opt: ; opt_union_order_or_limit: - /* Empty */ - | union_order_or_limit + /* Empty */{ $$= false; } + | union_order_or_limit { $$= true; } ; union_order_or_limit: |