Commit f1e9a0ac authored by Alexander Barkov's avatar Alexander Barkov

Cleanups in the two *.yy grammar files

Fixing unintentionally diverged parts:
- syncing indentation
- syncing "unlikely"
- syncyning missing new lines
- fixing typos
parent 1c022aaf
...@@ -9527,7 +9527,7 @@ subselect: ...@@ -9527,7 +9527,7 @@ subselect:
Consider the production rule of the SQL Standard Consider the production rule of the SQL Standard
subquery: subquery:
'(' query_expression')' '(' query_expression ')'
This rule is equivalent to the rule This rule is equivalent to the rule
subquery: subquery:
...@@ -9541,7 +9541,7 @@ subselect: ...@@ -9541,7 +9541,7 @@ subselect:
The latter can be re-written into The latter can be re-written into
subquery: subquery:
query_expression_body_ext_parens ')' query_expression_body_ext_parens
| '(' with_clause query_expression_no_with_clause ')' | '(' with_clause query_expression_no_with_clause ')'
The last rule allows us to resolve properly the shift/reduce conflict The last rule allows us to resolve properly the shift/reduce conflict
......
...@@ -287,6 +287,8 @@ void ORAerror(THD *thd, const char *s) ...@@ -287,6 +287,8 @@ void ORAerror(THD *thd, const char *s)
} }
%{ %{
/* avoid unintentional %union size increases, it's what a parser stack made of */
static_assert(sizeof(YYSTYPE) == sizeof(void*)*2+8, "%union size check");
bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize);
%} %}
...@@ -1129,8 +1131,8 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); ...@@ -1129,8 +1131,8 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize);
%left '^' %left '^'
%left MYSQL_CONCAT_SYM %left MYSQL_CONCAT_SYM
%left NEG '~' NOT2_SYM BINARY %left NEG '~' NOT2_SYM BINARY
%left SUBQUERY_AS_EXPR
%left COLLATE_SYM %left COLLATE_SYM
%left SUBQUERY_AS_EXPR
/* /*
Tokens that can change their meaning from identifier to something else Tokens that can change their meaning from identifier to something else
...@@ -2352,9 +2354,9 @@ create: ...@@ -2352,9 +2354,9 @@ create:
| create_or_replace view_algorithm definer_opt opt_view_suid VIEW_SYM | create_or_replace view_algorithm definer_opt opt_view_suid VIEW_SYM
opt_if_not_exists table_ident opt_if_not_exists table_ident
{ {
if (Lex->main_select_push()) if (unlikely(Lex->add_create_view(thd, $1 | $6, $2, $4, $7)))
MYSQL_YYABORT; MYSQL_YYABORT;
if (Lex->add_create_view(thd, $1 | $6, $2, $4, $7)) if (Lex->main_select_push())
MYSQL_YYABORT; MYSQL_YYABORT;
} }
view_list_opt AS view_select view_list_opt AS view_select
...@@ -4115,9 +4117,7 @@ sp_proc_stmt_return: ...@@ -4115,9 +4117,7 @@ sp_proc_stmt_return:
; ;
reset_lex_expr: reset_lex_expr:
{ Lex->sphead->reset_lex(thd); } { Lex->sphead->reset_lex(thd); } expr { $$= $2; }
expr
{ $$= $2; }
; ;
sp_proc_stmt_exit_oracle: sp_proc_stmt_exit_oracle:
...@@ -4133,14 +4133,14 @@ sp_proc_stmt_exit_oracle: ...@@ -4133,14 +4133,14 @@ sp_proc_stmt_exit_oracle:
} }
| EXIT_ORACLE_SYM WHEN_SYM reset_lex_expr | EXIT_ORACLE_SYM WHEN_SYM reset_lex_expr
{ {
if (Lex->sp_exit_statement(thd, $3) || if (unlikely(Lex->sp_exit_statement(thd, $3)) ||
Lex->sphead->restore_lex(thd)) unlikely(Lex->sphead->restore_lex(thd)))
MYSQL_YYABORT; MYSQL_YYABORT;
} }
| EXIT_ORACLE_SYM label_ident WHEN_SYM reset_lex_expr | EXIT_ORACLE_SYM label_ident WHEN_SYM reset_lex_expr
{ {
if (Lex->sp_exit_statement(thd, &$2, $4) || if (unlikely(Lex->sp_exit_statement(thd, &$2, $4)) ||
Lex->sphead->restore_lex(thd)) unlikely(Lex->sphead->restore_lex(thd)))
MYSQL_YYABORT; MYSQL_YYABORT;
} }
; ;
...@@ -4158,14 +4158,14 @@ sp_proc_stmt_continue_oracle: ...@@ -4158,14 +4158,14 @@ sp_proc_stmt_continue_oracle:
} }
| CONTINUE_ORACLE_SYM WHEN_SYM reset_lex_expr | CONTINUE_ORACLE_SYM WHEN_SYM reset_lex_expr
{ {
if (Lex->sp_continue_statement(thd, $3) || if (unlikely(Lex->sp_continue_statement(thd, $3)) ||
Lex->sphead->restore_lex(thd)) unlikely(Lex->sphead->restore_lex(thd)))
MYSQL_YYABORT; MYSQL_YYABORT;
} }
| CONTINUE_ORACLE_SYM label_ident WHEN_SYM reset_lex_expr | CONTINUE_ORACLE_SYM label_ident WHEN_SYM reset_lex_expr
{ {
if (Lex->sp_continue_statement(thd, &$2, $4) || if (unlikely(Lex->sp_continue_statement(thd, &$2, $4)) ||
Lex->sphead->restore_lex(thd)) unlikely(Lex->sphead->restore_lex(thd)))
MYSQL_YYABORT; MYSQL_YYABORT;
} }
; ;
...@@ -5386,13 +5386,12 @@ partition_entry: ...@@ -5386,13 +5386,12 @@ partition_entry:
thd->parse_error(ER_PARTITION_ENTRY_ERROR); thd->parse_error(ER_PARTITION_ENTRY_ERROR);
MYSQL_YYABORT; MYSQL_YYABORT;
} }
DBUG_ASSERT(Lex->part_info->table); if (Lex->main_select_push())
MYSQL_YYABORT;
/* /*
We enter here when opening the frm file to translate We enter here when opening the frm file to translate
partition info string into part_info data structure. partition info string into part_info data structure.
*/ */
if (Lex->main_select_push())
MYSQL_YYABORT;
} }
partition partition
{ {
...@@ -9285,6 +9284,7 @@ opt_ignore_leaves: ...@@ -9285,6 +9284,7 @@ opt_ignore_leaves:
Select : retrieve data from table Select : retrieve data from table
*/ */
select: select:
query_expression_no_with_clause query_expression_no_with_clause
{ {
...@@ -9317,7 +9317,6 @@ select: ...@@ -9317,7 +9317,6 @@ select:
} }
; ;
select_into: select_into:
select_into_query_specification select_into_query_specification
{ {
...@@ -9354,7 +9353,6 @@ select_into: ...@@ -9354,7 +9353,6 @@ select_into:
} }
; ;
simple_table: simple_table:
query_specification { $$= $1; } query_specification { $$= $1; }
| table_value_constructor { $$= $1; } | table_value_constructor { $$= $1; }
...@@ -9378,8 +9376,7 @@ query_specification_start: ...@@ -9378,8 +9376,7 @@ query_specification_start:
{ {
SELECT_LEX *sel; SELECT_LEX *sel;
LEX *lex= Lex; LEX *lex= Lex;
if (!(sel= lex->alloc_select(TRUE)) || if (!(sel= lex->alloc_select(TRUE)) || lex->push_select(sel))
lex->push_select(sel))
MYSQL_YYABORT; MYSQL_YYABORT;
sel->init_select(); sel->init_select();
sel->braces= FALSE; sel->braces= FALSE;
...@@ -9702,7 +9699,7 @@ select_options: ...@@ -9702,7 +9699,7 @@ select_options:
opt_history_unit: opt_history_unit:
/* empty*/ %prec PREC_BELOW_IDENTIFIER_OPT_SPECIAL_CASE /* empty*/ %prec PREC_BELOW_IDENTIFIER_OPT_SPECIAL_CASE
{ {
$$= VERS_UNDEFINED; $$= VERS_TIMESTAMP;
} }
| TRANSACTION_SYM | TRANSACTION_SYM
{ {
...@@ -9718,7 +9715,7 @@ history_point: ...@@ -9718,7 +9715,7 @@ history_point:
TIMESTAMP TEXT_STRING TIMESTAMP TEXT_STRING
{ {
Item *item; Item *item;
if (!(item= type_handler_datetime2.create_literal_item(thd, if (!(item= type_handler_datetime.create_literal_item(thd,
$2.str, $2.length, $2.str, $2.length,
YYCSCL, true))) YYCSCL, true)))
MYSQL_YYABORT; MYSQL_YYABORT;
...@@ -9834,6 +9831,7 @@ select_lock_type: ...@@ -9834,6 +9831,7 @@ select_lock_type:
} }
; ;
opt_select_lock_type: opt_select_lock_type:
/* empty */ /* empty */
{ {
...@@ -9845,6 +9843,7 @@ opt_select_lock_type: ...@@ -9845,6 +9843,7 @@ opt_select_lock_type:
} }
; ;
opt_lock_wait_timeout_new: opt_lock_wait_timeout_new:
/* empty */ /* empty */
{ {
...@@ -12483,7 +12482,6 @@ table_primary_derived: ...@@ -12483,7 +12482,6 @@ table_primary_derived:
MYSQL_YYABORT; MYSQL_YYABORT;
} }
; ;
;
opt_outer: opt_outer:
/* empty */ {} /* empty */ {}
...@@ -12984,7 +12982,7 @@ limit_clause: ...@@ -12984,7 +12982,7 @@ limit_clause:
{ {
$$.select_limit= 0; $$.select_limit= 0;
$$.offset_limit= 0; $$.offset_limit= 0;
$$.explicit_limit= 1; $$.explicit_limit= 0;
Lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_LIMIT); Lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_LIMIT);
} }
; ;
...@@ -13100,6 +13098,7 @@ order_limit_lock: ...@@ -13100,6 +13098,7 @@ order_limit_lock:
$$->lock= $1; $$->lock= $1;
} }
; ;
opt_order_limit_lock: opt_order_limit_lock:
/* empty */ /* empty */
{ {
...@@ -13138,7 +13137,6 @@ opt_procedure_or_into: ...@@ -13138,7 +13137,6 @@ opt_procedure_or_into:
} }
; ;
order_or_limit: order_or_limit:
order_clause opt_limit_clause order_clause opt_limit_clause
{ {
...@@ -14503,26 +14501,26 @@ show_param: ...@@ -14503,26 +14501,26 @@ show_param:
} }
| ALL SLAVES STATUS_SYM | ALL SLAVES STATUS_SYM
{ {
Lex->sql_command = SQLCOM_SHOW_SLAVE_STAT;
if (!(Lex->m_sql_cmd= new (thd->mem_root) if (!(Lex->m_sql_cmd= new (thd->mem_root)
Sql_cmd_show_slave_status(true))) Sql_cmd_show_slave_status(true)))
MYSQL_YYABORT; MYSQL_YYABORT;
Lex->sql_command = SQLCOM_SHOW_SLAVE_STAT;
} }
| SLAVE STATUS_SYM | SLAVE STATUS_SYM
{ {
LEX *lex= thd->lex; LEX *lex= thd->lex;
lex->mi.connection_name= null_clex_str; lex->mi.connection_name= null_clex_str;
lex->sql_command = SQLCOM_SHOW_SLAVE_STAT;
if (!(lex->m_sql_cmd= new (thd->mem_root) if (!(lex->m_sql_cmd= new (thd->mem_root)
Sql_cmd_show_slave_status())) Sql_cmd_show_slave_status()))
MYSQL_YYABORT; MYSQL_YYABORT;
lex->sql_command = SQLCOM_SHOW_SLAVE_STAT;
} }
| SLAVE connection_name STATUS_SYM | SLAVE connection_name STATUS_SYM
{ {
Lex->sql_command = SQLCOM_SHOW_SLAVE_STAT;
if (!(Lex->m_sql_cmd= new (thd->mem_root) if (!(Lex->m_sql_cmd= new (thd->mem_root)
Sql_cmd_show_slave_status())) Sql_cmd_show_slave_status()))
MYSQL_YYABORT; MYSQL_YYABORT;
Lex->sql_command = SQLCOM_SHOW_SLAVE_STAT;
} }
| CREATE PROCEDURE_SYM sp_name | CREATE PROCEDURE_SYM sp_name
{ {
...@@ -15106,6 +15104,7 @@ shutdown_option: ...@@ -15106,6 +15104,7 @@ shutdown_option:
Lex->is_shutdown_wait_for_slaves= true; Lex->is_shutdown_wait_for_slaves= true;
} }
; ;
/* change database */ /* change database */
use: use:
...@@ -15130,7 +15129,7 @@ load: ...@@ -15130,7 +15129,7 @@ load:
$2 == FILETYPE_CSV ? "LOAD DATA" : "LOAD XML"); $2 == FILETYPE_CSV ? "LOAD DATA" : "LOAD XML");
MYSQL_YYABORT; MYSQL_YYABORT;
} }
if (Lex->main_select_push()) if (lex->main_select_push())
MYSQL_YYABORT; MYSQL_YYABORT;
mysql_init_select(lex); mysql_init_select(lex);
} }
...@@ -15544,7 +15543,7 @@ temporal_literal: ...@@ -15544,7 +15543,7 @@ temporal_literal:
} }
| TIMESTAMP TEXT_STRING | TIMESTAMP TEXT_STRING
{ {
if (unlikely(!($$= type_handler_datetime2.create_literal_item(thd, if (unlikely(!($$= type_handler_datetime.create_literal_item(thd,
$2.str, $2.length, $2.str, $2.length,
YYCSCL, true)))) YYCSCL, true))))
MYSQL_YYABORT; MYSQL_YYABORT;
...@@ -16475,9 +16474,9 @@ keyword_sp_var_and_label: ...@@ -16475,9 +16474,9 @@ keyword_sp_var_and_label:
| MYSQL_SYM | MYSQL_SYM
| MYSQL_ERRNO_SYM | MYSQL_ERRNO_SYM
| NAME_SYM | NAME_SYM
| NEVER_SYM
| NEXT_SYM %prec PREC_BELOW_CONTRACTION_TOKEN2 | NEXT_SYM %prec PREC_BELOW_CONTRACTION_TOKEN2
| NEXTVAL_SYM | NEXTVAL_SYM
| NEVER_SYM
| NEW_SYM | NEW_SYM
| NOCACHE_SYM | NOCACHE_SYM
| NOCYCLE_SYM | NOCYCLE_SYM
...@@ -18510,6 +18509,7 @@ trigger_tail: ...@@ -18510,6 +18509,7 @@ trigger_tail:
**************************************************************************/ **************************************************************************/
sf_return_type: sf_return_type:
{ {
LEX *lex= Lex; LEX *lex= Lex;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment