Commit 828d9ae5 authored by Sergei Golubchik's avatar Sergei Golubchik

cleanup: reduce code duplication

parent a4a025f5
...@@ -1902,6 +1902,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); ...@@ -1902,6 +1902,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize);
%type <lock_type> %type <lock_type>
replace_lock_option opt_low_priority insert_lock_option load_data_lock replace_lock_option opt_low_priority insert_lock_option load_data_lock
insert_replace_option
%type <item> %type <item>
literal insert_ident order_ident temporal_literal literal insert_ident order_ident temporal_literal
...@@ -2069,7 +2070,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); ...@@ -2069,7 +2070,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize);
%type <NONE> %type <NONE>
analyze_stmt_command backup backup_statements analyze_stmt_command backup backup_statements
query verb_clause create change select select_into query verb_clause create change select select_into
do drop insert replace insert2 do drop insert replace insert_start stmt_end
insert_values update delete truncate rename compound_statement insert_values update delete truncate rename compound_statement
show describe load alter optimize keycache preload flush show describe load alter optimize keycache preload flush
reset purge begin_stmt_mariadb commit rollback savepoint release reset purge begin_stmt_mariadb commit rollback savepoint release
...@@ -5322,7 +5323,7 @@ opt_create_partitioning: ...@@ -5322,7 +5323,7 @@ opt_create_partitioning:
/* /*
This part of the parser is about handling of the partition information. This part of the parser is about handling of the partition information.
It's first version was written by Mikael Ronstrm with lots of answers to Its first version was written by Mikael Ronström with lots of answers to
questions provided by Antony Curtis. questions provided by Antony Curtis.
The partition grammar can be called from three places. The partition grammar can be called from three places.
...@@ -7894,10 +7895,7 @@ alter: ...@@ -7894,10 +7895,7 @@ alter:
lex->sql_command= SQLCOM_ALTER_PROCEDURE; lex->sql_command= SQLCOM_ALTER_PROCEDURE;
lex->spname= $3; lex->spname= $3;
Lex->pop_select(); //main select } stmt_end {}
if (Lex->check_main_unit_semantics())
MYSQL_YYABORT;
}
| ALTER FUNCTION_SYM sp_name | ALTER FUNCTION_SYM sp_name
{ {
LEX *lex= Lex; LEX *lex= Lex;
...@@ -7914,10 +7912,7 @@ alter: ...@@ -7914,10 +7912,7 @@ alter:
lex->sql_command= SQLCOM_ALTER_FUNCTION; lex->sql_command= SQLCOM_ALTER_FUNCTION;
lex->spname= $3; lex->spname= $3;
Lex->pop_select(); //main select } stmt_end {}
if (Lex->check_main_unit_semantics())
MYSQL_YYABORT;
}
| ALTER view_algorithm definer_opt opt_view_suid VIEW_SYM table_ident | ALTER view_algorithm definer_opt opt_view_suid VIEW_SYM table_ident
{ {
if (Lex->main_select_push()) if (Lex->main_select_push())
...@@ -7925,12 +7920,7 @@ alter: ...@@ -7925,12 +7920,7 @@ alter:
if (Lex->add_alter_view(thd, $2, $4, $6)) if (Lex->add_alter_view(thd, $2, $4, $6))
MYSQL_YYABORT; MYSQL_YYABORT;
} }
view_list_opt AS view_select view_list_opt AS view_select stmt_end {}
{
Lex->pop_select(); //main select
if (Lex->check_main_unit_semantics())
MYSQL_YYABORT;
}
| ALTER definer_opt opt_view_suid VIEW_SYM table_ident | ALTER definer_opt opt_view_suid VIEW_SYM table_ident
/* /*
We have two separate rules for ALTER VIEW rather that We have two separate rules for ALTER VIEW rather that
...@@ -7943,12 +7933,7 @@ alter: ...@@ -7943,12 +7933,7 @@ alter:
if (Lex->add_alter_view(thd, VIEW_ALGORITHM_INHERIT, $3, $5)) if (Lex->add_alter_view(thd, VIEW_ALGORITHM_INHERIT, $3, $5))
MYSQL_YYABORT; MYSQL_YYABORT;
} }
view_list_opt AS view_select view_list_opt AS view_select stmt_end {}
{
Lex->pop_select(); //main select
if (Lex->check_main_unit_semantics())
MYSQL_YYABORT;
}
| ALTER definer_opt remember_name EVENT_SYM sp_name | ALTER definer_opt remember_name EVENT_SYM sp_name
{ {
if (Lex->main_select_push()) if (Lex->main_select_push())
...@@ -8049,10 +8034,7 @@ alter: ...@@ -8049,10 +8034,7 @@ alter:
Lex->m_sql_cmd= new (thd->mem_root) Sql_cmd_alter_sequence($3); Lex->m_sql_cmd= new (thd->mem_root) Sql_cmd_alter_sequence($3);
if (unlikely(Lex->m_sql_cmd == NULL)) if (unlikely(Lex->m_sql_cmd == NULL))
MYSQL_YYABORT; MYSQL_YYABORT;
Lex->pop_select(); //main select } stmt_end {}
if (Lex->check_main_unit_semantics())
MYSQL_YYABORT;
}
; ;
opt_account_locking: opt_account_locking:
...@@ -13489,51 +13471,43 @@ opt_temporary: ...@@ -13489,51 +13471,43 @@ opt_temporary:
insert: insert:
INSERT INSERT
{ {
LEX *lex= Lex; Lex->sql_command= SQLCOM_INSERT;
lex->sql_command= SQLCOM_INSERT; Lex->duplicates= DUP_ERROR;
lex->duplicates= DUP_ERROR;
if (Lex->main_select_push())
MYSQL_YYABORT;
mysql_init_select(lex);
lex->current_select->parsing_place= BEFORE_OPT_LIST;
}
insert_lock_option
opt_ignore insert2
{
Select->set_lock_for_tables($3, true);
Lex->current_select= Lex->first_select_lex();
} }
insert_field_spec opt_insert_update insert_start insert_lock_option opt_ignore opt_into insert_table
{ {
Lex->pop_select(); //main select Select->set_lock_for_tables($4, true);
if (Lex->check_main_unit_semantics())
MYSQL_YYABORT;
} }
; insert_field_spec opt_insert_update stmt_end {}
;
replace: replace:
REPLACE REPLACE
{ {
LEX *lex=Lex; Lex->sql_command = SQLCOM_REPLACE;
lex->sql_command = SQLCOM_REPLACE; Lex->duplicates= DUP_REPLACE;
lex->duplicates= DUP_REPLACE;
if (Lex->main_select_push())
MYSQL_YYABORT;
mysql_init_select(lex);
lex->current_select->parsing_place= BEFORE_OPT_LIST;
} }
replace_lock_option insert2 insert_start replace_lock_option opt_into insert_table
{ {
Select->set_lock_for_tables($3, true); Select->set_lock_for_tables($4, true);
Lex->current_select= Lex->first_select_lex();
} }
insert_field_spec insert_field_spec stmt_end {}
{ ;
Lex->pop_select(); //main select
if (Lex->check_main_unit_semantics()) insert_start: {
MYSQL_YYABORT; if (Lex->main_select_push())
} MYSQL_YYABORT;
; mysql_init_select(Lex);
Lex->current_select->parsing_place= BEFORE_OPT_LIST;
}
;
stmt_end: {
Lex->pop_select(); //main select
if (Lex->check_main_unit_semantics())
MYSQL_YYABORT;
}
;
insert_lock_option: insert_lock_option:
/* empty */ /* empty */
...@@ -13545,19 +13519,17 @@ insert_lock_option: ...@@ -13545,19 +13519,17 @@ insert_lock_option:
*/ */
$$= (Lex->sphead ? TL_WRITE_DEFAULT : TL_WRITE_CONCURRENT_INSERT); $$= (Lex->sphead ? TL_WRITE_DEFAULT : TL_WRITE_CONCURRENT_INSERT);
} }
| LOW_PRIORITY { $$= TL_WRITE_LOW_PRIORITY; } | insert_replace_option
| DELAYED_SYM
{
// QQ: why was +1?
Lex->keyword_delayed_begin_offset= (uint)($1.pos() - thd->query());
Lex->keyword_delayed_end_offset= (uint)($1.end() - thd->query());
$$= TL_WRITE_DELAYED;
}
| HIGH_PRIORITY { $$= TL_WRITE; } | HIGH_PRIORITY { $$= TL_WRITE; }
; ;
replace_lock_option: replace_lock_option:
opt_low_priority { $$= $1; } /* empty */ { $$= TL_WRITE_DEFAULT; }
| insert_replace_option
;
insert_replace_option:
LOW_PRIORITY { $$= TL_WRITE_LOW_PRIORITY; }
| DELAYED_SYM | DELAYED_SYM
{ {
Lex->keyword_delayed_begin_offset= (uint)($1.pos() - thd->query()); Lex->keyword_delayed_begin_offset= (uint)($1.pos() - thd->query());
...@@ -13566,10 +13538,7 @@ replace_lock_option: ...@@ -13566,10 +13538,7 @@ replace_lock_option:
} }
; ;
insert2: opt_into: /* nothing */ | INTO ;
INTO insert_table {}
| insert_table {}
;
insert_table: insert_table:
{ {
...@@ -13818,10 +13787,7 @@ update: ...@@ -13818,10 +13787,7 @@ update:
{ {
if ($10) if ($10)
Select->order_list= *($10); Select->order_list= *($10);
Lex->pop_select(); //main select } stmt_end {}
if (Lex->check_main_unit_semantics())
MYSQL_YYABORT;
}
; ;
update_list: update_list:
...@@ -13941,10 +13907,7 @@ single_multi: ...@@ -13941,10 +13907,7 @@ single_multi:
{ {
if (unlikely(multi_delete_set_locks_and_link_aux_tables(Lex))) if (unlikely(multi_delete_set_locks_and_link_aux_tables(Lex)))
MYSQL_YYABORT; MYSQL_YYABORT;
Lex->pop_select(); //main select } stmt_end {}
if (Lex->check_main_unit_semantics())
MYSQL_YYABORT;
}
| FROM table_alias_ref_list | FROM table_alias_ref_list
{ {
mysql_init_multi_delete(Lex); mysql_init_multi_delete(Lex);
...@@ -13955,10 +13918,7 @@ single_multi: ...@@ -13955,10 +13918,7 @@ single_multi:
{ {
if (unlikely(multi_delete_set_locks_and_link_aux_tables(Lex))) if (unlikely(multi_delete_set_locks_and_link_aux_tables(Lex)))
MYSQL_YYABORT; MYSQL_YYABORT;
Lex->pop_select(); //main select } stmt_end {}
if (Lex->check_main_unit_semantics())
MYSQL_YYABORT;
}
; ;
opt_select_expressions: opt_select_expressions:
...@@ -15023,11 +14983,7 @@ load: ...@@ -15023,11 +14983,7 @@ load:
opt_xml_rows_identified_by opt_xml_rows_identified_by
opt_field_term opt_line_term opt_ignore_lines opt_field_or_var_spec opt_field_term opt_line_term opt_ignore_lines opt_field_or_var_spec
opt_load_data_set_spec opt_load_data_set_spec
{ stmt_end {}
Lex->pop_select(); //main select
if (Lex->check_main_unit_semantics())
MYSQL_YYABORT;
}
; ;
data_or_xml: data_or_xml:
...@@ -16701,11 +16657,7 @@ set: ...@@ -16701,11 +16657,7 @@ set:
lex->set_stmt_init(); lex->set_stmt_init();
} }
set_param set_param
{ stmt_end {}
Lex->pop_select(); //main select
if (Lex->check_main_unit_semantics())
MYSQL_YYABORT;
}
; ;
set_param: set_param:
......
...@@ -1375,6 +1375,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); ...@@ -1375,6 +1375,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize);
%type <lock_type> %type <lock_type>
replace_lock_option opt_low_priority insert_lock_option load_data_lock replace_lock_option opt_low_priority insert_lock_option load_data_lock
insert_replace_option
%type <item> %type <item>
literal insert_ident order_ident temporal_literal literal insert_ident order_ident temporal_literal
...@@ -1544,7 +1545,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); ...@@ -1544,7 +1545,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize);
%type <NONE> %type <NONE>
analyze_stmt_command backup backup_statements analyze_stmt_command backup backup_statements
query verb_clause create change select select_into query verb_clause create change select select_into
do drop insert replace insert2 do drop insert replace insert_start stmt_end
insert_values update delete truncate rename compound_statement insert_values update delete truncate rename compound_statement
show describe load alter optimize keycache preload flush show describe load alter optimize keycache preload flush
reset purge begin_stmt_mariadb commit rollback savepoint release reset purge begin_stmt_mariadb commit rollback savepoint release
...@@ -5320,7 +5321,7 @@ opt_create_partitioning: ...@@ -5320,7 +5321,7 @@ opt_create_partitioning:
/* /*
This part of the parser is about handling of the partition information. This part of the parser is about handling of the partition information.
It's first version was written by Mikael Ronstrm with lots of answers to Its first version was written by Mikael Ronström with lots of answers to
questions provided by Antony Curtis. questions provided by Antony Curtis.
The partition grammar can be called from three places. The partition grammar can be called from three places.
...@@ -7985,10 +7986,7 @@ alter: ...@@ -7985,10 +7986,7 @@ alter:
lex->sql_command= SQLCOM_ALTER_PROCEDURE; lex->sql_command= SQLCOM_ALTER_PROCEDURE;
lex->spname= $3; lex->spname= $3;
Lex->pop_select(); //main select } stmt_end {}
if (Lex->check_main_unit_semantics())
MYSQL_YYABORT;
}
| ALTER FUNCTION_SYM sp_name | ALTER FUNCTION_SYM sp_name
{ {
LEX *lex= Lex; LEX *lex= Lex;
...@@ -8005,10 +8003,7 @@ alter: ...@@ -8005,10 +8003,7 @@ alter:
lex->sql_command= SQLCOM_ALTER_FUNCTION; lex->sql_command= SQLCOM_ALTER_FUNCTION;
lex->spname= $3; lex->spname= $3;
Lex->pop_select(); //main select } stmt_end {}
if (Lex->check_main_unit_semantics())
MYSQL_YYABORT;
}
| ALTER view_algorithm definer_opt opt_view_suid VIEW_SYM table_ident | ALTER view_algorithm definer_opt opt_view_suid VIEW_SYM table_ident
{ {
if (Lex->main_select_push()) if (Lex->main_select_push())
...@@ -8016,12 +8011,7 @@ alter: ...@@ -8016,12 +8011,7 @@ alter:
if (Lex->add_alter_view(thd, $2, $4, $6)) if (Lex->add_alter_view(thd, $2, $4, $6))
MYSQL_YYABORT; MYSQL_YYABORT;
} }
view_list_opt AS view_select view_list_opt AS view_select stmt_end {}
{
Lex->pop_select(); //main select
if (Lex->check_main_unit_semantics())
MYSQL_YYABORT;
}
| ALTER definer_opt opt_view_suid VIEW_SYM table_ident | ALTER definer_opt opt_view_suid VIEW_SYM table_ident
/* /*
We have two separate rules for ALTER VIEW rather that We have two separate rules for ALTER VIEW rather that
...@@ -8034,12 +8024,7 @@ alter: ...@@ -8034,12 +8024,7 @@ alter:
if (Lex->add_alter_view(thd, VIEW_ALGORITHM_INHERIT, $3, $5)) if (Lex->add_alter_view(thd, VIEW_ALGORITHM_INHERIT, $3, $5))
MYSQL_YYABORT; MYSQL_YYABORT;
} }
view_list_opt AS view_select view_list_opt AS view_select stmt_end {}
{
Lex->pop_select(); //main select
if (Lex->check_main_unit_semantics())
MYSQL_YYABORT;
}
| ALTER definer_opt remember_name EVENT_SYM sp_name | ALTER definer_opt remember_name EVENT_SYM sp_name
{ {
if (Lex->main_select_push()) if (Lex->main_select_push())
...@@ -8140,10 +8125,7 @@ alter: ...@@ -8140,10 +8125,7 @@ alter:
Lex->m_sql_cmd= new (thd->mem_root) Sql_cmd_alter_sequence($3); Lex->m_sql_cmd= new (thd->mem_root) Sql_cmd_alter_sequence($3);
if (unlikely(Lex->m_sql_cmd == NULL)) if (unlikely(Lex->m_sql_cmd == NULL))
MYSQL_YYABORT; MYSQL_YYABORT;
Lex->pop_select(); //main select } stmt_end {}
if (Lex->check_main_unit_semantics())
MYSQL_YYABORT;
}
; ;
opt_account_locking: opt_account_locking:
...@@ -13605,51 +13587,43 @@ opt_temporary: ...@@ -13605,51 +13587,43 @@ opt_temporary:
insert: insert:
INSERT INSERT
{ {
LEX *lex= Lex; Lex->sql_command= SQLCOM_INSERT;
lex->sql_command= SQLCOM_INSERT; Lex->duplicates= DUP_ERROR;
lex->duplicates= DUP_ERROR;
if (Lex->main_select_push())
MYSQL_YYABORT;
mysql_init_select(lex);
lex->current_select->parsing_place= BEFORE_OPT_LIST;
}
insert_lock_option
opt_ignore insert2
{
Select->set_lock_for_tables($3, true);
Lex->current_select= Lex->first_select_lex();
} }
insert_field_spec opt_insert_update insert_start insert_lock_option opt_ignore opt_into insert_table
{ {
Lex->pop_select(); //main select Select->set_lock_for_tables($4, true);
if (Lex->check_main_unit_semantics())
MYSQL_YYABORT;
} }
; insert_field_spec opt_insert_update stmt_end {}
;
replace: replace:
REPLACE REPLACE
{ {
LEX *lex=Lex; Lex->sql_command = SQLCOM_REPLACE;
lex->sql_command = SQLCOM_REPLACE; Lex->duplicates= DUP_REPLACE;
lex->duplicates= DUP_REPLACE;
if (Lex->main_select_push())
MYSQL_YYABORT;
mysql_init_select(lex);
lex->current_select->parsing_place= BEFORE_OPT_LIST;
} }
replace_lock_option insert2 insert_start replace_lock_option opt_into insert_table
{ {
Select->set_lock_for_tables($3, true); Select->set_lock_for_tables($4, true);
Lex->current_select= Lex->first_select_lex();
} }
insert_field_spec insert_field_spec stmt_end {}
{ ;
Lex->pop_select(); //main select
if (Lex->check_main_unit_semantics()) insert_start: {
MYSQL_YYABORT; if (Lex->main_select_push())
} MYSQL_YYABORT;
; mysql_init_select(Lex);
Lex->current_select->parsing_place= BEFORE_OPT_LIST;
}
;
stmt_end: {
Lex->pop_select(); //main select
if (Lex->check_main_unit_semantics())
MYSQL_YYABORT;
}
;
insert_lock_option: insert_lock_option:
/* empty */ /* empty */
...@@ -13661,19 +13635,17 @@ insert_lock_option: ...@@ -13661,19 +13635,17 @@ insert_lock_option:
*/ */
$$= (Lex->sphead ? TL_WRITE_DEFAULT : TL_WRITE_CONCURRENT_INSERT); $$= (Lex->sphead ? TL_WRITE_DEFAULT : TL_WRITE_CONCURRENT_INSERT);
} }
| LOW_PRIORITY { $$= TL_WRITE_LOW_PRIORITY; } | insert_replace_option
| DELAYED_SYM
{
// QQ: why was +1?
Lex->keyword_delayed_begin_offset= (uint)($1.pos() - thd->query());
Lex->keyword_delayed_end_offset= (uint)($1.end() - thd->query());
$$= TL_WRITE_DELAYED;
}
| HIGH_PRIORITY { $$= TL_WRITE; } | HIGH_PRIORITY { $$= TL_WRITE; }
; ;
replace_lock_option: replace_lock_option:
opt_low_priority { $$= $1; } /* empty */ { $$= TL_WRITE_DEFAULT; }
| insert_replace_option
;
insert_replace_option:
LOW_PRIORITY { $$= TL_WRITE_LOW_PRIORITY; }
| DELAYED_SYM | DELAYED_SYM
{ {
Lex->keyword_delayed_begin_offset= (uint)($1.pos() - thd->query()); Lex->keyword_delayed_begin_offset= (uint)($1.pos() - thd->query());
...@@ -13682,10 +13654,7 @@ replace_lock_option: ...@@ -13682,10 +13654,7 @@ replace_lock_option:
} }
; ;
insert2: opt_into: /* nothing */ | INTO ;
INTO insert_table {}
| insert_table {}
;
insert_table: insert_table:
{ {
...@@ -13934,10 +13903,7 @@ update: ...@@ -13934,10 +13903,7 @@ update:
{ {
if ($10) if ($10)
Select->order_list= *($10); Select->order_list= *($10);
Lex->pop_select(); //main select } stmt_end {}
if (Lex->check_main_unit_semantics())
MYSQL_YYABORT;
}
; ;
update_list: update_list:
...@@ -14057,10 +14023,7 @@ single_multi: ...@@ -14057,10 +14023,7 @@ single_multi:
{ {
if (unlikely(multi_delete_set_locks_and_link_aux_tables(Lex))) if (unlikely(multi_delete_set_locks_and_link_aux_tables(Lex)))
MYSQL_YYABORT; MYSQL_YYABORT;
Lex->pop_select(); //main select } stmt_end {}
if (Lex->check_main_unit_semantics())
MYSQL_YYABORT;
}
| FROM table_alias_ref_list | FROM table_alias_ref_list
{ {
mysql_init_multi_delete(Lex); mysql_init_multi_delete(Lex);
...@@ -14071,10 +14034,7 @@ single_multi: ...@@ -14071,10 +14034,7 @@ single_multi:
{ {
if (unlikely(multi_delete_set_locks_and_link_aux_tables(Lex))) if (unlikely(multi_delete_set_locks_and_link_aux_tables(Lex)))
MYSQL_YYABORT; MYSQL_YYABORT;
Lex->pop_select(); //main select } stmt_end {}
if (Lex->check_main_unit_semantics())
MYSQL_YYABORT;
}
; ;
opt_select_expressions: opt_select_expressions:
...@@ -15145,11 +15105,7 @@ load: ...@@ -15145,11 +15105,7 @@ load:
opt_xml_rows_identified_by opt_xml_rows_identified_by
opt_field_term opt_line_term opt_ignore_lines opt_field_or_var_spec opt_field_term opt_line_term opt_ignore_lines opt_field_or_var_spec
opt_load_data_set_spec opt_load_data_set_spec
{ stmt_end {}
Lex->pop_select(); //main select
if (Lex->check_main_unit_semantics())
MYSQL_YYABORT;
}
; ;
data_or_xml: data_or_xml:
...@@ -16866,11 +16822,7 @@ set: ...@@ -16866,11 +16822,7 @@ set:
lex->set_stmt_init(); lex->set_stmt_init();
} }
set_param set_param
{ stmt_end {}
Lex->pop_select(); //main select
if (Lex->check_main_unit_semantics())
MYSQL_YYABORT;
}
; ;
set_param: set_param:
......
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