summaryrefslogtreecommitdiff
path: root/sql/sql_yacc_ora.yy
diff options
context:
space:
mode:
Diffstat (limited to 'sql/sql_yacc_ora.yy')
-rw-r--r--sql/sql_yacc_ora.yy114
1 files changed, 55 insertions, 59 deletions
diff --git a/sql/sql_yacc_ora.yy b/sql/sql_yacc_ora.yy
index f0e6b5b54c7..b5c8a987454 100644
--- a/sql/sql_yacc_ora.yy
+++ b/sql/sql_yacc_ora.yy
@@ -195,6 +195,7 @@ void ORAerror(THD *thd, const char *s)
Lex_for_loop_st for_loop;
Lex_for_loop_bounds_st for_loop_bounds;
Lex_trim_st trim;
+ Lex_substring_spec_st substring_spec;
vers_history_point_t vers_history_point;
/* pointers */
@@ -531,7 +532,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize);
%token RELEASE_SYM /* SQL-2003-R */
%token RENAME
%token REPEAT_SYM /* MYSQL-FUNC */
-%token REPLACE /* MYSQL-FUNC */
%token REQUIRE_SYM
%token RESIGNAL_SYM /* SQL-2003-R */
%token RESTRICT
@@ -571,7 +571,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize);
%token STDDEV_SAMP_SYM /* SQL-2003-N */
%token STD_SYM
%token STRAIGHT_JOIN
-%token SUBSTRING /* SQL-2003-N */
%token SUM_SYM /* SQL-2003-N */
%token SYSDATE
%token TABLE_REF_PRIORITY
@@ -585,7 +584,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize);
%token TO_SYM /* SQL-2003-R */
%token TRAILING /* SQL-2003-R */
%token TRIGGER_SYM /* SQL-2003-R */
-%token TRIM /* SQL-2003-N */
%token TRUE_SYM /* SQL-2003-R */
%token ULONGLONG_NUM
%token UNDERSCORE_CHARSET
@@ -637,6 +635,14 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize);
%token <kwd> ROWTYPE_MARIADB_SYM // PLSQL-R
/*
+ SQL functions with a special syntax
+*/
+%token <kwd> REPLACE /* MYSQL-FUNC */
+%token <kwd> SUBSTRING /* SQL-2003-N */
+%token <kwd> TRIM /* SQL-2003-N */
+
+
+/*
Non-reserved keywords
*/
@@ -722,8 +728,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize);
%token <kwd> DATE_SYM /* SQL-2003-R, Oracle-R, PLSQL-R */
%token <kwd> DAY_SYM /* SQL-2003-R */
%token <kwd> DEALLOCATE_SYM /* SQL-2003-R */
-%token <kwd> DECODE_MARIADB_SYM /* Function, non-reserved */
-%token <kwd> DECODE_ORACLE_SYM /* Function, non-reserved */
%token <kwd> DEFINER_SYM
%token <kwd> DELAYED_SYM
%token <kwd> DELAY_KEY_WRITE_SYM
@@ -1375,7 +1379,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize);
%type <item_list>
expr_list opt_udf_expr_list udf_expr_list when_list when_list_opt_else
ident_list ident_list_arg opt_expr_list
- decode_when_list_oracle
%type <sp_cursor_stmt>
sp_cursor_stmt_lex
@@ -1593,6 +1596,7 @@ END_OF_INPUT
%type <for_loop> sp_for_loop_index_and_bounds
%type <for_loop_bounds> sp_for_loop_bounds
%type <trim> trim_operands
+%type <substring_spec> substring_operands
%type <num> opt_sp_for_loop_direction
%type <spvar_mode> sp_opt_inout
%type <index_hint> index_hint_type
@@ -10596,7 +10600,8 @@ function_call_keyword:
}
| TRIM '(' trim_operands ')'
{
- if (unlikely(!($$= $3.make_item_func_trim(thd))))
+ if (unlikely(!($$= Schema::find_implied(thd)->
+ make_item_func_trim(thd, $3))))
MYSQL_YYABORT;
}
| USER_SYM '(' ')'
@@ -10615,6 +10620,26 @@ function_call_keyword:
}
;
+substring_operands:
+ expr ',' expr ',' expr
+ {
+ $$= Lex_substring_spec_st::init($1, $3, $5);
+ }
+ | expr ',' expr
+ {
+ $$= Lex_substring_spec_st::init($1, $3);
+ }
+ | expr FROM expr FOR_SYM expr
+ {
+ $$= Lex_substring_spec_st::init($1, $3, $5);
+ }
+ | expr FROM expr
+ {
+ $$= Lex_substring_spec_st::init($1, $3);
+ }
+ ;
+
+
/*
Function calls using non reserved keywords, with special syntaxic forms.
Dedicated grammar rules are needed because of the syntax,
@@ -10679,18 +10704,6 @@ function_call_nonkeyword:
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 ')'
{
$$=new (thd->mem_root) Item_extract(thd, $3, $5);
@@ -10729,24 +10742,10 @@ function_call_nonkeyword:
if (unlikely($$ == NULL))
MYSQL_YYABORT;
}
- | SUBSTRING '(' expr ',' expr ',' expr ')'
+ | SUBSTRING '(' substring_operands ')'
{
- if (unlikely(!($$= Lex->make_item_func_substr(thd, $3, $5, $7))))
- MYSQL_YYABORT;
- }
- | SUBSTRING '(' expr ',' expr ')'
- {
- if (unlikely(!($$= Lex->make_item_func_substr(thd, $3, $5))))
- MYSQL_YYABORT;
- }
- | SUBSTRING '(' expr FROM expr FOR_SYM expr ')'
- {
- if (unlikely(!($$= Lex->make_item_func_substr(thd, $3, $5, $7))))
- MYSQL_YYABORT;
- }
- | SUBSTRING '(' expr FROM expr ')'
- {
- if (unlikely(!($$= Lex->make_item_func_substr(thd, $3, $5))))
+ if (unlikely(!($$= Schema::find_implied(thd)->
+ make_item_func_substr(thd, $3))))
MYSQL_YYABORT;
}
| SYSDATE opt_time_precision
@@ -10962,7 +10961,8 @@ function_call_conflict:
}
| REPLACE '(' expr ',' expr ',' expr ')'
{
- if (unlikely(!($$= Lex->make_item_func_replace(thd, $3, $5, $7))))
+ if (unlikely(!($$= Schema::find_implied(thd)->
+ make_item_func_replace(thd, $3, $5, $7))))
MYSQL_YYABORT;
}
| REVERSE_SYM '(' expr ')'
@@ -11150,7 +11150,8 @@ function_call_generic:
This will be revised with WL#2128 (SQL PATH)
*/
- builder= find_native_function_builder(thd, &$1);
+ builder= Schema::find_implied(thd)->
+ find_native_function_builder(thd, $1);
if (builder)
{
item= builder->create_func(thd, &$1, $4);
@@ -11192,6 +11193,22 @@ function_call_generic:
if (unlikely(!($$= Lex->make_item_func_call_generic(thd, &$1, &$3, &$5, $7))))
MYSQL_YYABORT;
}
+ | ident_cli '.' REPLACE '(' expr ',' expr ',' expr ')'
+ {
+ if (unlikely(!($$= Lex->make_item_func_replace(thd, $1, $3,
+ $5, $7, $9))))
+ MYSQL_YYABORT;
+ }
+ | ident_cli '.' SUBSTRING '(' substring_operands ')'
+ {
+ if (unlikely(!($$= Lex->make_item_func_substr(thd, $1, $3, $5))))
+ MYSQL_YYABORT;
+ }
+ | ident_cli '.' TRIM '(' trim_operands ')'
+ {
+ if (unlikely(!($$= $5.make_item_func_trim(thd, $1, $3))))
+ MYSQL_YYABORT;
+ }
;
fulltext_options:
@@ -11859,25 +11876,6 @@ 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. */
/* Warning - may return NULL in case of incomplete SELECT */
table_ref:
@@ -16131,8 +16129,6 @@ keyword_sp_var_and_label:
| DATAFILE_SYM
| DATE_FORMAT_SYM
| DAY_SYM
- | DECODE_MARIADB_SYM
- | DECODE_ORACLE_SYM
| DEFINER_SYM
| DELAY_KEY_WRITE_SYM
| DES_KEY_FILE