summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2019-10-01 11:36:18 +0200
committerSergei Golubchik <serg@mariadb.org>2019-10-14 10:29:31 +0200
commit828d9ae597a88c2d4273929f5fcb1c0ae8d073e4 (patch)
treecfee50f83ca7ab634fe174f3950cc1d6056d0a39
parenta4a025f5d1aa123e31d86be82b79daa15a523b19 (diff)
downloadmariadb-git-828d9ae597a88c2d4273929f5fcb1c0ae8d073e4.tar.gz
cleanup: reduce code duplication
-rw-r--r--sql/sql_yacc.yy144
-rw-r--r--sql/sql_yacc_ora.yy144
2 files changed, 96 insertions, 192 deletions
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index d31af5ab3bb..d679b92a4a3 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -1902,6 +1902,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize);
%type <lock_type>
replace_lock_option opt_low_priority insert_lock_option load_data_lock
+ insert_replace_option
%type <item>
literal insert_ident order_ident temporal_literal
@@ -2069,7 +2070,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize);
%type <NONE>
analyze_stmt_command backup backup_statements
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
show describe load alter optimize keycache preload flush
reset purge begin_stmt_mariadb commit rollback savepoint release
@@ -5322,7 +5323,7 @@ opt_create_partitioning:
/*
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.
The partition grammar can be called from three places.
@@ -7894,10 +7895,7 @@ alter:
lex->sql_command= SQLCOM_ALTER_PROCEDURE;
lex->spname= $3;
- Lex->pop_select(); //main select
- if (Lex->check_main_unit_semantics())
- MYSQL_YYABORT;
- }
+ } stmt_end {}
| ALTER FUNCTION_SYM sp_name
{
LEX *lex= Lex;
@@ -7914,10 +7912,7 @@ alter:
lex->sql_command= SQLCOM_ALTER_FUNCTION;
lex->spname= $3;
- Lex->pop_select(); //main select
- if (Lex->check_main_unit_semantics())
- MYSQL_YYABORT;
- }
+ } stmt_end {}
| ALTER view_algorithm definer_opt opt_view_suid VIEW_SYM table_ident
{
if (Lex->main_select_push())
@@ -7925,12 +7920,7 @@ alter:
if (Lex->add_alter_view(thd, $2, $4, $6))
MYSQL_YYABORT;
}
- view_list_opt AS view_select
- {
- Lex->pop_select(); //main select
- if (Lex->check_main_unit_semantics())
- MYSQL_YYABORT;
- }
+ view_list_opt AS view_select stmt_end {}
| ALTER definer_opt opt_view_suid VIEW_SYM table_ident
/*
We have two separate rules for ALTER VIEW rather that
@@ -7943,12 +7933,7 @@ alter:
if (Lex->add_alter_view(thd, VIEW_ALGORITHM_INHERIT, $3, $5))
MYSQL_YYABORT;
}
- view_list_opt AS view_select
- {
- Lex->pop_select(); //main select
- if (Lex->check_main_unit_semantics())
- MYSQL_YYABORT;
- }
+ view_list_opt AS view_select stmt_end {}
| ALTER definer_opt remember_name EVENT_SYM sp_name
{
if (Lex->main_select_push())
@@ -8049,10 +8034,7 @@ alter:
Lex->m_sql_cmd= new (thd->mem_root) Sql_cmd_alter_sequence($3);
if (unlikely(Lex->m_sql_cmd == NULL))
MYSQL_YYABORT;
- Lex->pop_select(); //main select
- if (Lex->check_main_unit_semantics())
- MYSQL_YYABORT;
- }
+ } stmt_end {}
;
opt_account_locking:
@@ -13489,51 +13471,43 @@ opt_temporary:
insert:
INSERT
{
- LEX *lex= Lex;
- lex->sql_command= SQLCOM_INSERT;
- 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();
+ Lex->sql_command= SQLCOM_INSERT;
+ Lex->duplicates= DUP_ERROR;
}
- insert_field_spec opt_insert_update
+ insert_start insert_lock_option opt_ignore opt_into insert_table
{
- Lex->pop_select(); //main select
- if (Lex->check_main_unit_semantics())
- MYSQL_YYABORT;
+ Select->set_lock_for_tables($4, true);
}
- ;
+ insert_field_spec opt_insert_update stmt_end {}
+ ;
replace:
REPLACE
{
- LEX *lex=Lex;
- lex->sql_command = SQLCOM_REPLACE;
- lex->duplicates= DUP_REPLACE;
- if (Lex->main_select_push())
- MYSQL_YYABORT;
- mysql_init_select(lex);
- lex->current_select->parsing_place= BEFORE_OPT_LIST;
+ Lex->sql_command = SQLCOM_REPLACE;
+ Lex->duplicates= DUP_REPLACE;
}
- replace_lock_option insert2
+ insert_start replace_lock_option opt_into insert_table
{
- Select->set_lock_for_tables($3, true);
- Lex->current_select= Lex->first_select_lex();
+ Select->set_lock_for_tables($4, true);
}
- insert_field_spec
- {
- Lex->pop_select(); //main select
- if (Lex->check_main_unit_semantics())
- MYSQL_YYABORT;
- }
- ;
+ insert_field_spec stmt_end {}
+ ;
+
+insert_start: {
+ 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:
/* empty */
@@ -13545,19 +13519,17 @@ insert_lock_option:
*/
$$= (Lex->sphead ? TL_WRITE_DEFAULT : TL_WRITE_CONCURRENT_INSERT);
}
- | LOW_PRIORITY { $$= TL_WRITE_LOW_PRIORITY; }
- | 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;
- }
+ | insert_replace_option
| HIGH_PRIORITY { $$= TL_WRITE; }
;
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
{
Lex->keyword_delayed_begin_offset= (uint)($1.pos() - thd->query());
@@ -13566,10 +13538,7 @@ replace_lock_option:
}
;
-insert2:
- INTO insert_table {}
- | insert_table {}
- ;
+opt_into: /* nothing */ | INTO ;
insert_table:
{
@@ -13818,10 +13787,7 @@ update:
{
if ($10)
Select->order_list= *($10);
- Lex->pop_select(); //main select
- if (Lex->check_main_unit_semantics())
- MYSQL_YYABORT;
- }
+ } stmt_end {}
;
update_list:
@@ -13941,10 +13907,7 @@ single_multi:
{
if (unlikely(multi_delete_set_locks_and_link_aux_tables(Lex)))
MYSQL_YYABORT;
- Lex->pop_select(); //main select
- if (Lex->check_main_unit_semantics())
- MYSQL_YYABORT;
- }
+ } stmt_end {}
| FROM table_alias_ref_list
{
mysql_init_multi_delete(Lex);
@@ -13955,10 +13918,7 @@ single_multi:
{
if (unlikely(multi_delete_set_locks_and_link_aux_tables(Lex)))
MYSQL_YYABORT;
- Lex->pop_select(); //main select
- if (Lex->check_main_unit_semantics())
- MYSQL_YYABORT;
- }
+ } stmt_end {}
;
opt_select_expressions:
@@ -15023,11 +14983,7 @@ load:
opt_xml_rows_identified_by
opt_field_term opt_line_term opt_ignore_lines opt_field_or_var_spec
opt_load_data_set_spec
- {
- Lex->pop_select(); //main select
- if (Lex->check_main_unit_semantics())
- MYSQL_YYABORT;
- }
+ stmt_end {}
;
data_or_xml:
@@ -16701,11 +16657,7 @@ set:
lex->set_stmt_init();
}
set_param
- {
- Lex->pop_select(); //main select
- if (Lex->check_main_unit_semantics())
- MYSQL_YYABORT;
- }
+ stmt_end {}
;
set_param:
diff --git a/sql/sql_yacc_ora.yy b/sql/sql_yacc_ora.yy
index d475157f7ca..976e239beeb 100644
--- a/sql/sql_yacc_ora.yy
+++ b/sql/sql_yacc_ora.yy
@@ -1375,6 +1375,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize);
%type <lock_type>
replace_lock_option opt_low_priority insert_lock_option load_data_lock
+ insert_replace_option
%type <item>
literal insert_ident order_ident temporal_literal
@@ -1544,7 +1545,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize);
%type <NONE>
analyze_stmt_command backup backup_statements
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
show describe load alter optimize keycache preload flush
reset purge begin_stmt_mariadb commit rollback savepoint release
@@ -5320,7 +5321,7 @@ opt_create_partitioning:
/*
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.
The partition grammar can be called from three places.
@@ -7985,10 +7986,7 @@ alter:
lex->sql_command= SQLCOM_ALTER_PROCEDURE;
lex->spname= $3;
- Lex->pop_select(); //main select
- if (Lex->check_main_unit_semantics())
- MYSQL_YYABORT;
- }
+ } stmt_end {}
| ALTER FUNCTION_SYM sp_name
{
LEX *lex= Lex;
@@ -8005,10 +8003,7 @@ alter:
lex->sql_command= SQLCOM_ALTER_FUNCTION;
lex->spname= $3;
- Lex->pop_select(); //main select
- if (Lex->check_main_unit_semantics())
- MYSQL_YYABORT;
- }
+ } stmt_end {}
| ALTER view_algorithm definer_opt opt_view_suid VIEW_SYM table_ident
{
if (Lex->main_select_push())
@@ -8016,12 +8011,7 @@ alter:
if (Lex->add_alter_view(thd, $2, $4, $6))
MYSQL_YYABORT;
}
- view_list_opt AS view_select
- {
- Lex->pop_select(); //main select
- if (Lex->check_main_unit_semantics())
- MYSQL_YYABORT;
- }
+ view_list_opt AS view_select stmt_end {}
| ALTER definer_opt opt_view_suid VIEW_SYM table_ident
/*
We have two separate rules for ALTER VIEW rather that
@@ -8034,12 +8024,7 @@ alter:
if (Lex->add_alter_view(thd, VIEW_ALGORITHM_INHERIT, $3, $5))
MYSQL_YYABORT;
}
- view_list_opt AS view_select
- {
- Lex->pop_select(); //main select
- if (Lex->check_main_unit_semantics())
- MYSQL_YYABORT;
- }
+ view_list_opt AS view_select stmt_end {}
| ALTER definer_opt remember_name EVENT_SYM sp_name
{
if (Lex->main_select_push())
@@ -8140,10 +8125,7 @@ alter:
Lex->m_sql_cmd= new (thd->mem_root) Sql_cmd_alter_sequence($3);
if (unlikely(Lex->m_sql_cmd == NULL))
MYSQL_YYABORT;
- Lex->pop_select(); //main select
- if (Lex->check_main_unit_semantics())
- MYSQL_YYABORT;
- }
+ } stmt_end {}
;
opt_account_locking:
@@ -13605,51 +13587,43 @@ opt_temporary:
insert:
INSERT
{
- LEX *lex= Lex;
- lex->sql_command= SQLCOM_INSERT;
- 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();
+ Lex->sql_command= SQLCOM_INSERT;
+ Lex->duplicates= DUP_ERROR;
}
- insert_field_spec opt_insert_update
+ insert_start insert_lock_option opt_ignore opt_into insert_table
{
- Lex->pop_select(); //main select
- if (Lex->check_main_unit_semantics())
- MYSQL_YYABORT;
+ Select->set_lock_for_tables($4, true);
}
- ;
+ insert_field_spec opt_insert_update stmt_end {}
+ ;
replace:
REPLACE
{
- LEX *lex=Lex;
- lex->sql_command = SQLCOM_REPLACE;
- lex->duplicates= DUP_REPLACE;
- if (Lex->main_select_push())
- MYSQL_YYABORT;
- mysql_init_select(lex);
- lex->current_select->parsing_place= BEFORE_OPT_LIST;
+ Lex->sql_command = SQLCOM_REPLACE;
+ Lex->duplicates= DUP_REPLACE;
}
- replace_lock_option insert2
+ insert_start replace_lock_option opt_into insert_table
{
- Select->set_lock_for_tables($3, true);
- Lex->current_select= Lex->first_select_lex();
+ Select->set_lock_for_tables($4, true);
}
- insert_field_spec
- {
- Lex->pop_select(); //main select
- if (Lex->check_main_unit_semantics())
- MYSQL_YYABORT;
- }
- ;
+ insert_field_spec stmt_end {}
+ ;
+
+insert_start: {
+ 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:
/* empty */
@@ -13661,19 +13635,17 @@ insert_lock_option:
*/
$$= (Lex->sphead ? TL_WRITE_DEFAULT : TL_WRITE_CONCURRENT_INSERT);
}
- | LOW_PRIORITY { $$= TL_WRITE_LOW_PRIORITY; }
- | 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;
- }
+ | insert_replace_option
| HIGH_PRIORITY { $$= TL_WRITE; }
;
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
{
Lex->keyword_delayed_begin_offset= (uint)($1.pos() - thd->query());
@@ -13682,10 +13654,7 @@ replace_lock_option:
}
;
-insert2:
- INTO insert_table {}
- | insert_table {}
- ;
+opt_into: /* nothing */ | INTO ;
insert_table:
{
@@ -13934,10 +13903,7 @@ update:
{
if ($10)
Select->order_list= *($10);
- Lex->pop_select(); //main select
- if (Lex->check_main_unit_semantics())
- MYSQL_YYABORT;
- }
+ } stmt_end {}
;
update_list:
@@ -14057,10 +14023,7 @@ single_multi:
{
if (unlikely(multi_delete_set_locks_and_link_aux_tables(Lex)))
MYSQL_YYABORT;
- Lex->pop_select(); //main select
- if (Lex->check_main_unit_semantics())
- MYSQL_YYABORT;
- }
+ } stmt_end {}
| FROM table_alias_ref_list
{
mysql_init_multi_delete(Lex);
@@ -14071,10 +14034,7 @@ single_multi:
{
if (unlikely(multi_delete_set_locks_and_link_aux_tables(Lex)))
MYSQL_YYABORT;
- Lex->pop_select(); //main select
- if (Lex->check_main_unit_semantics())
- MYSQL_YYABORT;
- }
+ } stmt_end {}
;
opt_select_expressions:
@@ -15145,11 +15105,7 @@ load:
opt_xml_rows_identified_by
opt_field_term opt_line_term opt_ignore_lines opt_field_or_var_spec
opt_load_data_set_spec
- {
- Lex->pop_select(); //main select
- if (Lex->check_main_unit_semantics())
- MYSQL_YYABORT;
- }
+ stmt_end {}
;
data_or_xml:
@@ -16866,11 +16822,7 @@ set:
lex->set_stmt_init();
}
set_param
- {
- Lex->pop_select(); //main select
- if (Lex->check_main_unit_semantics())
- MYSQL_YYABORT;
- }
+ stmt_end {}
;
set_param: