Commit def2ac20 authored by Alexander Barkov's avatar Alexander Barkov

MDEV-17652 Add sql_mode specific tokens for some keywords

parent aa4772e7
...@@ -255,7 +255,8 @@ void compute_tokens() ...@@ -255,7 +255,8 @@ void compute_tokens()
set_start_expr_token(STARTS_SYM); set_start_expr_token(STARTS_SYM);
set_start_expr_token(ENDS_SYM); set_start_expr_token(ENDS_SYM);
set_start_expr_token(DEFAULT); set_start_expr_token(DEFAULT);
set_start_expr_token(RETURN_SYM); set_start_expr_token(RETURN_MARIADB_SYM);
set_start_expr_token(RETURN_ORACLE_SYM);
set_start_expr_token(IF_SYM); set_start_expr_token(IF_SYM);
set_start_expr_token(ELSEIF_SYM); set_start_expr_token(ELSEIF_SYM);
set_start_expr_token(CASE_SYM); set_start_expr_token(CASE_SYM);
......
...@@ -82,7 +82,7 @@ static SYMBOL symbols[] = { ...@@ -82,7 +82,7 @@ static SYMBOL symbols[] = {
{ "AVG_ROW_LENGTH", SYM(AVG_ROW_LENGTH)}, { "AVG_ROW_LENGTH", SYM(AVG_ROW_LENGTH)},
{ "BACKUP", SYM(BACKUP_SYM)}, { "BACKUP", SYM(BACKUP_SYM)},
{ "BEFORE", SYM(BEFORE_SYM)}, { "BEFORE", SYM(BEFORE_SYM)},
{ "BEGIN", SYM(BEGIN_SYM)}, { "BEGIN", SYM(BEGIN_MARIADB_SYM)},
{ "BETWEEN", SYM(BETWEEN_SYM)}, { "BETWEEN", SYM(BETWEEN_SYM)},
{ "BIGINT", SYM(BIGINT)}, { "BIGINT", SYM(BIGINT)},
{ "BINARY", SYM(BINARY)}, { "BINARY", SYM(BINARY)},
...@@ -90,7 +90,7 @@ static SYMBOL symbols[] = { ...@@ -90,7 +90,7 @@ static SYMBOL symbols[] = {
{ "BIT", SYM(BIT_SYM)}, { "BIT", SYM(BIT_SYM)},
{ "BLOB", SYM(BLOB_SYM)}, { "BLOB", SYM(BLOB_SYM)},
{ "BLOCK", SYM(BLOCK_SYM)}, { "BLOCK", SYM(BLOCK_SYM)},
{ "BODY", SYM(BODY_SYM)}, { "BODY", SYM(BODY_MARIADB_SYM)},
{ "BOOL", SYM(BOOL_SYM)}, { "BOOL", SYM(BOOL_SYM)},
{ "BOOLEAN", SYM(BOOLEAN_SYM)}, { "BOOLEAN", SYM(BOOLEAN_SYM)},
{ "BOTH", SYM(BOTH)}, { "BOTH", SYM(BOTH)},
...@@ -145,7 +145,7 @@ static SYMBOL symbols[] = { ...@@ -145,7 +145,7 @@ static SYMBOL symbols[] = {
{ "CONSTRAINT_SCHEMA", SYM(CONSTRAINT_SCHEMA_SYM)}, { "CONSTRAINT_SCHEMA", SYM(CONSTRAINT_SCHEMA_SYM)},
{ "CONTAINS", SYM(CONTAINS_SYM)}, { "CONTAINS", SYM(CONTAINS_SYM)},
{ "CONTEXT", SYM(CONTEXT_SYM)}, { "CONTEXT", SYM(CONTEXT_SYM)},
{ "CONTINUE", SYM(CONTINUE_SYM)}, { "CONTINUE", SYM(CONTINUE_MARIADB_SYM)},
{ "CONTRIBUTORS", SYM(CONTRIBUTORS_SYM)}, { "CONTRIBUTORS", SYM(CONTRIBUTORS_SYM)},
{ "CONVERT", SYM(CONVERT_SYM)}, { "CONVERT", SYM(CONVERT_SYM)},
{ "CPU", SYM(CPU_SYM)}, { "CPU", SYM(CPU_SYM)},
...@@ -206,7 +206,7 @@ static SYMBOL symbols[] = { ...@@ -206,7 +206,7 @@ static SYMBOL symbols[] = {
{ "EACH", SYM(EACH_SYM)}, { "EACH", SYM(EACH_SYM)},
{ "ELSE", SYM(ELSE)}, { "ELSE", SYM(ELSE)},
{ "ELSEIF", SYM(ELSEIF_SYM)}, { "ELSEIF", SYM(ELSEIF_SYM)},
{ "ELSIF", SYM(ELSIF_SYM)}, { "ELSIF", SYM(ELSIF_MARIADB_SYM)},
{ "ENABLE", SYM(ENABLE_SYM)}, { "ENABLE", SYM(ENABLE_SYM)},
{ "ENCLOSED", SYM(ENCLOSED)}, { "ENCLOSED", SYM(ENCLOSED)},
{ "END", SYM(END)}, { "END", SYM(END)},
...@@ -226,9 +226,9 @@ static SYMBOL symbols[] = { ...@@ -226,9 +226,9 @@ static SYMBOL symbols[] = {
{ "EXCHANGE", SYM(EXCHANGE_SYM)}, { "EXCHANGE", SYM(EXCHANGE_SYM)},
{ "EXCLUDE", SYM(EXCLUDE_SYM)}, { "EXCLUDE", SYM(EXCLUDE_SYM)},
{ "EXECUTE", SYM(EXECUTE_SYM)}, { "EXECUTE", SYM(EXECUTE_SYM)},
{ "EXCEPTION", SYM(EXCEPTION_SYM)}, { "EXCEPTION", SYM(EXCEPTION_MARIADB_SYM)},
{ "EXISTS", SYM(EXISTS)}, { "EXISTS", SYM(EXISTS)},
{ "EXIT", SYM(EXIT_SYM)}, { "EXIT", SYM(EXIT_MARIADB_SYM)},
{ "EXPANSION", SYM(EXPANSION_SYM)}, { "EXPANSION", SYM(EXPANSION_SYM)},
{ "EXPORT", SYM(EXPORT_SYM)}, { "EXPORT", SYM(EXPORT_SYM)},
{ "EXPLAIN", SYM(DESCRIBE)}, { "EXPLAIN", SYM(DESCRIBE)},
...@@ -264,7 +264,7 @@ static SYMBOL symbols[] = { ...@@ -264,7 +264,7 @@ static SYMBOL symbols[] = {
{ "GET_FORMAT", SYM(GET_FORMAT)}, { "GET_FORMAT", SYM(GET_FORMAT)},
{ "GET", SYM(GET_SYM)}, { "GET", SYM(GET_SYM)},
{ "GLOBAL", SYM(GLOBAL_SYM)}, { "GLOBAL", SYM(GLOBAL_SYM)},
{ "GOTO", SYM(GOTO_SYM)}, { "GOTO", SYM(GOTO_MARIADB_SYM)},
{ "GRANT", SYM(GRANT)}, { "GRANT", SYM(GRANT)},
{ "GRANTS", SYM(GRANTS)}, { "GRANTS", SYM(GRANTS)},
{ "GROUP", SYM(GROUP_SYM)}, { "GROUP", SYM(GROUP_SYM)},
...@@ -451,13 +451,13 @@ static SYMBOL symbols[] = { ...@@ -451,13 +451,13 @@ static SYMBOL symbols[] = {
{ "OPTIONALLY", SYM(OPTIONALLY)}, { "OPTIONALLY", SYM(OPTIONALLY)},
{ "OR", SYM(OR_SYM)}, { "OR", SYM(OR_SYM)},
{ "ORDER", SYM(ORDER_SYM)}, { "ORDER", SYM(ORDER_SYM)},
{ "OTHERS", SYM(OTHERS_SYM)}, { "OTHERS", SYM(OTHERS_MARIADB_SYM)},
{ "OUT", SYM(OUT_SYM)}, { "OUT", SYM(OUT_SYM)},
{ "OUTER", SYM(OUTER)}, { "OUTER", SYM(OUTER)},
{ "OUTFILE", SYM(OUTFILE)}, { "OUTFILE", SYM(OUTFILE)},
{ "OVER", SYM(OVER_SYM)}, { "OVER", SYM(OVER_SYM)},
{ "OWNER", SYM(OWNER_SYM)}, { "OWNER", SYM(OWNER_SYM)},
{ "PACKAGE", SYM(PACKAGE_SYM)}, { "PACKAGE", SYM(PACKAGE_MARIADB_SYM)},
{ "PACK_KEYS", SYM(PACK_KEYS_SYM)}, { "PACK_KEYS", SYM(PACK_KEYS_SYM)},
{ "PAGE", SYM(PAGE_SYM)}, { "PAGE", SYM(PAGE_SYM)},
{ "PAGE_CHECKSUM", SYM(PAGE_CHECKSUM_SYM)}, { "PAGE_CHECKSUM", SYM(PAGE_CHECKSUM_SYM)},
...@@ -495,7 +495,7 @@ static SYMBOL symbols[] = { ...@@ -495,7 +495,7 @@ static SYMBOL symbols[] = {
{ "QUARTER", SYM(QUARTER_SYM)}, { "QUARTER", SYM(QUARTER_SYM)},
{ "QUERY", SYM(QUERY_SYM)}, { "QUERY", SYM(QUERY_SYM)},
{ "QUICK", SYM(QUICK)}, { "QUICK", SYM(QUICK)},
{ "RAISE", SYM(RAISE_SYM)}, { "RAISE", SYM(RAISE_MARIADB_SYM)},
{ "RANGE", SYM(RANGE_SYM)}, { "RANGE", SYM(RANGE_SYM)},
{ "RAW", SYM(RAW)}, { "RAW", SYM(RAW)},
{ "READ", SYM(READ_SYM)}, { "READ", SYM(READ_SYM)},
...@@ -534,7 +534,7 @@ static SYMBOL symbols[] = { ...@@ -534,7 +534,7 @@ static SYMBOL symbols[] = {
{ "RESTRICT", SYM(RESTRICT)}, { "RESTRICT", SYM(RESTRICT)},
{ "RESUME", SYM(RESUME_SYM)}, { "RESUME", SYM(RESUME_SYM)},
{ "RETURNED_SQLSTATE",SYM(RETURNED_SQLSTATE_SYM)}, { "RETURNED_SQLSTATE",SYM(RETURNED_SQLSTATE_SYM)},
{ "RETURN", SYM(RETURN_SYM)}, { "RETURN", SYM(RETURN_MARIADB_SYM)},
{ "RETURNING", SYM(RETURNING_SYM)}, { "RETURNING", SYM(RETURNING_SYM)},
{ "RETURNS", SYM(RETURNS_SYM)}, { "RETURNS", SYM(RETURNS_SYM)},
{ "REUSE", SYM(REUSE_SYM)}, { "REUSE", SYM(REUSE_SYM)},
...@@ -549,7 +549,7 @@ static SYMBOL symbols[] = { ...@@ -549,7 +549,7 @@ static SYMBOL symbols[] = {
{ "ROW", SYM(ROW_SYM)}, { "ROW", SYM(ROW_SYM)},
{ "ROWCOUNT", SYM(ROWCOUNT_SYM)}, /* Oracle-N */ { "ROWCOUNT", SYM(ROWCOUNT_SYM)}, /* Oracle-N */
{ "ROWS", SYM(ROWS_SYM)}, { "ROWS", SYM(ROWS_SYM)},
{ "ROWTYPE", SYM(ROWTYPE_SYM)}, { "ROWTYPE", SYM(ROWTYPE_MARIADB_SYM)},
{ "ROW_COUNT", SYM(ROW_COUNT_SYM)}, { "ROW_COUNT", SYM(ROW_COUNT_SYM)},
{ "ROW_FORMAT", SYM(ROW_FORMAT_SYM)}, { "ROW_FORMAT", SYM(ROW_FORMAT_SYM)},
{ "RTREE", SYM(RTREE_SYM)}, { "RTREE", SYM(RTREE_SYM)},
......
...@@ -409,6 +409,19 @@ sp_condition_value *sp_pcontext::find_condition(const LEX_CSTRING *name, ...@@ -409,6 +409,19 @@ sp_condition_value *sp_pcontext::find_condition(const LEX_CSTRING *name,
NULL; NULL;
} }
sp_condition_value *
sp_pcontext::find_declared_or_predefined_condition(THD *thd,
const LEX_CSTRING *name)
const
{
sp_condition_value *p= find_condition(name, false);
if (p)
return p;
if (thd->variables.sql_mode & MODE_ORACLE)
return find_predefined_condition(name);
return NULL;
}
static sp_condition_value static sp_condition_value
// Warnings // Warnings
......
...@@ -592,13 +592,7 @@ class sp_pcontext : public Sql_alloc ...@@ -592,13 +592,7 @@ class sp_pcontext : public Sql_alloc
bool current_scope_only) const; bool current_scope_only) const;
sp_condition_value * sp_condition_value *
find_declared_or_predefined_condition(const LEX_CSTRING *name) const find_declared_or_predefined_condition(THD *thd, const LEX_CSTRING *name) const;
{
sp_condition_value *p= find_condition(name, false);
if (p)
return p;
return find_predefined_condition(name);
}
bool declare_condition(THD *thd, const LEX_CSTRING *name, bool declare_condition(THD *thd, const LEX_CSTRING *name,
sp_condition_value *val) sp_condition_value *val)
......
...@@ -838,6 +838,24 @@ int Lex_input_stream::find_keyword(Lex_ident_cli_st *kwd, ...@@ -838,6 +838,24 @@ int Lex_input_stream::find_keyword(Lex_ident_cli_st *kwd,
DBUG_ASSERT(tok >= get_buf()); DBUG_ASSERT(tok >= get_buf());
DBUG_ASSERT(tok < get_end_of_query()); DBUG_ASSERT(tok < get_end_of_query());
if (m_thd->variables.sql_mode & MODE_ORACLE)
{
switch (symbol->tok) {
case BEGIN_MARIADB_SYM: return BEGIN_ORACLE_SYM;
case BODY_MARIADB_SYM: return BODY_ORACLE_SYM;
case CONTINUE_MARIADB_SYM: return CONTINUE_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;
case GOTO_MARIADB_SYM: return GOTO_ORACLE_SYM;
case OTHERS_MARIADB_SYM: return OTHERS_ORACLE_SYM;
case PACKAGE_MARIADB_SYM: return PACKAGE_ORACLE_SYM;
case RAISE_MARIADB_SYM: return RAISE_ORACLE_SYM;
case RETURN_MARIADB_SYM: return RETURN_ORACLE_SYM;
case ROWTYPE_MARIADB_SYM: return ROWTYPE_ORACLE_SYM;
}
}
if ((symbol->tok == NOT_SYM) && if ((symbol->tok == NOT_SYM) &&
(m_thd->variables.sql_mode & MODE_HIGH_NOT_PRECEDENCE)) (m_thd->variables.sql_mode & MODE_HIGH_NOT_PRECEDENCE))
return NOT2_SYM; return NOT2_SYM;
......
This diff is collapsed.
This diff is collapsed.
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