revision-id: 867d65ef78405ed3a7b3c8c71265a7c4a2b71726 (mariadb-10.3.5-107-g867d65e) parent(s): 6936857654df02555fec95259c46ab07e7591413 author: Igor Babaev committer: Igor Babaev timestamp: 2018-04-05 19:15:49 -0700 message: Another attempt to fix the problem of using VALUE instead of VALUES in insert statements. --- sql/sql_lex.cc | 35 ++++++++++++++++++++--------------- sql/sql_priv.h | 3 ++- sql/sql_yacc.yy | 11 +++++++---- 3 files changed, 29 insertions(+), 20 deletions(-) diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index cc7cc8d..2765a46 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -1341,6 +1341,8 @@ int MYSQLlex(YYSTYPE *yylval, THD *thd) token= lex_one_token(yylval, thd); lip->add_digest_token(token, yylval); + SELECT_LEX *curr_sel= thd->lex->current_select; + switch(token) { case WITH: /* @@ -1391,15 +1393,16 @@ int MYSQLlex(YYSTYPE *yylval, THD *thd) } break; case VALUES: - if (thd->lex->current_select && - thd->lex->current_select->parsing_place == BEFORE_OPT_FIELD_LIST) + if (curr_sel && + (curr_sel->parsing_place == BEFORE_OPT_LIST || + curr_sel->parsing_place == AFTER_LIST)) { - thd->lex->current_select->parsing_place= NO_MATTER; + curr_sel->parsing_place= NO_MATTER; break; } - if (thd->lex->current_select && - (thd->lex->current_select->parsing_place == IN_UPDATE_ON_DUP_KEY || - thd->lex->current_select->parsing_place == IN_PART_FUNC)) + if (curr_sel && + (curr_sel->parsing_place == IN_UPDATE_ON_DUP_KEY || + curr_sel->parsing_place == IN_PART_FUNC)) return VALUE_SYM; token= lex_one_token(yylval, thd); lip->add_digest_token(token, yylval); @@ -1415,32 +1418,34 @@ int MYSQLlex(YYSTYPE *yylval, THD *thd) return VALUES; } case VALUE_SYM: - if (thd->lex->current_select && - thd->lex->current_select->parsing_place == BEFORE_OPT_FIELD_LIST) + if (curr_sel && + (curr_sel->parsing_place == BEFORE_OPT_LIST || + curr_sel->parsing_place == AFTER_LIST)) { - thd->lex->current_select->parsing_place= NO_MATTER; + curr_sel->parsing_place= NO_MATTER; return VALUES; } break; case PARTITION_SYM: case SELECT_SYM: case UNION_SYM: - if (thd->lex->current_select && - thd->lex->current_select->parsing_place == BEFORE_OPT_FIELD_LIST) + if (curr_sel && + (curr_sel->parsing_place == BEFORE_OPT_LIST || + curr_sel->parsing_place == AFTER_LIST)) { - thd->lex->current_select->parsing_place= NO_MATTER; + curr_sel->parsing_place= NO_MATTER; } break; case left_paren: - if (!thd->lex->current_select || - thd->lex->current_select->parsing_place != BEFORE_OPT_FIELD_LIST) + if (!curr_sel || + curr_sel->parsing_place != BEFORE_OPT_LIST) return token; token= lex_one_token(yylval, thd); lip->add_digest_token(token, yylval); lip->lookahead_yylval= lip->yylval; lip->yylval= NULL; lip->lookahead_token= token; - thd->lex->current_select->parsing_place= NO_MATTER; + curr_sel->parsing_place= NO_MATTER; if (token == LIKE) return LEFT_PAREN_LIKE; if (token == WITH) diff --git a/sql/sql_priv.h b/sql/sql_priv.h index ef8cb39..4de8b8c 100644 --- a/sql/sql_priv.h +++ b/sql/sql_priv.h @@ -359,7 +359,8 @@ enum enum_parsing_place IN_ORDER_BY, IN_UPDATE_ON_DUP_KEY, IN_PART_FUNC, - BEFORE_OPT_FIELD_LIST, + BEFORE_OPT_LIST, + AFTER_LIST, PARSING_PLACE_SIZE /* always should be the last */ }; diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 6b47205..f231bfb 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -2573,7 +2573,7 @@ create: lex->create_info.init(); if (lex->main_select_push()) MYSQL_YYABORT; - lex->current_select->parsing_place= BEFORE_OPT_FIELD_LIST; + lex->current_select->parsing_place= BEFORE_OPT_LIST; if (lex->set_command_with_check(SQLCOM_CREATE_TABLE, $2, $1 | $4)) MYSQL_YYABORT; } @@ -13390,7 +13390,7 @@ insert: if (Lex->main_select_push()) MYSQL_YYABORT; mysql_init_select(lex); - lex->current_select->parsing_place= BEFORE_OPT_FIELD_LIST; + lex->current_select->parsing_place= BEFORE_OPT_LIST; } insert_lock_option opt_ignore insert2 @@ -13415,7 +13415,7 @@ replace: if (Lex->main_select_push()) MYSQL_YYABORT; mysql_init_select(lex); - lex->current_select->parsing_place= BEFORE_OPT_FIELD_LIST; + lex->current_select->parsing_place= BEFORE_OPT_LIST; } replace_lock_option insert2 { @@ -13494,6 +13494,9 @@ insert_field_spec: insert_field_list: LEFT_PAREN_ALT opt_fields ')' + { + Lex->current_select->parsing_place= AFTER_LIST; + } ; opt_fields: @@ -15216,7 +15219,7 @@ with_clause: lex->curr_with_clause= with_clause; with_clause->add_to_list(Lex->with_clauses_list_last_next); if (lex->current_select && - lex->current_select->parsing_place == BEFORE_OPT_FIELD_LIST) + lex->current_select->parsing_place == BEFORE_OPT_LIST) lex->current_select->parsing_place= NO_MATTER; } with_list