mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
A join patch for MDEV-17660 and MDEV-17661
MDEV-17660 sql_mode=ORACLE: Some keywords do not work as label names: history, system, versioning, without MDEV-17661 Add sql_mode specific tokens for the keyword DECODE
This commit is contained in:
@ -499,3 +499,36 @@ test.comment()
|
|||||||
Warnings:
|
Warnings:
|
||||||
Note 1585 This function 'comment' has the same name as a native function
|
Note 1585 This function 'comment' has the same name as a native function
|
||||||
DROP FUNCTION comment;
|
DROP FUNCTION comment;
|
||||||
|
#
|
||||||
|
# MDEV-17660 sql_mode=ORACLE: Some keywords do not work as label names: history, system, versioning, without
|
||||||
|
#
|
||||||
|
BEGIN
|
||||||
|
<<date_format>>
|
||||||
|
NULL;
|
||||||
|
END;
|
||||||
|
/
|
||||||
|
BEGIN
|
||||||
|
<<decode>>
|
||||||
|
NULL;
|
||||||
|
END;
|
||||||
|
/
|
||||||
|
BEGIN
|
||||||
|
<<history>>
|
||||||
|
NULL;
|
||||||
|
END;
|
||||||
|
/
|
||||||
|
BEGIN
|
||||||
|
<<system>>
|
||||||
|
NULL;
|
||||||
|
END;
|
||||||
|
/
|
||||||
|
BEGIN
|
||||||
|
<<versioning>>
|
||||||
|
NULL;
|
||||||
|
END;
|
||||||
|
/
|
||||||
|
BEGIN
|
||||||
|
<<without>>
|
||||||
|
NULL;
|
||||||
|
END;
|
||||||
|
/
|
||||||
|
@ -258,3 +258,61 @@ enable_prepare_warnings;
|
|||||||
SELECT test.comment() FROM DUAL;
|
SELECT test.comment() FROM DUAL;
|
||||||
disable_prepare_warnings;
|
disable_prepare_warnings;
|
||||||
DROP FUNCTION comment;
|
DROP FUNCTION comment;
|
||||||
|
|
||||||
|
|
||||||
|
--echo #
|
||||||
|
--echo # MDEV-17660 sql_mode=ORACLE: Some keywords do not work as label names: history, system, versioning, without
|
||||||
|
--echo #
|
||||||
|
|
||||||
|
DELIMITER /;
|
||||||
|
BEGIN
|
||||||
|
<<date_format>>
|
||||||
|
NULL;
|
||||||
|
END;
|
||||||
|
/
|
||||||
|
DELIMITER ;/
|
||||||
|
|
||||||
|
|
||||||
|
DELIMITER /;
|
||||||
|
BEGIN
|
||||||
|
<<decode>>
|
||||||
|
NULL;
|
||||||
|
END;
|
||||||
|
/
|
||||||
|
DELIMITER ;/
|
||||||
|
|
||||||
|
|
||||||
|
DELIMITER /;
|
||||||
|
BEGIN
|
||||||
|
<<history>>
|
||||||
|
NULL;
|
||||||
|
END;
|
||||||
|
/
|
||||||
|
DELIMITER ;/
|
||||||
|
|
||||||
|
|
||||||
|
DELIMITER /;
|
||||||
|
BEGIN
|
||||||
|
<<system>>
|
||||||
|
NULL;
|
||||||
|
END;
|
||||||
|
/
|
||||||
|
DELIMITER ;/
|
||||||
|
|
||||||
|
|
||||||
|
DELIMITER /;
|
||||||
|
BEGIN
|
||||||
|
<<versioning>>
|
||||||
|
NULL;
|
||||||
|
END;
|
||||||
|
/
|
||||||
|
DELIMITER ;/
|
||||||
|
|
||||||
|
|
||||||
|
DELIMITER /;
|
||||||
|
BEGIN
|
||||||
|
<<without>>
|
||||||
|
NULL;
|
||||||
|
END;
|
||||||
|
/
|
||||||
|
DELIMITER ;/
|
||||||
|
@ -739,7 +739,7 @@ static SYMBOL sql_functions[] = {
|
|||||||
{ "DATE_ADD", SYM(DATE_ADD_INTERVAL)},
|
{ "DATE_ADD", SYM(DATE_ADD_INTERVAL)},
|
||||||
{ "DATE_SUB", SYM(DATE_SUB_INTERVAL)},
|
{ "DATE_SUB", SYM(DATE_SUB_INTERVAL)},
|
||||||
{ "DATE_FORMAT", SYM(DATE_FORMAT_SYM)},
|
{ "DATE_FORMAT", SYM(DATE_FORMAT_SYM)},
|
||||||
{ "DECODE", SYM(DECODE_SYM)},
|
{ "DECODE", SYM(DECODE_MARIADB_SYM)},
|
||||||
{ "DENSE_RANK", SYM(DENSE_RANK_SYM)},
|
{ "DENSE_RANK", SYM(DENSE_RANK_SYM)},
|
||||||
{ "EXTRACT", SYM(EXTRACT_SYM)},
|
{ "EXTRACT", SYM(EXTRACT_SYM)},
|
||||||
{ "FIRST_VALUE", SYM(FIRST_VALUE_SYM)},
|
{ "FIRST_VALUE", SYM(FIRST_VALUE_SYM)},
|
||||||
|
@ -844,6 +844,7 @@ int Lex_input_stream::find_keyword(Lex_ident_cli_st *kwd,
|
|||||||
case BEGIN_MARIADB_SYM: return BEGIN_ORACLE_SYM;
|
case BEGIN_MARIADB_SYM: return BEGIN_ORACLE_SYM;
|
||||||
case BODY_MARIADB_SYM: return BODY_ORACLE_SYM;
|
case BODY_MARIADB_SYM: return BODY_ORACLE_SYM;
|
||||||
case CONTINUE_MARIADB_SYM: return CONTINUE_ORACLE_SYM;
|
case CONTINUE_MARIADB_SYM: return CONTINUE_ORACLE_SYM;
|
||||||
|
case DECODE_MARIADB_SYM: return DECODE_ORACLE_SYM;
|
||||||
case ELSIF_MARIADB_SYM: return ELSIF_ORACLE_SYM;
|
case ELSIF_MARIADB_SYM: return ELSIF_ORACLE_SYM;
|
||||||
case EXCEPTION_MARIADB_SYM: return EXCEPTION_ORACLE_SYM;
|
case EXCEPTION_MARIADB_SYM: return EXCEPTION_ORACLE_SYM;
|
||||||
case EXIT_MARIADB_SYM: return EXIT_ORACLE_SYM;
|
case EXIT_MARIADB_SYM: return EXIT_ORACLE_SYM;
|
||||||
|
@ -1314,7 +1314,8 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize);
|
|||||||
%token <kwd> DATE_SYM /* SQL-2003-R, Oracle-R, PLSQL-R */
|
%token <kwd> DATE_SYM /* SQL-2003-R, Oracle-R, PLSQL-R */
|
||||||
%token <kwd> DAY_SYM /* SQL-2003-R */
|
%token <kwd> DAY_SYM /* SQL-2003-R */
|
||||||
%token <kwd> DEALLOCATE_SYM /* SQL-2003-R */
|
%token <kwd> DEALLOCATE_SYM /* SQL-2003-R */
|
||||||
%token <kwd> DECODE_SYM /* Oracle function, non-reserved */
|
%token <kwd> DECODE_MARIADB_SYM /* Function, non-reserved */
|
||||||
|
%token <kwd> DECODE_ORACLE_SYM /* Function, non-reserved */
|
||||||
%token <kwd> DEFINER_SYM
|
%token <kwd> DEFINER_SYM
|
||||||
%token <kwd> DELAYED_SYM
|
%token <kwd> DELAYED_SYM
|
||||||
%token <kwd> DELAY_KEY_WRITE_SYM
|
%token <kwd> DELAY_KEY_WRITE_SYM
|
||||||
@ -1961,6 +1962,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize);
|
|||||||
%type <item_list>
|
%type <item_list>
|
||||||
expr_list opt_udf_expr_list udf_expr_list when_list when_list_opt_else
|
expr_list opt_udf_expr_list udf_expr_list when_list when_list_opt_else
|
||||||
ident_list ident_list_arg opt_expr_list
|
ident_list ident_list_arg opt_expr_list
|
||||||
|
decode_when_list_oracle
|
||||||
|
|
||||||
%type <sp_cursor_stmt>
|
%type <sp_cursor_stmt>
|
||||||
sp_cursor_stmt_lex
|
sp_cursor_stmt_lex
|
||||||
@ -10538,12 +10540,18 @@ function_call_nonkeyword:
|
|||||||
if (unlikely($$ == NULL))
|
if (unlikely($$ == NULL))
|
||||||
MYSQL_YYABORT;
|
MYSQL_YYABORT;
|
||||||
}
|
}
|
||||||
| DECODE_SYM '(' expr ',' expr ')'
|
| DECODE_MARIADB_SYM '(' expr ',' expr ')'
|
||||||
{
|
{
|
||||||
$$= new (thd->mem_root) Item_func_decode(thd, $3, $5);
|
$$= new (thd->mem_root) Item_func_decode(thd, $3, $5);
|
||||||
if (unlikely($$ == NULL))
|
if (unlikely($$ == NULL))
|
||||||
MYSQL_YYABORT;
|
MYSQL_YYABORT;
|
||||||
}
|
}
|
||||||
|
| DECODE_ORACLE_SYM '(' expr ',' decode_when_list_oracle ')'
|
||||||
|
{
|
||||||
|
$5->push_front($3, thd->mem_root);
|
||||||
|
if (unlikely(!($$= new (thd->mem_root) Item_func_decode_oracle(thd, *$5))))
|
||||||
|
MYSQL_YYABORT;
|
||||||
|
}
|
||||||
| EXTRACT_SYM '(' interval FROM expr ')'
|
| EXTRACT_SYM '(' interval FROM expr ')'
|
||||||
{
|
{
|
||||||
$$=new (thd->mem_root) Item_extract(thd, $3, $5);
|
$$=new (thd->mem_root) Item_extract(thd, $3, $5);
|
||||||
@ -11701,6 +11709,25 @@ when_list_opt_else:
|
|||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
decode_when_list_oracle:
|
||||||
|
expr ',' expr
|
||||||
|
{
|
||||||
|
$$= new (thd->mem_root) List<Item>;
|
||||||
|
if (unlikely($$ == NULL) ||
|
||||||
|
unlikely($$->push_back($1, thd->mem_root)) ||
|
||||||
|
unlikely($$->push_back($3, thd->mem_root)))
|
||||||
|
MYSQL_YYABORT;
|
||||||
|
|
||||||
|
}
|
||||||
|
| decode_when_list_oracle ',' expr
|
||||||
|
{
|
||||||
|
$$= $1;
|
||||||
|
if (unlikely($$->push_back($3, thd->mem_root)))
|
||||||
|
MYSQL_YYABORT;
|
||||||
|
}
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
/* Equivalent to <table reference> in the SQL:2003 standard. */
|
/* Equivalent to <table reference> in the SQL:2003 standard. */
|
||||||
/* Warning - may return NULL in case of incomplete SELECT */
|
/* Warning - may return NULL in case of incomplete SELECT */
|
||||||
table_ref:
|
table_ref:
|
||||||
@ -15801,7 +15828,8 @@ keyword_sp_var_and_label:
|
|||||||
| DATAFILE_SYM
|
| DATAFILE_SYM
|
||||||
| DATE_FORMAT_SYM
|
| DATE_FORMAT_SYM
|
||||||
| DAY_SYM
|
| DAY_SYM
|
||||||
| DECODE_SYM
|
| DECODE_MARIADB_SYM
|
||||||
|
| DECODE_ORACLE_SYM
|
||||||
| DEFINER_SYM
|
| DEFINER_SYM
|
||||||
| DELAY_KEY_WRITE_SYM
|
| DELAY_KEY_WRITE_SYM
|
||||||
| DES_KEY_FILE
|
| DES_KEY_FILE
|
||||||
|
@ -708,7 +708,8 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize);
|
|||||||
%token <kwd> DATE_SYM /* SQL-2003-R, Oracle-R, PLSQL-R */
|
%token <kwd> DATE_SYM /* SQL-2003-R, Oracle-R, PLSQL-R */
|
||||||
%token <kwd> DAY_SYM /* SQL-2003-R */
|
%token <kwd> DAY_SYM /* SQL-2003-R */
|
||||||
%token <kwd> DEALLOCATE_SYM /* SQL-2003-R */
|
%token <kwd> DEALLOCATE_SYM /* SQL-2003-R */
|
||||||
%token <kwd> DECODE_SYM /* Oracle function, non-reserved */
|
%token <kwd> DECODE_MARIADB_SYM /* Function, non-reserved */
|
||||||
|
%token <kwd> DECODE_ORACLE_SYM /* Function, non-reserved */
|
||||||
%token <kwd> DEFINER_SYM
|
%token <kwd> DEFINER_SYM
|
||||||
%token <kwd> DELAYED_SYM
|
%token <kwd> DELAYED_SYM
|
||||||
%token <kwd> DELAY_KEY_WRITE_SYM
|
%token <kwd> DELAY_KEY_WRITE_SYM
|
||||||
@ -1364,7 +1365,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize);
|
|||||||
%type <item_list>
|
%type <item_list>
|
||||||
expr_list opt_udf_expr_list udf_expr_list when_list when_list_opt_else
|
expr_list opt_udf_expr_list udf_expr_list when_list when_list_opt_else
|
||||||
ident_list ident_list_arg opt_expr_list
|
ident_list ident_list_arg opt_expr_list
|
||||||
decode_when_list
|
decode_when_list_oracle
|
||||||
|
|
||||||
%type <sp_cursor_stmt>
|
%type <sp_cursor_stmt>
|
||||||
sp_cursor_stmt_lex
|
sp_cursor_stmt_lex
|
||||||
@ -10211,24 +10212,6 @@ column_default_non_parenthesized_expr:
|
|||||||
if (unlikely($$ == NULL))
|
if (unlikely($$ == NULL))
|
||||||
MYSQL_YYABORT;
|
MYSQL_YYABORT;
|
||||||
}
|
}
|
||||||
| DATE_FORMAT_SYM '(' expr ',' expr ')'
|
|
||||||
{
|
|
||||||
$$= new (thd->mem_root) Item_func_date_format(thd, $3, $5);
|
|
||||||
if (unlikely($$ == NULL))
|
|
||||||
MYSQL_YYABORT;
|
|
||||||
}
|
|
||||||
| DATE_FORMAT_SYM '(' expr ',' expr ',' expr ')'
|
|
||||||
{
|
|
||||||
$$= new (thd->mem_root) Item_func_date_format(thd, $3, $5, $7);
|
|
||||||
if (unlikely($$ == NULL))
|
|
||||||
MYSQL_YYABORT;
|
|
||||||
}
|
|
||||||
| DECODE_SYM '(' expr ',' decode_when_list ')'
|
|
||||||
{
|
|
||||||
$5->push_front($3, thd->mem_root);
|
|
||||||
if (unlikely(!($$= new (thd->mem_root) Item_func_decode_oracle(thd, *$5))))
|
|
||||||
MYSQL_YYABORT;
|
|
||||||
}
|
|
||||||
| DEFAULT '(' simple_ident ')'
|
| DEFAULT '(' simple_ident ')'
|
||||||
{
|
{
|
||||||
Item_splocal *il= $3->get_item_splocal();
|
Item_splocal *il= $3->get_item_splocal();
|
||||||
@ -10565,6 +10548,30 @@ function_call_nonkeyword:
|
|||||||
if (unlikely($$ == NULL))
|
if (unlikely($$ == NULL))
|
||||||
MYSQL_YYABORT;
|
MYSQL_YYABORT;
|
||||||
}
|
}
|
||||||
|
| DATE_FORMAT_SYM '(' expr ',' expr ')'
|
||||||
|
{
|
||||||
|
$$= new (thd->mem_root) Item_func_date_format(thd, $3, $5);
|
||||||
|
if (unlikely($$ == NULL))
|
||||||
|
MYSQL_YYABORT;
|
||||||
|
}
|
||||||
|
| DATE_FORMAT_SYM '(' expr ',' expr ',' expr ')'
|
||||||
|
{
|
||||||
|
$$= new (thd->mem_root) Item_func_date_format(thd, $3, $5, $7);
|
||||||
|
if (unlikely($$ == NULL))
|
||||||
|
MYSQL_YYABORT;
|
||||||
|
}
|
||||||
|
| DECODE_MARIADB_SYM '(' expr ',' expr ')'
|
||||||
|
{
|
||||||
|
$$= new (thd->mem_root) Item_func_decode(thd, $3, $5);
|
||||||
|
if (unlikely($$ == NULL))
|
||||||
|
MYSQL_YYABORT;
|
||||||
|
}
|
||||||
|
| DECODE_ORACLE_SYM '(' expr ',' decode_when_list_oracle ')'
|
||||||
|
{
|
||||||
|
$5->push_front($3, thd->mem_root);
|
||||||
|
if (unlikely(!($$= new (thd->mem_root) Item_func_decode_oracle(thd, *$5))))
|
||||||
|
MYSQL_YYABORT;
|
||||||
|
}
|
||||||
| EXTRACT_SYM '(' interval FROM expr ')'
|
| EXTRACT_SYM '(' interval FROM expr ')'
|
||||||
{
|
{
|
||||||
$$=new (thd->mem_root) Item_extract(thd, $3, $5);
|
$$=new (thd->mem_root) Item_extract(thd, $3, $5);
|
||||||
@ -11730,7 +11737,7 @@ when_list_opt_else:
|
|||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
decode_when_list:
|
decode_when_list_oracle:
|
||||||
expr ',' expr
|
expr ',' expr
|
||||||
{
|
{
|
||||||
$$= new (thd->mem_root) List<Item>;
|
$$= new (thd->mem_root) List<Item>;
|
||||||
@ -11740,7 +11747,7 @@ decode_when_list:
|
|||||||
MYSQL_YYABORT;
|
MYSQL_YYABORT;
|
||||||
|
|
||||||
}
|
}
|
||||||
| decode_when_list ',' expr
|
| decode_when_list_oracle ',' expr
|
||||||
{
|
{
|
||||||
$$= $1;
|
$$= $1;
|
||||||
if (unlikely($$->push_back($3, thd->mem_root)))
|
if (unlikely($$->push_back($3, thd->mem_root)))
|
||||||
@ -15704,7 +15711,6 @@ keyword_sp_var_not_label:
|
|||||||
| FORMAT_SYM
|
| FORMAT_SYM
|
||||||
| GET_SYM
|
| GET_SYM
|
||||||
| HELP_SYM
|
| HELP_SYM
|
||||||
| HISTORY_SYM
|
|
||||||
| HOST_SYM
|
| HOST_SYM
|
||||||
| INSTALL_SYM
|
| INSTALL_SYM
|
||||||
| OPTION
|
| OPTION
|
||||||
@ -15729,15 +15735,11 @@ keyword_sp_var_not_label:
|
|||||||
| START_SYM
|
| START_SYM
|
||||||
| STOP_SYM
|
| STOP_SYM
|
||||||
| STORED_SYM
|
| STORED_SYM
|
||||||
| SYSTEM
|
|
||||||
| SYSTEM_TIME_SYM
|
|
||||||
| TIES_SYM
|
| TIES_SYM
|
||||||
| UNICODE_SYM
|
| UNICODE_SYM
|
||||||
| UNINSTALL_SYM
|
| UNINSTALL_SYM
|
||||||
| UNBOUNDED_SYM
|
| UNBOUNDED_SYM
|
||||||
| VERSIONING_SYM
|
|
||||||
| WITHIN
|
| WITHIN
|
||||||
| WITHOUT
|
|
||||||
| WRAPPER_SYM
|
| WRAPPER_SYM
|
||||||
| XA_SYM
|
| XA_SYM
|
||||||
| UPGRADE_SYM
|
| UPGRADE_SYM
|
||||||
@ -15925,7 +15927,8 @@ keyword_sp_var_and_label:
|
|||||||
| DATAFILE_SYM
|
| DATAFILE_SYM
|
||||||
| DATE_FORMAT_SYM
|
| DATE_FORMAT_SYM
|
||||||
| DAY_SYM
|
| DAY_SYM
|
||||||
| DECODE_SYM
|
| DECODE_MARIADB_SYM
|
||||||
|
| DECODE_ORACLE_SYM
|
||||||
| DEFINER_SYM
|
| DEFINER_SYM
|
||||||
| DELAY_KEY_WRITE_SYM
|
| DELAY_KEY_WRITE_SYM
|
||||||
| DES_KEY_FILE
|
| DES_KEY_FILE
|
||||||
@ -15967,6 +15970,7 @@ keyword_sp_var_and_label:
|
|||||||
| GOTO_MARIADB_SYM
|
| GOTO_MARIADB_SYM
|
||||||
| HASH_SYM
|
| HASH_SYM
|
||||||
| HARD_SYM
|
| HARD_SYM
|
||||||
|
| HISTORY_SYM
|
||||||
| HOSTS_SYM
|
| HOSTS_SYM
|
||||||
| HOUR_SYM
|
| HOUR_SYM
|
||||||
| ID_SYM
|
| ID_SYM
|
||||||
@ -16144,6 +16148,8 @@ keyword_sp_var_and_label:
|
|||||||
| SUSPEND_SYM
|
| SUSPEND_SYM
|
||||||
| SWAPS_SYM
|
| SWAPS_SYM
|
||||||
| SWITCHES_SYM
|
| SWITCHES_SYM
|
||||||
|
| SYSTEM
|
||||||
|
| SYSTEM_TIME_SYM
|
||||||
| TABLE_NAME_SYM
|
| TABLE_NAME_SYM
|
||||||
| TABLES
|
| TABLES
|
||||||
| TABLE_CHECKSUM_SYM
|
| TABLE_CHECKSUM_SYM
|
||||||
@ -16169,6 +16175,7 @@ keyword_sp_var_and_label:
|
|||||||
| USER_SYM %prec PREC_BELOW_CONTRACTION_TOKEN2
|
| USER_SYM %prec PREC_BELOW_CONTRACTION_TOKEN2
|
||||||
| USE_FRM
|
| USE_FRM
|
||||||
| VARIABLES
|
| VARIABLES
|
||||||
|
| VERSIONING_SYM
|
||||||
| VIEW_SYM
|
| VIEW_SYM
|
||||||
| VIRTUAL_SYM
|
| VIRTUAL_SYM
|
||||||
| VALUE_SYM
|
| VALUE_SYM
|
||||||
@ -16176,6 +16183,7 @@ keyword_sp_var_and_label:
|
|||||||
| WAIT_SYM
|
| WAIT_SYM
|
||||||
| WEEK_SYM
|
| WEEK_SYM
|
||||||
| WEIGHT_STRING_SYM
|
| WEIGHT_STRING_SYM
|
||||||
|
| WITHOUT
|
||||||
| WORK_SYM
|
| WORK_SYM
|
||||||
| X509_SYM
|
| X509_SYM
|
||||||
| XML_SYM
|
| XML_SYM
|
||||||
|
Reference in New Issue
Block a user