diff options
Diffstat (limited to '')
-rw-r--r-- | sql/item_func.h | 90 |
1 files changed, 75 insertions, 15 deletions
diff --git a/sql/item_func.h b/sql/item_func.h index 435875bd..1f185eff 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -55,8 +55,40 @@ protected: bool check_argument_types_can_return_date(uint start, uint end) const; bool check_argument_types_can_return_time(uint start, uint end) const; void print_cast_temporal(String *str, enum_query_type query_type); + + void print_schema_qualified_name(String *to, + const LEX_CSTRING &schema_name, + const LEX_CSTRING &function_name) const + { + // e.g. oracle_schema.func() + to->append(schema_name); + to->append('.'); + to->append(function_name); + } + + void print_sql_mode_qualified_name(String *to, + enum_query_type query_type, + const LEX_CSTRING &function_name) const + { + const Schema *func_schema= schema(); + if (!func_schema || func_schema == Schema::find_implied(current_thd)) + to->append(function_name); + else + print_schema_qualified_name(to, func_schema->name(), function_name); + } + + void print_sql_mode_qualified_name(String *to, enum_query_type query_type) + const + { + return print_sql_mode_qualified_name(to, query_type, func_name_cstring()); + } + public: + // Print an error message for a builtin-schema qualified function call + static void wrong_param_count_error(const LEX_CSTRING &schema_name, + const LEX_CSTRING &func_name); + table_map not_null_tables_cache; enum Functype { UNKNOWN_FUNC,EQ_FUNC,EQUAL_FUNC,NE_FUNC,LT_FUNC,LE_FUNC, @@ -79,6 +111,38 @@ public: CASE_SEARCHED_FUNC, // Used by ColumnStore/Spider CASE_SIMPLE_FUNC, // Used by ColumnStore/spider, }; + + /* + A function bitmap. Useful when some operation needs to be applied only + to certain functions. For now we only need to distinguish some + comparison predicates. + */ + enum Bitmap : ulonglong + { + BITMAP_NONE= 0, + BITMAP_EQ= 1ULL << EQ_FUNC, + BITMAP_EQUAL= 1ULL << EQUAL_FUNC, + BITMAP_NE= 1ULL << NE_FUNC, + BITMAP_LT= 1ULL << LT_FUNC, + BITMAP_LE= 1ULL << LE_FUNC, + BITMAP_GE= 1ULL << GE_FUNC, + BITMAP_GT= 1ULL << GT_FUNC, + BITMAP_LIKE= 1ULL << LIKE_FUNC, + BITMAP_BETWEEN= 1ULL << BETWEEN, + BITMAP_IN= 1ULL << IN_FUNC, + BITMAP_MULT_EQUAL= 1ULL << MULT_EQUAL_FUNC, + BITMAP_OTHER= 1ULL << 63, + BITMAP_ALL= 0xFFFFFFFFFFFFFFFFULL, + BITMAP_ANY_EQUALITY= BITMAP_EQ | BITMAP_EQUAL | BITMAP_MULT_EQUAL, + BITMAP_EXCEPT_ANY_EQUALITY= BITMAP_ALL & ~BITMAP_ANY_EQUALITY, + }; + + ulonglong bitmap_bit() const + { + Functype type= functype(); + return 1ULL << (type > 63 ? 63 : type); + } + static scalar_comparison_op functype_to_scalar_comparison_op(Functype type) { switch (type) { @@ -170,9 +234,15 @@ public: List<Item> &fields, uint flags) override; void print(String *str, enum_query_type query_type) override; void print_op(String *str, enum_query_type query_type); - void print_args(String *str, uint from, enum_query_type query_type); + void print_args(String *str, uint from, enum_query_type query_type) const; + void print_args_parenthesized(String *str, enum_query_type query_type) const + { + str->append('('); + print_args(str, 0, query_type); + str->append(')'); + } bool is_null() override - { + { update_null_value(); return null_value; } @@ -388,15 +458,6 @@ public: } } void convert_const_compared_to_int_field(THD *thd); - /** - Prepare arguments and setup a comparator. - Used in Item_func_xxx with two arguments and a comparator, - e.g. Item_bool_func2 and Item_func_nullif. - args[0] or args[1] can be modified: - - converted to character set and collation of the operation - - or replaced to an Item_int_with_ref - */ - bool setup_args_and_comparator(THD *thd, Arg_comparator *cmp); Item_func *get_item_func() override { return this; } bool is_simplified_cond_processor(void *arg) override { return const_item() && !val_int(); } @@ -3386,8 +3447,8 @@ public: String *str_result(String *str) override; my_decimal *val_decimal_result(my_decimal *) override; bool is_null_result() override; - bool update_hash(void *ptr, size_t length, enum Item_result type, - CHARSET_INFO *cs, bool unsigned_arg); + bool update_hash(void *ptr, size_t length, const Type_handler *th, + CHARSET_INFO *cs); bool send(Protocol *protocol, st_value *buffer) override; void make_send_field(THD *thd, Send_field *tmp_field) override; bool check(bool use_result_field); @@ -4234,7 +4295,6 @@ double my_double_round(double value, longlong dec, bool dec_unsigned, extern bool volatile mqh_used; bool update_hash(user_var_entry *entry, bool set_null, void *ptr, size_t length, - Item_result type, CHARSET_INFO *cs, - bool unsigned_arg); + const Type_handler *th, CHARSET_INFO *cs); #endif /* ITEM_FUNC_INCLUDED */ |