diff options
author | Alexander Barkov <bar@mariadb.com> | 2018-11-12 00:01:12 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mariadb.com> | 2018-11-12 00:01:12 +0400 |
commit | 7f4aee22335c24a410d59978bf1cf20fc3fe90e3 (patch) | |
tree | 8adb827acaab033d4537ece20747cff11f4d5eff | |
parent | f5855ba03deef188516453b71e56d4239f74a653 (diff) | |
download | mariadb-git-7f4aee22335c24a410d59978bf1cf20fc3fe90e3.tar.gz |
MDEV-17666 sql_mode=ORACLE: Keyword ELSEIF should not be reserved
-rw-r--r-- | mysql-test/suite/compat/oracle/r/parser.result | 14 | ||||
-rw-r--r-- | mysql-test/suite/compat/oracle/t/parser.test | 23 | ||||
-rw-r--r-- | sql/gen_lex_token.cc | 3 | ||||
-rw-r--r-- | sql/lex.h | 2 | ||||
-rw-r--r-- | sql/sql_lex.cc | 1 | ||||
-rw-r--r-- | sql/sql_yacc.yy | 6 | ||||
-rw-r--r-- | sql/sql_yacc_ora.yy | 4 |
7 files changed, 48 insertions, 5 deletions
diff --git a/mysql-test/suite/compat/oracle/r/parser.result b/mysql-test/suite/compat/oracle/r/parser.result index 4ee34e5e2b3..7540763696f 100644 --- a/mysql-test/suite/compat/oracle/r/parser.result +++ b/mysql-test/suite/compat/oracle/r/parser.result @@ -532,3 +532,17 @@ BEGIN NULL; END; / +# +# MDEV-17666 sql_mode=ORACLE: Keyword ELSEIF should not be reserved +# +DECLARE +ELSEIF INT; +BEGIN +ELSEIF:=1; +END; +/ +BEGIN +<<ELSEIF>> +NULL; +END; +/ diff --git a/mysql-test/suite/compat/oracle/t/parser.test b/mysql-test/suite/compat/oracle/t/parser.test index b3387b3f922..dabd7956c44 100644 --- a/mysql-test/suite/compat/oracle/t/parser.test +++ b/mysql-test/suite/compat/oracle/t/parser.test @@ -316,3 +316,26 @@ BEGIN END; / DELIMITER ;/ + + +--echo # +--echo # MDEV-17666 sql_mode=ORACLE: Keyword ELSEIF should not be reserved +--echo # + +DELIMITER /; +DECLARE + ELSEIF INT; +BEGIN + ELSEIF:=1; +END; +/ +DELIMITER ;/ + +DELIMITER /; +BEGIN +<<ELSEIF>> + NULL; +END; +/ +DELIMITER ;/ + diff --git a/sql/gen_lex_token.cc b/sql/gen_lex_token.cc index aee0f12a4fe..f8c511e53ff 100644 --- a/sql/gen_lex_token.cc +++ b/sql/gen_lex_token.cc @@ -258,7 +258,8 @@ void compute_tokens() set_start_expr_token(RETURN_MARIADB_SYM); set_start_expr_token(RETURN_ORACLE_SYM); set_start_expr_token(IF_SYM); - set_start_expr_token(ELSEIF_SYM); + set_start_expr_token(ELSEIF_MARIADB_SYM); + set_start_expr_token(ELSEIF_ORACLE_SYM); set_start_expr_token(CASE_SYM); set_start_expr_token(WHEN_SYM); set_start_expr_token(WHILE_SYM); diff --git a/sql/lex.h b/sql/lex.h index 707bd464a14..9f0be46e905 100644 --- a/sql/lex.h +++ b/sql/lex.h @@ -205,7 +205,7 @@ static SYMBOL symbols[] = { { "DYNAMIC", SYM(DYNAMIC_SYM)}, { "EACH", SYM(EACH_SYM)}, { "ELSE", SYM(ELSE)}, - { "ELSEIF", SYM(ELSEIF_SYM)}, + { "ELSEIF", SYM(ELSEIF_MARIADB_SYM)}, { "ELSIF", SYM(ELSIF_MARIADB_SYM)}, { "ENABLE", SYM(ENABLE_SYM)}, { "ENCLOSED", SYM(ENCLOSED)}, diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 254889ac414..b0072b10c9c 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -845,6 +845,7 @@ int Lex_input_stream::find_keyword(Lex_ident_cli_st *kwd, case BODY_MARIADB_SYM: return BODY_ORACLE_SYM; case CONTINUE_MARIADB_SYM: return CONTINUE_ORACLE_SYM; case DECODE_MARIADB_SYM: return DECODE_ORACLE_SYM; + case ELSEIF_MARIADB_SYM: return ELSEIF_ORACLE_SYM; case ELSIF_MARIADB_SYM: return ELSIF_ORACLE_SYM; case EXCEPTION_MARIADB_SYM: return EXCEPTION_ORACLE_SYM; case EXIT_MARIADB_SYM: return EXIT_ORACLE_SYM; diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 8aea71b44ba..6a075e70cc5 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -984,7 +984,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %token DUAL_SYM %token EACH_SYM /* SQL-2003-R */ %token ELSE /* SQL-2003-R */ -%token ELSEIF_SYM +%token ELSEIF_MARIADB_SYM %token ELSIF_ORACLE_SYM /* PLSQL-R */ %token ENCLOSED %token END_OF_INPUT /* INTERNAL */ @@ -1219,6 +1219,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); Keywords that have different reserved status in std/oracle modes. */ %token <kwd> BODY_MARIADB_SYM // Oracle-R +%token <kwd> ELSEIF_ORACLE_SYM %token <kwd> ELSIF_MARIADB_SYM // PLSQL-R %token <kwd> EXCEPTION_ORACLE_SYM // SQL-2003-N, PLSQL-R %token <kwd> GOTO_MARIADB_SYM // Oracle-R @@ -4510,7 +4511,7 @@ sp_if: sp_elseifs: /* Empty */ - | ELSEIF_SYM sp_if + | ELSEIF_MARIADB_SYM sp_if | ELSE sp_proc_stmts1 ; @@ -15883,6 +15884,7 @@ keyword_sp_var_and_label: | DUMPFILE | DUPLICATE_SYM | DYNAMIC_SYM + | ELSEIF_ORACLE_SYM | ELSIF_MARIADB_SYM | ENDS_SYM | ENGINE_SYM diff --git a/sql/sql_yacc_ora.yy b/sql/sql_yacc_ora.yy index e465e3a19b6..87482a51c43 100644 --- a/sql/sql_yacc_ora.yy +++ b/sql/sql_yacc_ora.yy @@ -378,7 +378,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %token DUAL_SYM %token EACH_SYM /* SQL-2003-R */ %token ELSE /* SQL-2003-R */ -%token ELSEIF_SYM +%token ELSEIF_MARIADB_SYM %token ELSIF_ORACLE_SYM /* PLSQL-R */ %token ENCLOSED %token END_OF_INPUT /* INTERNAL */ @@ -613,6 +613,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); Keywords that have different reserved status in std/oracle modes. */ %token <kwd> BODY_MARIADB_SYM // Oracle-R +%token <kwd> ELSEIF_ORACLE_SYM %token <kwd> ELSIF_MARIADB_SYM // PLSQL-R %token <kwd> EXCEPTION_ORACLE_SYM // SQL-2003-N, PLSQL-R %token <kwd> GOTO_MARIADB_SYM // Oracle-R @@ -15917,6 +15918,7 @@ keyword_sp_var_and_label: | DUMPFILE | DUPLICATE_SYM | DYNAMIC_SYM + | ELSEIF_ORACLE_SYM | ELSIF_MARIADB_SYM | ENDS_SYM | ENGINE_SYM |