diff options
| author | Alexander Barkov <bar@mariadb.com> | 2023-04-28 16:13:38 +0400 |
|---|---|---|
| committer | Alexander Barkov <bar@mariadb.com> | 2023-05-04 10:44:44 +0400 |
| commit | ce1458de6499f6764ffccbdbe55c6fd34fd44fc9 (patch) | |
| tree | 4756a58e147b80f957eef7143580e74baf1634f7 /sql/item_create.cc | |
| parent | 01ea779149a32f0dfd6fe8ea52c7ba51a69e1016 (diff) | |
| download | mariadb-git-bb-10.4-bar.tar.gz | |
MDEV-31184 Remove parser tokens DECODE_MARIADB_SYM and DECODE_ORACLE_SYMbb-10.4-bar
Changing the code handling sql_mode-dependent function DECODE():
- removing parser tokens DECODE_MARIADB_SYM and DECODE_ORACLE_SYM
- removing the DECODE() related code from sql_yacc.yy/sql_yacc_ora.yy
- adding handling of DECODE() with help of a new Create_func_func_decode
Diffstat (limited to 'sql/item_create.cc')
| -rw-r--r-- | sql/item_create.cc | 53 |
1 files changed, 39 insertions, 14 deletions
diff --git a/sql/item_create.cc b/sql/item_create.cc index a95d2ae4f9a..3f8c71cbe00 100644 --- a/sql/item_create.cc +++ b/sql/item_create.cc @@ -602,7 +602,15 @@ class Create_func_decode_oracle : public Create_native_func { public: virtual Item *create_native(THD *thd, const LEX_CSTRING *name, - List<Item> *item_list); + List<Item> *item_list) + { + if (unlikely(!item_list || item_list->elements < 3)) + { + my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str); + return NULL; + } + return new (thd->mem_root) Item_func_decode_oracle(thd, *item_list); + } static Create_func_decode_oracle s_singleton; @@ -612,6 +620,33 @@ protected: }; +class Create_func_decode : public Create_native_func +{ +public: + virtual Item *create_native(THD *thd, const LEX_CSTRING *name, + List<Item> *item_list) + { + if (thd->variables.sql_mode & MODE_ORACLE) + return Create_func_decode_oracle::s_singleton.create_native(thd, name, + item_list); + if (unlikely(!item_list || item_list->elements != 2)) + { + my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str); + return NULL; + } + Item_args args(thd, *item_list); + return new (thd->mem_root) Item_func_decode(thd, args.arguments()[0], + args.arguments()[1]); + } + + static Create_func_decode s_singleton; + +protected: + Create_func_decode() {} + virtual ~Create_func_decode() {} +}; + + class Create_func_concat_ws : public Create_native_func { public: @@ -4074,20 +4109,9 @@ Create_func_decode_histogram::create_2_arg(THD *thd, Item *arg1, Item *arg2) return new (thd->mem_root) Item_func_decode_histogram(thd, arg1, arg2); } -Create_func_decode_oracle Create_func_decode_oracle::s_singleton; +Create_func_decode Create_func_decode::s_singleton; -Item* -Create_func_decode_oracle::create_native(THD *thd, const LEX_CSTRING *name, - List<Item> *item_list) -{ - uint arg_count= item_list ? item_list->elements : 0; - if (unlikely(arg_count < 3)) - { - my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str); - return NULL; - } - return new (thd->mem_root) Item_func_decode_oracle(thd, *item_list); -} +Create_func_decode_oracle Create_func_decode_oracle::s_singleton; Create_func_concat_ws Create_func_concat_ws::s_singleton; @@ -7299,6 +7323,7 @@ const Native_func_registry func_array[] = { { STRING_WITH_LEN("DAYOFMONTH") }, BUILDER(Create_func_dayofmonth)}, { { STRING_WITH_LEN("DAYOFWEEK") }, BUILDER(Create_func_dayofweek)}, { { STRING_WITH_LEN("DAYOFYEAR") }, BUILDER(Create_func_dayofyear)}, + { { STRING_WITH_LEN("DECODE") }, BUILDER(Create_func_decode)}, { { STRING_WITH_LEN("DEGREES") }, BUILDER(Create_func_degrees)}, { { STRING_WITH_LEN("DECODE_HISTOGRAM") }, BUILDER(Create_func_decode_histogram)}, { { STRING_WITH_LEN("DECODE_ORACLE") }, BUILDER(Create_func_decode_oracle)}, |
