Commit 3105c9e7 authored by Michael Widenius's avatar Michael Widenius Committed by Sergei Golubchik

Change bitfields in Item to an uint16

The reason for the change is that neither clang or gcc can do efficient
code when several bit fields are change at the same time or when copying
one or more bits between identical bit fields.
Updated bits explicitely with & and | is MUCH more efficient than what
current compilers can do.
parent 451c4ae5
...@@ -32,7 +32,7 @@ class Item_func_sysconst_test :public Item_func_sysconst ...@@ -32,7 +32,7 @@ class Item_func_sysconst_test :public Item_func_sysconst
bool fix_length_and_dec() bool fix_length_and_dec()
{ {
max_length= MAX_FIELD_NAME * system_charset_info->mbmaxlen; max_length= MAX_FIELD_NAME * system_charset_info->mbmaxlen;
maybe_null= true; flags|= ITEM_FLAG_MAYBE_NULL;
return false; return false;
} }
const char *func_name() const { return "sysconst_test"; } const char *func_name() const { return "sysconst_test"; }
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
longlong Item_func_inet_aton::val_int() longlong Item_func_inet_aton::val_int()
{ {
DBUG_ASSERT(fixed); DBUG_ASSERT(fixed());
uint byte_result= 0; uint byte_result= 0;
ulonglong result= 0; // We are ready for 64 bit addresses ulonglong result= 0; // We are ready for 64 bit addresses
...@@ -85,7 +85,7 @@ longlong Item_func_inet_aton::val_int() ...@@ -85,7 +85,7 @@ longlong Item_func_inet_aton::val_int()
String* Item_func_inet_ntoa::val_str(String* str) String* Item_func_inet_ntoa::val_str(String* str)
{ {
DBUG_ASSERT(fixed); DBUG_ASSERT(fixed());
ulonglong n= (ulonglong) args[0]->val_int(); ulonglong n= (ulonglong) args[0]->val_int();
...@@ -145,7 +145,7 @@ String* Item_func_inet_ntoa::val_str(String* str) ...@@ -145,7 +145,7 @@ String* Item_func_inet_ntoa::val_str(String* str)
String *Item_func_inet6_aton::val_str(String *buffer) String *Item_func_inet6_aton::val_str(String *buffer)
{ {
DBUG_ASSERT(fixed); DBUG_ASSERT(fixed());
Ascii_ptr_and_buffer<STRING_BUFFER_USUAL_SIZE> tmp(args[0]); Ascii_ptr_and_buffer<STRING_BUFFER_USUAL_SIZE> tmp(args[0]);
if ((null_value= tmp.is_null())) if ((null_value= tmp.is_null()))
...@@ -176,7 +176,7 @@ String *Item_func_inet6_aton::val_str(String *buffer) ...@@ -176,7 +176,7 @@ String *Item_func_inet6_aton::val_str(String *buffer)
String *Item_func_inet6_ntoa::val_str_ascii(String *buffer) String *Item_func_inet6_ntoa::val_str_ascii(String *buffer)
{ {
DBUG_ASSERT(fixed); DBUG_ASSERT(fixed());
// Binary string argument expected // Binary string argument expected
if (unlikely(args[0]->result_type() != STRING_RESULT || if (unlikely(args[0]->result_type() != STRING_RESULT ||
...@@ -216,7 +216,7 @@ String *Item_func_inet6_ntoa::val_str_ascii(String *buffer) ...@@ -216,7 +216,7 @@ String *Item_func_inet6_ntoa::val_str_ascii(String *buffer)
longlong Item_func_is_ipv4::val_int() longlong Item_func_is_ipv4::val_int()
{ {
DBUG_ASSERT(fixed); DBUG_ASSERT(fixed());
String_ptr_and_buffer<STRING_BUFFER_USUAL_SIZE> tmp(args[0]); String_ptr_and_buffer<STRING_BUFFER_USUAL_SIZE> tmp(args[0]);
return !tmp.is_null() && !Inet4_null(*tmp.string()).is_null(); return !tmp.is_null() && !Inet4_null(*tmp.string()).is_null();
} }
...@@ -228,7 +228,7 @@ longlong Item_func_is_ipv4::val_int() ...@@ -228,7 +228,7 @@ longlong Item_func_is_ipv4::val_int()
longlong Item_func_is_ipv6::val_int() longlong Item_func_is_ipv6::val_int()
{ {
DBUG_ASSERT(fixed); DBUG_ASSERT(fixed());
String_ptr_and_buffer<STRING_BUFFER_USUAL_SIZE> tmp(args[0]); String_ptr_and_buffer<STRING_BUFFER_USUAL_SIZE> tmp(args[0]);
return !tmp.is_null() && !Inet6_null(*tmp.string()).is_null(); return !tmp.is_null() && !Inet6_null(*tmp.string()).is_null();
} }
......
...@@ -37,7 +37,7 @@ class Item_func_inet_aton : public Item_longlong_func ...@@ -37,7 +37,7 @@ class Item_func_inet_aton : public Item_longlong_func
{ {
decimals= 0; decimals= 0;
max_length= 21; max_length= 21;
maybe_null= 1; flags|= ITEM_FLAG_MAYBE_NULL;
unsigned_flag= 1; unsigned_flag= 1;
return FALSE; return FALSE;
} }
...@@ -61,7 +61,7 @@ class Item_func_inet_ntoa : public Item_str_func ...@@ -61,7 +61,7 @@ class Item_func_inet_ntoa : public Item_str_func
{ {
decimals= 0; decimals= 0;
fix_length_and_charset(3 * 8 + 7, default_charset()); fix_length_and_charset(3 * 8 + 7, default_charset());
maybe_null= 1; flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE; return FALSE;
} }
Item *get_copy(THD *thd) Item *get_copy(THD *thd)
...@@ -105,7 +105,7 @@ class Item_func_inet6_aton : public Item_str_func ...@@ -105,7 +105,7 @@ class Item_func_inet6_aton : public Item_str_func
{ {
decimals= 0; decimals= 0;
fix_length_and_charset(16, &my_charset_bin); fix_length_and_charset(16, &my_charset_bin);
maybe_null= 1; flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE; return FALSE;
} }
Item *get_copy(THD *thd) Item *get_copy(THD *thd)
...@@ -139,7 +139,7 @@ class Item_func_inet6_ntoa : public Item_str_ascii_func ...@@ -139,7 +139,7 @@ class Item_func_inet6_ntoa : public Item_str_ascii_func
// 4 symbols per group // 4 symbols per group
fix_length_and_charset(8 * 4 + 7, default_charset()); fix_length_and_charset(8 * 4 + 7, default_charset());
maybe_null= 1; flags|= ITEM_FLAG_MAYBE_NULL;;
return FALSE; return FALSE;
} }
String *val_str_ascii(String *to); String *val_str_ascii(String *to);
......
...@@ -510,7 +510,7 @@ size_t Inet6::to_string(char *dst, size_t dstsize) const ...@@ -510,7 +510,7 @@ size_t Inet6::to_string(char *dst, size_t dstsize) const
bool Inet6::fix_fields_maybe_null_on_conversion_to_inet6(Item *item) bool Inet6::fix_fields_maybe_null_on_conversion_to_inet6(Item *item)
{ {
if (item->maybe_null) if (item->maybe_null())
return true; return true;
if (item->type_handler() == &type_handler_inet6) if (item->type_handler() == &type_handler_inet6)
return false; return false;
...@@ -1055,7 +1055,7 @@ class Item_typecast_inet6: public Item_func ...@@ -1055,7 +1055,7 @@ class Item_typecast_inet6: public Item_func
{ {
Type_std_attributes::operator=(Type_std_attributes_inet6()); Type_std_attributes::operator=(Type_std_attributes_inet6());
if (Inet6::fix_fields_maybe_null_on_conversion_to_inet6(args[0])) if (Inet6::fix_fields_maybe_null_on_conversion_to_inet6(args[0]))
maybe_null= true; flags|= ITEM_FLAG_MAYBE_NULL;
return false; return false;
} }
String *val_str(String *to) override String *val_str(String *to) override
...@@ -1388,7 +1388,7 @@ void Type_handler_inet6::make_sort_key_part(uchar *to, Item *item, ...@@ -1388,7 +1388,7 @@ void Type_handler_inet6::make_sort_key_part(uchar *to, Item *item,
DBUG_ASSERT(item->type_handler() == this); DBUG_ASSERT(item->type_handler() == this);
NativeBufferInet6 tmp; NativeBufferInet6 tmp;
item->val_native_result(current_thd, &tmp); item->val_native_result(current_thd, &tmp);
if (item->maybe_null) if (item->maybe_null())
{ {
if (item->null_value) if (item->null_value)
{ {
...@@ -1411,7 +1411,7 @@ Type_handler_inet6::make_packed_sort_key_part(uchar *to, Item *item, ...@@ -1411,7 +1411,7 @@ Type_handler_inet6::make_packed_sort_key_part(uchar *to, Item *item,
DBUG_ASSERT(item->type_handler() == this); DBUG_ASSERT(item->type_handler() == this);
NativeBufferInet6 tmp; NativeBufferInet6 tmp;
item->val_native_result(current_thd, &tmp); item->val_native_result(current_thd, &tmp);
if (item->maybe_null) if (item->maybe_null())
{ {
if (item->null_value) if (item->null_value)
{ {
......
...@@ -1109,7 +1109,7 @@ Type_handler_string_result::make_sort_key_part(uchar *to, Item *item, ...@@ -1109,7 +1109,7 @@ Type_handler_string_result::make_sort_key_part(uchar *to, Item *item,
Sort_param *param) const Sort_param *param) const
{ {
CHARSET_INFO *cs= item->collation.collation; CHARSET_INFO *cs= item->collation.collation;
bool maybe_null= item->maybe_null; bool maybe_null= item->maybe_null();
if (maybe_null) if (maybe_null)
*to++= 1; *to++= 1;
...@@ -1179,7 +1179,7 @@ Type_handler_int_result::make_sort_key_part(uchar *to, Item *item, ...@@ -1179,7 +1179,7 @@ Type_handler_int_result::make_sort_key_part(uchar *to, Item *item,
Sort_param *param) const Sort_param *param) const
{ {
longlong value= item->val_int_result(); longlong value= item->val_int_result();
make_sort_key_longlong(to, item->maybe_null, item->null_value, make_sort_key_longlong(to, item->maybe_null(), item->null_value,
item->unsigned_flag, value); item->unsigned_flag, value);
} }
...@@ -1195,13 +1195,13 @@ Type_handler_temporal_result::make_sort_key_part(uchar *to, Item *item, ...@@ -1195,13 +1195,13 @@ Type_handler_temporal_result::make_sort_key_part(uchar *to, Item *item,
static const Temporal::Options opt(TIME_INVALID_DATES, TIME_FRAC_NONE); static const Temporal::Options opt(TIME_INVALID_DATES, TIME_FRAC_NONE);
if (item->get_date_result(current_thd, &buf, opt)) if (item->get_date_result(current_thd, &buf, opt))
{ {
DBUG_ASSERT(item->maybe_null); DBUG_ASSERT(item->maybe_null());
DBUG_ASSERT(item->null_value); DBUG_ASSERT(item->null_value);
make_sort_key_longlong(to, item->maybe_null, true, make_sort_key_longlong(to, item->maybe_null(), true,
item->unsigned_flag, 0); item->unsigned_flag, 0);
} }
else else
make_sort_key_longlong(to, item->maybe_null, false, make_sort_key_longlong(to, item->maybe_null(), false,
item->unsigned_flag, pack_time(&buf)); item->unsigned_flag, pack_time(&buf));
} }
...@@ -1217,11 +1217,11 @@ Type_handler_timestamp_common::make_sort_key_part(uchar *to, Item *item, ...@@ -1217,11 +1217,11 @@ Type_handler_timestamp_common::make_sort_key_part(uchar *to, Item *item,
if (native.is_null() || native.is_zero_datetime()) if (native.is_null() || native.is_zero_datetime())
{ {
// NULL or '0000-00-00 00:00:00' // NULL or '0000-00-00 00:00:00'
bzero(to, item->maybe_null ? binlen + 1 : binlen); bzero(to, item->maybe_null() ? binlen + 1 : binlen);
} }
else else
{ {
if (item->maybe_null) if (item->maybe_null())
*to++= 1; *to++= 1;
if (native.length() != binlen) if (native.length() != binlen)
{ {
...@@ -1305,7 +1305,7 @@ Type_handler_decimal_result::make_sort_key_part(uchar *to, Item *item, ...@@ -1305,7 +1305,7 @@ Type_handler_decimal_result::make_sort_key_part(uchar *to, Item *item,
Sort_param *param) const Sort_param *param) const
{ {
my_decimal dec_buf, *dec_val= item->val_decimal_result(&dec_buf); my_decimal dec_buf, *dec_val= item->val_decimal_result(&dec_buf);
if (item->maybe_null) if (item->maybe_null())
{ {
if (item->null_value) if (item->null_value)
{ {
...@@ -1325,7 +1325,7 @@ Type_handler_real_result::make_sort_key_part(uchar *to, Item *item, ...@@ -1325,7 +1325,7 @@ Type_handler_real_result::make_sort_key_part(uchar *to, Item *item,
Sort_param *param) const Sort_param *param) const
{ {
double value= item->val_result(); double value= item->val_result();
if (item->maybe_null) if (item->maybe_null())
{ {
if (item->null_value) if (item->null_value)
{ {
...@@ -2262,7 +2262,7 @@ sortlength(THD *thd, Sort_keys *sort_keys, bool *allow_packing_for_sortkeys) ...@@ -2262,7 +2262,7 @@ sortlength(THD *thd, Sort_keys *sort_keys, bool *allow_packing_for_sortkeys)
thd->variables.max_sort_length)); thd->variables.max_sort_length));
} }
if ((sortorder->maybe_null= sortorder->item->maybe_null)) if ((sortorder->maybe_null= sortorder->item->maybe_null()))
nullable_cols++; // Place for NULL marker nullable_cols++; // Place for NULL marker
} }
if (sortorder->is_variable_sized()) if (sortorder->is_variable_sized())
...@@ -2565,7 +2565,7 @@ Type_handler_string_result::make_packed_sort_key_part(uchar *to, Item *item, ...@@ -2565,7 +2565,7 @@ Type_handler_string_result::make_packed_sort_key_part(uchar *to, Item *item,
Sort_param *param) const Sort_param *param) const
{ {
CHARSET_INFO *cs= item->collation.collation; CHARSET_INFO *cs= item->collation.collation;
bool maybe_null= item->maybe_null; bool maybe_null= item->maybe_null();
if (maybe_null) if (maybe_null)
*to++= 1; *to++= 1;
...@@ -2604,7 +2604,7 @@ Type_handler_int_result::make_packed_sort_key_part(uchar *to, Item *item, ...@@ -2604,7 +2604,7 @@ Type_handler_int_result::make_packed_sort_key_part(uchar *to, Item *item,
Sort_param *param) const Sort_param *param) const
{ {
longlong value= item->val_int_result(); longlong value= item->val_int_result();
return make_packed_sort_key_longlong(to, item->maybe_null, return make_packed_sort_key_longlong(to, item->maybe_null(),
item->null_value, item->unsigned_flag, item->null_value, item->unsigned_flag,
value, sort_field); value, sort_field);
} }
...@@ -2616,7 +2616,7 @@ Type_handler_decimal_result::make_packed_sort_key_part(uchar *to, Item *item, ...@@ -2616,7 +2616,7 @@ Type_handler_decimal_result::make_packed_sort_key_part(uchar *to, Item *item,
Sort_param *param) const Sort_param *param) const
{ {
my_decimal dec_buf, *dec_val= item->val_decimal_result(&dec_buf); my_decimal dec_buf, *dec_val= item->val_decimal_result(&dec_buf);
if (item->maybe_null) if (item->maybe_null())
{ {
if (item->null_value) if (item->null_value)
{ {
...@@ -2638,7 +2638,7 @@ Type_handler_real_result::make_packed_sort_key_part(uchar *to, Item *item, ...@@ -2638,7 +2638,7 @@ Type_handler_real_result::make_packed_sort_key_part(uchar *to, Item *item,
Sort_param *param) const Sort_param *param) const
{ {
double value= item->val_result(); double value= item->val_result();
if (item->maybe_null) if (item->maybe_null())
{ {
if (item->null_value) if (item->null_value)
{ {
...@@ -2664,12 +2664,12 @@ Type_handler_temporal_result::make_packed_sort_key_part(uchar *to, Item *item, ...@@ -2664,12 +2664,12 @@ Type_handler_temporal_result::make_packed_sort_key_part(uchar *to, Item *item,
static const Temporal::Options opt(TIME_INVALID_DATES, TIME_FRAC_NONE); static const Temporal::Options opt(TIME_INVALID_DATES, TIME_FRAC_NONE);
if (item->get_date_result(current_thd, &buf, opt)) if (item->get_date_result(current_thd, &buf, opt))
{ {
DBUG_ASSERT(item->maybe_null); DBUG_ASSERT(item->maybe_null());
DBUG_ASSERT(item->null_value); DBUG_ASSERT(item->null_value);
return make_packed_sort_key_longlong(to, item->maybe_null, true, return make_packed_sort_key_longlong(to, item->maybe_null(), true,
item->unsigned_flag, 0, sort_field); item->unsigned_flag, 0, sort_field);
} }
return make_packed_sort_key_longlong(to, item->maybe_null, false, return make_packed_sort_key_longlong(to, item->maybe_null(), false,
item->unsigned_flag, pack_time(&buf), item->unsigned_flag, pack_time(&buf),
sort_field); sort_field);
} }
...@@ -2686,7 +2686,7 @@ Type_handler_timestamp_common::make_packed_sort_key_part(uchar *to, Item *item, ...@@ -2686,7 +2686,7 @@ Type_handler_timestamp_common::make_packed_sort_key_part(uchar *to, Item *item,
if (native.is_null() || native.is_zero_datetime()) if (native.is_null() || native.is_zero_datetime())
{ {
// NULL or '0000-00-00 00:00:00' // NULL or '0000-00-00 00:00:00'
if (item->maybe_null) if (item->maybe_null())
{ {
*to++=0; *to++=0;
return 0; return 0;
...@@ -2699,7 +2699,7 @@ Type_handler_timestamp_common::make_packed_sort_key_part(uchar *to, Item *item, ...@@ -2699,7 +2699,7 @@ Type_handler_timestamp_common::make_packed_sort_key_part(uchar *to, Item *item,
} }
else else
{ {
if (item->maybe_null) if (item->maybe_null())
*to++= 1; *to++= 1;
if (native.length() != binlen) if (native.length() != binlen)
{ {
...@@ -3023,7 +3023,7 @@ static uint make_sortkey(Sort_param *param, uchar *to) ...@@ -3023,7 +3023,7 @@ static uint make_sortkey(Sort_param *param, uchar *to)
sort_field->item->type_handler()->make_sort_key_part(to, sort_field->item->type_handler()->make_sort_key_part(to,
sort_field->item, sort_field->item,
sort_field, param); sort_field, param);
if ((maybe_null= sort_field->item->maybe_null)) if ((maybe_null= sort_field->item->maybe_null()))
to++; to++;
} }
...@@ -3076,7 +3076,7 @@ static uint make_packed_sortkey(Sort_param *param, uchar *to) ...@@ -3076,7 +3076,7 @@ static uint make_packed_sortkey(Sort_param *param, uchar *to)
length= item->type_handler()->make_packed_sort_key_part(to, item, length= item->type_handler()->make_packed_sort_key_part(to, item,
sort_field, sort_field,
param); param);
if ((maybe_null= sort_field->item->maybe_null)) if ((maybe_null= sort_field->item->maybe_null()))
to++; to++;
} }
to+= length; to+= length;
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -366,7 +366,9 @@ class Item_in_optimizer: public Item_bool_func ...@@ -366,7 +366,9 @@ class Item_in_optimizer: public Item_bool_func
Item_in_optimizer(THD *thd, Item *a, Item *b): Item_in_optimizer(THD *thd, Item *a, Item *b):
Item_bool_func(thd, a, b), cache(0), expr_cache(0), Item_bool_func(thd, a, b), cache(0), expr_cache(0),
save_cache(0), result_for_null_param(UNKNOWN) save_cache(0), result_for_null_param(UNKNOWN)
{ with_subquery= true; } {
flags|= ITEM_FLAG_WITH_SUBQUERY;
}
bool fix_fields(THD *, Item **) override; bool fix_fields(THD *, Item **) override;
bool fix_left(THD *thd); bool fix_left(THD *thd);
table_map not_null_tables() const override { return 0; } table_map not_null_tables() const override { return 0; }
...@@ -914,7 +916,7 @@ class Item_func_between :public Item_func_opt_neg ...@@ -914,7 +916,7 @@ class Item_func_between :public Item_func_opt_neg
Item_func_opt_neg(thd, a, b, c) { } Item_func_opt_neg(thd, a, b, c) { }
longlong val_int() longlong val_int()
{ {
DBUG_ASSERT(fixed); DBUG_ASSERT(fixed());
return m_comparator.type_handler()->Item_func_between_val_int(this); return m_comparator.type_handler()->Item_func_between_val_int(this);
} }
enum Functype functype() const { return BETWEEN; } enum Functype functype() const { return BETWEEN; }
...@@ -1066,7 +1068,7 @@ class Item_func_case_abbreviation2 :public Item_func_case_expression ...@@ -1066,7 +1068,7 @@ class Item_func_case_abbreviation2 :public Item_func_case_expression
{ {
Type_std_attributes::set(source); Type_std_attributes::set(source);
set_handler(source->type_handler()); set_handler(source->type_handler());
maybe_null= maybe_null_arg; set_maybe_null(maybe_null_arg);
} }
bool fix_length_and_dec2_eliminate_null(Item **items) bool fix_length_and_dec2_eliminate_null(Item **items)
...@@ -1123,7 +1125,7 @@ class Item_func_ifnull :public Item_func_case_abbreviation2 ...@@ -1123,7 +1125,7 @@ class Item_func_ifnull :public Item_func_case_abbreviation2
IFNULL(inet6_not_null_expr, 'foo') -> INET6 NULL IFNULL(inet6_not_null_expr, 'foo') -> INET6 NULL
IFNULL(inet6_not_null_expr, '::1') -> INET6 NOT NULL IFNULL(inet6_not_null_expr, '::1') -> INET6 NOT NULL
*/ */
maybe_null= args[1]->maybe_null; copy_flags(args[1], ITEM_FLAG_MAYBE_NULL);
if (Item_func_case_abbreviation2::fix_length_and_dec2(args)) if (Item_func_case_abbreviation2::fix_length_and_dec2(args))
return TRUE; return TRUE;
return FALSE; return FALSE;
...@@ -2403,7 +2405,7 @@ class Item_func_in :public Item_func_opt_neg, ...@@ -2403,7 +2405,7 @@ class Item_func_in :public Item_func_opt_neg,
DBUG_ASSERT(m_comparator.cmp_type() == ROW_RESULT); DBUG_ASSERT(m_comparator.cmp_type() == ROW_RESULT);
return all_items_are_consts(args + 1, arg_count - 1) && // Bisection #2 return all_items_are_consts(args + 1, arg_count - 1) && // Bisection #2
((is_top_level_item() && !negated) || // Bisection #3 ((is_top_level_item() && !negated) || // Bisection #3
(!list_contains_null() && !args[0]->maybe_null)); // Bisection #4 (!list_contains_null() && !args[0]->maybe_null())); // Bisection #4
} }
bool agg_all_arg_charsets_for_comparison() bool agg_all_arg_charsets_for_comparison()
{ {
...@@ -2562,7 +2564,9 @@ class Item_func_null_predicate :public Item_bool_func ...@@ -2562,7 +2564,9 @@ class Item_func_null_predicate :public Item_bool_func
{ return args[0]->collation.collation; } { return args[0]->collation.collation; }
bool fix_length_and_dec() bool fix_length_and_dec()
{ {
decimals=0; max_length=1; maybe_null=0; decimals=0;
max_length=1;
flags&= (item_flags_t) ~ITEM_FLAG_MAYBE_NULL;
return FALSE; return FALSE;
} }
bool count_sargable_conds(void *arg); bool count_sargable_conds(void *arg);
...@@ -2596,7 +2600,7 @@ class Item_func_isnull :public Item_func_null_predicate ...@@ -2596,7 +2600,7 @@ class Item_func_isnull :public Item_func_null_predicate
/* Optimize case of not_null_column IS NULL */ /* Optimize case of not_null_column IS NULL */
virtual void update_used_tables() virtual void update_used_tables()
{ {
if (!args[0]->maybe_null && !arg_is_datetime_notnull_field()) if (!args[0]->maybe_null() && !arg_is_datetime_notnull_field())
{ {
used_tables_cache= 0; /* is always false */ used_tables_cache= 0; /* is always false */
const_item_cache= 1; const_item_cache= 1;
...@@ -3457,7 +3461,10 @@ class Item_func_cursor_found: public Item_func_cursor_bool_attr ...@@ -3457,7 +3461,10 @@ class Item_func_cursor_found: public Item_func_cursor_bool_attr
{ {
public: public:
Item_func_cursor_found(THD *thd, const LEX_CSTRING *name, uint offset) Item_func_cursor_found(THD *thd, const LEX_CSTRING *name, uint offset)
:Item_func_cursor_bool_attr(thd, name, offset) { maybe_null= true; } :Item_func_cursor_bool_attr(thd, name, offset)
{
flags|= ITEM_FLAG_MAYBE_NULL;
}
const char *func_name() const { return "%FOUND"; } const char *func_name() const { return "%FOUND"; }
longlong val_int(); longlong val_int();
Item *get_copy(THD *thd) Item *get_copy(THD *thd)
...@@ -3469,7 +3476,10 @@ class Item_func_cursor_notfound: public Item_func_cursor_bool_attr ...@@ -3469,7 +3476,10 @@ class Item_func_cursor_notfound: public Item_func_cursor_bool_attr
{ {
public: public:
Item_func_cursor_notfound(THD *thd, const LEX_CSTRING *name, uint offset) Item_func_cursor_notfound(THD *thd, const LEX_CSTRING *name, uint offset)
:Item_func_cursor_bool_attr(thd, name, offset) { maybe_null= true; } :Item_func_cursor_bool_attr(thd, name, offset)
{
flags|= ITEM_FLAG_MAYBE_NULL;
}
const char *func_name() const { return "%NOTFOUND"; } const char *func_name() const { return "%NOTFOUND"; }
longlong val_int(); longlong val_int();
Item *get_copy(THD *thd) Item *get_copy(THD *thd)
......
...@@ -2387,7 +2387,7 @@ static bool has_named_parameters(List<Item> *params) ...@@ -2387,7 +2387,7 @@ static bool has_named_parameters(List<Item> *params)
List_iterator<Item> it(*params); List_iterator<Item> it(*params);
while ((param= it++)) while ((param= it++))
{ {
if (! param->is_autogenerated_name) if (! param->is_autogenerated_name())
return true; return true;
} }
} }
...@@ -2633,7 +2633,7 @@ Create_func_arg1::create_func(THD *thd, LEX_CSTRING *name, List<Item> *item_list ...@@ -2633,7 +2633,7 @@ Create_func_arg1::create_func(THD *thd, LEX_CSTRING *name, List<Item> *item_list
Item *param_1= item_list->pop(); Item *param_1= item_list->pop();
if (unlikely(! param_1->is_autogenerated_name)) if (unlikely(! param_1->is_autogenerated_name()))
{ {
my_error(ER_WRONG_PARAMETERS_TO_NATIVE_FCT, MYF(0), name->str); my_error(ER_WRONG_PARAMETERS_TO_NATIVE_FCT, MYF(0), name->str);
return NULL; return NULL;
...@@ -2660,8 +2660,8 @@ Create_func_arg2::create_func(THD *thd, LEX_CSTRING *name, List<Item> *item_list ...@@ -2660,8 +2660,8 @@ Create_func_arg2::create_func(THD *thd, LEX_CSTRING *name, List<Item> *item_list
Item *param_1= item_list->pop(); Item *param_1= item_list->pop();
Item *param_2= item_list->pop(); Item *param_2= item_list->pop();
if (unlikely(!param_1->is_autogenerated_name || if (unlikely(!param_1->is_autogenerated_name() ||
!param_2->is_autogenerated_name)) !param_2->is_autogenerated_name()))
{ {
my_error(ER_WRONG_PARAMETERS_TO_NATIVE_FCT, MYF(0), name->str); my_error(ER_WRONG_PARAMETERS_TO_NATIVE_FCT, MYF(0), name->str);
return NULL; return NULL;
...@@ -2689,9 +2689,9 @@ Create_func_arg3::create_func(THD *thd, LEX_CSTRING *name, List<Item> *item_list ...@@ -2689,9 +2689,9 @@ Create_func_arg3::create_func(THD *thd, LEX_CSTRING *name, List<Item> *item_list
Item *param_2= item_list->pop(); Item *param_2= item_list->pop();
Item *param_3= item_list->pop(); Item *param_3= item_list->pop();
if (unlikely(!param_1->is_autogenerated_name || if (unlikely(!param_1->is_autogenerated_name() ||
!param_2->is_autogenerated_name || !param_2->is_autogenerated_name() ||
!param_3->is_autogenerated_name)) !param_3->is_autogenerated_name()))
{ {
my_error(ER_WRONG_PARAMETERS_TO_NATIVE_FCT, MYF(0), name->str); my_error(ER_WRONG_PARAMETERS_TO_NATIVE_FCT, MYF(0), name->str);
return NULL; return NULL;
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -284,7 +284,7 @@ class Item_func_as_wkb: public Item_binary_func_args_geometry ...@@ -284,7 +284,7 @@ class Item_func_as_wkb: public Item_binary_func_args_geometry
collation.set(&my_charset_bin); collation.set(&my_charset_bin);
decimals=0; decimals=0;
max_length= (uint32) UINT_MAX32; max_length= (uint32) UINT_MAX32;
maybe_null= 1; flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE; return FALSE;
} }
Item *get_copy(THD *thd) Item *get_copy(THD *thd)
...@@ -326,7 +326,7 @@ class Item_func_geometry_type: public Item_str_ascii_func_args_geometry ...@@ -326,7 +326,7 @@ class Item_func_geometry_type: public Item_str_ascii_func_args_geometry
{ {
// "GeometryCollection" is the longest // "GeometryCollection" is the longest
fix_length_and_charset(20, default_charset()); fix_length_and_charset(20, default_charset());
maybe_null= 1; flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE; return FALSE;
}; };
Item *get_copy(THD *thd) Item *get_copy(THD *thd)
...@@ -675,7 +675,7 @@ class Item_func_spatial_rel: public Item_bool_func2_with_rev ...@@ -675,7 +675,7 @@ class Item_func_spatial_rel: public Item_bool_func2_with_rev
Item_func_spatial_rel(THD *thd, Item *a, Item *b, enum Functype sp_rel): Item_func_spatial_rel(THD *thd, Item *a, Item *b, enum Functype sp_rel):
Item_bool_func2_with_rev(thd, a, b), spatial_rel(sp_rel) Item_bool_func2_with_rev(thd, a, b), spatial_rel(sp_rel)
{ {
maybe_null= true; flags|= ITEM_FLAG_MAYBE_NULL;
} }
enum Functype functype() const { return spatial_rel; } enum Functype functype() const { return spatial_rel; }
enum Functype rev_functype() const enum Functype rev_functype() const
...@@ -856,7 +856,7 @@ class Item_func_isempty: public Item_bool_func_args_geometry ...@@ -856,7 +856,7 @@ class Item_func_isempty: public Item_bool_func_args_geometry
:Item_bool_func_args_geometry(thd, a) {} :Item_bool_func_args_geometry(thd, a) {}
longlong val_int(); longlong val_int();
const char *func_name() const { return "st_isempty"; } const char *func_name() const { return "st_isempty"; }
bool fix_length_and_dec() { maybe_null= 1; return FALSE; } bool fix_length_and_dec() { flags|= ITEM_FLAG_MAYBE_NULL; return FALSE; }
bool need_parentheses_in_default() { return false; } bool need_parentheses_in_default() { return false; }
Item *get_copy(THD *thd) Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_isempty>(thd, this); } { return get_item_copy<Item_func_isempty>(thd, this); }
...@@ -909,7 +909,7 @@ class Item_func_dimension: public Item_long_func_args_geometry ...@@ -909,7 +909,7 @@ class Item_func_dimension: public Item_long_func_args_geometry
:Item_long_func_args_geometry(thd, a) {} :Item_long_func_args_geometry(thd, a) {}
longlong val_int(); longlong val_int();
const char *func_name() const { return "st_dimension"; } const char *func_name() const { return "st_dimension"; }
bool fix_length_and_dec() { max_length= 10; maybe_null= 1; return FALSE; } bool fix_length_and_dec() { max_length= 10; flags|= ITEM_FLAG_MAYBE_NULL; return FALSE; }
Item *get_copy(THD *thd) Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_dimension>(thd, this); } { return get_item_copy<Item_func_dimension>(thd, this); }
}; };
...@@ -925,7 +925,7 @@ class Item_func_x: public Item_real_func_args_geometry ...@@ -925,7 +925,7 @@ class Item_func_x: public Item_real_func_args_geometry
{ {
if (Item_real_func::fix_length_and_dec()) if (Item_real_func::fix_length_and_dec())
return TRUE; return TRUE;
maybe_null= 1; flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE; return FALSE;
} }
Item *get_copy(THD *thd) Item *get_copy(THD *thd)
...@@ -943,7 +943,7 @@ class Item_func_y: public Item_real_func_args_geometry ...@@ -943,7 +943,7 @@ class Item_func_y: public Item_real_func_args_geometry
{ {
if (Item_real_func::fix_length_and_dec()) if (Item_real_func::fix_length_and_dec())
return TRUE; return TRUE;
maybe_null= 1; flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE; return FALSE;
} }
Item *get_copy(THD *thd) Item *get_copy(THD *thd)
...@@ -958,7 +958,7 @@ class Item_func_numgeometries: public Item_long_func_args_geometry ...@@ -958,7 +958,7 @@ class Item_func_numgeometries: public Item_long_func_args_geometry
:Item_long_func_args_geometry(thd, a) {} :Item_long_func_args_geometry(thd, a) {}
longlong val_int(); longlong val_int();
const char *func_name() const { return "st_numgeometries"; } const char *func_name() const { return "st_numgeometries"; }
bool fix_length_and_dec() { max_length= 10; maybe_null= 1; return FALSE; } bool fix_length_and_dec() { max_length= 10; flags|= ITEM_FLAG_MAYBE_NULL; return FALSE; }
Item *get_copy(THD *thd) Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_numgeometries>(thd, this); } { return get_item_copy<Item_func_numgeometries>(thd, this); }
}; };
...@@ -971,7 +971,7 @@ class Item_func_numinteriorring: public Item_long_func_args_geometry ...@@ -971,7 +971,7 @@ class Item_func_numinteriorring: public Item_long_func_args_geometry
:Item_long_func_args_geometry(thd, a) {} :Item_long_func_args_geometry(thd, a) {}
longlong val_int(); longlong val_int();
const char *func_name() const { return "st_numinteriorrings"; } const char *func_name() const { return "st_numinteriorrings"; }
bool fix_length_and_dec() { max_length= 10; maybe_null= 1; return FALSE; } bool fix_length_and_dec() { max_length= 10; flags|= ITEM_FLAG_MAYBE_NULL; return FALSE; }
Item *get_copy(THD *thd) Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_numinteriorring>(thd, this); } { return get_item_copy<Item_func_numinteriorring>(thd, this); }
}; };
...@@ -984,7 +984,7 @@ class Item_func_numpoints: public Item_long_func_args_geometry ...@@ -984,7 +984,7 @@ class Item_func_numpoints: public Item_long_func_args_geometry
:Item_long_func_args_geometry(thd, a) {} :Item_long_func_args_geometry(thd, a) {}
longlong val_int(); longlong val_int();
const char *func_name() const { return "st_numpoints"; } const char *func_name() const { return "st_numpoints"; }
bool fix_length_and_dec() { max_length= 10; maybe_null= 1; return FALSE; } bool fix_length_and_dec() { max_length= 10; flags|= ITEM_FLAG_MAYBE_NULL; return FALSE; }
Item *get_copy(THD *thd) Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_numpoints>(thd, this); } { return get_item_copy<Item_func_numpoints>(thd, this); }
}; };
...@@ -1000,7 +1000,7 @@ class Item_func_area: public Item_real_func_args_geometry ...@@ -1000,7 +1000,7 @@ class Item_func_area: public Item_real_func_args_geometry
{ {
if (Item_real_func::fix_length_and_dec()) if (Item_real_func::fix_length_and_dec())
return TRUE; return TRUE;
maybe_null= 1; flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE; return FALSE;
} }
Item *get_copy(THD *thd) Item *get_copy(THD *thd)
...@@ -1020,7 +1020,7 @@ class Item_func_glength: public Item_real_func_args_geometry ...@@ -1020,7 +1020,7 @@ class Item_func_glength: public Item_real_func_args_geometry
{ {
if (Item_real_func::fix_length_and_dec()) if (Item_real_func::fix_length_and_dec())
return TRUE; return TRUE;
maybe_null= 1; flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE; return FALSE;
} }
Item *get_copy(THD *thd) Item *get_copy(THD *thd)
...@@ -1035,7 +1035,7 @@ class Item_func_srid: public Item_long_func_args_geometry ...@@ -1035,7 +1035,7 @@ class Item_func_srid: public Item_long_func_args_geometry
:Item_long_func_args_geometry(thd, a) {} :Item_long_func_args_geometry(thd, a) {}
longlong val_int(); longlong val_int();
const char *func_name() const { return "srid"; } const char *func_name() const { return "srid"; }
bool fix_length_and_dec() { max_length= 10; maybe_null= 1; return FALSE; } bool fix_length_and_dec() { max_length= 10; flags|= ITEM_FLAG_MAYBE_NULL; return FALSE; }
Item *get_copy(THD *thd) Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_srid>(thd, this); } { return get_item_copy<Item_func_srid>(thd, this); }
}; };
......
...@@ -397,7 +397,7 @@ bool Item_func_json_exists::fix_length_and_dec() ...@@ -397,7 +397,7 @@ bool Item_func_json_exists::fix_length_and_dec()
{ {
if (Item_bool_func::fix_length_and_dec()) if (Item_bool_func::fix_length_and_dec())
return TRUE; return TRUE;
maybe_null= 1; flags|= ITEM_FLAG_MAYBE_NULL;
path.set_constant_flag(args[1]->const_item()); path.set_constant_flag(args[1]->const_item());
return FALSE; return FALSE;
} }
...@@ -451,7 +451,7 @@ bool Item_func_json_value::fix_length_and_dec() ...@@ -451,7 +451,7 @@ bool Item_func_json_value::fix_length_and_dec()
collation.set(args[0]->collation); collation.set(args[0]->collation);
max_length= args[0]->max_length; max_length= args[0]->max_length;
set_constant_flag(args[1]->const_item()); set_constant_flag(args[1]->const_item());
maybe_null= 1; flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE; return FALSE;
} }
...@@ -461,7 +461,7 @@ bool Item_func_json_query::fix_length_and_dec() ...@@ -461,7 +461,7 @@ bool Item_func_json_query::fix_length_and_dec()
collation.set(args[0]->collation); collation.set(args[0]->collation);
max_length= args[0]->max_length; max_length= args[0]->max_length;
set_constant_flag(args[1]->const_item()); set_constant_flag(args[1]->const_item());
maybe_null= 1; flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE; return FALSE;
} }
...@@ -609,7 +609,7 @@ bool Item_func_json_unquote::fix_length_and_dec() ...@@ -609,7 +609,7 @@ bool Item_func_json_unquote::fix_length_and_dec()
collation.set(&my_charset_utf8mb3_general_ci, collation.set(&my_charset_utf8mb3_general_ci,
DERIVATION_COERCIBLE, MY_REPERTOIRE_ASCII); DERIVATION_COERCIBLE, MY_REPERTOIRE_ASCII);
max_length= args[0]->max_length; max_length= args[0]->max_length;
maybe_null= 1; flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE; return FALSE;
} }
...@@ -730,7 +730,7 @@ bool Item_func_json_extract::fix_length_and_dec() ...@@ -730,7 +730,7 @@ bool Item_func_json_extract::fix_length_and_dec()
max_length= args[0]->max_length * (arg_count - 1); max_length= args[0]->max_length * (arg_count - 1);
mark_constant_paths(paths, args+1, arg_count-1); mark_constant_paths(paths, args+1, arg_count-1);
maybe_null= 1; flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE; return FALSE;
} }
...@@ -1000,7 +1000,7 @@ bool Item_func_json_contains::fix_length_and_dec() ...@@ -1000,7 +1000,7 @@ bool Item_func_json_contains::fix_length_and_dec()
{ {
a2_constant= args[1]->const_item(); a2_constant= args[1]->const_item();
a2_parsed= FALSE; a2_parsed= FALSE;
maybe_null= 1; flags|= ITEM_FLAG_MAYBE_NULL;
if (arg_count > 2) if (arg_count > 2)
path.set_constant_flag(args[2]->const_item()); path.set_constant_flag(args[2]->const_item());
return Item_bool_func::fix_length_and_dec(); return Item_bool_func::fix_length_and_dec();
...@@ -1251,7 +1251,7 @@ bool Item_func_json_contains_path::fix_length_and_dec() ...@@ -1251,7 +1251,7 @@ bool Item_func_json_contains_path::fix_length_and_dec()
{ {
ooa_constant= args[1]->const_item(); ooa_constant= args[1]->const_item();
ooa_parsed= FALSE; ooa_parsed= FALSE;
maybe_null= 1; flags|= ITEM_FLAG_MAYBE_NULL;
mark_constant_paths(paths, args+2, arg_count-2); mark_constant_paths(paths, args+2, arg_count-2);
return Item_bool_func::fix_length_and_dec(); return Item_bool_func::fix_length_and_dec();
} }
...@@ -1589,7 +1589,7 @@ bool Item_func_json_array::fix_length_and_dec() ...@@ -1589,7 +1589,7 @@ bool Item_func_json_array::fix_length_and_dec()
String *Item_func_json_array::val_str(String *str) String *Item_func_json_array::val_str(String *str)
{ {
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed());
uint n_arg; uint n_arg;
str->length(0); str->length(0);
...@@ -1642,7 +1642,7 @@ bool Item_func_json_array_append::fix_length_and_dec() ...@@ -1642,7 +1642,7 @@ bool Item_func_json_array_append::fix_length_and_dec()
} }
fix_char_length_ulonglong(char_length); fix_char_length_ulonglong(char_length);
maybe_null= 1; flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE; return FALSE;
} }
...@@ -1655,7 +1655,7 @@ String *Item_func_json_array_append::val_str(String *str) ...@@ -1655,7 +1655,7 @@ String *Item_func_json_array_append::val_str(String *str)
size_t str_rest_len; size_t str_rest_len;
const uchar *ar_end; const uchar *ar_end;
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed());
if ((null_value= args[0]->null_value)) if ((null_value= args[0]->null_value))
return 0; return 0;
...@@ -1783,7 +1783,7 @@ String *Item_func_json_array_insert::val_str(String *str) ...@@ -1783,7 +1783,7 @@ String *Item_func_json_array_insert::val_str(String *str)
String *js= args[0]->val_json(&tmp_js); String *js= args[0]->val_json(&tmp_js);
uint n_arg, n_path; uint n_arg, n_path;
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed());
if ((null_value= args[0]->null_value)) if ((null_value= args[0]->null_value))
return 0; return 0;
...@@ -1919,7 +1919,7 @@ String *Item_func_json_array_insert::val_str(String *str) ...@@ -1919,7 +1919,7 @@ String *Item_func_json_array_insert::val_str(String *str)
String *Item_func_json_object::val_str(String *str) String *Item_func_json_object::val_str(String *str)
{ {
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed());
uint n_arg; uint n_arg;
str->length(0); str->length(0);
...@@ -2167,7 +2167,7 @@ static int do_merge(String *str, json_engine_t *je1, json_engine_t *je2) ...@@ -2167,7 +2167,7 @@ static int do_merge(String *str, json_engine_t *je1, json_engine_t *je2)
String *Item_func_json_merge::val_str(String *str) String *Item_func_json_merge::val_str(String *str)
{ {
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed());
json_engine_t je1, je2; json_engine_t je1, je2;
String *js1= args[0]->val_json(&tmp_js1), *js2=NULL; String *js1= args[0]->val_json(&tmp_js1), *js2=NULL;
uint n_arg; uint n_arg;
...@@ -2468,7 +2468,7 @@ static int do_merge_patch(String *str, json_engine_t *je1, json_engine_t *je2, ...@@ -2468,7 +2468,7 @@ static int do_merge_patch(String *str, json_engine_t *je1, json_engine_t *je2,
String *Item_func_json_merge_patch::val_str(String *str) String *Item_func_json_merge_patch::val_str(String *str)
{ {
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed());
json_engine_t je1, je2; json_engine_t je1, je2;
String *js1= args[0]->val_json(&tmp_js1), *js2=NULL; String *js1= args[0]->val_json(&tmp_js1), *js2=NULL;
uint n_arg; uint n_arg;
...@@ -2561,7 +2561,7 @@ bool Item_func_json_length::fix_length_and_dec() ...@@ -2561,7 +2561,7 @@ bool Item_func_json_length::fix_length_and_dec()
{ {
if (arg_count > 1) if (arg_count > 1)
path.set_constant_flag(args[1]->const_item()); path.set_constant_flag(args[1]->const_item());
maybe_null= 1; flags|= ITEM_FLAG_MAYBE_NULL;
max_length= 10; max_length= 10;
return FALSE; return FALSE;
} }
...@@ -2707,7 +2707,7 @@ bool Item_func_json_type::fix_length_and_dec() ...@@ -2707,7 +2707,7 @@ bool Item_func_json_type::fix_length_and_dec()
{ {
collation.set(&my_charset_utf8mb3_general_ci); collation.set(&my_charset_utf8mb3_general_ci);
max_length= 12; max_length= 12;
maybe_null= 1; flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE; return FALSE;
} }
...@@ -2776,7 +2776,7 @@ bool Item_func_json_insert::fix_length_and_dec() ...@@ -2776,7 +2776,7 @@ bool Item_func_json_insert::fix_length_and_dec()
} }
fix_char_length_ulonglong(char_length); fix_char_length_ulonglong(char_length);
maybe_null= 1; flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE; return FALSE;
} }
...@@ -2788,7 +2788,7 @@ String *Item_func_json_insert::val_str(String *str) ...@@ -2788,7 +2788,7 @@ String *Item_func_json_insert::val_str(String *str)
uint n_arg, n_path; uint n_arg, n_path;
json_string_t key_name; json_string_t key_name;
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed());
if ((null_value= args[0]->null_value)) if ((null_value= args[0]->null_value))
return 0; return 0;
...@@ -3028,7 +3028,7 @@ bool Item_func_json_remove::fix_length_and_dec() ...@@ -3028,7 +3028,7 @@ bool Item_func_json_remove::fix_length_and_dec()
max_length= args[0]->max_length; max_length= args[0]->max_length;
mark_constant_paths(paths, args+1, arg_count-1); mark_constant_paths(paths, args+1, arg_count-1);
maybe_null= 1; flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE; return FALSE;
} }
...@@ -3040,7 +3040,7 @@ String *Item_func_json_remove::val_str(String *str) ...@@ -3040,7 +3040,7 @@ String *Item_func_json_remove::val_str(String *str)
uint n_arg, n_path; uint n_arg, n_path;
json_string_t key_name; json_string_t key_name;
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed());
if (args[0]->null_value) if (args[0]->null_value)
goto null_return; goto null_return;
...@@ -3213,7 +3213,7 @@ bool Item_func_json_keys::fix_length_and_dec() ...@@ -3213,7 +3213,7 @@ bool Item_func_json_keys::fix_length_and_dec()
{ {
collation.set(args[0]->collation); collation.set(args[0]->collation);
max_length= args[0]->max_length; max_length= args[0]->max_length;
maybe_null= 1; flags|= ITEM_FLAG_MAYBE_NULL;
if (arg_count > 1) if (arg_count > 1)
path.set_constant_flag(args[1]->const_item()); path.set_constant_flag(args[1]->const_item());
return FALSE; return FALSE;
...@@ -3398,7 +3398,7 @@ bool Item_func_json_search::fix_length_and_dec() ...@@ -3398,7 +3398,7 @@ bool Item_func_json_search::fix_length_and_dec()
if (arg_count > 4) if (arg_count > 4)
mark_constant_paths(paths, args+4, arg_count-4); mark_constant_paths(paths, args+4, arg_count-4);
maybe_null= 1; flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE; return FALSE;
} }
...@@ -3581,7 +3581,7 @@ bool Item_func_json_format::fix_length_and_dec() ...@@ -3581,7 +3581,7 @@ bool Item_func_json_format::fix_length_and_dec()
{ {
decimals= 0; decimals= 0;
max_length= args[0]->max_length; max_length= args[0]->max_length;
maybe_null= 1; flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE; return FALSE;
} }
...@@ -3782,14 +3782,14 @@ bool ...@@ -3782,14 +3782,14 @@ bool
Item_func_json_objectagg::fix_fields(THD *thd, Item **ref) Item_func_json_objectagg::fix_fields(THD *thd, Item **ref)
{ {
uint i; /* for loop variable */ uint i; /* for loop variable */
DBUG_ASSERT(fixed == 0); DBUG_ASSERT(fixed() == 0);
memcpy(orig_args, args, sizeof(Item*) * arg_count); memcpy(orig_args, args, sizeof(Item*) * arg_count);
if (init_sum_func_check(thd)) if (init_sum_func_check(thd))
return TRUE; return TRUE;
maybe_null= 1; flags|= ITEM_FLAG_MAYBE_NULL;
/* /*
Fix fields for select list and ORDER clause Fix fields for select list and ORDER clause
...@@ -3799,9 +3799,9 @@ Item_func_json_objectagg::fix_fields(THD *thd, Item **ref) ...@@ -3799,9 +3799,9 @@ Item_func_json_objectagg::fix_fields(THD *thd, Item **ref)
{ {
if (args[i]->fix_fields_if_needed_for_scalar(thd, &args[i])) if (args[i]->fix_fields_if_needed_for_scalar(thd, &args[i]))
return TRUE; return TRUE;
with_subquery|= args[i]->with_subquery; flags|= (args[i]->flags & (ITEM_FLAG_WITH_SUBQUERY |
with_param|= args[i]->with_param; ITEM_FLAG_WITH_PARAM |
with_window_func|= args[i]->with_window_func; ITEM_FLAG_WITH_WINDOW_FUNC));
} }
/* skip charset aggregation for order columns */ /* skip charset aggregation for order columns */
...@@ -3818,7 +3818,7 @@ Item_func_json_objectagg::fix_fields(THD *thd, Item **ref) ...@@ -3818,7 +3818,7 @@ Item_func_json_objectagg::fix_fields(THD *thd, Item **ref)
if (check_sum_func(thd, ref)) if (check_sum_func(thd, ref))
return TRUE; return TRUE;
fixed= 1; flags|= ITEM_FLAG_FIXED;
return FALSE; return FALSE;
} }
...@@ -3872,7 +3872,7 @@ bool Item_func_json_objectagg::add() ...@@ -3872,7 +3872,7 @@ bool Item_func_json_objectagg::add()
String* Item_func_json_objectagg::val_str(String* str) String* Item_func_json_objectagg::val_str(String* str)
{ {
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed());
if (null_value) if (null_value)
return 0; return 0;
......
...@@ -88,7 +88,7 @@ class Item_func_json_valid: public Item_bool_func ...@@ -88,7 +88,7 @@ class Item_func_json_valid: public Item_bool_func
{ {
if (Item_bool_func::fix_length_and_dec()) if (Item_bool_func::fix_length_and_dec())
return TRUE; return TRUE;
maybe_null= 1; flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE; return FALSE;
} }
bool set_format_by_check_constraint(Send_field_extended_metadata *to) const bool set_format_by_check_constraint(Send_field_extended_metadata *to) const
......
...@@ -36,9 +36,10 @@ void Item_row::illegal_method_call(const char *method) ...@@ -36,9 +36,10 @@ void Item_row::illegal_method_call(const char *method)
bool Item_row::fix_fields(THD *thd, Item **ref) bool Item_row::fix_fields(THD *thd, Item **ref)
{ {
DBUG_ASSERT(fixed == 0); DBUG_ASSERT(fixed() == 0);
null_value= 0; null_value= 0;
maybe_null= 0; flags&= (item_flags_t) ~ITEM_FLAG_MAYBE_NULL;
Item **arg, **arg_end; Item **arg, **arg_end;
for (arg= args, arg_end= args + arg_count; arg != arg_end ; arg++) for (arg= args, arg_end= args + arg_count; arg != arg_end ; arg++)
{ {
...@@ -60,14 +61,14 @@ bool Item_row::fix_fields(THD *thd, Item **ref) ...@@ -60,14 +61,14 @@ bool Item_row::fix_fields(THD *thd, Item **ref)
with_null|= 1; with_null|= 1;
} }
} }
maybe_null|= item->maybe_null; flags|= (item->flags & (ITEM_FLAG_MAYBE_NULL |
with_sum_func= with_sum_func || item->with_sum_func; ITEM_FLAG_WITH_SUM_FUNC |
with_window_func = with_window_func || item->with_window_func; ITEM_FLAG_WITH_WINDOW_FUNC |
with_field= with_field || item->with_field; ITEM_FLAG_WITH_FIELD |
with_subquery|= item->with_subquery; ITEM_FLAG_WITH_SUBQUERY |
with_param|= item->with_param; ITEM_FLAG_WITH_PARAM));
} }
fixed= 1; flags|= ITEM_FLAG_FIXED;
return FALSE; return FALSE;
} }
......
This diff is collapsed.
...@@ -299,7 +299,7 @@ class Item_func_decode_histogram :public Item_str_func ...@@ -299,7 +299,7 @@ class Item_func_decode_histogram :public Item_str_func
{ {
collation.set(system_charset_info); collation.set(system_charset_info);
max_length= MAX_BLOB_WIDTH; max_length= MAX_BLOB_WIDTH;
maybe_null= 1; flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE; return FALSE;
} }
const char *func_name() const { return "decode_histogram"; } const char *func_name() const { return "decode_histogram"; }
...@@ -511,7 +511,7 @@ class Item_func_substr_oracle :public Item_func_substr ...@@ -511,7 +511,7 @@ class Item_func_substr_oracle :public Item_func_substr
bool fix_length_and_dec() bool fix_length_and_dec()
{ {
bool res= Item_func_substr::fix_length_and_dec(); bool res= Item_func_substr::fix_length_and_dec();
maybe_null= true; flags|= ITEM_FLAG_MAYBE_NULL;
return res; return res;
} }
const char *func_name() const { return "substr_oracle"; } const char *func_name() const { return "substr_oracle"; }
...@@ -586,7 +586,7 @@ class Item_func_trim_oracle :public Item_func_trim ...@@ -586,7 +586,7 @@ class Item_func_trim_oracle :public Item_func_trim
bool fix_length_and_dec() bool fix_length_and_dec()
{ {
bool res= Item_func_trim::fix_length_and_dec(); bool res= Item_func_trim::fix_length_and_dec();
maybe_null= true; flags|= ITEM_FLAG_MAYBE_NULL;
return res; return res;
} }
Item *get_copy(THD *thd) Item *get_copy(THD *thd)
...@@ -625,7 +625,7 @@ class Item_func_ltrim_oracle :public Item_func_ltrim ...@@ -625,7 +625,7 @@ class Item_func_ltrim_oracle :public Item_func_ltrim
bool fix_length_and_dec() bool fix_length_and_dec()
{ {
bool res= Item_func_ltrim::fix_length_and_dec(); bool res= Item_func_ltrim::fix_length_and_dec();
maybe_null= true; flags|= ITEM_FLAG_MAYBE_NULL;
return res; return res;
} }
Item *get_copy(THD *thd) Item *get_copy(THD *thd)
...@@ -660,7 +660,7 @@ class Item_func_rtrim_oracle :public Item_func_rtrim ...@@ -660,7 +660,7 @@ class Item_func_rtrim_oracle :public Item_func_rtrim
bool fix_length_and_dec() bool fix_length_and_dec()
{ {
bool res= Item_func_rtrim::fix_length_and_dec(); bool res= Item_func_rtrim::fix_length_and_dec();
maybe_null= true; flags|= ITEM_FLAG_MAYBE_NULL;
return res; return res;
} }
Item *get_copy(THD *thd) Item *get_copy(THD *thd)
...@@ -719,7 +719,7 @@ class Item_func_des_encrypt :public Item_str_binary_checksum_func ...@@ -719,7 +719,7 @@ class Item_func_des_encrypt :public Item_str_binary_checksum_func
String *val_str(String *); String *val_str(String *);
bool fix_length_and_dec() bool fix_length_and_dec()
{ {
maybe_null=1; flags|= ITEM_FLAG_MAYBE_NULL;
/* 9 = MAX ((8- (arg_len % 8)) + 1) */ /* 9 = MAX ((8- (arg_len % 8)) + 1) */
max_length = args[0]->max_length + 9; max_length = args[0]->max_length + 9;
return FALSE; return FALSE;
...@@ -740,7 +740,7 @@ class Item_func_des_decrypt :public Item_str_binary_checksum_func ...@@ -740,7 +740,7 @@ class Item_func_des_decrypt :public Item_str_binary_checksum_func
String *val_str(String *); String *val_str(String *);
bool fix_length_and_dec() bool fix_length_and_dec()
{ {
maybe_null=1; flags|= ITEM_FLAG_MAYBE_NULL;
/* 9 = MAX ((8- (arg_len % 8)) + 1) */ /* 9 = MAX ((8- (arg_len % 8)) + 1) */
max_length= args[0]->max_length; max_length= args[0]->max_length;
if (max_length >= 9U) if (max_length >= 9U)
...@@ -778,7 +778,12 @@ class Item_func_encrypt :public Item_str_binary_checksum_func ...@@ -778,7 +778,12 @@ class Item_func_encrypt :public Item_str_binary_checksum_func
constructor_helper(); constructor_helper();
} }
String *val_str(String *); String *val_str(String *);
bool fix_length_and_dec() { maybe_null=1; max_length = 13; return FALSE; } bool fix_length_and_dec()
{
flags|= ITEM_FLAG_MAYBE_NULL;
max_length = 13;
return FALSE;
}
const char *func_name() const { return "encrypt"; } const char *func_name() const { return "encrypt"; }
bool check_vcol_func_processor(void *arg) bool check_vcol_func_processor(void *arg)
{ {
...@@ -855,7 +860,7 @@ class Item_func_database :public Item_func_sysconst ...@@ -855,7 +860,7 @@ class Item_func_database :public Item_func_sysconst
bool fix_length_and_dec() bool fix_length_and_dec()
{ {
max_length= MAX_FIELD_NAME * system_charset_info->mbmaxlen; max_length= MAX_FIELD_NAME * system_charset_info->mbmaxlen;
maybe_null=1; flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE; return FALSE;
} }
const char *func_name() const { return "database"; } const char *func_name() const { return "database"; }
...@@ -880,7 +885,7 @@ class Item_func_sqlerrm :public Item_func_sysconst ...@@ -880,7 +885,7 @@ class Item_func_sqlerrm :public Item_func_sysconst
{ {
max_length= 512 * system_charset_info->mbmaxlen; max_length= 512 * system_charset_info->mbmaxlen;
null_value= false; null_value= false;
maybe_null= false; flags&= (item_flags_t) ~ITEM_FLAG_MAYBE_NULL;
return FALSE; return FALSE;
} }
Item *get_copy(THD *thd) Item *get_copy(THD *thd)
...@@ -900,7 +905,7 @@ class Item_func_user :public Item_func_sysconst ...@@ -900,7 +905,7 @@ class Item_func_user :public Item_func_sysconst
} }
String *val_str(String *) String *val_str(String *)
{ {
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed());
return (null_value ? 0 : &str_value); return (null_value ? 0 : &str_value);
} }
bool fix_fields(THD *thd, Item **ref); bool fix_fields(THD *thd, Item **ref);
...@@ -959,7 +964,7 @@ class Item_func_current_role :public Item_func_sysconst ...@@ -959,7 +964,7 @@ class Item_func_current_role :public Item_func_sysconst
const char *fully_qualified_func_name() const { return "current_role()"; } const char *fully_qualified_func_name() const { return "current_role()"; }
String *val_str(String *) String *val_str(String *)
{ {
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed());
return null_value ? NULL : &str_value; return null_value ? NULL : &str_value;
} }
bool check_vcol_func_processor(void *arg) bool check_vcol_func_processor(void *arg)
...@@ -1155,7 +1160,7 @@ class Item_func_rpad_oracle :public Item_func_rpad ...@@ -1155,7 +1160,7 @@ class Item_func_rpad_oracle :public Item_func_rpad
bool fix_length_and_dec() bool fix_length_and_dec()
{ {
bool res= Item_func_rpad::fix_length_and_dec(); bool res= Item_func_rpad::fix_length_and_dec();
maybe_null= true; flags|= ITEM_FLAG_MAYBE_NULL;
return res; return res;
} }
const char *func_name() const { return "rpad_oracle"; } const char *func_name() const { return "rpad_oracle"; }
...@@ -1190,7 +1195,7 @@ class Item_func_lpad_oracle :public Item_func_lpad ...@@ -1190,7 +1195,7 @@ class Item_func_lpad_oracle :public Item_func_lpad
bool fix_length_and_dec() bool fix_length_and_dec()
{ {
bool res= Item_func_lpad::fix_length_and_dec(); bool res= Item_func_lpad::fix_length_and_dec();
maybe_null= true; flags|= ITEM_FLAG_MAYBE_NULL;
return res; return res;
} }
const char *func_name() const { return "lpad_oracle"; } const char *func_name() const { return "lpad_oracle"; }
...@@ -1210,7 +1215,7 @@ class Item_func_conv :public Item_str_func ...@@ -1210,7 +1215,7 @@ class Item_func_conv :public Item_str_func
{ {
collation.set(default_charset()); collation.set(default_charset());
fix_char_length(64); fix_char_length(64);
maybe_null= 1; flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE; return FALSE;
} }
Item *get_copy(THD *thd) Item *get_copy(THD *thd)
...@@ -1238,7 +1243,7 @@ class Item_func_hex :public Item_str_ascii_checksum_func ...@@ -1238,7 +1243,7 @@ class Item_func_hex :public Item_str_ascii_checksum_func
String *val_str_ascii_from_val_str(String *str); String *val_str_ascii_from_val_str(String *str);
String *val_str_ascii(String *str) String *val_str_ascii(String *str)
{ {
DBUG_ASSERT(fixed); DBUG_ASSERT(fixed());
return m_arg0_type_handler->Item_func_hex_val_str_ascii(this, str); return m_arg0_type_handler->Item_func_hex_val_str_ascii(this, str);
} }
bool fix_length_and_dec() bool fix_length_and_dec()
...@@ -1260,7 +1265,7 @@ class Item_func_unhex :public Item_str_func ...@@ -1260,7 +1265,7 @@ class Item_func_unhex :public Item_str_func
Item_func_unhex(THD *thd, Item *a): Item_str_func(thd, a) Item_func_unhex(THD *thd, Item *a): Item_str_func(thd, a)
{ {
/* there can be bad hex strings */ /* there can be bad hex strings */
maybe_null= 1; flags|= ITEM_FLAG_MAYBE_NULL;
} }
const char *func_name() const { return "unhex"; } const char *func_name() const { return "unhex"; }
String *val_str(String *); String *val_str(String *);
...@@ -1286,7 +1291,9 @@ class Item_func_like_range :public Item_str_func ...@@ -1286,7 +1291,9 @@ class Item_func_like_range :public Item_str_func
public: public:
Item_func_like_range(THD *thd, Item *a, Item *b, bool is_min_arg): Item_func_like_range(THD *thd, Item *a, Item *b, bool is_min_arg):
Item_str_func(thd, a, b), is_min(is_min_arg) Item_str_func(thd, a, b), is_min(is_min_arg)
{ maybe_null= 1; } {
flags|= ITEM_FLAG_MAYBE_NULL;
}
String *val_str(String *); String *val_str(String *);
bool fix_length_and_dec() bool fix_length_and_dec()
{ {
...@@ -1327,7 +1334,7 @@ class Item_func_binary :public Item_str_func ...@@ -1327,7 +1334,7 @@ class Item_func_binary :public Item_str_func
Item_func_binary(THD *thd, Item *a): Item_str_func(thd, a) {} Item_func_binary(THD *thd, Item *a): Item_str_func(thd, a) {}
String *val_str(String *a) String *val_str(String *a)
{ {
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed());
String *tmp=args[0]->val_str(a); String *tmp=args[0]->val_str(a);
null_value=args[0]->null_value; null_value=args[0]->null_value;
if (tmp) if (tmp)
...@@ -1358,7 +1365,7 @@ class Item_load_file :public Item_str_func ...@@ -1358,7 +1365,7 @@ class Item_load_file :public Item_str_func
bool fix_length_and_dec() bool fix_length_and_dec()
{ {
collation.set(&my_charset_bin, DERIVATION_COERCIBLE); collation.set(&my_charset_bin, DERIVATION_COERCIBLE);
maybe_null=1; flags|= ITEM_FLAG_MAYBE_NULL;
max_length=MAX_BLOB_WIDTH; max_length=MAX_BLOB_WIDTH;
return FALSE; return FALSE;
} }
...@@ -1532,7 +1539,7 @@ class Item_func_expr_str_metadata :public Item_str_func ...@@ -1532,7 +1539,7 @@ class Item_func_expr_str_metadata :public Item_str_func
{ {
collation.set(system_charset_info); collation.set(system_charset_info);
max_length= 64 * collation.collation->mbmaxlen; // should be enough max_length= 64 * collation.collation->mbmaxlen; // should be enough
maybe_null= 0; flags&= (item_flags_t) ~ITEM_FLAG_MAYBE_NULL;
return FALSE; return FALSE;
}; };
table_map not_null_tables() const { return 0; } table_map not_null_tables() const { return 0; }
...@@ -1622,7 +1629,11 @@ class Item_func_uncompressed_length : public Item_long_func_length ...@@ -1622,7 +1629,11 @@ class Item_func_uncompressed_length : public Item_long_func_length
Item_func_uncompressed_length(THD *thd, Item *a) Item_func_uncompressed_length(THD *thd, Item *a)
:Item_long_func_length(thd, a) {} :Item_long_func_length(thd, a) {}
const char *func_name() const{return "uncompressed_length";} const char *func_name() const{return "uncompressed_length";}
bool fix_length_and_dec() { max_length=10; maybe_null= true; return FALSE; } bool fix_length_and_dec()
{
max_length=10;
flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE; }
longlong val_int(); longlong val_int();
Item *get_copy(THD *thd) Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_uncompressed_length>(thd, this); } { return get_item_copy<Item_func_uncompressed_length>(thd, this); }
...@@ -1659,7 +1670,8 @@ class Item_func_uncompress: public Item_str_binary_checksum_func ...@@ -1659,7 +1670,8 @@ class Item_func_uncompress: public Item_str_binary_checksum_func
:Item_str_binary_checksum_func(thd, a) {} :Item_str_binary_checksum_func(thd, a) {}
bool fix_length_and_dec() bool fix_length_and_dec()
{ {
maybe_null= 1; max_length= MAX_BLOB_WIDTH; flags|= ITEM_FLAG_MAYBE_NULL;
max_length= MAX_BLOB_WIDTH;
return FALSE; return FALSE;
} }
const char *func_name() const{return "uncompress";} const char *func_name() const{return "uncompress";}
...@@ -1738,7 +1750,7 @@ class Item_func_dyncol_json: public Item_str_func ...@@ -1738,7 +1750,7 @@ class Item_func_dyncol_json: public Item_str_func
bool fix_length_and_dec() bool fix_length_and_dec()
{ {
max_length= MAX_BLOB_WIDTH; max_length= MAX_BLOB_WIDTH;
maybe_null= 1; flags|= ITEM_FLAG_MAYBE_NULL;
decimals= 0; decimals= 0;
return FALSE; return FALSE;
} }
...@@ -1756,7 +1768,11 @@ class Item_dyncol_get: public Item_str_func ...@@ -1756,7 +1768,11 @@ class Item_dyncol_get: public Item_str_func
Item_dyncol_get(THD *thd, Item *str, Item *num): Item_str_func(thd, str, num) Item_dyncol_get(THD *thd, Item *str, Item *num): Item_str_func(thd, str, num)
{} {}
bool fix_length_and_dec() bool fix_length_and_dec()
{ maybe_null= 1;; max_length= MAX_BLOB_WIDTH; return FALSE; } {
flags|= ITEM_FLAG_MAYBE_NULL;
max_length= MAX_BLOB_WIDTH;
return FALSE;
}
/* Mark that collation can change between calls */ /* Mark that collation can change between calls */
bool dynamic_result() { return 1; } bool dynamic_result() { return 1; }
...@@ -1795,7 +1811,11 @@ class Item_func_dyncol_list: public Item_str_func ...@@ -1795,7 +1811,11 @@ class Item_func_dyncol_list: public Item_str_func
Item_func_dyncol_list(THD *thd, Item *str): Item_str_func(thd, str) Item_func_dyncol_list(THD *thd, Item *str): Item_str_func(thd, str)
{collation.set(DYNCOL_UTF);} {collation.set(DYNCOL_UTF);}
bool fix_length_and_dec() bool fix_length_and_dec()
{ maybe_null= 1; max_length= MAX_BLOB_WIDTH; return FALSE; }; {
flags|= ITEM_FLAG_MAYBE_NULL;
max_length= MAX_BLOB_WIDTH;
return FALSE;
}
const char *func_name() const{ return "column_list"; } const char *func_name() const{ return "column_list"; }
String *val_str(String *); String *val_str(String *);
Item *get_copy(THD *thd) Item *get_copy(THD *thd)
...@@ -1836,7 +1856,7 @@ class Item_func_wsrep_last_written_gtid: public Item_str_ascii_func ...@@ -1836,7 +1856,7 @@ class Item_func_wsrep_last_written_gtid: public Item_str_ascii_func
bool fix_length_and_dec() bool fix_length_and_dec()
{ {
max_length= WSREP_GTID_STR_LEN; max_length= WSREP_GTID_STR_LEN;
maybe_null= true; flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE; return FALSE;
} }
Item *get_copy(THD *thd) Item *get_copy(THD *thd)
...@@ -1853,7 +1873,7 @@ class Item_func_wsrep_last_seen_gtid: public Item_str_ascii_func ...@@ -1853,7 +1873,7 @@ class Item_func_wsrep_last_seen_gtid: public Item_str_ascii_func
bool fix_length_and_dec() bool fix_length_and_dec()
{ {
max_length= WSREP_GTID_STR_LEN; max_length= WSREP_GTID_STR_LEN;
maybe_null= true; flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE; return FALSE;
} }
Item *get_copy(THD *thd) Item *get_copy(THD *thd)
......
This diff is collapsed.
This diff is collapsed.
...@@ -462,7 +462,11 @@ class Item_sum :public Item_func_or_sum ...@@ -462,7 +462,11 @@ class Item_sum :public Item_func_or_sum
*/ */
virtual void update_field()=0; virtual void update_field()=0;
virtual bool fix_length_and_dec() virtual bool fix_length_and_dec()
{ maybe_null=1; null_value=1; return FALSE; } {
flags|= ITEM_FLAG_MAYBE_NULL;
null_value=1;
return FALSE;
}
virtual Item *result_item(THD *thd, Field *field); virtual Item *result_item(THD *thd, Field *field);
void update_used_tables (); void update_used_tables ();
...@@ -531,7 +535,7 @@ class Item_sum :public Item_func_or_sum ...@@ -531,7 +535,7 @@ class Item_sum :public Item_func_or_sum
Item *get_arg(uint i) const { return args[i]; } Item *get_arg(uint i) const { return args[i]; }
Item *set_arg(uint i, THD *thd, Item *new_val); Item *set_arg(uint i, THD *thd, Item *new_val);
uint get_arg_count() const { return arg_count; } uint get_arg_count() const { return arg_count; }
virtual Item **get_args() { return fixed ? orig_args : args; } virtual Item **get_args() { return fixed() ? orig_args : args; }
/* Initialization of distinct related members */ /* Initialization of distinct related members */
void init_aggregator() void init_aggregator()
...@@ -771,7 +775,7 @@ class Item_sum_int :public Item_sum_num ...@@ -771,7 +775,7 @@ class Item_sum_int :public Item_sum_num
Item_sum_int(THD *thd, Item *item_par): Item_sum_num(thd, item_par) {} Item_sum_int(THD *thd, Item *item_par): Item_sum_num(thd, item_par) {}
Item_sum_int(THD *thd, List<Item> &list): Item_sum_num(thd, list) {} Item_sum_int(THD *thd, List<Item> &list): Item_sum_num(thd, list) {}
Item_sum_int(THD *thd, Item_sum_int *item) :Item_sum_num(thd, item) {} Item_sum_int(THD *thd, Item_sum_int *item) :Item_sum_num(thd, item) {}
double val_real() { DBUG_ASSERT(fixed == 1); return (double) val_int(); } double val_real() { DBUG_ASSERT(fixed()); return (double) val_int(); }
String *val_str(String*str); String *val_str(String*str);
my_decimal *val_decimal(my_decimal *); my_decimal *val_decimal(my_decimal *);
bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate) bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate)
...@@ -779,7 +783,12 @@ class Item_sum_int :public Item_sum_num ...@@ -779,7 +783,12 @@ class Item_sum_int :public Item_sum_num
return get_date_from_int(thd, ltime, fuzzydate); return get_date_from_int(thd, ltime, fuzzydate);
} }
bool fix_length_and_dec() bool fix_length_and_dec()
{ decimals=0; max_length=21; maybe_null=null_value=0; return FALSE; } {
decimals=0;
max_length=21;
flags&= (item_flags_t) ~ITEM_FLAG_MAYBE_NULL;
null_value=0;
return FALSE; }
}; };
...@@ -1209,7 +1218,9 @@ class Item_sum_bit :public Item_sum_int ...@@ -1209,7 +1218,9 @@ class Item_sum_bit :public Item_sum_int
{ {
if (args[0]->check_type_can_return_int(func_name())) if (args[0]->check_type_can_return_int(func_name()))
return true; return true;
decimals= 0; max_length=21; unsigned_flag= 1; maybe_null= null_value= 0; decimals= 0; max_length=21; unsigned_flag= 1;
flags&= (item_flags_t) ~ITEM_FLAG_MAYBE_NULL;
null_value= 0;
return FALSE; return FALSE;
} }
void cleanup() void cleanup()
...@@ -1459,7 +1470,7 @@ class Item_sum_field :public Item ...@@ -1459,7 +1470,7 @@ class Item_sum_field :public Item
:Item(thd), field(item->result_field) :Item(thd), field(item->result_field)
{ {
name= item->name; name= item->name;
maybe_null= true; flags|= ITEM_FLAG_MAYBE_NULL;
decimals= item->decimals; decimals= item->decimals;
max_length= item->max_length; max_length= item->max_length;
unsigned_flag= item->unsigned_flag; unsigned_flag= item->unsigned_flag;
...@@ -1598,12 +1609,12 @@ class Item_udf_sum : public Item_sum ...@@ -1598,12 +1609,12 @@ class Item_udf_sum : public Item_sum
const char *func_name() const { return udf.name(); } const char *func_name() const { return udf.name(); }
bool fix_fields(THD *thd, Item **ref) bool fix_fields(THD *thd, Item **ref)
{ {
DBUG_ASSERT(fixed == 0); DBUG_ASSERT(fixed() == 0);
if (init_sum_func_check(thd)) if (init_sum_func_check(thd))
return TRUE; return TRUE;
fixed= 1; flags|= ITEM_FLAG_FIXED;
/* /*
We set const_item_cache to false in constructors. We set const_item_cache to false in constructors.
It can be later changed to "true", in a Item_sum::make_const() call. It can be later changed to "true", in a Item_sum::make_const() call.
...@@ -1678,7 +1689,7 @@ class Item_sum_udf_int :public Item_udf_sum ...@@ -1678,7 +1689,7 @@ class Item_sum_udf_int :public Item_udf_sum
:Item_udf_sum(thd, item) {} :Item_udf_sum(thd, item) {}
longlong val_int(); longlong val_int();
double val_real() double val_real()
{ DBUG_ASSERT(fixed == 1); return (double) Item_sum_udf_int::val_int(); } { DBUG_ASSERT(fixed()); return (double) Item_sum_udf_int::val_int(); }
String *val_str(String*str); String *val_str(String*str);
my_decimal *val_decimal(my_decimal *); my_decimal *val_decimal(my_decimal *);
const Type_handler *type_handler() const const Type_handler *type_handler() const
...@@ -1776,7 +1787,7 @@ class Item_sum_udf_float :public Item_sum_double ...@@ -1776,7 +1787,7 @@ class Item_sum_udf_float :public Item_sum_double
Item_sum_udf_float(THD *thd, Item_sum_udf_float *item) Item_sum_udf_float(THD *thd, Item_sum_udf_float *item)
:Item_sum_double(thd, item) {} :Item_sum_double(thd, item) {}
enum Sumfunctype sum_func () const { return UDF_SUM_FUNC; } enum Sumfunctype sum_func () const { return UDF_SUM_FUNC; }
double val_real() { DBUG_ASSERT(fixed == 1); return 0.0; } double val_real() { DBUG_ASSERT(fixed()); return 0.0; }
void clear() {} void clear() {}
bool add() { return 0; } bool add() { return 0; }
void reset_field() { DBUG_ASSERT(0); }; void reset_field() { DBUG_ASSERT(0); };
...@@ -1794,8 +1805,8 @@ class Item_sum_udf_int :public Item_sum_double ...@@ -1794,8 +1805,8 @@ class Item_sum_udf_int :public Item_sum_double
Item_sum_udf_int(THD *thd, Item_sum_udf_int *item) Item_sum_udf_int(THD *thd, Item_sum_udf_int *item)
:Item_sum_double(thd, item) {} :Item_sum_double(thd, item) {}
enum Sumfunctype sum_func () const { return UDF_SUM_FUNC; } enum Sumfunctype sum_func () const { return UDF_SUM_FUNC; }
longlong val_int() { DBUG_ASSERT(fixed == 1); return 0; } longlong val_int() { DBUG_ASSERT(fixed()); return 0; }
double val_real() { DBUG_ASSERT(fixed == 1); return 0; } double val_real() { DBUG_ASSERT(fixed()); return 0; }
void clear() {} void clear() {}
bool add() { return 0; } bool add() { return 0; }
void reset_field() { DBUG_ASSERT(0); }; void reset_field() { DBUG_ASSERT(0); };
...@@ -1813,8 +1824,8 @@ class Item_sum_udf_decimal :public Item_sum_double ...@@ -1813,8 +1824,8 @@ class Item_sum_udf_decimal :public Item_sum_double
Item_sum_udf_decimal(THD *thd, Item_sum_udf_float *item) Item_sum_udf_decimal(THD *thd, Item_sum_udf_float *item)
:Item_sum_double(thd, item) {} :Item_sum_double(thd, item) {}
enum Sumfunctype sum_func () const { return UDF_SUM_FUNC; } enum Sumfunctype sum_func () const { return UDF_SUM_FUNC; }
double val_real() { DBUG_ASSERT(fixed == 1); return 0.0; } double val_real() { DBUG_ASSERT(fixed()); return 0.0; }
my_decimal *val_decimal(my_decimal *) { DBUG_ASSERT(fixed == 1); return 0; } my_decimal *val_decimal(my_decimal *) { DBUG_ASSERT(fixed()); return 0; }
void clear() {} void clear() {}
bool add() { return 0; } bool add() { return 0; }
void reset_field() { DBUG_ASSERT(0); }; void reset_field() { DBUG_ASSERT(0); };
...@@ -1832,10 +1843,10 @@ class Item_sum_udf_str :public Item_sum_double ...@@ -1832,10 +1843,10 @@ class Item_sum_udf_str :public Item_sum_double
Item_sum_udf_str(THD *thd, Item_sum_udf_str *item) Item_sum_udf_str(THD *thd, Item_sum_udf_str *item)
:Item_sum_double(thd, item) {} :Item_sum_double(thd, item) {}
String *val_str(String *) String *val_str(String *)
{ DBUG_ASSERT(fixed == 1); null_value=1; return 0; } { DBUG_ASSERT(fixed()); null_value=1; return 0; }
double val_real() { DBUG_ASSERT(fixed == 1); null_value=1; return 0.0; } double val_real() { DBUG_ASSERT(fixed()); null_value=1; return 0.0; }
longlong val_int() { DBUG_ASSERT(fixed == 1); null_value=1; return 0; } longlong val_int() { DBUG_ASSERT(fixed()); null_value=1; return 0; }
bool fix_length_and_dec() { maybe_null=1; max_length=0; return FALSE; } bool fix_length_and_dec() { flags|= ITEM_FLAG_MAYBE_NULL; max_length=0; return FALSE; }
enum Sumfunctype sum_func () const { return UDF_SUM_FUNC; } enum Sumfunctype sum_func () const { return UDF_SUM_FUNC; }
void clear() {} void clear() {}
bool add() { return 0; } bool add() { return 0; }
......
This diff is collapsed.
...@@ -97,7 +97,7 @@ class Item_func_to_days :public Item_long_func_date_field ...@@ -97,7 +97,7 @@ class Item_func_to_days :public Item_long_func_date_field
{ {
decimals=0; decimals=0;
max_length=6*MY_CHARSET_BIN_MB_MAXLEN; max_length=6*MY_CHARSET_BIN_MB_MAXLEN;
maybe_null=1; flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE; return FALSE;
} }
enum_monotonicity_info get_monotonicity_info() const; enum_monotonicity_info get_monotonicity_info() const;
...@@ -125,7 +125,7 @@ class Item_func_to_seconds :public Item_longlong_func ...@@ -125,7 +125,7 @@ class Item_func_to_seconds :public Item_longlong_func
{ {
decimals=0; decimals=0;
fix_char_length(12); fix_char_length(12);
maybe_null= 1; flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE; return FALSE;
} }
enum_monotonicity_info get_monotonicity_info() const; enum_monotonicity_info get_monotonicity_info() const;
...@@ -152,7 +152,7 @@ class Item_func_dayofmonth :public Item_long_func_date_field ...@@ -152,7 +152,7 @@ class Item_func_dayofmonth :public Item_long_func_date_field
{ {
decimals=0; decimals=0;
max_length=2*MY_CHARSET_BIN_MB_MAXLEN; max_length=2*MY_CHARSET_BIN_MB_MAXLEN;
maybe_null=1; flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE; return FALSE;
} }
bool check_partition_func_processor(void *int_arg) {return FALSE;} bool check_partition_func_processor(void *int_arg) {return FALSE;}
...@@ -177,7 +177,7 @@ class Item_func_month :public Item_long_func ...@@ -177,7 +177,7 @@ class Item_func_month :public Item_long_func
{ {
decimals= 0; decimals= 0;
fix_char_length(2); fix_char_length(2);
maybe_null=1; flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE; return FALSE;
} }
bool check_partition_func_processor(void *int_arg) {return FALSE;} bool check_partition_func_processor(void *int_arg) {return FALSE;}
...@@ -223,7 +223,7 @@ class Item_func_dayofyear :public Item_long_func_date_field ...@@ -223,7 +223,7 @@ class Item_func_dayofyear :public Item_long_func_date_field
{ {
decimals= 0; decimals= 0;
fix_char_length(3); fix_char_length(3);
maybe_null=1; flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE; return FALSE;
} }
bool check_partition_func_processor(void *int_arg) {return FALSE;} bool check_partition_func_processor(void *int_arg) {return FALSE;}
...@@ -247,7 +247,7 @@ class Item_func_hour :public Item_long_func_time_field ...@@ -247,7 +247,7 @@ class Item_func_hour :public Item_long_func_time_field
{ {
decimals=0; decimals=0;
max_length=2*MY_CHARSET_BIN_MB_MAXLEN; max_length=2*MY_CHARSET_BIN_MB_MAXLEN;
maybe_null=1; flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE; return FALSE;
} }
bool check_partition_func_processor(void *int_arg) {return FALSE;} bool check_partition_func_processor(void *int_arg) {return FALSE;}
...@@ -271,7 +271,7 @@ class Item_func_minute :public Item_long_func_time_field ...@@ -271,7 +271,7 @@ class Item_func_minute :public Item_long_func_time_field
{ {
decimals=0; decimals=0;
max_length=2*MY_CHARSET_BIN_MB_MAXLEN; max_length=2*MY_CHARSET_BIN_MB_MAXLEN;
maybe_null=1; flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE; return FALSE;
} }
bool check_partition_func_processor(void *int_arg) {return FALSE;} bool check_partition_func_processor(void *int_arg) {return FALSE;}
...@@ -295,7 +295,7 @@ class Item_func_quarter :public Item_long_func_date_field ...@@ -295,7 +295,7 @@ class Item_func_quarter :public Item_long_func_date_field
{ {
decimals=0; decimals=0;
max_length=1*MY_CHARSET_BIN_MB_MAXLEN; max_length=1*MY_CHARSET_BIN_MB_MAXLEN;
maybe_null=1; flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE; return FALSE;
} }
bool check_partition_func_processor(void *int_arg) {return FALSE;} bool check_partition_func_processor(void *int_arg) {return FALSE;}
...@@ -319,7 +319,7 @@ class Item_func_second :public Item_long_func_time_field ...@@ -319,7 +319,7 @@ class Item_func_second :public Item_long_func_time_field
{ {
decimals=0; decimals=0;
max_length=2*MY_CHARSET_BIN_MB_MAXLEN; max_length=2*MY_CHARSET_BIN_MB_MAXLEN;
maybe_null=1; flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE; return FALSE;
} }
bool check_partition_func_processor(void *int_arg) {return FALSE;} bool check_partition_func_processor(void *int_arg) {return FALSE;}
...@@ -349,7 +349,7 @@ class Item_func_week :public Item_long_func ...@@ -349,7 +349,7 @@ class Item_func_week :public Item_long_func
{ {
decimals=0; decimals=0;
max_length=2*MY_CHARSET_BIN_MB_MAXLEN; max_length=2*MY_CHARSET_BIN_MB_MAXLEN;
maybe_null=1; flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE; return FALSE;
} }
bool check_vcol_func_processor(void *arg) bool check_vcol_func_processor(void *arg)
...@@ -382,7 +382,7 @@ class Item_func_yearweek :public Item_long_func ...@@ -382,7 +382,7 @@ class Item_func_yearweek :public Item_long_func
{ {
decimals=0; decimals=0;
max_length=6*MY_CHARSET_BIN_MB_MAXLEN; max_length=6*MY_CHARSET_BIN_MB_MAXLEN;
maybe_null=1; flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE; return FALSE;
} }
bool check_partition_func_processor(void *int_arg) {return FALSE;} bool check_partition_func_processor(void *int_arg) {return FALSE;}
...@@ -408,7 +408,7 @@ class Item_func_year :public Item_long_func_date_field ...@@ -408,7 +408,7 @@ class Item_func_year :public Item_long_func_date_field
{ {
decimals=0; decimals=0;
max_length=4*MY_CHARSET_BIN_MB_MAXLEN; max_length=4*MY_CHARSET_BIN_MB_MAXLEN;
maybe_null=1; flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE; return FALSE;
} }
bool check_partition_func_processor(void *int_arg) {return FALSE;} bool check_partition_func_processor(void *int_arg) {return FALSE;}
...@@ -441,7 +441,7 @@ class Item_func_weekday :public Item_long_func ...@@ -441,7 +441,7 @@ class Item_func_weekday :public Item_long_func
{ {
decimals= 0; decimals= 0;
fix_char_length(1); fix_char_length(1);
maybe_null=1; flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE; return FALSE;
} }
bool check_partition_func_processor(void *int_arg) {return FALSE;} bool check_partition_func_processor(void *int_arg) {return FALSE;}
...@@ -487,7 +487,7 @@ class Item_func_seconds_hybrid: public Item_func_numhybrid ...@@ -487,7 +487,7 @@ class Item_func_seconds_hybrid: public Item_func_numhybrid
DBUG_ASSERT(dec <= TIME_SECOND_PART_DIGITS); DBUG_ASSERT(dec <= TIME_SECOND_PART_DIGITS);
decimals= dec; decimals= dec;
max_length=17 + (decimals ? decimals + 1 : 0); max_length=17 + (decimals ? decimals + 1 : 0);
maybe_null= true; flags|= ITEM_FLAG_MAYBE_NULL;
if (decimals) if (decimals)
set_handler(&type_handler_newdecimal); set_handler(&type_handler_newdecimal);
else else
...@@ -580,7 +580,7 @@ class Item_datefunc :public Item_func ...@@ -580,7 +580,7 @@ class Item_datefunc :public Item_func
bool fix_length_and_dec() bool fix_length_and_dec()
{ {
fix_attributes_date(); fix_attributes_date();
maybe_null= (arg_count > 0); set_maybe_null(arg_count > 0);
return FALSE; return FALSE;
} }
}; };
...@@ -906,7 +906,7 @@ class Item_func_convert_tz :public Item_datetimefunc ...@@ -906,7 +906,7 @@ class Item_func_convert_tz :public Item_datetimefunc
bool fix_length_and_dec() bool fix_length_and_dec()
{ {
fix_attributes_datetime(args[0]->datetime_precision(current_thd)); fix_attributes_datetime(args[0]->datetime_precision(current_thd));
maybe_null= true; flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE; return FALSE;
} }
bool get_date(THD *thd, MYSQL_TIME *res, date_mode_t fuzzydate); bool get_date(THD *thd, MYSQL_TIME *res, date_mode_t fuzzydate);
...@@ -926,7 +926,7 @@ class Item_func_sec_to_time :public Item_timefunc ...@@ -926,7 +926,7 @@ class Item_func_sec_to_time :public Item_timefunc
bool fix_length_and_dec() bool fix_length_and_dec()
{ {
fix_attributes_time(args[0]->decimals); fix_attributes_time(args[0]->decimals);
maybe_null= true; flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE; return FALSE;
} }
const char *func_name() const { return "sec_to_time"; } const char *func_name() const { return "sec_to_time"; }
...@@ -1214,7 +1214,7 @@ class Item_func_timestamp :public Item_datetimefunc ...@@ -1214,7 +1214,7 @@ class Item_func_timestamp :public Item_datetimefunc
uint dec0= args[0]->datetime_precision(thd); uint dec0= args[0]->datetime_precision(thd);
uint dec1= Interval_DDhhmmssff::fsp(thd, args[1]); uint dec1= Interval_DDhhmmssff::fsp(thd, args[1]);
fix_attributes_datetime(MY_MAX(dec0, dec1)); fix_attributes_datetime(MY_MAX(dec0, dec1));
maybe_null= true; flags|= ITEM_FLAG_MAYBE_NULL;
return false; return false;
} }
bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate) bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate)
...@@ -1274,7 +1274,7 @@ class Item_func_timediff :public Item_timefunc ...@@ -1274,7 +1274,7 @@ class Item_func_timediff :public Item_timefunc
uint dec= MY_MAX(args[0]->time_precision(thd), uint dec= MY_MAX(args[0]->time_precision(thd),
args[1]->time_precision(thd)); args[1]->time_precision(thd));
fix_attributes_time(dec); fix_attributes_time(dec);
maybe_null= true; flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE; return FALSE;
} }
bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate); bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate);
...@@ -1296,7 +1296,7 @@ class Item_func_maketime :public Item_timefunc ...@@ -1296,7 +1296,7 @@ class Item_func_maketime :public Item_timefunc
bool fix_length_and_dec() bool fix_length_and_dec()
{ {
fix_attributes_time(args[2]->decimals); fix_attributes_time(args[2]->decimals);
maybe_null= true; flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE; return FALSE;
} }
const char *func_name() const { return "maketime"; } const char *func_name() const { return "maketime"; }
...@@ -1315,7 +1315,7 @@ class Item_func_microsecond :public Item_long_func_time_field ...@@ -1315,7 +1315,7 @@ class Item_func_microsecond :public Item_long_func_time_field
bool fix_length_and_dec() bool fix_length_and_dec()
{ {
decimals=0; decimals=0;
maybe_null=1; flags|= ITEM_FLAG_MAYBE_NULL;
fix_char_length(6); fix_char_length(6);
return FALSE; return FALSE;
} }
...@@ -1346,7 +1346,7 @@ class Item_func_timestamp_diff :public Item_longlong_func ...@@ -1346,7 +1346,7 @@ class Item_func_timestamp_diff :public Item_longlong_func
bool fix_length_and_dec() bool fix_length_and_dec()
{ {
decimals=0; decimals=0;
maybe_null=1; flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE; return FALSE;
} }
virtual void print(String *str, enum_query_type query_type); virtual void print(String *str, enum_query_type query_type);
...@@ -1371,7 +1371,7 @@ class Item_func_get_format :public Item_str_ascii_func ...@@ -1371,7 +1371,7 @@ class Item_func_get_format :public Item_str_ascii_func
const char *func_name() const { return "get_format"; } const char *func_name() const { return "get_format"; }
bool fix_length_and_dec() bool fix_length_and_dec()
{ {
maybe_null= 1; flags|= ITEM_FLAG_MAYBE_NULL;
decimals=0; decimals=0;
fix_length_and_charset(17, default_charset()); fix_length_and_charset(17, default_charset());
return FALSE; return FALSE;
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
bool Item_func_history::val_bool() bool Item_func_history::val_bool()
{ {
Item_field *f= static_cast<Item_field *>(args[0]); Item_field *f= static_cast<Item_field *>(args[0]);
DBUG_ASSERT(f->fixed); DBUG_ASSERT(is_fixed());
DBUG_ASSERT(f->field->flags & VERS_SYS_END_FLAG); DBUG_ASSERT(f->field->flags & VERS_SYS_END_FLAG);
return !f->field->is_max(); return !f->field->is_max();
} }
......
...@@ -40,7 +40,7 @@ class Item_func_history: public Item_bool_func ...@@ -40,7 +40,7 @@ class Item_func_history: public Item_bool_func
} }
bool fix_length_and_dec() bool fix_length_and_dec()
{ {
maybe_null= 0; set_maybe_null(0);
null_value= 0; null_value= 0;
decimals= 0; decimals= 0;
max_length= 1; max_length= 1;
......
This diff is collapsed.
...@@ -110,12 +110,12 @@ class Item_xml_str_func: public Item_str_func ...@@ -110,12 +110,12 @@ class Item_xml_str_func: public Item_str_func
public: public:
Item_xml_str_func(THD *thd, Item *a, Item *b): Item_str_func(thd, a, b) Item_xml_str_func(THD *thd, Item *a, Item *b): Item_str_func(thd, a, b)
{ {
maybe_null= TRUE; flags|= ITEM_FLAG_MAYBE_NULL;
} }
Item_xml_str_func(THD *thd, Item *a, Item *b, Item *c): Item_xml_str_func(THD *thd, Item *a, Item *b, Item *c):
Item_str_func(thd, a, b, c) Item_str_func(thd, a, b, c)
{ {
maybe_null= TRUE; flags|= ITEM_FLAG_MAYBE_NULL;
} }
bool fix_fields(THD *thd, Item **ref); bool fix_fields(THD *thd, Item **ref);
bool fix_length_and_dec(); bool fix_length_and_dec();
......
This diff is collapsed.
...@@ -342,7 +342,7 @@ int opt_sum_query(THD *thd, ...@@ -342,7 +342,7 @@ int opt_sum_query(THD *thd,
to the number of rows in the tables if this number is exact and to the number of rows in the tables if this number is exact and
there are no outer joins. there are no outer joins.
*/ */
if (!conds && !((Item_sum_count*) item)->get_arg(0)->maybe_null && if (!conds && !((Item_sum_count*) item)->get_arg(0)->maybe_null() &&
!outer_tables && maybe_exact_count && !outer_tables && maybe_exact_count &&
((item->used_tables() & OUTER_REF_TABLE_BIT) == 0)) ((item->used_tables() & OUTER_REF_TABLE_BIT) == 0))
{ {
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment