diff options
author | Aleksey Midenkov <midenok@gmail.com> | 2017-07-07 17:52:23 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-07 17:52:23 +0300 |
commit | dcb54040bcb6927e1fafe039979b816865c7c805 (patch) | |
tree | 317000323dfbe92cd59ceaae998c68eaa4348720 /sql/item_create.cc | |
parent | 42a0289de9789979fedd51240be52347c5330995 (diff) | |
download | mariadb-git-dcb54040bcb6927e1fafe039979b816865c7c805.tar.gz |
SQL: VTQ testing iface moved to plugin [closes #224]
Diffstat (limited to 'sql/item_create.cc')
-rw-r--r-- | sql/item_create.cc | 169 |
1 files changed, 10 insertions, 159 deletions
diff --git a/sql/item_create.cc b/sql/item_create.cc index 7e8c60591e6..140abdd074d 100644 --- a/sql/item_create.cc +++ b/sql/item_create.cc @@ -104,36 +104,6 @@ bool get_length_and_scale(ulonglong length, ulonglong decimals, ============================================================================= */ -/** - Adapter for native functions with a variable number of arguments. - The main use of this class is to discard the following calls: - <code>foo(expr1 AS name1, expr2 AS name2, ...)</code> - which are syntactically correct (the syntax can refer to a UDF), - but semantically invalid for native functions. -*/ - -class Create_native_func : public Create_func -{ -public: - virtual Item *create_func(THD *thd, LEX_STRING name, List<Item> *item_list); - - /** - Builder method, with no arguments. - @param thd The current thread - @param name The native function name - @param item_list The function parameters, none of which are named - @return An item representing the function call - */ - virtual Item *create_native(THD *thd, LEX_STRING name, - List<Item> *item_list) = 0; - -protected: - /** Constructor. */ - Create_native_func() {} - /** Destructor. */ - virtual ~Create_native_func() {} -}; - /** Adapter for functions that takes exactly zero arguments. @@ -6678,125 +6648,6 @@ Create_func_year_week::create_native(THD *thd, LEX_STRING name, } -/* System Versioning: VTQ_TRX_ID(), VTQ_COMMIT_ID(), VTQ_BEGIN_TS(), VTQ_COMMIT_TS(), VTQ_ISO_LEVEL() */ -template <vtq_field_t VTQ_FIELD> -class Create_func_vtq : public Create_native_func -{ -public: - virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list); - - static Create_func_vtq<VTQ_FIELD> s_singleton; - -protected: - Create_func_vtq<VTQ_FIELD>() {} - virtual ~Create_func_vtq<VTQ_FIELD>() {} -}; - -template<vtq_field_t VTQ_FIELD> -Create_func_vtq<VTQ_FIELD> Create_func_vtq<VTQ_FIELD>::s_singleton; - -template <vtq_field_t VTQ_FIELD> -Item* -Create_func_vtq<VTQ_FIELD>::create_native(THD *thd, LEX_STRING name, - List<Item> *item_list) -{ - Item *func= NULL; - int arg_count= 0; - - if (item_list != NULL) - arg_count= item_list->elements; - - switch (arg_count) { - case 1: - { - Item *param_1= item_list->pop(); - switch (VTQ_FIELD) - { - case VTQ_BEGIN_TS: - case VTQ_COMMIT_TS: - func= new (thd->mem_root) Item_func_vtq_ts(thd, param_1, VTQ_FIELD); - break; - case VTQ_TRX_ID: - case VTQ_COMMIT_ID: - case VTQ_ISO_LEVEL: - func= new (thd->mem_root) Item_func_vtq_id(thd, param_1, VTQ_FIELD); - break; - default: - DBUG_ASSERT(0); - } - break; - } - case 2: - { - Item *param_1= item_list->pop(); - Item *param_2= item_list->pop(); - switch (VTQ_FIELD) - { - case VTQ_TRX_ID: - case VTQ_COMMIT_ID: - func= new (thd->mem_root) Item_func_vtq_id(thd, param_1, param_2, VTQ_FIELD); - break; - default: - goto error; - } - break; - } - error: - default: - { - my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str); - break; - } - } - - return func; -}; - -template <class Item_func_vtq_trx_seesX> -class Create_func_vtq_trx_sees : public Create_native_func -{ -public: - virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list) - { - Item *func= NULL; - int arg_count= 0; - - if (item_list != NULL) - arg_count= item_list->elements; - - switch (arg_count) { - case 2: - { - Item *param_1= item_list->pop(); - Item *param_2= item_list->pop(); - func= new (thd->mem_root) Item_func_vtq_trx_seesX(thd, param_1, param_2); - break; - } - default: - my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str); - break; - } - - return func; - } - - static Create_func_vtq_trx_sees<Item_func_vtq_trx_seesX> s_singleton; - -protected: - Create_func_vtq_trx_sees<Item_func_vtq_trx_seesX>() {} - virtual ~Create_func_vtq_trx_sees<Item_func_vtq_trx_seesX>() {} -}; - -template<class X> -Create_func_vtq_trx_sees<X> Create_func_vtq_trx_sees<X>::s_singleton; - - -struct Native_func_registry -{ - LEX_STRING name; - Create_func *builder; -}; - #define BUILDER(F) & F::s_singleton #ifdef HAVE_SPATIAL @@ -7146,13 +6997,6 @@ static Native_func_registry func_array[] = { { C_STRING_WITH_LEN("UUID") }, BUILDER(Create_func_uuid)}, { { C_STRING_WITH_LEN("UUID_SHORT") }, BUILDER(Create_func_uuid_short)}, { { C_STRING_WITH_LEN("VERSION") }, BUILDER(Create_func_version)}, - { { C_STRING_WITH_LEN("VTQ_BEGIN_TS") }, BUILDER(Create_func_vtq<VTQ_BEGIN_TS>)}, - { { C_STRING_WITH_LEN("VTQ_COMMIT_ID") }, BUILDER(Create_func_vtq<VTQ_COMMIT_ID>)}, - { { C_STRING_WITH_LEN("VTQ_COMMIT_TS") }, BUILDER(Create_func_vtq<VTQ_COMMIT_TS>)}, - { { C_STRING_WITH_LEN("VTQ_ISO_LEVEL") }, BUILDER(Create_func_vtq<VTQ_ISO_LEVEL>)}, - { { C_STRING_WITH_LEN("VTQ_TRX_ID") }, BUILDER(Create_func_vtq<VTQ_TRX_ID>)}, - { { C_STRING_WITH_LEN("VTQ_TRX_SEES") }, BUILDER(Create_func_vtq_trx_sees<Item_func_vtq_trx_sees>)}, - { { C_STRING_WITH_LEN("VTQ_TRX_SEES_EQ") }, BUILDER(Create_func_vtq_trx_sees<Item_func_vtq_trx_sees_eq>)}, { { C_STRING_WITH_LEN("WEEKDAY") }, BUILDER(Create_func_weekday)}, { { C_STRING_WITH_LEN("WEEKOFYEAR") }, BUILDER(Create_func_weekofyear)}, { { C_STRING_WITH_LEN("WITHIN") }, GEOM_BUILDER(Create_func_within)}, @@ -7182,8 +7026,6 @@ get_native_fct_hash_key(const uchar *buff, size_t *length, int item_create_init() { - Native_func_registry *func; - DBUG_ENTER("item_create_init"); if (my_hash_init(& native_functions_hash, @@ -7196,7 +7038,16 @@ int item_create_init() MYF(0))) DBUG_RETURN(1); - for (func= func_array; func->builder != NULL; func++) + DBUG_RETURN(item_create_append(func_array)); +} + +int item_create_append(Native_func_registry array[]) +{ + Native_func_registry *func; + + DBUG_ENTER("item_create_append"); + + for (func= array; func->builder != NULL; func++) { if (my_hash_insert(& native_functions_hash, (uchar*) func)) DBUG_RETURN(1); |