diff options
Diffstat (limited to 'sql/item_create.h')
-rw-r--r-- | sql/item_create.h | 130 |
1 files changed, 130 insertions, 0 deletions
diff --git a/sql/item_create.h b/sql/item_create.h index 5890e8ad057..c9bdb23dffe 100644 --- a/sql/item_create.h +++ b/sql/item_create.h @@ -69,6 +69,111 @@ protected: /** + Adapter for functions that takes exactly zero arguments. +*/ + +class Create_func_arg0 : public Create_func +{ +public: + virtual Item *create_func(THD *thd, LEX_CSTRING *name, + List<Item> *item_list); + + /** + Builder method, with no arguments. + @param thd The current thread + @return An item representing the function call + */ + virtual Item *create_builder(THD *thd) = 0; + +protected: + /** Constructor. */ + Create_func_arg0() {} + /** Destructor. */ + virtual ~Create_func_arg0() {} +}; + + +/** + Adapter for functions that takes exactly one argument. +*/ + +class Create_func_arg1 : public Create_func +{ +public: + virtual Item *create_func(THD *thd, LEX_CSTRING *name, List<Item> *item_list); + + /** + Builder method, with one argument. + @param thd The current thread + @param arg1 The first argument of the function + @return An item representing the function call + */ + virtual Item *create_1_arg(THD *thd, Item *arg1) = 0; + +protected: + /** Constructor. */ + Create_func_arg1() {} + /** Destructor. */ + virtual ~Create_func_arg1() {} +}; + + +/** + Adapter for functions that takes exactly two arguments. +*/ + +class Create_func_arg2 : public Create_func +{ +public: + virtual Item *create_func(THD *thd, LEX_CSTRING *name, List<Item> *item_list); + + /** + Builder method, with two arguments. + @param thd The current thread + @param arg1 The first argument of the function + @param arg2 The second argument of the function + @return An item representing the function call + */ + virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2) = 0; + +protected: + /** Constructor. */ + Create_func_arg2() {} + /** Destructor. */ + virtual ~Create_func_arg2() {} +}; + + +/** + Adapter for functions that takes exactly three arguments. +*/ + +class Create_func_arg3 : public Create_func +{ +public: + virtual Item *create_func(THD *thd, LEX_CSTRING *name, List<Item> *item_list); + + /** + Builder method, with three arguments. + @param thd The current thread + @param arg1 The first argument of the function + @param arg2 The second argument of the function + @param arg3 The third argument of the function + @return An item representing the function call + */ + virtual Item *create_3_arg(THD *thd, Item *arg1, Item *arg2, Item *arg3) = 0; + +protected: + /** Constructor. */ + Create_func_arg3() {} + /** Destructor. */ + virtual ~Create_func_arg3() {} +}; + + + + +/** 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> @@ -210,5 +315,30 @@ Item *create_func_dyncol_get(THD *thd, Item *num, Item *str, const char *c_len, const char *c_dec, CHARSET_INFO *cs); Item *create_func_dyncol_json(THD *thd, Item *str); + + +class Native_func_registry_array +{ + const Native_func_registry *m_elements; + size_t m_count; +public: + Native_func_registry_array() + :m_elements(NULL), + m_count(0) + { } + Native_func_registry_array(const Native_func_registry *elements, size_t count) + :m_elements(elements), + m_count(count) + { } + const Native_func_registry& element(size_t i) const + { + DBUG_ASSERT(i < m_count); + return m_elements[i]; + } + size_t count() const { return m_count; } + bool append_to_hash(HASH *hash) const; +}; + + #endif |