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