summaryrefslogtreecommitdiff
path: root/sql/item_cmpfunc.h
diff options
context:
space:
mode:
authorOleksandr Byelkin <sanja@mariadb.com>2018-06-19 14:51:50 +0200
committerOleksandr Byelkin <sanja@mariadb.com>2018-06-19 14:51:50 +0200
commit083279f7838d45c475344d20585ead72a147a21d (patch)
treec3ff5b3f6af1c9009b35d9b2560a7073be41ce90 /sql/item_cmpfunc.h
parent0121d5a790983c08dabedc66e70f862e47f7c8c7 (diff)
parent6b8802e8dd5467556a024d807a1df23940b00895 (diff)
downloadmariadb-git-083279f7838d45c475344d20585ead72a147a21d.tar.gz
Merge commit '6b8802e8dd5467556a024d807a1df23940b00895' into bb-10.3-fix_len_decbb-10.3-fix_len_dec
Diffstat (limited to 'sql/item_cmpfunc.h')
-rw-r--r--sql/item_cmpfunc.h82
1 files changed, 48 insertions, 34 deletions
diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h
index 30d682f05aa..c321b826ea4 100644
--- a/sql/item_cmpfunc.h
+++ b/sql/item_cmpfunc.h
@@ -218,7 +218,7 @@ public:
const Type_handler *type_handler() const { return &type_handler_long; }
bool is_bool_type() { return true; }
virtual CHARSET_INFO *compare_collation() const { return NULL; }
- void fix_length_and_dec() { decimals=0; max_length=1; }
+ bool fix_length_and_dec() { decimals=0; max_length=1; return FALSE; }
uint decimal_precision() const { return 1; }
bool need_parentheses_in_default() { return true; }
};
@@ -234,7 +234,7 @@ class Item_func_truth : public Item_bool_func
public:
virtual bool val_bool();
virtual longlong val_int();
- virtual void fix_length_and_dec();
+ virtual bool fix_length_and_dec();
virtual void print(String *str, enum_query_type query_type);
enum precedence precedence() const { return CMP_PRECEDENCE; }
@@ -521,7 +521,7 @@ public:
cond);
return this;
}
- void fix_length_and_dec();
+ bool fix_length_and_dec();
int set_cmp_func()
{
return cmp.set_cmp_func(this, tmp_arg, tmp_arg + 1, true);
@@ -734,7 +734,7 @@ public:
Item_func_equal(THD *thd, Item *a, Item *b):
Item_bool_rowready_func2(thd, a, b) {}
longlong val_int();
- void fix_length_and_dec();
+ bool fix_length_and_dec();
table_map not_null_tables() const { return 0; }
enum Functype functype() const { return EQUAL_FUNC; }
enum Functype rev_functype() const { return EQUAL_FUNC; }
@@ -903,7 +903,7 @@ public:
enum Functype functype() const { return BETWEEN; }
const char *func_name() const { return "between"; }
enum precedence precedence() const { return BETWEEN_PRECEDENCE; }
- void fix_length_and_dec();
+ bool fix_length_and_dec();
bool fix_length_and_dec_string(THD *)
{
return agg_arg_charsets_for_comparison(cmp_collation, args, 3);
@@ -950,10 +950,12 @@ public:
longlong val_int();
uint decimal_precision() const { return 1; }
const char *func_name() const { return "strcmp"; }
- void fix_length_and_dec()
+ bool fix_length_and_dec()
{
- agg_arg_charsets_for_comparison(cmp_collation, args, 2);
- fix_char_length(2); // returns "1" or "0" or "-1"
+ if (agg_arg_charsets_for_comparison(cmp_collation, args, 2))
+ return TRUE;
+ fix_char_length(2);
+ return FALSE;
}
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_strcmp>(thd, this); }
@@ -982,7 +984,7 @@ public:
{ }
bool fix_fields(THD *, Item **);
longlong val_int();
- void fix_length_and_dec();
+ bool fix_length_and_dec();
const char *func_name() const { return "interval"; }
uint decimal_precision() const { return 2; }
void print(String *str, enum_query_type query_type)
@@ -1008,10 +1010,12 @@ public:
my_decimal *decimal_op(my_decimal *);
bool date_op(MYSQL_TIME *ltime, ulonglong fuzzydate);
bool time_op(MYSQL_TIME *ltime);
- void fix_length_and_dec()
+ bool fix_length_and_dec()
{
- if (!aggregate_for_result(func_name(), args, arg_count, true))
- fix_attributes(args, arg_count);
+ if (aggregate_for_result(func_name(), args, arg_count, true))
+ return TRUE;
+ fix_attributes(args, arg_count);
+ return FALSE;
}
const char *func_name() const { return "coalesce"; }
table_map not_null_tables() const { return 0; }
@@ -1029,10 +1033,12 @@ public:
class Item_func_case_abbreviation2 :public Item_func_case_expression
{
protected:
- void fix_length_and_dec2(Item **items)
+ bool fix_length_and_dec2(Item **items)
{
- if (!aggregate_for_result(func_name(), items, 2, true))
- fix_attributes(items, 2);
+ if (aggregate_for_result(func_name(), items, 2, true))
+ return TRUE;
+ fix_attributes(items, 2);
+ return FALSE;
}
void cache_type_info(const Item *source, bool maybe_null_arg)
@@ -1042,7 +1048,7 @@ protected:
maybe_null= maybe_null_arg;
}
- void fix_length_and_dec2_eliminate_null(Item **items)
+ bool fix_length_and_dec2_eliminate_null(Item **items)
{
// Let IF(cond, expr, NULL) and IF(cond, NULL, expr) inherit type from expr.
if (items[0]->type() == NULL_ITEM)
@@ -1058,8 +1064,10 @@ protected:
}
else
{
- fix_length_and_dec2(items);
+ if (fix_length_and_dec2(items))
+ return TRUE;
}
+ return FALSE;
}
public:
@@ -1081,10 +1089,12 @@ public:
my_decimal *decimal_op(my_decimal *);
bool date_op(MYSQL_TIME *ltime, ulonglong fuzzydate);
bool time_op(MYSQL_TIME *ltime);
- void fix_length_and_dec()
+ bool fix_length_and_dec()
{
- Item_func_case_abbreviation2::fix_length_and_dec2(args);
+ if (Item_func_case_abbreviation2::fix_length_and_dec2(args))
+ return TRUE;
maybe_null= args[1]->maybe_null;
+ return FALSE;
}
const char *func_name() const { return "ifnull"; }
@@ -1150,9 +1160,9 @@ public:
Item_func_case_abbreviation2_switch(thd, a, b, c)
{}
bool fix_fields(THD *, Item **);
- void fix_length_and_dec()
+ bool fix_length_and_dec()
{
- fix_length_and_dec2_eliminate_null(args + 1);
+ return fix_length_and_dec2_eliminate_null(args + 1);
}
const char *func_name() const { return "if"; }
bool eval_not_null_tables(void *opt_arg);
@@ -1174,9 +1184,9 @@ public:
Item_func_case_abbreviation2_switch(thd, a, b, c)
{}
const char *func_name() const { return "nvl2"; }
- void fix_length_and_dec()
+ bool fix_length_and_dec()
{
- fix_length_and_dec2_eliminate_null(args + 1);
+ return fix_length_and_dec2_eliminate_null(args + 1);
}
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_nvl2>(thd, this); }
@@ -1236,7 +1246,7 @@ public:
longlong int_op();
String *str_op(String *str);
my_decimal *decimal_op(my_decimal *);
- void fix_length_and_dec();
+ bool fix_length_and_dec();
bool walk(Item_processor processor, bool walk_subquery, void *arg);
const char *func_name() const { return "nullif"; }
void print(String *str, enum_query_type query_type);
@@ -2145,7 +2155,7 @@ public:
reorder_args(0);
}
void print(String *str, enum_query_type query_type);
- void fix_length_and_dec();
+ bool fix_length_and_dec();
Item *propagate_equal_fields(THD *thd, const Context &ctx, COND_EQUAL *cond)
{
// None of the arguments are in a comparison context
@@ -2197,7 +2207,7 @@ public:
DBUG_VOID_RETURN;
}
void print(String *str, enum_query_type query_type);
- void fix_length_and_dec();
+ bool fix_length_and_dec();
Item *propagate_equal_fields(THD *thd, const Context &ctx, COND_EQUAL *cond);
Item *find_item();
Item *build_clone(THD *thd)
@@ -2222,7 +2232,7 @@ public:
{ }
const char *func_name() const { return "decode_oracle"; }
void print(String *str, enum_query_type query_type);
- void fix_length_and_dec();
+ bool fix_length_and_dec();
Item *find_item();
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_decode_oracle>(thd, this); }
@@ -2310,7 +2320,7 @@ public:
{ }
longlong val_int();
bool fix_fields(THD *, Item **);
- void fix_length_and_dec();
+ bool fix_length_and_dec();
bool compatible_types_scalar_bisection_possible()
{
DBUG_ASSERT(m_comparator.cmp_type() != ROW_RESULT);
@@ -2469,7 +2479,11 @@ public:
}
CHARSET_INFO *compare_collation() const
{ return args[0]->collation.collation; }
- void fix_length_and_dec() { decimals=0; max_length=1; maybe_null=0; }
+ bool fix_length_and_dec()
+ {
+ decimals=0; max_length=1; maybe_null=0;
+ return FALSE;
+ }
bool count_sargable_conds(void *arg);
};
@@ -2693,10 +2707,10 @@ public:
const char *func_name() const { return "like"; }
enum precedence precedence() const { return CMP_PRECEDENCE; }
bool fix_fields(THD *thd, Item **ref);
- void fix_length_and_dec()
+ bool fix_length_and_dec()
{
max_length= 1;
- agg_arg_charsets_for_comparison(cmp_collation, args, 2);
+ return agg_arg_charsets_for_comparison(cmp_collation, args, 2);
}
void cleanup();
@@ -2817,7 +2831,7 @@ public:
}
longlong val_int();
bool fix_fields(THD *thd, Item **ref);
- void fix_length_and_dec();
+ bool fix_length_and_dec();
const char *func_name() const { return "regexp"; }
enum precedence precedence() const { return CMP_PRECEDENCE; }
Item *get_copy(THD *thd)
@@ -2867,7 +2881,7 @@ public:
}
longlong val_int();
bool fix_fields(THD *thd, Item **ref);
- void fix_length_and_dec();
+ bool fix_length_and_dec();
const char *func_name() const { return "regexp_instr"; }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_regexp_instr>(thd, this); }
@@ -3103,7 +3117,7 @@ public:
longlong val_int();
const char *func_name() const { return "multiple equal"; }
void sort(Item_field_cmpfunc compare, void *arg);
- void fix_length_and_dec();
+ bool fix_length_and_dec();
bool fix_fields(THD *thd, Item **ref);
void cleanup()
{