diff --git a/client/mysql.cc b/client/mysql.cc index 82684b390cd96..67435704fcbdd 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -914,6 +914,7 @@ static COMMANDS commands[] = { { "ADDTIME", 0, 0, 0, ""}, { "AES_ENCRYPT", 0, 0, 0, ""}, { "AES_DECRYPT", 0, 0, 0, ""}, + { "ANY_VALUE", 0, 0, 0, ""}, { "AREA", 0, 0, 0, ""}, { "ASIN", 0, 0, 0, ""}, { "ASBINARY", 0, 0, 0, ""}, diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index 22a8cebca668f..18374e2e69887 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -1250,6 +1250,8 @@ class Item_func_interval :public Item_long_func class Item_func_coalesce :public Item_func_case_expression { public: + Item_func_coalesce(THD *thd, Item *a): + Item_func_case_expression(thd, a) {} Item_func_coalesce(THD *thd, Item *a, Item *b): Item_func_case_expression(thd, a, b) {} Item_func_coalesce(THD *thd, List &list): @@ -1289,6 +1291,23 @@ class Item_func_coalesce :public Item_func_case_expression }; +class Item_func_any_value final :public Item_func_coalesce +{ +public: + Item_func_any_value(THD *thd, Item *a): + Item_func_coalesce(thd, a) {} + LEX_CSTRING func_name_cstring() const override + { + static LEX_CSTRING name= {STRING_WITH_LEN("any_value") }; + return name; + } + +protected: + Item *shallow_copy(THD *thd) const override + { return get_item_copy(thd, this); } +}; + + /* Case abbreviations that aggregate its result field type by two arguments: IFNULL(arg1, arg2) diff --git a/sql/item_create.cc b/sql/item_create.cc index f2716e643668a..e2df1f626795f 100644 --- a/sql/item_create.cc +++ b/sql/item_create.cc @@ -168,6 +168,19 @@ class Create_func_aes_decrypt : public Create_native_func }; +class Create_func_any_value : public Create_func_arg1 +{ +public: + Item *create_1_arg(THD *thd, Item *arg1) override; + + static Create_func_any_value s_singleton; + +protected: + Create_func_any_value() = default; + ~Create_func_any_value() override = default; +}; + + class Create_func_kdf : public Create_native_func { public: @@ -3252,6 +3265,15 @@ Create_func_aes_decrypt::create_native(THD *thd, const LEX_CSTRING *name, } +Create_func_any_value Create_func_any_value::s_singleton; + +Item* +Create_func_any_value::create_1_arg(THD *thd, Item *arg1) +{ + return new (thd->mem_root) Item_func_any_value(thd, arg1); +} + + Create_func_kdf Create_func_kdf::s_singleton; Item* @@ -6330,6 +6352,7 @@ const Native_func_registry func_array[] = { { STRING_WITH_LEN("ADD_MONTHS") }, BUILDER(Create_func_addmonths)}, { { STRING_WITH_LEN("AES_DECRYPT") }, BUILDER(Create_func_aes_decrypt)}, { { STRING_WITH_LEN("AES_ENCRYPT") }, BUILDER(Create_func_aes_encrypt)}, + { { STRING_WITH_LEN("ANY_VALUE") }, BUILDER(Create_func_any_value)}, { { STRING_WITH_LEN("ASIN") }, BUILDER(Create_func_asin)}, { { STRING_WITH_LEN("ATAN") }, BUILDER(Create_func_atan)}, { { STRING_WITH_LEN("ATAN2") }, BUILDER(Create_func_atan)},