summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Widenius <monty@mariadb.org>2020-08-02 12:31:14 +0300
committerSergei Golubchik <serg@mariadb.org>2021-05-19 22:27:28 +0200
commit3105c9e7a5eb3706f6520e1566ed4a2add06c6a5 (patch)
tree628f083d286f970ac8358f882195ea834c16131e
parent451c4ae548fd4b0dda93ac499682e95b249bfcf4 (diff)
downloadmariadb-git-3105c9e7a5eb3706f6520e1566ed4a2add06c6a5.tar.gz
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.
-rw-r--r--plugin/func_test/plugin.cc2
-rw-r--r--plugin/type_inet/item_inetfunc.cc12
-rw-r--r--plugin/type_inet/item_inetfunc.h8
-rw-r--r--plugin/type_inet/sql_type_inet.cc8
-rw-r--r--sql/filesort.cc42
-rw-r--r--sql/item.cc241
-rw-r--r--sql/item.h173
-rw-r--r--sql/item_cmpfunc.cc212
-rw-r--r--sql/item_cmpfunc.h28
-rw-r--r--sql/item_create.cc14
-rw-r--r--sql/item_func.cc257
-rw-r--r--sql/item_func.h188
-rw-r--r--sql/item_geofunc.cc81
-rw-r--r--sql/item_geofunc.h26
-rw-r--r--sql/item_jsonfunc.cc60
-rw-r--r--sql/item_jsonfunc.h2
-rw-r--r--sql/item_row.cc19
-rw-r--r--sql/item_strfunc.cc160
-rw-r--r--sql/item_strfunc.h76
-rw-r--r--sql/item_subselect.cc116
-rw-r--r--sql/item_sum.cc131
-rw-r--r--sql/item_sum.h47
-rw-r--r--sql/item_timefunc.cc88
-rw-r--r--sql/item_timefunc.h46
-rw-r--r--sql/item_vers.cc2
-rw-r--r--sql/item_vers.h2
-rw-r--r--sql/item_windowfunc.cc42
-rw-r--r--sql/item_xmlfunc.h4
-rw-r--r--sql/opt_subselect.cc10
-rw-r--r--sql/opt_sum.cc2
-rw-r--r--sql/sp_head.cc4
-rw-r--r--sql/sql_admin.cc8
-rw-r--r--sql/sql_analyse.cc6
-rw-r--r--sql/sql_base.cc10
-rw-r--r--sql/sql_class.cc24
-rw-r--r--sql/sql_class.h2
-rw-r--r--sql/sql_cte.cc4
-rw-r--r--sql/sql_insert.cc2
-rw-r--r--sql/sql_lex.cc2
-rw-r--r--sql/sql_select.cc105
-rw-r--r--sql/sql_select.h4
-rw-r--r--sql/sql_show.cc10
-rw-r--r--sql/sql_table.cc4
-rw-r--r--sql/sql_type.cc35
-rw-r--r--sql/sql_view.cc10
-rw-r--r--sql/sql_window.cc10
-rw-r--r--sql/sql_yacc.yy4
-rw-r--r--sql/table.cc4
-rw-r--r--storage/spider/spd_table.cc2
49 files changed, 1240 insertions, 1109 deletions
diff --git a/plugin/func_test/plugin.cc b/plugin/func_test/plugin.cc
index 811189773f1..827c627dece 100644
--- a/plugin/func_test/plugin.cc
+++ b/plugin/func_test/plugin.cc
@@ -32,7 +32,7 @@ public:
bool fix_length_and_dec()
{
max_length= MAX_FIELD_NAME * system_charset_info->mbmaxlen;
- maybe_null= true;
+ flags|= ITEM_FLAG_MAYBE_NULL;
return false;
}
const char *func_name() const { return "sysconst_test"; }
diff --git a/plugin/type_inet/item_inetfunc.cc b/plugin/type_inet/item_inetfunc.cc
index 50bd82817e0..dcccf762295 100644
--- a/plugin/type_inet/item_inetfunc.cc
+++ b/plugin/type_inet/item_inetfunc.cc
@@ -24,7 +24,7 @@
longlong Item_func_inet_aton::val_int()
{
- DBUG_ASSERT(fixed);
+ DBUG_ASSERT(fixed());
uint byte_result= 0;
ulonglong result= 0; // We are ready for 64 bit addresses
@@ -85,7 +85,7 @@ err:
String* Item_func_inet_ntoa::val_str(String* str)
{
- DBUG_ASSERT(fixed);
+ DBUG_ASSERT(fixed());
ulonglong n= (ulonglong) args[0]->val_int();
@@ -145,7 +145,7 @@ String* Item_func_inet_ntoa::val_str(String* str)
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]);
if ((null_value= tmp.is_null()))
@@ -176,7 +176,7 @@ String *Item_func_inet6_aton::val_str(String *buffer)
String *Item_func_inet6_ntoa::val_str_ascii(String *buffer)
{
- DBUG_ASSERT(fixed);
+ DBUG_ASSERT(fixed());
// Binary string argument expected
if (unlikely(args[0]->result_type() != STRING_RESULT ||
@@ -216,7 +216,7 @@ String *Item_func_inet6_ntoa::val_str_ascii(String *buffer)
longlong Item_func_is_ipv4::val_int()
{
- DBUG_ASSERT(fixed);
+ DBUG_ASSERT(fixed());
String_ptr_and_buffer<STRING_BUFFER_USUAL_SIZE> tmp(args[0]);
return !tmp.is_null() && !Inet4_null(*tmp.string()).is_null();
}
@@ -228,7 +228,7 @@ longlong Item_func_is_ipv4::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]);
return !tmp.is_null() && !Inet6_null(*tmp.string()).is_null();
}
diff --git a/plugin/type_inet/item_inetfunc.h b/plugin/type_inet/item_inetfunc.h
index 94255426f68..2a4605065da 100644
--- a/plugin/type_inet/item_inetfunc.h
+++ b/plugin/type_inet/item_inetfunc.h
@@ -37,7 +37,7 @@ public:
{
decimals= 0;
max_length= 21;
- maybe_null= 1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
unsigned_flag= 1;
return FALSE;
}
@@ -61,7 +61,7 @@ public:
{
decimals= 0;
fix_length_and_charset(3 * 8 + 7, default_charset());
- maybe_null= 1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE;
}
Item *get_copy(THD *thd)
@@ -105,7 +105,7 @@ public:
{
decimals= 0;
fix_length_and_charset(16, &my_charset_bin);
- maybe_null= 1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE;
}
Item *get_copy(THD *thd)
@@ -139,7 +139,7 @@ public:
// 4 symbols per group
fix_length_and_charset(8 * 4 + 7, default_charset());
- maybe_null= 1;
+ flags|= ITEM_FLAG_MAYBE_NULL;;
return FALSE;
}
String *val_str_ascii(String *to);
diff --git a/plugin/type_inet/sql_type_inet.cc b/plugin/type_inet/sql_type_inet.cc
index 14d854be14f..ab251d660b3 100644
--- a/plugin/type_inet/sql_type_inet.cc
+++ b/plugin/type_inet/sql_type_inet.cc
@@ -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)
{
- if (item->maybe_null)
+ if (item->maybe_null())
return true;
if (item->type_handler() == &type_handler_inet6)
return false;
@@ -1055,7 +1055,7 @@ public:
{
Type_std_attributes::operator=(Type_std_attributes_inet6());
if (Inet6::fix_fields_maybe_null_on_conversion_to_inet6(args[0]))
- maybe_null= true;
+ flags|= ITEM_FLAG_MAYBE_NULL;
return false;
}
String *val_str(String *to) override
@@ -1388,7 +1388,7 @@ void Type_handler_inet6::make_sort_key_part(uchar *to, Item *item,
DBUG_ASSERT(item->type_handler() == this);
NativeBufferInet6 tmp;
item->val_native_result(current_thd, &tmp);
- if (item->maybe_null)
+ if (item->maybe_null())
{
if (item->null_value)
{
@@ -1411,7 +1411,7 @@ Type_handler_inet6::make_packed_sort_key_part(uchar *to, Item *item,
DBUG_ASSERT(item->type_handler() == this);
NativeBufferInet6 tmp;
item->val_native_result(current_thd, &tmp);
- if (item->maybe_null)
+ if (item->maybe_null())
{
if (item->null_value)
{
diff --git a/sql/filesort.cc b/sql/filesort.cc
index 1db95732e0f..4d100980580 100644
--- a/sql/filesort.cc
+++ b/sql/filesort.cc
@@ -1109,7 +1109,7 @@ Type_handler_string_result::make_sort_key_part(uchar *to, Item *item,
Sort_param *param) const
{
CHARSET_INFO *cs= item->collation.collation;
- bool maybe_null= item->maybe_null;
+ bool maybe_null= item->maybe_null();
if (maybe_null)
*to++= 1;
@@ -1179,7 +1179,7 @@ Type_handler_int_result::make_sort_key_part(uchar *to, Item *item,
Sort_param *param) const
{
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);
}
@@ -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);
if (item->get_date_result(current_thd, &buf, opt))
{
- DBUG_ASSERT(item->maybe_null);
+ DBUG_ASSERT(item->maybe_null());
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);
}
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));
}
@@ -1217,11 +1217,11 @@ Type_handler_timestamp_common::make_sort_key_part(uchar *to, Item *item,
if (native.is_null() || native.is_zero_datetime())
{
// 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
{
- if (item->maybe_null)
+ if (item->maybe_null())
*to++= 1;
if (native.length() != binlen)
{
@@ -1305,7 +1305,7 @@ Type_handler_decimal_result::make_sort_key_part(uchar *to, Item *item,
Sort_param *param) const
{
my_decimal dec_buf, *dec_val= item->val_decimal_result(&dec_buf);
- if (item->maybe_null)
+ if (item->maybe_null())
{
if (item->null_value)
{
@@ -1325,7 +1325,7 @@ Type_handler_real_result::make_sort_key_part(uchar *to, Item *item,
Sort_param *param) const
{
double value= item->val_result();
- if (item->maybe_null)
+ if (item->maybe_null())
{
if (item->null_value)
{
@@ -2262,7 +2262,7 @@ sortlength(THD *thd, Sort_keys *sort_keys, bool *allow_packing_for_sortkeys)
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
}
if (sortorder->is_variable_sized())
@@ -2565,7 +2565,7 @@ Type_handler_string_result::make_packed_sort_key_part(uchar *to, Item *item,
Sort_param *param) const
{
CHARSET_INFO *cs= item->collation.collation;
- bool maybe_null= item->maybe_null;
+ bool maybe_null= item->maybe_null();
if (maybe_null)
*to++= 1;
@@ -2604,7 +2604,7 @@ Type_handler_int_result::make_packed_sort_key_part(uchar *to, Item *item,
Sort_param *param) const
{
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,
value, sort_field);
}
@@ -2616,7 +2616,7 @@ Type_handler_decimal_result::make_packed_sort_key_part(uchar *to, Item *item,
Sort_param *param) const
{
my_decimal dec_buf, *dec_val= item->val_decimal_result(&dec_buf);
- if (item->maybe_null)
+ if (item->maybe_null())
{
if (item->null_value)
{
@@ -2638,7 +2638,7 @@ Type_handler_real_result::make_packed_sort_key_part(uchar *to, Item *item,
Sort_param *param) const
{
double value= item->val_result();
- if (item->maybe_null)
+ if (item->maybe_null())
{
if (item->null_value)
{
@@ -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);
if (item->get_date_result(current_thd, &buf, opt))
{
- DBUG_ASSERT(item->maybe_null);
+ DBUG_ASSERT(item->maybe_null());
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);
}
- 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),
sort_field);
}
@@ -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())
{
// NULL or '0000-00-00 00:00:00'
- if (item->maybe_null)
+ if (item->maybe_null())
{
*to++=0;
return 0;
@@ -2699,7 +2699,7 @@ Type_handler_timestamp_common::make_packed_sort_key_part(uchar *to, Item *item,
}
else
{
- if (item->maybe_null)
+ if (item->maybe_null())
*to++= 1;
if (native.length() != binlen)
{
@@ -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,
sort_field, param);
- if ((maybe_null= sort_field->item->maybe_null))
+ if ((maybe_null= sort_field->item->maybe_null()))
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,
sort_field,
param);
- if ((maybe_null= sort_field->item->maybe_null))
+ if ((maybe_null= sort_field->item->maybe_null()))
to++;
}
to+= length;
diff --git a/sql/item.cc b/sql/item.cc
index e5b1ef6cf39..37c3e0b817f 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -413,10 +413,7 @@ Item::Item(THD *thd):
name(null_clex_str), orig_name(0), is_expensive_cache(-1)
{
DBUG_ASSERT(thd);
- maybe_null= with_window_func= with_field= in_rollup= with_param= 0;
- is_in_with_cycle= with_sum_func= with_subquery= 0;
- fixed= 1; // Simple Item's doesn't have to be fixed
- is_autogenerated_name= 1;
+ flags= ITEM_FLAG_FIXED | ITEM_FLAG_IS_AUTOGENERATED_NAME;
null_value= 0;
marker= 0;
@@ -448,10 +445,7 @@ Item::Item():
name(null_clex_str), orig_name(0), is_expensive_cache(-1)
{
DBUG_ASSERT(my_progname == NULL); // before main()
- maybe_null= with_window_func= with_field= in_rollup= with_param= 0;
- is_in_with_cycle= 0;
- fixed= 1; // Simple Item's doesn't have to be fixed
- is_autogenerated_name= 1;
+ flags= ITEM_FLAG_FIXED | ITEM_FLAG_IS_AUTOGENERATED_NAME;
null_value= 0;
marker= 0;
join_tab_idx= MAX_TABLES;
@@ -479,20 +473,13 @@ Item::Item(THD *thd, Item *item):
str_value(item->str_value),
name(item->name),
orig_name(item->orig_name),
- maybe_null(item->maybe_null),
- in_rollup(item->in_rollup),
- with_param(item->with_param),
- with_window_func(item->with_window_func),
- with_field(item->with_field),
- is_autogenerated_name(item->is_autogenerated_name),
- is_in_with_cycle(item->is_in_with_cycle),
- with_sum_func(item->with_sum_func),
- with_subquery(item->with_subquery),
marker(item->marker),
null_value(item->null_value),
is_expensive_cache(-1),
join_tab_idx(item->join_tab_idx)
{
+ flags= item->flags & (item_flags_t) ~ITEM_FLAG_FIXED;
+
next= thd->free_list; // Put in free list
thd->free_list= this;
}
@@ -708,7 +695,7 @@ Item_ident::Item_ident(THD *thd, Item_ident *item)
void Item_ident::cleanup()
{
DBUG_ENTER("Item_ident::cleanup");
- bool was_fixed= fixed;
+ bool was_fixed= fixed();
Item_result_field::cleanup();
db_name= orig_db_name;
table_name= orig_table_name;
@@ -1170,7 +1157,7 @@ void Item::set_name(THD *thd, const char *str, size_t length, CHARSET_INFO *cs)
str++;
}
}
- if (str != str_start && !is_autogenerated_name)
+ if (str != str_start && !is_autogenerated_name())
{
char buff[SAFE_NAME_LEN];
@@ -1612,10 +1599,9 @@ bool Item_sp_variable::fix_fields_from_item(THD *thd, Item **, const Item *it)
max_length= it->max_length;
decimals= it->decimals;
unsigned_flag= it->unsigned_flag;
- with_param= 1;
+ flags|= ITEM_FLAG_WITH_PARAM | ITEM_FLAG_FIXED;
if (thd->lex->current_select && thd->lex->current_select->master_unit()->item)
- thd->lex->current_select->master_unit()->item->with_param= 1;
- fixed= 1;
+ thd->lex->current_select->master_unit()->item->flags|= ITEM_FLAG_WITH_PARAM;
collation.set(it->collation.collation, it->collation.derivation);
return FALSE;
@@ -1624,7 +1610,7 @@ bool Item_sp_variable::fix_fields_from_item(THD *thd, Item **, const Item *it)
double Item_sp_variable::val_real()
{
- DBUG_ASSERT(fixed);
+ DBUG_ASSERT(fixed());
Item *it= this_item();
double ret= it->val_real();
null_value= it->null_value;
@@ -1634,7 +1620,7 @@ double Item_sp_variable::val_real()
longlong Item_sp_variable::val_int()
{
- DBUG_ASSERT(fixed);
+ DBUG_ASSERT(fixed());
Item *it= this_item();
longlong ret= it->val_int();
null_value= it->null_value;
@@ -1644,7 +1630,7 @@ longlong Item_sp_variable::val_int()
String *Item_sp_variable::val_str(String *sp)
{
- DBUG_ASSERT(fixed);
+ DBUG_ASSERT(fixed());
Item *it= this_item();
String *res= it->val_str(sp);
@@ -1686,7 +1672,7 @@ bool Item_sp_variable::val_native(THD *thd, Native *to)
my_decimal *Item_sp_variable::val_decimal(my_decimal *decimal_value)
{
- DBUG_ASSERT(fixed);
+ DBUG_ASSERT(fixed());
Item *it= this_item();
my_decimal *val= it->val_decimal(decimal_value);
null_value= it->null_value;
@@ -1696,7 +1682,7 @@ my_decimal *Item_sp_variable::val_decimal(my_decimal *decimal_value)
bool Item_sp_variable::get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate)
{
- DBUG_ASSERT(fixed);
+ DBUG_ASSERT(fixed());
Item *it= this_item();
bool val= it->get_date(thd, ltime, fuzzydate);
null_value= it->null_value;
@@ -1737,7 +1723,7 @@ Item_splocal::Item_splocal(THD *thd,
m_var_idx(sp_var_idx),
m_type(handler == &type_handler_row ? ROW_ITEM : CONST_ITEM)
{
- maybe_null= TRUE;
+ flags|= ITEM_FLAG_MAYBE_NULL;
}
@@ -1755,7 +1741,7 @@ Item_field *Item_splocal::get_variable(sp_rcontext *ctx) const
bool Item_splocal::fix_fields(THD *thd, Item **ref)
{
- DBUG_ASSERT(!fixed);
+ DBUG_ASSERT(fixed() == 0);
Item *item= get_variable(thd->spcont);
set_handler(item->type_handler());
return fix_fields_from_item(thd, ref, item);
@@ -1766,7 +1752,7 @@ Item *
Item_splocal::this_item()
{
DBUG_ASSERT(m_sp == m_thd->spcont->m_sp);
- DBUG_ASSERT(fixed);
+ DBUG_ASSERT(fixed());
return get_variable(m_thd->spcont);
}
@@ -1774,7 +1760,7 @@ const Item *
Item_splocal::this_item() const
{
DBUG_ASSERT(m_sp == m_thd->spcont->m_sp);
- DBUG_ASSERT(fixed);
+ DBUG_ASSERT(fixed());
return get_variable(m_thd->spcont);
}
@@ -1783,7 +1769,7 @@ Item **
Item_splocal::this_item_addr(THD *thd, Item **)
{
DBUG_ASSERT(m_sp == thd->spcont->m_sp);
- DBUG_ASSERT(fixed);
+ DBUG_ASSERT(fixed());
return get_rcontext(thd->spcont)->get_variable_addr(m_var_idx);
}
@@ -1883,7 +1869,7 @@ bool Item_splocal::check_cols(uint n)
bool Item_splocal_row_field::fix_fields(THD *thd, Item **ref)
{
- DBUG_ASSERT(!fixed);
+ DBUG_ASSERT(fixed() == 0);
Item *item= get_variable(thd->spcont)->element_index(m_field_idx);
return fix_fields_from_item(thd, ref, item);
}
@@ -1893,7 +1879,7 @@ Item *
Item_splocal_row_field::this_item()
{
DBUG_ASSERT(m_sp == m_thd->spcont->m_sp);
- DBUG_ASSERT(fixed);
+ DBUG_ASSERT(fixed());
return get_variable(m_thd->spcont)->element_index(m_field_idx);
}
@@ -1902,7 +1888,7 @@ const Item *
Item_splocal_row_field::this_item() const
{
DBUG_ASSERT(m_sp == m_thd->spcont->m_sp);
- DBUG_ASSERT(fixed);
+ DBUG_ASSERT(fixed());
return get_variable(m_thd->spcont)->element_index(m_field_idx);
}
@@ -1911,7 +1897,7 @@ Item **
Item_splocal_row_field::this_item_addr(THD *thd, Item **)
{
DBUG_ASSERT(m_sp == thd->spcont->m_sp);
- DBUG_ASSERT(fixed);
+ DBUG_ASSERT(fixed());
return get_variable(thd->spcont)->addr(m_field_idx);
}
@@ -1941,7 +1927,7 @@ bool Item_splocal_row_field::set_value(THD *thd, sp_rcontext *ctx, Item **it)
bool Item_splocal_row_field_by_name::fix_fields(THD *thd, Item **it)
{
- DBUG_ASSERT(!fixed);
+ DBUG_ASSERT(fixed() == 0);
m_thd= thd;
if (get_rcontext(thd->spcont)->find_row_field_by_name_or_error(&m_field_idx,
m_var_idx,
@@ -1974,7 +1960,7 @@ void Item_splocal_row_field_by_name::print(String *str, enum_query_type)
bool Item_splocal_row_field_by_name::set_value(THD *thd, sp_rcontext *ctx, Item **it)
{
- DBUG_ASSERT(fixed); // Make sure m_field_idx is already set
+ DBUG_ASSERT(fixed()); // Make sure m_field_idx is already set
return Item_splocal_row_field::set_value(thd, ctx, it);
}
@@ -2042,7 +2028,7 @@ void Item_case_expr::print(String *str, enum_query_type)
double Item_name_const::val_real()
{
- DBUG_ASSERT(fixed);
+ DBUG_ASSERT(fixed());
double ret= value_item->val_real();
null_value= value_item->null_value;
return ret;
@@ -2051,7 +2037,7 @@ double Item_name_const::val_real()
longlong Item_name_const::val_int()
{
- DBUG_ASSERT(fixed);
+ DBUG_ASSERT(fixed());
longlong ret= value_item->val_int();
null_value= value_item->null_value;
return ret;
@@ -2060,7 +2046,7 @@ longlong Item_name_const::val_int()
String *Item_name_const::val_str(String *sp)
{
- DBUG_ASSERT(fixed);
+ DBUG_ASSERT(fixed());
String *ret= value_item->val_str(sp);
null_value= value_item->null_value;
return ret;
@@ -2069,7 +2055,7 @@ String *Item_name_const::val_str(String *sp)
my_decimal *Item_name_const::val_decimal(my_decimal *decimal_value)
{
- DBUG_ASSERT(fixed);
+ DBUG_ASSERT(fixed());
my_decimal *val= value_item->val_decimal(decimal_value);
null_value= value_item->null_value;
return val;
@@ -2077,7 +2063,7 @@ my_decimal *Item_name_const::val_decimal(my_decimal *decimal_value)
bool Item_name_const::get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate)
{
- DBUG_ASSERT(fixed);
+ DBUG_ASSERT(fixed());
bool rc= value_item->get_date(thd, ltime, fuzzydate);
null_value= value_item->null_value;
return rc;
@@ -2099,7 +2085,8 @@ Item_name_const::Item_name_const(THD *thd, Item *name_arg, Item *val):
{
StringBuffer<128> name_buffer;
String *name_str;
- Item::maybe_null= TRUE;
+
+ flags|= ITEM_FLAG_MAYBE_NULL;
if (name_item->basic_const_item() &&
(name_str= name_item->val_str(&name_buffer))) // Can't have a NULL name
set_name(thd, name_str);
@@ -2153,7 +2140,7 @@ bool Item_name_const::fix_fields(THD *thd, Item **ref)
max_length= value_item->max_length;
decimals= value_item->decimals;
unsigned_flag= value_item->unsigned_flag;
- fixed= 1;
+ flags|= ITEM_FLAG_FIXED;
return FALSE;
}
@@ -2232,7 +2219,7 @@ void Item::split_sum_func2(THD *thd, Ref_ptr_array ref_pointer_array,
((Item_sum *) this)->ref_by)
return;
}
- else if (type() == WINDOW_FUNC_ITEM || with_window_func)
+ else if (type() == WINDOW_FUNC_ITEM || with_window_func())
{
/*
Skip the else part, window functions are very special functions:
@@ -2250,7 +2237,7 @@ void Item::split_sum_func2(THD *thd, Ref_ptr_array ref_pointer_array,
else
{
/* Not a SUM() function */
- if (unlikely((!with_sum_func && !(split_flags & SPLIT_SUM_SELECT))))
+ if (unlikely((!with_sum_func() && !(split_flags & SPLIT_SUM_SELECT))))
{
/*
This is not a SUM function and there are no SUM functions inside.
@@ -2258,7 +2245,7 @@ void Item::split_sum_func2(THD *thd, Ref_ptr_array ref_pointer_array,
*/
return;
}
- if (likely(with_sum_func ||
+ if (likely(with_sum_func() ||
(type() == FUNC_ITEM &&
(((Item_func *) this)->functype() ==
Item_func::ISNOTNULLTEST_FUNC ||
@@ -2972,7 +2959,7 @@ Item_field::Item_field(THD *thd, Field *f)
*/
orig_table_name= table_name;
orig_field_name= field_name;
- with_field= 1;
+ flags|= ITEM_FLAG_WITH_FIELD;
}
@@ -3022,7 +3009,7 @@ Item_field::Item_field(THD *thd, Name_resolution_context *context_arg,
name= orig_field_name;
}
set_field(f);
- with_field= 1;
+ flags|= ITEM_FLAG_WITH_FIELD;
}
@@ -3038,7 +3025,7 @@ Item_field::Item_field(THD *thd, Name_resolution_context *context_arg,
collation.set(DERIVATION_IMPLICIT);
if (select && select->parsing_place != IN_HAVING)
select->select_n_where_fields++;
- with_field= 1;
+ flags|= ITEM_FLAG_WITH_FIELD;
}
/**
@@ -3053,7 +3040,7 @@ Item_field::Item_field(THD *thd, Item_field *item)
any_privileges(item->any_privileges)
{
collation.set(DERIVATION_IMPLICIT);
- with_field= 1;
+ flags|= ITEM_FLAG_WITH_FIELD;
}
@@ -3071,14 +3058,14 @@ bool Item_field::is_json_type()
void Item_field::set_field(Field *field_par)
{
field=result_field=field_par; // for easy coding with fields
- maybe_null=field->maybe_null();
+ set_maybe_null(field->maybe_null());
Type_std_attributes::set(field_par->type_std_attributes());
table_name= Lex_cstring_strlen(*field_par->table_name);
field_name= field_par->field_name;
db_name= field_par->table->s->db;
alias_name_used= field_par->table->alias_name_used;
- fixed= 1;
+ flags|= ITEM_FLAG_FIXED;
if (field->table->s->tmp_table == SYSTEM_TMP_TABLE)
any_privileges= 0;
}
@@ -3151,7 +3138,7 @@ bool Item_field::switch_to_nullable_fields_processor(void *arg)
Field **new_fields= (Field **)arg;
set_field_to_new_field(&field, new_fields);
set_field_to_new_field(&result_field, new_fields);
- maybe_null= field && field->maybe_null();
+ set_maybe_null(field && field->maybe_null());
return 0;
}
@@ -3263,7 +3250,7 @@ void Item_ident::print(String *str, enum_query_type query_type)
/* ARGSUSED */
String *Item_field::val_str(String *str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
if ((null_value=field->is_null()))
return 0;
str->set_charset(str_value.charset());
@@ -3273,7 +3260,7 @@ String *Item_field::val_str(String *str)
double Item_field::val_real()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
if ((null_value=field->is_null()))
return 0.0;
return field->val_real();
@@ -3282,7 +3269,7 @@ double Item_field::val_real()
longlong Item_field::val_int()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
if ((null_value=field->is_null()))
return 0;
return field->val_int();
@@ -3341,7 +3328,7 @@ bool Item_field::val_native_result(THD *thd, Native *to)
longlong Item_field::val_datetime_packed(THD *thd)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
if ((null_value= field->is_null()))
return 0;
return field->val_datetime_packed(thd);
@@ -3350,7 +3337,7 @@ longlong Item_field::val_datetime_packed(THD *thd)
longlong Item_field::val_time_packed(THD *thd)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
if ((null_value= field->is_null()))
return 0;
return field->val_time_packed(thd);
@@ -3972,7 +3959,7 @@ Item_param::Item_param(THD *thd, const LEX_CSTRING *name_arg,
before mysql_stmt_execute(), so we assuming that it can be NULL until
value is set.
*/
- maybe_null= 1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
}
@@ -4004,7 +3991,7 @@ void Item_param::sync_clones()
{
Item_param *c= *c_ptr;
/* Scalar-type members: */
- c->maybe_null= maybe_null;
+ c->copy_flags(this, ITEM_FLAG_MAYBE_NULL);
c->null_value= null_value;
c->Type_std_attributes::operator=(*this);
c->Type_handler_hybrid_field_type::operator=(*this);
@@ -4056,7 +4043,7 @@ void Item_param::set_int(longlong i, uint32 max_length_arg)
collation= DTCollation_numeric();
max_length= max_length_arg;
decimals= 0;
- maybe_null= 0;
+ flags&= (item_flags_t) ~ITEM_FLAG_MAYBE_NULL;
null_value= 0;
DBUG_VOID_RETURN;
}
@@ -4070,7 +4057,7 @@ void Item_param::set_double(double d)
collation= DTCollation_numeric();
max_length= DBL_DIG + 8;
decimals= NOT_FIXED_DEC;
- maybe_null= 0;
+ flags&= (item_flags_t) ~ITEM_FLAG_MAYBE_NULL;
null_value= 0;
DBUG_VOID_RETURN;
}
@@ -4102,7 +4089,7 @@ void Item_param::set_decimal(const char *str, ulong length)
max_length=
my_decimal_precision_to_length_no_truncation(value.m_decimal.precision(),
decimals, unsigned_flag);
- maybe_null= 0;
+ flags&= (item_flags_t) ~ITEM_FLAG_MAYBE_NULL;
null_value= 0;
DBUG_VOID_RETURN;
}
@@ -4119,7 +4106,7 @@ void Item_param::set_decimal(const my_decimal *dv, bool unsigned_arg)
unsigned_flag= unsigned_arg;
max_length= my_decimal_precision_to_length(value.m_decimal.intg + decimals,
decimals, unsigned_flag);
- maybe_null= 0;
+ flags&= (item_flags_t) ~ITEM_FLAG_MAYBE_NULL;
null_value= 0;
}
@@ -4130,7 +4117,7 @@ void Item_param::fix_temporal(uint32 max_length_arg, uint decimals_arg)
collation= DTCollation_numeric();
max_length= max_length_arg;
decimals= decimals_arg;
- maybe_null= 0;
+ flags&= (item_flags_t) ~ITEM_FLAG_MAYBE_NULL;
null_value= 0;
}
@@ -4140,7 +4127,7 @@ void Item_param::set_time(const MYSQL_TIME *tm,
{
DBUG_ASSERT(value.type_handler()->cmp_type() == TIME_RESULT);
value.time= *tm;
- maybe_null= 0;
+ flags&= (item_flags_t) ~ITEM_FLAG_MAYBE_NULL;
null_value= 0;
fix_temporal(max_length_arg, decimals_arg);
}
@@ -4175,7 +4162,7 @@ void Item_param::set_time(MYSQL_TIME *tm, timestamp_type time_type,
&str, time_type, NULL, NULL, NULL);
set_zero_time(&value.time, time_type);
}
- maybe_null= 0;
+ flags&= (item_flags_t) ~ITEM_FLAG_MAYBE_NULL;
null_value= 0;
fix_temporal(max_length_arg,
tm->second_part > 0 ? TIME_SECOND_PART_DIGITS : 0);
@@ -4212,7 +4199,7 @@ bool Item_param::set_str(const char *str, ulong length,
state= SHORT_DATA_VALUE;
collation.set(tocs, DERIVATION_COERCIBLE);
max_length= length;
- maybe_null= 0;
+ flags&= (item_flags_t) ~ITEM_FLAG_MAYBE_NULL;
null_value= 0;
/* max_length and decimals are set after charset conversion */
/* sic: str may be not null-terminated, don't add DBUG_PRINT here */
@@ -4247,7 +4234,7 @@ bool Item_param::set_longdata(const char *str, ulong length)
if (value.m_string.append(str, length, &my_charset_bin))
DBUG_RETURN(TRUE);
state= LONG_DATA_VALUE;
- maybe_null= 0;
+ flags&= (item_flags_t) ~ITEM_FLAG_MAYBE_NULL;
null_value= 0;
DBUG_RETURN(FALSE);
@@ -4348,7 +4335,7 @@ void Item_param::reset()
value.m_string.set_charset(&my_charset_bin);
collation.set(&my_charset_bin, DERIVATION_COERCIBLE);
state= NO_VALUE;
- maybe_null= 1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
null_value= 0;
DBUG_VOID_RETURN;
}
@@ -4807,7 +4794,7 @@ Item_param::set_param_type_and_swap_value(Item_param *src)
Type_std_attributes::set(src);
set_handler(src->type_handler());
- maybe_null= src->maybe_null;
+ copy_flags(src, ITEM_FLAG_MAYBE_NULL);
null_value= src->null_value;
state= src->state;
@@ -5002,7 +4989,7 @@ my_decimal *Item_copy_string::val_decimal(my_decimal *decimal_value)
void Item_ref_null_helper::save_val(Field *to)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
(*ref)->save_val(to);
owner->was_null|= null_value= (*ref)->null_value;
}
@@ -5010,7 +4997,7 @@ void Item_ref_null_helper::save_val(Field *to)
double Item_ref_null_helper::val_real()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
double tmp= (*ref)->val_result();
owner->was_null|= null_value= (*ref)->null_value;
return tmp;
@@ -5019,7 +5006,7 @@ double Item_ref_null_helper::val_real()
longlong Item_ref_null_helper::val_int()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
longlong tmp= (*ref)->val_int_result();
owner->was_null|= null_value= (*ref)->null_value;
return tmp;
@@ -5028,7 +5015,7 @@ longlong Item_ref_null_helper::val_int()
my_decimal *Item_ref_null_helper::val_decimal(my_decimal *decimal_value)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
my_decimal *val= (*ref)->val_decimal_result(decimal_value);
owner->was_null|= null_value= (*ref)->null_value;
return val;
@@ -5037,7 +5024,7 @@ my_decimal *Item_ref_null_helper::val_decimal(my_decimal *decimal_value)
bool Item_ref_null_helper::val_bool()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
bool val= (*ref)->val_bool_result();
owner->was_null|= null_value= (*ref)->null_value;
return val;
@@ -5046,7 +5033,7 @@ bool Item_ref_null_helper::val_bool()
String* Item_ref_null_helper::val_str(String* s)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
String* tmp= (*ref)->str_result(s);
owner->was_null|= null_value= (*ref)->null_value;
return tmp;
@@ -5233,7 +5220,7 @@ static Item** find_field_in_group_list(Item *find_item, ORDER *group_list)
/* SELECT list element with explicit alias */
if ((*(cur_group->item))->name.str && !table_name.str &&
- !(*(cur_group->item))->is_autogenerated_name &&
+ !(*(cur_group->item))->is_autogenerated_name() &&
!lex_string_cmp(system_charset_info,
&(*(cur_group->item))->name, &field_name))
{
@@ -5363,7 +5350,7 @@ resolve_ref_in_select_and_group(THD *thd, Item_ident *ref, SELECT_LEX *select)
ref->alias_name_used= TRUE;
/* If this is a non-aggregated field inside HAVING, search in GROUP BY. */
- if (select->having_fix_field && !ref->with_sum_func && group_list)
+ if (select->having_fix_field && !ref->with_sum_func() && group_list)
{
group_by_ref= find_field_in_group_list(ref, group_list);
@@ -5642,7 +5629,7 @@ Item_field::fix_outer_field(THD *thd, Field **from_field, Item **reference)
set_if_bigger(thd->lex->in_sum_func->max_arg_level,
select->nest_level);
set_field(*from_field);
- fixed= 1;
+ flags|= ITEM_FLAG_FIXED;
mark_as_dependent(thd, last_checked_context->select_lex,
context->select_lex, this,
((ref_type == REF_ITEM ||
@@ -5763,7 +5750,7 @@ Item_field::fix_outer_field(THD *thd, Field **from_field, Item **reference)
rf is Item_ref => never substitute other items (in this case)
during fix_fields() => we can use rf after fix_fields()
*/
- DBUG_ASSERT(!rf->fixed); // Assured by Item_ref()
+ DBUG_ASSERT(!rf->fixed()); // Assured by Item_ref()
if (rf->fix_fields(thd, reference) || rf->check_cols(1))
return -1;
@@ -5803,7 +5790,7 @@ Item_field::fix_outer_field(THD *thd, Field **from_field, Item **reference)
rf is Item_ref => never substitute other items (in this case)
during fix_fields() => we can use rf after fix_fields()
*/
- DBUG_ASSERT(!rf->fixed); // Assured by Item_ref()
+ DBUG_ASSERT(!rf->fixed()); // Assured by Item_ref()
if (rf->fix_fields(thd, reference) || rf->check_cols(1))
return -1;
return 0;
@@ -5860,7 +5847,7 @@ Item_field::fix_outer_field(THD *thd, Field **from_field, Item **reference)
bool Item_field::fix_fields(THD *thd, Item **reference)
{
- DBUG_ASSERT(fixed == 0);
+ DBUG_ASSERT(fixed() == 0);
Field *from_field= (Field *)not_found_field;
bool outer_fixed= false;
SELECT_LEX *select= thd->lex->current_select;
@@ -6062,7 +6049,7 @@ bool Item_field::fix_fields(THD *thd, Item **reference)
}
}
#endif
- fixed= 1;
+ flags|= ITEM_FLAG_FIXED;
if (field->vcol_info)
fix_session_vcol_expr_for_read(thd, field, field->vcol_info);
if (thd->variables.sql_mode & MODE_ONLY_FULL_GROUP_BY &&
@@ -6079,7 +6066,7 @@ mark_non_agg_field:
table->pos_in_table_list can be 0 when fixing partition functions
or virtual fields.
*/
- if (fixed && (thd->variables.sql_mode & MODE_ONLY_FULL_GROUP_BY) &&
+ if (fixed() && (thd->variables.sql_mode & MODE_ONLY_FULL_GROUP_BY) &&
field->table->pos_in_table_list)
{
/*
@@ -6122,7 +6109,7 @@ error:
bool Item_field::post_fix_fields_part_expr_processor(void *int_arg)
{
- DBUG_ASSERT(fixed);
+ DBUG_ASSERT(fixed());
if (field->vcol_info)
field->vcol_info->mark_as_in_partitioning_expr();
/*
@@ -6332,7 +6319,7 @@ void Item::init_make_send_field(Send_field *tmp_field,
tmp_field->org_col_name= empty_clex_str;
tmp_field->table_name= empty_clex_str;
tmp_field->col_name= name;
- tmp_field->flags= (maybe_null ? 0 : NOT_NULL_FLAG) |
+ tmp_field->flags= (maybe_null() ? 0 : NOT_NULL_FLAG) |
(my_binary_compare(charset_for_protocol()) ?
BINARY_FLAG : 0);
tmp_field->set_handler(h);
@@ -7318,7 +7305,7 @@ void Item_field::update_null_value()
Item *Item_field::update_value_transformer(THD *thd, uchar *select_arg)
{
SELECT_LEX *select= (SELECT_LEX*)select_arg;
- DBUG_ASSERT(fixed);
+ DBUG_ASSERT(fixed());
if (field->table != select->context.table_list->table &&
type() != Item::TRIGGER_FIELD_ITEM)
@@ -7851,7 +7838,7 @@ Item_ref::Item_ref(THD *thd, TABLE_LIST *view_arg, Item **item,
bool Item_ref::fix_fields(THD *thd, Item **reference)
{
enum_parsing_place place= NO_MATTER;
- DBUG_ASSERT(fixed == 0);
+ DBUG_ASSERT(fixed() == 0);
SELECT_LEX *current_sel= thd->lex->current_select;
if (set_properties_only)
@@ -8054,13 +8041,13 @@ bool Item_ref::fix_fields(THD *thd, Item **reference)
*/
if (!((*ref)->type() == REF_ITEM &&
((Item_ref *)(*ref))->ref_type() == OUTER_REF) &&
- (((*ref)->with_sum_func && name.str &&
+ (((*ref)->with_sum_func() && name.str &&
!(current_sel->get_linkage() != GLOBAL_OPTIONS_TYPE &&
current_sel->having_fix_field)) ||
!(*ref)->is_fixed()))
{
my_error(ER_ILLEGAL_REFERENCE, MYF(0),
- name.str, ((*ref)->with_sum_func ?
+ name.str, ((*ref)->with_sum_func() ?
"reference to group function":
"forward reference in item list"));
goto error;
@@ -8081,16 +8068,24 @@ error:
void Item_ref::set_properties()
{
Type_std_attributes::set(*ref);
- maybe_null= (*ref)->maybe_null;
/*
We have to remember if we refer to a sum function, to ensure that
split_sum_func() doesn't try to change the reference.
*/
- with_sum_func= (*ref)->with_sum_func;
- with_param= (*ref)->with_param;
- with_window_func= (*ref)->with_window_func;
- with_field= (*ref)->with_field;
- fixed= 1;
+ /* Reset flags if called from update_ref() */
+ flags&= ~ (ITEM_FLAG_WITH_SUM_FUNC |
+ ITEM_FLAG_WITH_PARAM |
+ ITEM_FLAG_WITH_WINDOW_FUNC |
+ ITEM_FLAG_WITH_SUBQUERY |
+ ITEM_FLAG_WITH_FIELD);
+
+ flags|= (ITEM_FLAG_FIXED |
+ ((*ref)->flags & (ITEM_FLAG_MAYBE_NULL |
+ ITEM_FLAG_WITH_SUM_FUNC |
+ ITEM_FLAG_WITH_PARAM |
+ ITEM_FLAG_WITH_WINDOW_FUNC |
+ ITEM_FLAG_WITH_SUBQUERY |
+ ITEM_FLAG_WITH_FIELD)));
if (alias_name_used)
return;
if ((*ref)->type() == FIELD_ITEM)
@@ -8325,7 +8320,7 @@ void Item_ref::save_val(Field *to)
double Item_ref::val_real()
{
- DBUG_ASSERT(fixed);
+ DBUG_ASSERT(fixed());
double tmp=(*ref)->val_result();
null_value=(*ref)->null_value;
return tmp;
@@ -8334,7 +8329,7 @@ double Item_ref::val_real()
longlong Item_ref::val_int()
{
- DBUG_ASSERT(fixed);
+ DBUG_ASSERT(fixed());
longlong tmp=(*ref)->val_int_result();
null_value=(*ref)->null_value;
return tmp;
@@ -8343,7 +8338,7 @@ longlong Item_ref::val_int()
bool Item_ref::val_bool()
{
- DBUG_ASSERT(fixed);
+ DBUG_ASSERT(fixed());
bool tmp= (*ref)->val_bool_result();
null_value= (*ref)->null_value;
return tmp;
@@ -8352,7 +8347,7 @@ bool Item_ref::val_bool()
String *Item_ref::val_str(String* tmp)
{
- DBUG_ASSERT(fixed);
+ DBUG_ASSERT(fixed());
tmp=(*ref)->str_result(tmp);
null_value=(*ref)->null_value;
return tmp;
@@ -8361,7 +8356,7 @@ String *Item_ref::val_str(String* tmp)
bool Item_ref::is_null()
{
- DBUG_ASSERT(fixed);
+ DBUG_ASSERT(fixed());
bool tmp=(*ref)->is_null_result();
null_value=(*ref)->null_value;
return tmp;
@@ -8382,7 +8377,7 @@ bool Item_ref::val_native(THD *thd, Native *to)
longlong Item_ref::val_datetime_packed(THD *thd)
{
- DBUG_ASSERT(fixed);
+ DBUG_ASSERT(fixed());
longlong tmp= (*ref)->val_datetime_packed_result(thd);
null_value= (*ref)->null_value;
return tmp;
@@ -8391,7 +8386,7 @@ longlong Item_ref::val_datetime_packed(THD *thd)
longlong Item_ref::val_time_packed(THD *thd)
{
- DBUG_ASSERT(fixed);
+ DBUG_ASSERT(fixed());
longlong tmp= (*ref)->val_time_packed_result(thd);
null_value= (*ref)->null_value;
return tmp;
@@ -8567,17 +8562,19 @@ Item_cache_wrapper::Item_cache_wrapper(THD *thd, Item *item_arg):
{
DBUG_ASSERT(orig_item->is_fixed());
Type_std_attributes::set(orig_item);
- maybe_null= orig_item->maybe_null;
- with_sum_func= orig_item->with_sum_func;
- with_subquery= orig_item->with_subquery;
- with_param= orig_item->with_param;
- with_field= orig_item->with_field;
+
+ flags|= ITEM_FLAG_FIXED |
+ (orig_item->flags &
+ (ITEM_FLAG_MAYBE_NULL |
+ ITEM_FLAG_WITH_SUM_FUNC |
+ ITEM_FLAG_WITH_SUBQUERY |
+ ITEM_FLAG_WITH_PARAM |
+ ITEM_FLAG_WITH_FIELD));
+
name= item_arg->name;
if ((expr_value= orig_item->get_cache(thd)))
expr_value->setup(thd, orig_item);
-
- fixed= 1;
}
@@ -8628,7 +8625,7 @@ bool Item_cache_wrapper::fix_fields(THD *thd __attribute__((unused)),
Item **it __attribute__((unused)))
{
DBUG_ASSERT(orig_item->is_fixed());
- DBUG_ASSERT(fixed);
+ DBUG_ASSERT(fixed());
return FALSE;
}
@@ -8980,7 +8977,7 @@ int Item_cache_wrapper::save_in_field(Field *to, bool no_conversions)
Item* Item_cache_wrapper::get_tmp_table_item(THD *thd)
{
- if (!orig_item->with_sum_func && !orig_item->const_item())
+ if (!orig_item->with_sum_func() && !orig_item->const_item())
return new (thd->mem_root) Item_temptable_field(thd, result_field);
return copy_or_same(thd);
}
@@ -9032,7 +9029,7 @@ bool Item_direct_view_ref::fix_fields(THD *thd, Item **reference)
if (Item_direct_ref::fix_fields(thd, reference))
return TRUE;
if (view->table && view->table->maybe_null)
- maybe_null= TRUE;
+ flags|= ITEM_FLAG_MAYBE_NULL;
set_null_ref_table();
return FALSE;
}
@@ -9370,7 +9367,7 @@ bool Item_default_value::fix_fields(THD *thd, Item **items)
Item *real_arg;
Item_field *field_arg;
Field *def_field;
- DBUG_ASSERT(fixed == 0);
+ DBUG_ASSERT(fixed() == 0);
DBUG_ASSERT(arg);
/*
@@ -9610,7 +9607,7 @@ bool Item_insert_value::eq(const Item *item, bool binary_cmp) const
bool Item_insert_value::fix_fields(THD *thd, Item **items)
{
- DBUG_ASSERT(fixed == 0);
+ DBUG_ASSERT(fixed() == 0);
/* We should only check that arg is in first table */
if (!arg->is_fixed())
{
@@ -9764,7 +9761,7 @@ bool Item_trigger_field::fix_fields(THD *thd, Item **items)
parsing! So we have little to do in fix_fields. :)
*/
- DBUG_ASSERT(fixed == 0);
+ DBUG_ASSERT(fixed() == 0);
/* Set field. */
@@ -9792,7 +9789,7 @@ bool Item_trigger_field::fix_fields(THD *thd, Item **items)
field= (row_version == OLD_ROW) ? triggers->old_field[field_idx] :
triggers->new_field[field_idx];
set_field(field);
- fixed= 1;
+ flags|= ITEM_FLAG_FIXED;
return FALSE;
}
@@ -9931,7 +9928,7 @@ void Item_cache::print(String *str, enum_query_type query_type)
void Item_cache::set_null()
{
- if (maybe_null)
+ if (maybe_null())
{
null_value= TRUE;
value_cached= TRUE;
@@ -10602,7 +10599,7 @@ void Item_direct_view_ref::update_used_tables()
table_map Item_direct_view_ref::used_tables() const
{
- DBUG_ASSERT(fixed);
+ DBUG_ASSERT(fixed());
if (get_depended_from())
return OUTER_REF_TABLE_BIT;
diff --git a/sql/item.h b/sql/item.h
index 60ad20b0750..6c590ace6d4 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -726,6 +726,30 @@ public:
#define STOP_PTR ((void *) 1)
+/* Bits used in Item.flags */
+/* If item may be null */
+#define ITEM_FLAG_MAYBE_NULL_SHIFT 0
+#define ITEM_FLAG_MAYBE_NULL (1<<ITEM_FLAG_MAYBE_NULL_SHIFT)
+/* If used in GROUP BY list of a query with ROLLUP */
+#define ITEM_FLAG_IN_ROLLUP (1<<1)
+/* If Item contains an SP parameter */
+#define ITEM_FLAG_WITH_PARAM (1<<2)
+/* If item contains a window func */
+#define ITEM_FLAG_WITH_WINDOW_FUNC (1<<3)
+/* True if any item except Item_sum contains a field. Set during parsing. */
+#define ITEM_FLAG_WITH_FIELD (1<<4)
+/* If item was fixed with fix_fields */
+#define ITEM_FLAG_FIXED (1<<5)
+/* Indicates that name of this Item autogenerated or set by user */
+#define ITEM_FLAG_IS_AUTOGENERATED_NAME (1 << 6)
+/* Indicates that this item is in CYCLE clause of WITH */
+#define ITEM_FLAG_IS_IN_WITH_CYCLE (1<<7)
+/* True if item contains a sum func */
+#define ITEM_FLAG_WITH_SUM_FUNC (1<< 8)
+/* True if item containts a sub query */
+#define ITEM_FLAG_WITH_SUBQUERY (1<< 9)
+
+
class Item :public Value_source,
public Type_all_attributes
{
@@ -773,7 +797,7 @@ protected:
{
const Type_handler *h= type_handler();
return h->make_and_init_table_field(root, &name,
- Record_addr(maybe_null),
+ Record_addr(maybe_null()),
*this, table);
}
/**
@@ -791,7 +815,7 @@ protected:
DBUG_ASSERT(is_fixed());
const Type_handler *h= type_handler()->type_handler_for_tmp_table(this);
return h->make_and_init_table_field(root, &name,
- Record_addr(maybe_null),
+ Record_addr(maybe_null()),
*this, table);
}
/**
@@ -916,42 +940,49 @@ public:
/* Original item name (if it was renamed)*/
const char *orig_name;
- uint32 /* All common bool variables for Item stored here */
- maybe_null:1, /* If item may be null */
- in_rollup:1, /* If used in GROUP BY list of a query with ROLLUP */
- with_param:1, /* True if Item contains an SP parameter */
- with_window_func:1, /* True if item contains a window func */
- with_field:1, /* True if any item except Item_sum contains a field.
- Set during parsing. */
- fixed:1, /* If item was fixed with fix_fields */
- /* Indicates that name of this Item autogenerated or set by user */
- is_autogenerated_name:1,
- /* Indicates that this item is in CYCLE clause of WITH */
- is_in_with_cycle:1,
- with_sum_func:1, /* True if item contains a sum func */
- with_subquery:1; /* True if item containts a sub query */
+ /* All common bool variables for an Item is stored here */
+ typedef uint16 item_flags_t;
+ item_flags_t flags;
+ /* Marker is used in some functions to temporary mark an item */
int16 marker;
/*
Tells is the val() value of the item is/was null.
- This should not be part of the bit flags as it's changed a lot and also we use
- pointers to it
+ This should not be part of the bit flags as it's changed a lot and also
+ we use pointers to it
*/
bool null_value;
/* Cache of the result of is_expensive(). */
int8 is_expensive_cache;
/**
- The index in the JOIN::join_tab array of the JOIN_TAB this Item is attached
- to. Items are attached (or 'pushed') to JOIN_TABs during optimization by the
- make_cond_for_table procedure. During query execution, this item is
- evaluated when the join loop reaches the corresponding JOIN_TAB.
+ The index in the JOIN::join_tab array of the JOIN_TAB this Item
+ is attached to. Items are attached (or 'pushed') to JOIN_TABs
+ during optimization by the make_cond_for_table procedure. During
+ query execution, this item is evaluated when the join loop reaches
+ the corresponding JOIN_TAB.
If the value of join_tab_idx >= MAX_TABLES, this means that there is no
corresponding JOIN_TAB.
*/
uint8 join_tab_idx;
+ inline bool maybe_null() const { return (flags & ITEM_FLAG_MAYBE_NULL); }
+ inline bool in_rollup() const { return (flags & ITEM_FLAG_IN_ROLLUP); }
+ inline bool with_param() const { return (flags & ITEM_FLAG_WITH_PARAM); }
+ inline bool with_window_func() const { return (flags & ITEM_FLAG_WITH_WINDOW_FUNC); }
+ inline bool with_field() const { return (flags & ITEM_FLAG_WITH_FIELD); }
+ inline bool fixed() const { return (flags & ITEM_FLAG_FIXED); }
+ inline bool is_fixed() const { return fixed(); } /* Legacy function */
+ inline bool is_autogenerated_name() const { return (flags & ITEM_FLAG_IS_AUTOGENERATED_NAME); }
+ inline bool is_in_with_cycle() const { return (flags & ITEM_FLAG_IS_IN_WITH_CYCLE); }
+ inline bool with_sum_func() const { return (flags & ITEM_FLAG_WITH_SUM_FUNC); }
+ inline bool with_subquery() const { return (flags & ITEM_FLAG_WITH_SUBQUERY); }
+ inline void copy_flags(const Item *org, item_flags_t mask)
+ {
+ flags= (item_flags_t) ((flags & ~mask) | (org->flags & mask));
+ }
+
// alloc & destruct is done as start of select on THD::mem_root
Item(THD *thd);
/*
@@ -987,14 +1018,14 @@ public:
void share_name_with(const Item *item)
{
name= item->name;
- is_autogenerated_name= item->is_autogenerated_name;
+ copy_flags(item, ITEM_FLAG_IS_AUTOGENERATED_NAME);
}
virtual void cleanup();
virtual void make_send_field(THD *thd, Send_field *field);
bool fix_fields_if_needed(THD *thd, Item **ref)
{
- return is_fixed() ? false : fix_fields(thd, ref);
+ return fixed() ? false : fix_fields(thd, ref);
}
bool fix_fields_if_needed_for_scalar(THD *thd, Item **ref)
{
@@ -1023,7 +1054,6 @@ public:
DBUG_ASSERT(basic_const_item());
return false;
}
- virtual bool is_fixed() const { return true; }
virtual void unfix_fields()
{
DBUG_ASSERT(0);
@@ -1150,7 +1180,12 @@ public:
return type_handler()->max_display_length(this);
}
const TYPELIB *get_typelib() const { return NULL; }
- void set_maybe_null(bool maybe_null_arg) { maybe_null= maybe_null_arg; }
+ inline void set_maybe_null(bool maybe_null_arg)
+ {
+ flags= ((item_flags_t)
+ ((flags & (item_flags_t) ~ITEM_FLAG_MAYBE_NULL) |
+ ((maybe_null_arg << ITEM_FLAG_MAYBE_NULL_SHIFT))));
+ }
/* This is used when calling Type_all_attributes::set_type_maybe_null() */
void set_type_maybe_null(bool maybe_null_arg) override
{
@@ -2408,7 +2443,7 @@ public:
virtual bool is_outer_field() const { DBUG_ASSERT(is_fixed()); return FALSE; }
/** Checks if this item or any of its decendents contains a subquery */
- bool has_subquery() const { DBUG_ASSERT(is_fixed()); return with_subquery; }
+ bool has_subquery() const { DBUG_ASSERT(is_fixed()); return with_subquery(); }
Item* set_expr_cache(THD *thd);
@@ -2534,7 +2569,7 @@ public:
str_length--;
}
};
-#endif
+#endif /* DBUG_OFF */
/**
@@ -2711,27 +2746,26 @@ class Item_fixed_hybrid: public Item
public:
Item_fixed_hybrid(THD *thd): Item(thd)
{
- fixed= false;
+ flags&= (item_flags_t) ~ITEM_FLAG_FIXED;
}
Item_fixed_hybrid(THD *thd, Item_fixed_hybrid *item)
:Item(thd, item)
{
- fixed= item->fixed;
+ flags|= (item_flags_t) (item->flags & ITEM_FLAG_FIXED);
}
- bool fix_fields(THD *thd, Item **ref)
+ bool fix_fields(THD *thd, Item **ref) override
{
- DBUG_ASSERT(!fixed);
- fixed= true;
+ DBUG_ASSERT(!fixed());
+ flags|= ITEM_FLAG_FIXED;
return false;
}
- void cleanup()
+ void cleanup() override
{
Item::cleanup();
- fixed= false;
+ flags&= (item_flags_t) ~ITEM_FLAG_FIXED;
}
- void quick_fix_field() { fixed= true; }
- void unfix_fields() { fixed= false; }
- bool is_fixed() const { return fixed; }
+ void quick_fix_field() override { flags|= ITEM_FLAG_FIXED; }
+ void unfix_fields() override { flags&= (item_flags_t) ~ITEM_FLAG_FIXED; }
};
@@ -3239,7 +3273,7 @@ public:
Field *create_tmp_field_ex(MEM_ROOT *root, TABLE *table, Tmp_field_src *src,
const Tmp_field_param *param) override
{
- DBUG_ASSERT(fixed);
+ DBUG_ASSERT(fixed());
const Type_handler *h= type_handler()->type_handler_for_tmp_table(this);
return create_tmp_field_ex_from_handler(root, table, src, param, h);
}
@@ -3567,7 +3601,7 @@ public:
{ return get_item_copy<Item_field>(thd, this); }
bool is_outer_field() const override
{
- DBUG_ASSERT(fixed);
+ DBUG_ASSERT(fixed());
return field->table->pos_in_table_list->outer_join;
}
bool check_index_dependence(void *arg) override;
@@ -3655,7 +3689,7 @@ public:
Item_null(THD *thd, const char *name_par=0, CHARSET_INFO *cs= &my_charset_bin):
Item_basic_constant(thd)
{
- maybe_null= TRUE;
+ flags|= ITEM_FLAG_MAYBE_NULL;
null_value= TRUE;
max_length= 0;
name.str= name_par ? name_par : "NULL";
@@ -4876,8 +4910,8 @@ protected:
Date cached_time;
bool update_null()
{
- return maybe_null &&
- (null_value= cached_time.check_date_with_warn(current_thd));
+ return (maybe_null() &&
+ (null_value= cached_time.check_date_with_warn(current_thd)));
}
public:
Item_date_literal(THD *thd, const Date *ltime)
@@ -4899,7 +4933,8 @@ public:
will be checked per row, according to the execution time sql_mode.
The check_date() below call should cover all cases mentioned.
*/
- maybe_null= cached_time.check_date(TIME_NO_ZERO_DATE | TIME_NO_ZERO_IN_DATE);
+ set_maybe_null(cached_time.check_date(TIME_NO_ZERO_DATE |
+ TIME_NO_ZERO_IN_DATE));
}
const Type_handler *type_handler() const override
{ return &type_handler_newdate; }
@@ -4987,8 +5022,8 @@ protected:
Datetime cached_time;
bool update_null()
{
- return maybe_null &&
- (null_value= cached_time.check_date_with_warn(current_thd));
+ return (maybe_null() &&
+ (null_value= cached_time.check_date_with_warn(current_thd)));
}
public:
Item_datetime_literal(THD *thd, const Datetime *ltime,
@@ -4999,7 +5034,8 @@ public:
DBUG_ASSERT(cached_time.is_valid_datetime());
max_length= MAX_DATETIME_WIDTH + (decimals ? decimals + 1 : 0);
// See the comment on maybe_null in Item_date_literal
- maybe_null= cached_time.check_date(TIME_NO_ZERO_DATE | TIME_NO_ZERO_IN_DATE);
+ set_maybe_null(cached_time.check_date(TIME_NO_ZERO_DATE |
+ TIME_NO_ZERO_IN_DATE));
}
const Type_handler *type_handler() const override
{ return &type_handler_datetime2; }
@@ -5067,7 +5103,7 @@ public:
Item_date_literal_for_invalid_dates(THD *thd, const Date *ltime)
:Item_date_literal(thd, ltime)
{
- maybe_null= false;
+ flags&= (item_flags_t) ~ITEM_FLAG_MAYBE_NULL;
}
bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate)
{
@@ -5089,7 +5125,7 @@ public:
decimal_digits_t dec_arg)
:Item_datetime_literal(thd, ltime, dec_arg)
{
- maybe_null= false;
+ flags&= (item_flags_t) ~ITEM_FLAG_MAYBE_NULL;
}
bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate)
{
@@ -5516,7 +5552,7 @@ public:
{ return ref && (*ref)->basic_const_item(); }
bool is_outer_field() const override
{
- DBUG_ASSERT(fixed);
+ DBUG_ASSERT(fixed());
DBUG_ASSERT(ref);
return (*ref)->is_outer_field();
}
@@ -5609,6 +5645,12 @@ public:
{ return get_item_copy<Item_direct_ref>(thd, this); }
Item *remove_item_direct_ref() override
{ return (*ref)->remove_item_direct_ref(); }
+
+ /* Should be called if ref is changed */
+ inline void ref_changed()
+ {
+ set_properties();
+ }
};
@@ -5640,7 +5682,6 @@ public:
void print(String *str, enum_query_type query_type) override
{ ident->print(str, query_type); }
-
};
@@ -5813,7 +5854,7 @@ public:
item_equal(0), view(view_arg),
null_ref_table(NULL)
{
- if (fixed)
+ if (fixed())
set_null_ref_table();
}
@@ -6008,7 +6049,8 @@ public:
{
ref= &outer_ref;
set_properties();
- fixed= 0; /* reset flag set in set_properties() */
+ /* reset flag set in set_properties() */
+ flags&= (item_flags_t) ~ITEM_FLAG_FIXED;
}
Item_outer_ref(THD *thd, Name_resolution_context *context_arg, Item **item,
const LEX_CSTRING &table_name_arg, LEX_CSTRING &field_name_arg,
@@ -6151,12 +6193,12 @@ protected:
stores metadata information about the original class as well as a
pointer to it.
*/
- Item_copy(THD *thd, Item *i): Item(thd)
+ Item_copy(THD *thd, Item *org): Item(thd)
{
- DBUG_ASSERT(i->is_fixed());
- item= i;
- null_value= item->maybe_null;
- maybe_null= item->maybe_null;
+ DBUG_ASSERT(org->fixed());
+ item= org;
+ null_value= item->maybe_null();
+ copy_flags(item, ITEM_FLAG_MAYBE_NULL);
Type_std_attributes::set(item);
name= item->name;
set_handler(item->type_handler());
@@ -6783,7 +6825,7 @@ public:
value_cached(0),
used_table_map(0)
{
- maybe_null= 1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
null_value= 1;
null_value_inside= true;
}
@@ -6795,7 +6837,7 @@ protected:
value_cached(0),
used_table_map(0)
{
- maybe_null= 1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
null_value= 1;
null_value_inside= true;
}
@@ -7345,9 +7387,10 @@ public:
{
name= item->name;
Type_std_attributes::set(*attr);
- maybe_null= maybe_null_arg;
- is_autogenerated_name= item->is_autogenerated_name;
- is_in_with_cycle= item->is_in_with_cycle;
+ set_maybe_null(maybe_null_arg);
+ copy_flags(item,
+ ITEM_FLAG_IS_AUTOGENERATED_NAME |
+ ITEM_FLAG_IS_IN_WITH_CYCLE);
}
const Type_handler *type_handler() const override
@@ -7388,8 +7431,8 @@ public:
const Tmp_field_param *param) override
{
return Item_type_holder::real_type_handler()->
- make_and_init_table_field(root, &name, Record_addr(maybe_null),
- *this, table);
+ make_and_init_table_field(root, &name, Record_addr(maybe_null()),
+ *this, table);
}
Item* get_copy(THD *) override { return nullptr; }
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index 686cd245369..97252b419e4 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -198,7 +198,7 @@ static uint collect_cmp_types(Item **items, uint nitems, bool skip_nulls= FALSE)
longlong Item_func_not::val_int()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
bool value= args[0]->val_bool();
null_value=args[0]->null_value;
return ((!null_value && value == 0) ? 1 : 0);
@@ -217,7 +217,7 @@ void Item_func_not::print(String *str, enum_query_type query_type)
longlong Item_func_not_all::val_int()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
bool value= args[0]->val_bool();
/*
@@ -258,7 +258,7 @@ void Item_func_not_all::print(String *str, enum_query_type query_type)
longlong Item_func_nop_all::val_int()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
longlong value= args[0]->val_int();
/*
@@ -1148,7 +1148,7 @@ int Arg_comparator::compare_e_str_json()
bool Item_func_truth::fix_length_and_dec()
{
- maybe_null= 0;
+ flags&= (item_flags_t) ~ITEM_FLAG_MAYBE_NULL;
null_value= 0;
decimals= 0;
max_length= 1;
@@ -1207,7 +1207,7 @@ bool Item_in_optimizer::is_top_level_item() const
void Item_in_optimizer::fix_after_pullout(st_select_lex *new_parent,
Item **ref, bool merge)
{
- DBUG_ASSERT(fixed);
+ DBUG_ASSERT(fixed());
/* This will re-calculate attributes of our Item_in_subselect: */
Item_bool_func::fix_after_pullout(new_parent, ref, merge);
@@ -1342,19 +1342,20 @@ bool Item_in_optimizer::fix_left(THD *thd)
used_tables_cache= args[0]->used_tables();
}
eval_not_null_tables(NULL);
- with_sum_func= args[0]->with_sum_func;
- with_param= args[0]->with_param || args[1]->with_param;
- with_field= args[0]->with_field;
+ flags|= ((args[0]->flags & (ITEM_FLAG_WITH_SUM_FUNC | ITEM_FLAG_WITH_PARAM |
+ ITEM_FLAG_WITH_FIELD)) |
+ (args[1]->flags & (ITEM_FLAG_WITH_PARAM)));
+
if ((const_item_cache= args[0]->const_item()))
{
cache->store(args[0]);
cache->cache_value();
}
- if (args[1]->is_fixed())
+ if (args[1]->fixed())
{
/* to avoid overriding is called to update left expression */
used_tables_and_const_cache_join(args[1]);
- with_sum_func= with_sum_func || args[1]->with_sum_func;
+ flags|= args[1]->flags & ITEM_FLAG_WITH_SUM_FUNC;
}
DBUG_RETURN(0);
}
@@ -1362,7 +1363,7 @@ bool Item_in_optimizer::fix_left(THD *thd)
bool Item_in_optimizer::fix_fields(THD *thd, Item **ref)
{
- DBUG_ASSERT(fixed == 0);
+ DBUG_ASSERT(fixed() == 0);
Item_subselect *sub= 0;
uint col;
@@ -1375,8 +1376,8 @@ bool Item_in_optimizer::fix_fields(THD *thd, Item **ref)
if (fix_left(thd))
return TRUE;
- if (args[0]->maybe_null)
- maybe_null=1;
+ if (args[0]->maybe_null())
+ flags|= ITEM_FLAG_MAYBE_NULL;
if (args[1]->fix_fields_if_needed(thd, args + 1))
return TRUE;
@@ -1387,14 +1388,14 @@ bool Item_in_optimizer::fix_fields(THD *thd, Item **ref)
my_error(ER_OPERAND_COLUMNS, MYF(0), col);
return TRUE;
}
- if (args[1]->maybe_null)
- maybe_null=1;
- with_subquery= 1;
- with_sum_func= with_sum_func || args[1]->with_sum_func;
- with_field= with_field || args[1]->with_field;
- with_param= args[0]->with_param || args[1]->with_param;
+
+ flags|= (ITEM_FLAG_FIXED | ITEM_FLAG_WITH_SUBQUERY |
+ (args[1]->flags & (ITEM_FLAG_MAYBE_NULL |
+ ITEM_FLAG_WITH_SUM_FUNC |
+ ITEM_FLAG_WITH_FIELD |
+ ITEM_FLAG_WITH_PARAM)) |
+ (args[0]->flags & ITEM_FLAG_WITH_PARAM));
used_tables_and_const_cache_join(args[1]);
- fixed= 1;
return FALSE;
}
@@ -1442,7 +1443,7 @@ bool Item_in_optimizer::invisible_mode()
Item *Item_in_optimizer::expr_cache_insert_transformer(THD *thd, uchar *unused)
{
DBUG_ENTER("Item_in_optimizer::expr_cache_insert_transformer");
- DBUG_ASSERT(fixed);
+ DBUG_ASSERT(fixed());
if (invisible_mode())
DBUG_RETURN(this);
@@ -1467,7 +1468,7 @@ Item *Item_in_optimizer::expr_cache_insert_transformer(THD *thd, uchar *unused)
void Item_in_optimizer::get_cache_parameters(List<Item> &parameters)
{
- DBUG_ASSERT(fixed);
+ DBUG_ASSERT(fixed());
/* Add left expression to the list of the parameters of the subquery */
if (!invisible_mode())
{
@@ -1558,7 +1559,7 @@ void Item_in_optimizer::get_cache_parameters(List<Item> &parameters)
longlong Item_in_optimizer::val_int()
{
bool tmp;
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
cache->store(args[0]);
cache->cache_value();
DBUG_ENTER(" Item_in_optimizer::val_int");
@@ -1705,7 +1706,7 @@ Item *Item_in_optimizer::transform(THD *thd, Item_transformer transformer,
{
Item *new_item;
- DBUG_ASSERT(fixed);
+ DBUG_ASSERT(fixed());
DBUG_ASSERT(!thd->stmt_arena->is_stmt_prepare());
DBUG_ASSERT(arg_count == 2);
@@ -1756,7 +1757,7 @@ Item *Item_in_optimizer::transform(THD *thd, Item_transformer transformer,
bool Item_in_optimizer::is_expensive_processor(void *arg)
{
- DBUG_ASSERT(fixed);
+ DBUG_ASSERT(fixed());
return args[0]->is_expensive_processor(arg) ||
args[1]->is_expensive_processor(arg);
}
@@ -1764,14 +1765,14 @@ bool Item_in_optimizer::is_expensive_processor(void *arg)
bool Item_in_optimizer::is_expensive()
{
- DBUG_ASSERT(fixed);
+ DBUG_ASSERT(fixed());
return args[0]->is_expensive() || args[1]->is_expensive();
}
longlong Item_func_eq::val_int()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
int value= cmp.compare();
return value == 0 ? 1 : 0;
}
@@ -1782,19 +1783,20 @@ longlong Item_func_eq::val_int()
bool Item_func_equal::fix_length_and_dec()
{
bool rc= Item_bool_rowready_func2::fix_length_and_dec();
- maybe_null=null_value=0;
+ flags&= (item_flags_t) ~ITEM_FLAG_MAYBE_NULL;
+ null_value=0;
return rc;
}
longlong Item_func_equal::val_int()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
return cmp.compare();
}
longlong Item_func_ne::val_int()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
int value= cmp.compare();
return value != 0 && !null_value ? 1 : 0;
}
@@ -1802,7 +1804,7 @@ longlong Item_func_ne::val_int()
longlong Item_func_ge::val_int()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
int value= cmp.compare();
return value >= 0 ? 1 : 0;
}
@@ -1810,14 +1812,14 @@ longlong Item_func_ge::val_int()
longlong Item_func_gt::val_int()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
int value= cmp.compare();
return value > 0 ? 1 : 0;
}
longlong Item_func_le::val_int()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
int value= cmp.compare();
return value <= 0 && !null_value ? 1 : 0;
}
@@ -1825,7 +1827,7 @@ longlong Item_func_le::val_int()
longlong Item_func_lt::val_int()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
int value= cmp.compare();
return value < 0 && !null_value ? 1 : 0;
}
@@ -1833,7 +1835,7 @@ longlong Item_func_lt::val_int()
longlong Item_func_strcmp::val_int()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
String *a= args[0]->val_str(&value1);
String *b= args[1]->val_str(&value2);
if (!a || !b)
@@ -1935,13 +1937,13 @@ bool Item_func_interval::fix_length_and_dec()
}
}
}
- maybe_null= 0;
+ flags&= (item_flags_t) ~ITEM_FLAG_MAYBE_NULL;
max_length= 2;
used_tables_and_const_cache_join(row);
not_null_tables_cache= row->not_null_tables();
- with_sum_func= with_sum_func || row->with_sum_func;
- with_param= with_param || row->with_param;
- with_field= with_field || row->with_field;
+ flags|= (row->flags & (ITEM_FLAG_WITH_SUM_FUNC |
+ ITEM_FLAG_WITH_PARAM |
+ ITEM_FLAG_WITH_FIELD));
return FALSE;
}
@@ -1962,7 +1964,7 @@ bool Item_func_interval::fix_length_and_dec()
longlong Item_func_interval::val_int()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
double value;
my_decimal dec_buf, *dec= NULL;
uint i;
@@ -2345,7 +2347,7 @@ void Item_func_between::print(String *str, enum_query_type query_type)
double
Item_func_ifnull::real_op()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
double value= args[0]->val_real();
if (!args[0]->null_value)
{
@@ -2361,7 +2363,7 @@ Item_func_ifnull::real_op()
longlong
Item_func_ifnull::int_op()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
longlong value=args[0]->val_int();
if (!args[0]->null_value)
{
@@ -2377,7 +2379,7 @@ Item_func_ifnull::int_op()
my_decimal *Item_func_ifnull::decimal_op(my_decimal *decimal_value)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
my_decimal *value= args[0]->val_decimal(decimal_value);
if (!args[0]->null_value)
{
@@ -2394,7 +2396,7 @@ my_decimal *Item_func_ifnull::decimal_op(my_decimal *decimal_value)
String *
Item_func_ifnull::str_op(String *str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
String *res =args[0]->val_str(str);
if (!args[0]->null_value)
{
@@ -2412,7 +2414,7 @@ Item_func_ifnull::str_op(String *str)
bool Item_func_ifnull::native_op(THD *thd, Native *to)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
if (!val_native_with_conversion_from_item(thd, args[0], to, type_handler()))
return false;
return val_native_with_conversion_from_item(thd, args[1], to, type_handler());
@@ -2421,7 +2423,7 @@ bool Item_func_ifnull::native_op(THD *thd, Native *to)
bool Item_func_ifnull::date_op(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
for (uint i= 0; i < 2; i++)
{
Datetime_truncation_not_needed dt(thd, args[i],
@@ -2435,7 +2437,7 @@ bool Item_func_ifnull::date_op(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydat
bool Item_func_ifnull::time_op(THD *thd, MYSQL_TIME *ltime)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
for (uint i= 0; i < 2; i++)
{
if (!Time(thd, args[i]).copy_to_mysql_time(ltime))
@@ -2474,7 +2476,7 @@ bool Item_func_ifnull::time_op(THD *thd, MYSQL_TIME *ltime)
bool
Item_func_if::fix_fields(THD *thd, Item **ref)
{
- DBUG_ASSERT(fixed == 0);
+ DBUG_ASSERT(fixed() == 0);
args[0]->top_level_item();
if (Item_func::fix_fields(thd, ref))
@@ -2726,7 +2728,7 @@ Item_func_nullif::fix_length_and_dec()
decimals= args[2]->decimals;
unsigned_flag= args[2]->unsigned_flag;
fix_char_length(args[2]->max_char_length());
- maybe_null=1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
m_arg0= args[0];
if (setup_args_and_comparator(thd, &cmp))
return TRUE;
@@ -2860,7 +2862,7 @@ int Item_func_nullif::compare()
double
Item_func_nullif::real_op()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
double value;
if (!compare())
{
@@ -2875,7 +2877,7 @@ Item_func_nullif::real_op()
longlong
Item_func_nullif::int_op()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
longlong value;
if (!compare())
{
@@ -2890,7 +2892,7 @@ Item_func_nullif::int_op()
String *
Item_func_nullif::str_op(String *str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
String *res;
if (!compare())
{
@@ -2906,7 +2908,7 @@ Item_func_nullif::str_op(String *str)
my_decimal *
Item_func_nullif::decimal_op(my_decimal * decimal_value)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
my_decimal *res;
if (!compare())
{
@@ -2922,7 +2924,7 @@ Item_func_nullif::decimal_op(my_decimal * decimal_value)
bool
Item_func_nullif::date_op(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
if (!compare())
return (null_value= true);
Datetime_truncation_not_needed dt(thd, args[2], fuzzydate);
@@ -2933,7 +2935,7 @@ Item_func_nullif::date_op(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate)
bool
Item_func_nullif::time_op(THD *thd, MYSQL_TIME *ltime)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
if (!compare())
return (null_value= true);
return (null_value= Time(thd, args[2]).copy_to_mysql_time(ltime));
@@ -2944,7 +2946,7 @@ Item_func_nullif::time_op(THD *thd, MYSQL_TIME *ltime)
bool
Item_func_nullif::native_op(THD *thd, Native *to)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
if (!compare())
return (null_value= true);
return val_native_with_conversion_from_item(thd, args[2], to, type_handler());
@@ -3037,7 +3039,7 @@ Item *Item_func_decode_oracle::find_item()
String *Item_func_case::str_op(String *str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
String *res;
Item *item= find_item();
@@ -3055,7 +3057,7 @@ String *Item_func_case::str_op(String *str)
longlong Item_func_case::int_op()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
Item *item= find_item();
longlong res;
@@ -3071,7 +3073,7 @@ longlong Item_func_case::int_op()
double Item_func_case::real_op()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
Item *item= find_item();
double res;
@@ -3088,7 +3090,7 @@ double Item_func_case::real_op()
my_decimal *Item_func_case::decimal_op(my_decimal *decimal_value)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
Item *item= find_item();
my_decimal *res;
@@ -3106,7 +3108,7 @@ my_decimal *Item_func_case::decimal_op(my_decimal *decimal_value)
bool Item_func_case::date_op(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
Item *item= find_item();
if (!item)
return (null_value= true);
@@ -3117,7 +3119,7 @@ bool Item_func_case::date_op(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate)
bool Item_func_case::time_op(THD *thd, MYSQL_TIME *ltime)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
Item *item= find_item();
if (!item)
return (null_value= true);
@@ -3127,7 +3129,7 @@ bool Item_func_case::time_op(THD *thd, MYSQL_TIME *ltime)
bool Item_func_case::native_op(THD *thd, Native *to)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
Item *item= find_item();
if (!item)
return (null_value= true);
@@ -3140,8 +3142,8 @@ bool Item_func_case::fix_fields(THD *thd, Item **ref)
bool res= Item_func::fix_fields(thd, ref);
Item **pos= else_expr_addr();
- if (!pos || pos[0]->maybe_null)
- maybe_null= 1;
+ if (!pos || pos[0]->maybe_null())
+ flags|= ITEM_FLAG_MAYBE_NULL;
return res;
}
@@ -3427,7 +3429,7 @@ void Item_func_decode_oracle::print(String *str, enum_query_type query_type)
String *Item_func_coalesce::str_op(String *str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
null_value=0;
for (uint i=0 ; i < arg_count ; i++)
{
@@ -3441,7 +3443,7 @@ String *Item_func_coalesce::str_op(String *str)
longlong Item_func_coalesce::int_op()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
null_value=0;
for (uint i=0 ; i < arg_count ; i++)
{
@@ -3455,7 +3457,7 @@ longlong Item_func_coalesce::int_op()
double Item_func_coalesce::real_op()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
null_value=0;
for (uint i=0 ; i < arg_count ; i++)
{
@@ -3470,7 +3472,7 @@ double Item_func_coalesce::real_op()
bool Item_func_coalesce::date_op(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
for (uint i= 0; i < arg_count; i++)
{
Datetime_truncation_not_needed dt(thd, args[i],
@@ -3484,7 +3486,7 @@ bool Item_func_coalesce::date_op(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzyd
bool Item_func_coalesce::time_op(THD *thd, MYSQL_TIME *ltime)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
for (uint i= 0; i < arg_count; i++)
{
if (!Time(thd, args[i]).copy_to_mysql_time(ltime))
@@ -3496,7 +3498,7 @@ bool Item_func_coalesce::time_op(THD *thd, MYSQL_TIME *ltime)
bool Item_func_coalesce::native_op(THD *thd, Native *to)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
for (uint i= 0; i < arg_count; i++)
{
if (!val_native_with_conversion_from_item(thd, args[i], to, type_handler()))
@@ -3508,7 +3510,7 @@ bool Item_func_coalesce::native_op(THD *thd, Native *to)
my_decimal *Item_func_coalesce::decimal_op(my_decimal *decimal_value)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
null_value= 0;
for (uint i= 0; i < arg_count; i++)
{
@@ -4680,7 +4682,7 @@ void Item_func_in::print(String *str, enum_query_type query_type)
longlong Item_func_in::val_int()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
if (array)
{
bool tmp=array->find(args[0]);
@@ -4837,7 +4839,7 @@ void Item_cond::copy_andor_arguments(THD *thd, Item_cond *item)
bool
Item_cond::fix_fields(THD *thd, Item **ref)
{
- DBUG_ASSERT(fixed == 0);
+ DBUG_ASSERT(fixed() == 0);
List_iterator<Item> li(list);
Item *item;
uchar buff[sizeof(char*)]; // Max local vars in function
@@ -4902,7 +4904,7 @@ Item_cond::fix_fields(THD *thd, Item **ref)
return TRUE; /* purecov: inspected */
item= *li.ref(); // item can be substituted in fix_fields
used_tables_cache|= item->used_tables();
- if (item->const_item() && !item->with_param &&
+ if (item->const_item() && !item->with_param() &&
!item->is_expensive() && !cond_has_datetime_is_null(item))
{
if (item->eval_const_cond() == is_and_cond && top_level())
@@ -4939,16 +4941,16 @@ Item_cond::fix_fields(THD *thd, Item **ref)
const_item_cache= FALSE;
}
- with_sum_func|= item->with_sum_func;
- with_param|= item->with_param;
- with_field|= item->with_field;
- with_subquery|= item->with_subquery;
- with_window_func|= item->with_window_func;
- maybe_null|= item->maybe_null;
+ flags|= (item->flags & (ITEM_FLAG_WITH_SUM_FUNC |
+ ITEM_FLAG_WITH_PARAM |
+ ITEM_FLAG_WITH_FIELD |
+ ITEM_FLAG_WITH_SUBQUERY |
+ ITEM_FLAG_WITH_WINDOW_FUNC |
+ ITEM_FLAG_MAYBE_NULL));
}
if (fix_length_and_dec())
return TRUE;
- fixed= 1;
+ flags|= ITEM_FLAG_FIXED;
return FALSE;
}
@@ -4964,7 +4966,7 @@ Item_cond::eval_not_null_tables(void *opt_arg)
while ((item=li++))
{
table_map tmp_table_map;
- if (item->const_item() && !item->with_param &&
+ if (item->const_item() && !item->with_param() &&
!item->is_expensive() && !cond_has_datetime_is_null(item))
{
if (item->eval_const_cond() == is_and_cond && top_level())
@@ -5420,7 +5422,7 @@ void Item_cond_and::mark_as_condition_AND_part(TABLE_LIST *embedding)
longlong Item_cond_and::val_int()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
List_iterator_fast<Item> li(list);
Item *item;
null_value= 0;
@@ -5438,7 +5440,7 @@ longlong Item_cond_and::val_int()
longlong Item_cond_or::val_int()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
List_iterator_fast<Item> li(list);
Item *item;
null_value=0;
@@ -5515,8 +5517,8 @@ bool Item_func_null_predicate::count_sargable_conds(void *arg)
longlong Item_func_isnull::val_int()
{
- DBUG_ASSERT(fixed == 1);
- if (const_item() && !args[0]->maybe_null)
+ DBUG_ASSERT(fixed());
+ if (const_item() && !args[0]->maybe_null())
return 0;
return args[0]->is_null() ? 1: 0;
}
@@ -5537,7 +5539,7 @@ bool Item_func_isnull::find_not_null_fields(table_map allowed)
void Item_func_isnull::print(String *str, enum_query_type query_type)
{
- if (const_item() && !args[0]->maybe_null &&
+ if (const_item() && !args[0]->maybe_null() &&
!(query_type & (QT_NO_DATA_EXPANSION | QT_VIEW_INTERNAL)))
str->append("/*always not null*/ 1");
else
@@ -5548,9 +5550,9 @@ void Item_func_isnull::print(String *str, enum_query_type query_type)
longlong Item_is_not_null_test::val_int()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
DBUG_ENTER("Item_is_not_null_test::val_int");
- if (const_item() && !args[0]->maybe_null)
+ if (const_item() && !args[0]->maybe_null())
DBUG_RETURN(1);
if (args[0]->is_null())
{
@@ -5567,7 +5569,7 @@ longlong Item_is_not_null_test::val_int()
*/
void Item_is_not_null_test::update_used_tables()
{
- if (!args[0]->maybe_null)
+ if (!args[0]->maybe_null())
used_tables_cache= 0; /* is always true */
else
args[0]->update_used_tables();
@@ -5576,7 +5578,7 @@ void Item_is_not_null_test::update_used_tables()
longlong Item_func_isnotnull::val_int()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
return args[0]->is_null() ? 0 : 1;
}
@@ -5615,7 +5617,7 @@ void Item_func_like::print(String *str, enum_query_type query_type)
longlong Item_func_like::val_int()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
DBUG_ASSERT(escape != -1);
String* res= args[0]->val_str(&cmp_value1);
if (args[0]->null_value)
@@ -5780,7 +5782,7 @@ bool fix_escape_item(THD *thd, Item *escape_item, String *tmp_str,
bool Item_func_like::fix_fields(THD *thd, Item **ref)
{
- DBUG_ASSERT(fixed == 0);
+ DBUG_ASSERT(fixed() == 0);
if (Item_bool_func2::fix_fields(thd, ref) ||
escape_item->fix_fields_if_needed_for_scalar(thd, &escape_item) ||
fix_escape_item(thd, escape_item, &cmp_value1, escape_used_in_parsing,
@@ -6094,14 +6096,14 @@ void Regexp_processor_pcre::fix_owner(Item_func *owner,
{
if (compile(pattern_arg, true))
{
- owner->maybe_null= 1; // Will always return NULL
+ owner->flags|= ITEM_FLAG_MAYBE_NULL; // Will always return NULL
return;
}
set_const(true);
- owner->maybe_null= subject_arg->maybe_null;
+ owner->flags|= subject_arg->flags & ITEM_FLAG_MAYBE_NULL;
}
else
- owner->maybe_null= 1;
+ owner->flags|= ITEM_FLAG_MAYBE_NULL;
}
@@ -6120,7 +6122,7 @@ Item_func_regex::fix_length_and_dec()
longlong Item_func_regex::val_int()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
if ((null_value= re.recompile(args[1])))
return 0;
@@ -6146,7 +6148,7 @@ Item_func_regexp_instr::fix_length_and_dec()
longlong Item_func_regexp_instr::val_int()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
if ((null_value= re.recompile(args[1])))
return 0;
@@ -6395,7 +6397,7 @@ bool Item_func_like::turboBM_matches(const char* text, int text_len) const
longlong Item_func_xor::val_int()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
int result= 0;
null_value= false;
for (uint i= 0; i < arg_count; i++)
@@ -7044,7 +7046,7 @@ void Item_equal::update_const(THD *thd)
bool Item_equal::fix_fields(THD *thd, Item **ref)
{
- DBUG_ASSERT(fixed == 0);
+ DBUG_ASSERT(fixed() == 0);
Item_equal_fields_iterator it(*this);
Item *item;
Field *first_equal_field= NULL;
@@ -7058,9 +7060,9 @@ bool Item_equal::fix_fields(THD *thd, Item **ref)
used_tables_cache|= item->used_tables();
tmp_table_map= item->not_null_tables();
not_null_tables_cache|= tmp_table_map;
- DBUG_ASSERT(!item->with_sum_func && !item->with_subquery);
- if (item->maybe_null)
- maybe_null= 1;
+ DBUG_ASSERT(!item->with_sum_func() && !item->with_subquery());
+ if (item->maybe_null())
+ flags|= ITEM_FLAG_MAYBE_NULL;
if (!item->get_item_equal())
item->set_item_equal(this);
if (link_equal_fields && item->real_item()->type() == FIELD_ITEM)
@@ -7077,7 +7079,7 @@ bool Item_equal::fix_fields(THD *thd, Item **ref)
last_equal_field->next_equal_field= first_equal_field;
if (fix_length_and_dec())
return TRUE;
- fixed= 1;
+ flags|= ITEM_FLAG_FIXED;
return FALSE;
}
diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h
index bddbe970207..33838d9f92c 100644
--- a/sql/item_cmpfunc.h
+++ b/sql/item_cmpfunc.h
@@ -366,7 +366,9 @@ public:
Item_in_optimizer(THD *thd, Item *a, Item *b):
Item_bool_func(thd, a, b), cache(0), expr_cache(0),
save_cache(0), result_for_null_param(UNKNOWN)
- { with_subquery= true; }
+ {
+ flags|= ITEM_FLAG_WITH_SUBQUERY;
+ }
bool fix_fields(THD *, Item **) override;
bool fix_left(THD *thd);
table_map not_null_tables() const override { return 0; }
@@ -914,7 +916,7 @@ public:
Item_func_opt_neg(thd, a, b, c) { }
longlong val_int()
{
- DBUG_ASSERT(fixed);
+ DBUG_ASSERT(fixed());
return m_comparator.type_handler()->Item_func_between_val_int(this);
}
enum Functype functype() const { return BETWEEN; }
@@ -1066,7 +1068,7 @@ protected:
{
Type_std_attributes::set(source);
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)
@@ -1123,7 +1125,7 @@ public:
IFNULL(inet6_not_null_expr, 'foo') -> INET6 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))
return TRUE;
return FALSE;
@@ -2403,7 +2405,7 @@ public:
DBUG_ASSERT(m_comparator.cmp_type() == ROW_RESULT);
return all_items_are_consts(args + 1, arg_count - 1) && // Bisection #2
((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()
{
@@ -2562,7 +2564,9 @@ public:
{ return args[0]->collation.collation; }
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;
}
bool count_sargable_conds(void *arg);
@@ -2596,7 +2600,7 @@ public:
/* Optimize case of not_null_column IS NULL */
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 */
const_item_cache= 1;
@@ -3457,7 +3461,10 @@ class Item_func_cursor_found: public Item_func_cursor_bool_attr
{
public:
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"; }
longlong val_int();
Item *get_copy(THD *thd)
@@ -3469,7 +3476,10 @@ class Item_func_cursor_notfound: public Item_func_cursor_bool_attr
{
public:
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"; }
longlong val_int();
Item *get_copy(THD *thd)
diff --git a/sql/item_create.cc b/sql/item_create.cc
index 264d11332d3..3a08add73b7 100644
--- a/sql/item_create.cc
+++ b/sql/item_create.cc
@@ -2387,7 +2387,7 @@ static bool has_named_parameters(List<Item> *params)
List_iterator<Item> it(*params);
while ((param= it++))
{
- if (! param->is_autogenerated_name)
+ if (! param->is_autogenerated_name())
return true;
}
}
@@ -2633,7 +2633,7 @@ Create_func_arg1::create_func(THD *thd, LEX_CSTRING *name, List<Item> *item_list
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);
return NULL;
@@ -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_2= item_list->pop();
- if (unlikely(!param_1->is_autogenerated_name ||
- !param_2->is_autogenerated_name))
+ if (unlikely(!param_1->is_autogenerated_name() ||
+ !param_2->is_autogenerated_name()))
{
my_error(ER_WRONG_PARAMETERS_TO_NATIVE_FCT, MYF(0), name->str);
return NULL;
@@ -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_3= item_list->pop();
- if (unlikely(!param_1->is_autogenerated_name ||
- !param_2->is_autogenerated_name ||
- !param_3->is_autogenerated_name))
+ if (unlikely(!param_1->is_autogenerated_name() ||
+ !param_2->is_autogenerated_name() ||
+ !param_3->is_autogenerated_name()))
{
my_error(ER_WRONG_PARAMETERS_TO_NATIVE_FCT, MYF(0), name->str);
return NULL;
diff --git a/sql/item_func.cc b/sql/item_func.cc
index 6acfdfc2749..f22544d8334 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -134,10 +134,10 @@ void Item_func::sync_with_sum_func_and_with_field(List<Item> &list)
Item *item;
while ((item= li++))
{
- with_sum_func|= item->with_sum_func;
- with_window_func|= item->with_window_func;
- with_field|= item->with_field;
- with_param|= item->with_param;
+ flags|= (item->flags & (ITEM_FLAG_WITH_SUM_FUNC |
+ ITEM_FLAG_WITH_WINDOW_FUNC |
+ ITEM_FLAG_WITH_FIELD |
+ ITEM_FLAG_WITH_PARAM));
}
}
@@ -297,7 +297,7 @@ bool Item_func::check_argument_types_scalar(uint start, uint end) const
Sets as a side effect the following class variables:
maybe_null Set if any argument may return NULL
with_sum_func Set if any of the arguments contains a sum function
- with_window_func Set if any of the arguments contain a window function
+ with_window_func() Set if any of the arguments contain a window function
with_field Set if any of the arguments contains or is a field
used_tables_cache Set to union of the tables used by arguments
@@ -318,7 +318,7 @@ bool Item_func::check_argument_types_scalar(uint start, uint end) const
bool
Item_func::fix_fields(THD *thd, Item **ref)
{
- DBUG_ASSERT(fixed == 0);
+ DBUG_ASSERT(fixed() == 0);
Item **arg,**arg_end;
uchar buff[STACK_BUFF_ALLOC]; // Max argument in function
@@ -353,12 +353,8 @@ Item_func::fix_fields(THD *thd, Item **ref)
return TRUE; /* purecov: inspected */
item= *arg;
- maybe_null |= item->maybe_null;
- with_sum_func |= item->with_sum_func;
- with_param |= item->with_param;
- with_window_func |= item->with_window_func;
- with_field |= item->with_field;
- with_subquery|= item->with_subquery;
+ flags|= item->flags & ~(ITEM_FLAG_IS_AUTOGENERATED_NAME |
+ ITEM_FLAG_IS_IN_WITH_CYCLE);
used_tables_and_const_cache_join(item);
not_null_tables_cache|= item->not_null_tables();
}
@@ -367,7 +363,7 @@ Item_func::fix_fields(THD *thd, Item **ref)
return true;
if (fix_length_and_dec())
return TRUE;
- fixed= 1;
+ flags|= ITEM_FLAG_FIXED;
return FALSE;
}
@@ -383,7 +379,7 @@ Item_func::quick_fix_field()
(*arg)->quick_fix_field();
}
}
- fixed= 1;
+ flags|= ITEM_FLAG_FIXED;
}
@@ -687,7 +683,7 @@ bool Item_hybrid_func::fix_attributes(Item **items, uint nitems)
String *Item_real_func::val_str(String *str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
double nr= val_real();
if (null_value)
return 0; /* purecov: inspected */
@@ -698,7 +694,7 @@ String *Item_real_func::val_str(String *str)
my_decimal *Item_real_func::val_decimal(my_decimal *decimal_value)
{
- DBUG_ASSERT(fixed);
+ DBUG_ASSERT(fixed());
double nr= val_real();
if (null_value)
return 0; /* purecov: inspected */
@@ -739,14 +735,14 @@ void Item_func::signal_divide_by_null()
Item *Item_func::get_tmp_table_item(THD *thd)
{
- if (!with_sum_func && !const_item())
+ if (!with_sum_func() && !const_item())
return new (thd->mem_root) Item_temptable_field(thd, result_field);
return copy_or_same(thd);
}
double Item_int_func::val_real()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
return unsigned_flag ? (double) ((ulonglong) val_int()) : (double) val_int();
}
@@ -754,7 +750,7 @@ double Item_int_func::val_real()
String *Item_int_func::val_str(String *str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
longlong nr=val_int();
if (null_value)
return 0;
@@ -1370,7 +1366,7 @@ my_decimal *Item_func_minus::decimal_op(my_decimal *decimal_value)
double Item_func_mul::real_op()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
double value= args[0]->val_real() * args[1]->val_real();
if ((null_value=args[0]->null_value || args[1]->null_value))
return 0.0;
@@ -1380,7 +1376,7 @@ double Item_func_mul::real_op()
longlong Item_func_mul::int_op()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
longlong a= args[0]->val_int();
longlong b= args[1]->val_int();
longlong res;
@@ -1502,7 +1498,7 @@ bool Item_func_mul::fix_length_and_dec(void)
double Item_func_div::real_op()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
double value= args[0]->val_real();
double val2= args[1]->val_real();
if ((null_value= args[0]->null_value || args[1]->null_value))
@@ -1590,7 +1586,7 @@ bool Item_func_div::fix_length_and_dec()
DBUG_ENTER("Item_func_div::fix_length_and_dec");
DBUG_PRINT("info", ("name %s", func_name()));
prec_increment= current_thd->variables.div_precincrement;
- maybe_null= 1; // division by zero
+ flags|= ITEM_FLAG_MAYBE_NULL; // division by zero
const Type_aggregator *aggregator= &type_handler_data->m_type_aggregator_for_div;
DBUG_EXECUTE_IF("num_op", aggregator= &type_handler_data->m_type_aggregator_non_commutative_test;);
@@ -1607,7 +1603,7 @@ bool Item_func_div::fix_length_and_dec()
/* Integer division */
longlong Item_func_int_div::val_int()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
/*
Perform division using DECIMAL math if either of the operands has a
@@ -1668,7 +1664,7 @@ bool Item_func_int_div::fix_length_and_dec()
uint32 prec= args[0]->decimal_int_part();
set_if_smaller(prec, MY_INT64_NUM_DECIMAL_DIGITS);
fix_char_length(prec);
- maybe_null=1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
unsigned_flag=args[0]->unsigned_flag | args[1]->unsigned_flag;
return false;
}
@@ -1676,7 +1672,7 @@ bool Item_func_int_div::fix_length_and_dec()
longlong Item_func_mod::int_op()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
Longlong_hybrid val0= args[0]->to_longlong_hybrid();
Longlong_hybrid val1= args[1]->to_longlong_hybrid();
@@ -1700,7 +1696,7 @@ longlong Item_func_mod::int_op()
double Item_func_mod::real_op()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
double value= args[0]->val_real();
double val2= args[1]->val_real();
if ((null_value= args[0]->null_value || args[1]->null_value))
@@ -1748,7 +1744,7 @@ bool Item_func_mod::fix_length_and_dec()
{
DBUG_ENTER("Item_func_mod::fix_length_and_dec");
DBUG_PRINT("info", ("name %s", func_name()));
- maybe_null= true; // division by zero
+ flags|= ITEM_FLAG_MAYBE_NULL; // division by zero
const Type_aggregator *aggregator= &type_handler_data->m_type_aggregator_for_mod;
DBUG_EXECUTE_IF("num_op", aggregator= &type_handler_data->m_type_aggregator_non_commutative_test;);
DBUG_ASSERT(!aggregator->is_commutative());
@@ -1983,7 +1979,7 @@ bool Item_func_abs::fix_length_and_dec()
/** Gateway to natural LOG function. */
double Item_func_ln::val_real()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
double value= args[0]->val_real();
if ((null_value= args[0]->null_value))
return 0.0;
@@ -2003,7 +1999,7 @@ double Item_func_ln::val_real()
*/
double Item_func_log::val_real()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
double value= args[0]->val_real();
if ((null_value= args[0]->null_value))
return 0.0;
@@ -2029,7 +2025,7 @@ double Item_func_log::val_real()
double Item_func_log2::val_real()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
double value= args[0]->val_real();
if ((null_value=args[0]->null_value))
@@ -2044,7 +2040,7 @@ double Item_func_log2::val_real()
double Item_func_log10::val_real()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
double value= args[0]->val_real();
if ((null_value= args[0]->null_value))
return 0.0;
@@ -2058,7 +2054,7 @@ double Item_func_log10::val_real()
double Item_func_exp::val_real()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
double value= args[0]->val_real();
if ((null_value=args[0]->null_value))
return 0.0; /* purecov: inspected */
@@ -2067,7 +2063,7 @@ double Item_func_exp::val_real()
double Item_func_sqrt::val_real()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
double value= args[0]->val_real();
if ((null_value=(args[0]->null_value || value < 0)))
return 0.0; /* purecov: inspected */
@@ -2076,7 +2072,7 @@ double Item_func_sqrt::val_real()
double Item_func_pow::val_real()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
double value= args[0]->val_real();
double val2= args[1]->val_real();
if ((null_value=(args[0]->null_value || args[1]->null_value)))
@@ -2088,7 +2084,7 @@ double Item_func_pow::val_real()
double Item_func_acos::val_real()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
/* One can use this to defer SELECT processing. */
DEBUG_SYNC(current_thd, "before_acos_function");
// the volatile's for BUG #2338 to calm optimizer down (because of gcc's bug)
@@ -2100,7 +2096,7 @@ double Item_func_acos::val_real()
double Item_func_asin::val_real()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
// the volatile's for BUG #2338 to calm optimizer down (because of gcc's bug)
volatile double value= args[0]->val_real();
if ((null_value=(args[0]->null_value || (value < -1.0 || value > 1.0))))
@@ -2110,7 +2106,7 @@ double Item_func_asin::val_real()
double Item_func_atan::val_real()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
double value= args[0]->val_real();
if ((null_value=args[0]->null_value))
return 0.0;
@@ -2126,7 +2122,7 @@ double Item_func_atan::val_real()
double Item_func_cos::val_real()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
double value= args[0]->val_real();
if ((null_value=args[0]->null_value))
return 0.0;
@@ -2135,7 +2131,7 @@ double Item_func_cos::val_real()
double Item_func_sin::val_real()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
double value= args[0]->val_real();
if ((null_value=args[0]->null_value))
return 0.0;
@@ -2144,7 +2140,7 @@ double Item_func_sin::val_real()
double Item_func_tan::val_real()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
double value= args[0]->val_real();
if ((null_value=args[0]->null_value))
return 0.0;
@@ -2154,7 +2150,7 @@ double Item_func_tan::val_real()
double Item_func_cot::val_real()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
double value= args[0]->val_real();
if ((null_value=args[0]->null_value))
return 0.0;
@@ -2205,7 +2201,7 @@ class Func_handler_shift_right_int_to_ulonglong:
public:
Longlong_null to_longlong_null(Item_handled_func *item) const
{
- DBUG_ASSERT(item->fixed == 1);
+ DBUG_ASSERT(item->fixed());
return item->arguments()[0]->to_longlong_null() >>
item->arguments()[1]->to_longlong_null();
}
@@ -2381,13 +2377,14 @@ my_decimal *Item_func_ceiling::decimal_op(my_decimal *decimal_value)
}
-bool Item_func_ceiling::date_op(THD *thd, MYSQL_TIME *to, date_mode_t fuzzydate)
+bool Item_func_ceiling::date_op(THD *thd, MYSQL_TIME *to,
+ date_mode_t fuzzydate)
{
Datetime::Options opt(thd, TIME_FRAC_TRUNCATE);
Datetime *tm= new (to) Datetime(thd, args[0], opt);
tm->ceiling(thd);
null_value= !tm->is_valid_datetime();
- DBUG_ASSERT(maybe_null || !null_value);
+ DBUG_ASSERT(maybe_null() || !null_value);
return null_value;
}
@@ -2398,7 +2395,7 @@ bool Item_func_ceiling::time_op(THD *thd, MYSQL_TIME *to)
Time *tm= new (to) Time(thd, args[0], opt);
tm->ceiling();
null_value= !tm->is_valid_time();
- DBUG_ASSERT(maybe_null || !null_value);
+ DBUG_ASSERT(maybe_null() || !null_value);
return null_value;
}
@@ -2450,7 +2447,7 @@ bool Item_func_floor::date_op(THD *thd, MYSQL_TIME *to, date_mode_t fuzzydate)
Datetime::Options opt(thd, TIME_FRAC_TRUNCATE);
Datetime *tm= new (to) Datetime(thd, args[0], opt, 0);
null_value= !tm->is_valid_datetime();
- DBUG_ASSERT(maybe_null || !null_value);
+ DBUG_ASSERT(maybe_null() || !null_value);
return null_value;
}
@@ -2461,7 +2458,7 @@ bool Item_func_floor::time_op(THD *thd, MYSQL_TIME *to)
Time *tm= new (to) Time(thd, args[0], opt);
tm->floor();
null_value= !tm->is_valid_time();
- DBUG_ASSERT(maybe_null || !null_value);
+ DBUG_ASSERT(maybe_null() || !null_value);
return null_value;
}
@@ -2556,7 +2553,7 @@ void Item_func_round::fix_arg_datetime()
return NULL.
*/
if (!truncate)
- maybe_null= true;
+ flags|= ITEM_FLAG_MAYBE_NULL;
fix_arg_temporal(&type_handler_datetime2, MAX_DATETIME_WIDTH);
}
@@ -2753,7 +2750,7 @@ bool Item_func_round::time_op(THD *thd, MYSQL_TIME *to)
Time *tm= new (to) Time(thd, args[0], opt,
dec.to_uint(TIME_SECOND_PART_DIGITS));
null_value= !tm->is_valid_time() || dec.is_null();
- DBUG_ASSERT(maybe_null || !null_value);
+ DBUG_ASSERT(maybe_null() || !null_value);
return null_value;
}
@@ -2767,7 +2764,7 @@ bool Item_func_round::date_op(THD *thd, MYSQL_TIME *to, date_mode_t fuzzydate)
Datetime *tm= new (to) Datetime(thd, args[0], opt,
dec.to_uint(TIME_SECOND_PART_DIGITS));
null_value= !tm->is_valid_datetime() || dec.is_null();
- DBUG_ASSERT(maybe_null || !null_value);
+ DBUG_ASSERT(maybe_null() || !null_value);
return null_value;
}
@@ -2844,7 +2841,7 @@ void Item_func_rand::update_used_tables()
double Item_func_rand::val_real()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
if (arg_count)
{
if (!args[0]->const_item())
@@ -2865,7 +2862,7 @@ double Item_func_rand::val_real()
longlong Item_func_sign::val_int()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
double value= args[0]->val_real();
null_value=args[0]->null_value;
return value < 0.0 ? -1 : (value > 0 ? 1 : 0);
@@ -2874,7 +2871,7 @@ longlong Item_func_sign::val_int()
double Item_func_units::val_real()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
double value= args[0]->val_real();
if ((null_value=args[0]->null_value))
return 0;
@@ -2909,7 +2906,7 @@ bool Item_func_min_max::get_date_native(THD *thd, MYSQL_TIME *ltime,
date_mode_t fuzzydate)
{
longlong UNINIT_VAR(min_max);
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
for (uint i=0; i < arg_count ; i++)
{
@@ -2935,7 +2932,7 @@ bool Item_func_min_max::get_date_native(THD *thd, MYSQL_TIME *ltime,
bool Item_func_min_max::get_time_native(THD *thd, MYSQL_TIME *ltime)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
Time value(thd, args[0], Time::Options(thd), decimals);
if (!value.is_valid_time())
@@ -3004,7 +3001,7 @@ double Item_func_min_max::val_real_native()
longlong Item_func_min_max::val_int_native()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
longlong value=0;
for (uint i=0; i < arg_count ; i++)
{
@@ -3025,7 +3022,7 @@ longlong Item_func_min_max::val_int_native()
my_decimal *Item_func_min_max::val_decimal_native(my_decimal *dec)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
my_decimal tmp_buf, *tmp, *UNINIT_VAR(res);
for (uint i=0; i < arg_count ; i++)
@@ -3059,7 +3056,7 @@ my_decimal *Item_func_min_max::val_decimal_native(my_decimal *dec)
bool Item_func_min_max::val_native(THD *thd, Native *native)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
const Type_handler *handler= Item_hybrid_func::type_handler();
NativeBuffer<STRING_BUFFER_USUAL_SIZE> cur;
for (uint i= 0; i < arg_count; i++)
@@ -3081,7 +3078,7 @@ bool Item_func_min_max::val_native(THD *thd, Native *native)
longlong Item_func_bit_length::val_int()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
String *res= args[0]->val_str(&value);
return (null_value= !res) ? 0 : (longlong) res->length() * 8;
}
@@ -3089,7 +3086,7 @@ longlong Item_func_bit_length::val_int()
longlong Item_func_octet_length::val_int()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
String *res=args[0]->val_str(&value);
if (!res)
{
@@ -3103,7 +3100,7 @@ longlong Item_func_octet_length::val_int()
longlong Item_func_char_length::val_int()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
String *res=args[0]->val_str(&value);
if (!res)
{
@@ -3117,7 +3114,7 @@ longlong Item_func_char_length::val_int()
longlong Item_func_coercibility::val_int()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
null_value= 0;
return (longlong) args[0]->collation.derivation;
}
@@ -3125,7 +3122,7 @@ longlong Item_func_coercibility::val_int()
longlong Item_func_locate::val_int()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
String *a=args[0]->val_str(&value1);
String *b=args[1]->val_str(&value2);
if (!a || !b)
@@ -3183,7 +3180,7 @@ void Item_func_locate::print(String *str, enum_query_type query_type)
longlong Item_func_field::val_int()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
if (cmp_type == STRING_RESULT)
{
@@ -3238,7 +3235,8 @@ longlong Item_func_field::val_int()
bool Item_func_field::fix_length_and_dec()
{
- maybe_null=0; max_length=3;
+ flags&= (item_flags_t) ~ITEM_FLAG_MAYBE_NULL;
+ max_length=3;
cmp_type= args[0]->result_type();
for (uint i=1; i < arg_count ; i++)
cmp_type= item_cmp_type(cmp_type, args[i]->result_type());
@@ -3250,7 +3248,7 @@ bool Item_func_field::fix_length_and_dec()
longlong Item_func_ascii::val_int()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
String *res=args[0]->val_str(&value);
if (!res)
{
@@ -3263,7 +3261,7 @@ longlong Item_func_ascii::val_int()
longlong Item_func_ord::val_int()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
String *res=args[0]->val_str(&value);
if (!res)
{
@@ -3320,7 +3318,7 @@ static const char separator=',';
longlong Item_func_find_in_set::val_int()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
if (enum_value)
{
// enum_value is set iff args[0]->const_item() in fix_length_and_dec().
@@ -3481,7 +3479,7 @@ udf_handler::fix_fields(THD *thd, Item_func_or_sum *func,
args=arguments;
/* Fix all arguments */
- func->maybe_null=0;
+ func->flags&= (Item::item_flags_t) ~ITEM_FLAG_MAYBE_NULL;
func->used_tables_and_const_cache_init();
if ((f_args.arg_count=arg_count))
@@ -3516,12 +3514,12 @@ udf_handler::fix_fields(THD *thd, Item_func_or_sum *func,
*/
if (item->collation.collation->state & MY_CS_BINSORT)
func->collation.set(&my_charset_bin);
- func->maybe_null |= item->maybe_null;
- func->with_sum_func |= item->with_sum_func;
- func->with_window_func |= item->with_window_func;
- func->with_field |= item->with_field;
- func->with_param |= item->with_param;
- func->with_subquery |= item->with_subquery;
+ func->flags|= (item->flags & (ITEM_FLAG_MAYBE_NULL |
+ ITEM_FLAG_WITH_SUM_FUNC |
+ ITEM_FLAG_WITH_WINDOW_FUNC |
+ ITEM_FLAG_WITH_FIELD |
+ ITEM_FLAG_WITH_PARAM |
+ ITEM_FLAG_WITH_SUBQUERY));
func->used_tables_and_const_cache_join(item);
f_args.arg_type[i]=item->result_type();
}
@@ -3542,7 +3540,7 @@ udf_handler::fix_fields(THD *thd, Item_func_or_sum *func,
if (func->fix_length_and_dec())
DBUG_RETURN(TRUE);
initid.max_length=func->max_length;
- initid.maybe_null=func->maybe_null;
+ initid.maybe_null=func->maybe_null();
initid.const_item=func->const_item_cache;
initid.decimals=func->decimals;
initid.ptr=0;
@@ -3562,7 +3560,7 @@ udf_handler::fix_fields(THD *thd, Item_func_or_sum *func,
f_args.args[i]= NULL; /* Non-const unless updated below. */
f_args.lengths[i]= arguments[i]->max_length;
- f_args.maybe_null[i]= (char) arguments[i]->maybe_null;
+ f_args.maybe_null[i]= (char) arguments[i]->maybe_null();
f_args.attributes[i]= arguments[i]->name.str;
f_args.attribute_lengths[i]= (ulong)arguments[i]->name.length;
@@ -3609,7 +3607,7 @@ udf_handler::fix_fields(THD *thd, Item_func_or_sum *func,
DBUG_RETURN(TRUE);
}
func->max_length=MY_MIN(initid.max_length,MAX_BLOB_WIDTH);
- func->maybe_null=initid.maybe_null;
+ func->set_maybe_null(initid.maybe_null);
/*
The above call for init() can reset initid.const_item to "false",
e.g. when the UDF function wants to be non-deterministic.
@@ -3778,7 +3776,7 @@ double Item_func_udf_float::val_real()
{
double res;
my_bool tmp_null_value;
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
DBUG_ENTER("Item_func_udf_float::val");
DBUG_PRINT("info",("result_type: %d arg_count: %d",
args[0]->result_type(), arg_count));
@@ -3790,7 +3788,7 @@ double Item_func_udf_float::val_real()
String *Item_func_udf_float::val_str(String *str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
double nr= val_real();
if (null_value)
return 0; /* purecov: inspected */
@@ -3803,7 +3801,7 @@ longlong Item_func_udf_int::val_int()
{
longlong res;
my_bool tmp_null_value;
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
DBUG_ENTER("Item_func_udf_int::val_int");
res= udf.val_int(&tmp_null_value);
null_value= tmp_null_value;
@@ -3813,7 +3811,7 @@ longlong Item_func_udf_int::val_int()
String *Item_func_udf_int::val_str(String *str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
longlong nr=val_int();
if (null_value)
return 0;
@@ -3826,7 +3824,7 @@ my_decimal *Item_func_udf_decimal::val_decimal(my_decimal *dec_buf)
{
my_decimal *res;
my_bool tmp_null_value;
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
DBUG_ENTER("Item_func_udf_decimal::val_decimal");
DBUG_PRINT("info",("result_type: %d arg_count: %d",
args[0]->result_type(), arg_count));
@@ -3850,7 +3848,7 @@ bool Item_func_udf_str::fix_length_and_dec()
String *Item_func_udf_str::val_str(String *str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
String *res=udf.val_str(str,&str_value);
null_value = !res;
return res;
@@ -3876,7 +3874,7 @@ bool udf_handler::get_arguments() { return 0; }
longlong Item_master_pos_wait::val_int()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
THD* thd = current_thd;
String *log_name = args[0]->val_str(&value);
int event_count= 0;
@@ -3938,7 +3936,7 @@ err:
longlong Item_master_gtid_wait::val_int()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
longlong result= 0;
String *gtid_pos __attribute__((unused)) = args[0]->val_str(&value);
DBUG_ENTER("Item_master_gtid_wait::val_int");
@@ -4201,7 +4199,7 @@ static int ull_name_ok(String *name)
longlong Item_func_get_lock::val_int()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
String *res= args[0]->val_str(&value);
double timeout= args[1]->val_real();
THD *thd= current_thd;
@@ -4308,7 +4306,7 @@ longlong Item_func_get_lock::val_int()
*/
longlong Item_func_release_all_locks::val_int()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
THD *thd= current_thd;
ulong num_unlocked= 0;
DBUG_ENTER("Item_func_release_all_locks::val_int");
@@ -4334,7 +4332,7 @@ longlong Item_func_release_all_locks::val_int()
longlong Item_func_release_lock::val_int()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
String *res= args[0]->val_str(&value);
THD *thd= current_thd;
DBUG_ENTER("Item_func_release_lock::val_int");
@@ -4383,7 +4381,7 @@ longlong Item_func_release_lock::val_int()
longlong Item_func_is_free_lock::val_int()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
String *res= args[0]->val_str(&value);
THD *thd= current_thd;
null_value= 1;
@@ -4401,7 +4399,7 @@ longlong Item_func_is_free_lock::val_int()
longlong Item_func_is_used_lock::val_int()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
String *res= args[0]->val_str(&value);
THD *thd= current_thd;
null_value= 1;
@@ -4423,7 +4421,7 @@ longlong Item_func_is_used_lock::val_int()
longlong Item_func_last_insert_id::val_int()
{
THD *thd= current_thd;
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
if (arg_count)
{
longlong value= args[0]->val_int();
@@ -4455,7 +4453,7 @@ bool Item_func_last_insert_id::fix_fields(THD *thd, Item **ref)
longlong Item_func_benchmark::val_int()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
char buff[MAX_FIELD_WIDTH];
String tmp(buff,sizeof(buff), &my_charset_bin);
my_decimal tmp_decimal;
@@ -4575,7 +4573,7 @@ longlong Item_func_sleep::val_int()
double timeout;
int error;
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
timeout= args[0]->val_real();
/*
@@ -4715,7 +4713,7 @@ end:
bool Item_func_set_user_var::fix_fields(THD *thd, Item **ref)
{
- DBUG_ASSERT(fixed == 0);
+ DBUG_ASSERT(fixed() == 0);
/* fix_fields will call Item_func_set_user_var::fix_length_and_dec */
if (Item_func::fix_fields(thd, ref) || set_entry(thd, TRUE))
return TRUE;
@@ -4791,7 +4789,7 @@ bool Item_func_set_user_var::fix_fields(THD *thd, Item **ref)
bool
Item_func_set_user_var::fix_length_and_dec()
{
- maybe_null=args[0]->maybe_null;
+ flags|= (args[0]->flags & ITEM_FLAG_MAYBE_NULL);
decimals=args[0]->decimals;
if (args[0]->collation.derivation == DERIVATION_NUMERIC)
{
@@ -5238,7 +5236,7 @@ Item_func_set_user_var::update()
double Item_func_set_user_var::val_real()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
check(0);
update(); // Store expression
return m_var_entry->val_real(&null_value);
@@ -5246,7 +5244,7 @@ double Item_func_set_user_var::val_real()
longlong Item_func_set_user_var::val_int()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
check(0);
update(); // Store expression
return m_var_entry->val_int(&null_value);
@@ -5254,7 +5252,7 @@ longlong Item_func_set_user_var::val_int()
String *Item_func_set_user_var::val_str(String *str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
check(0);
update(); // Store expression
return m_var_entry->val_str(&null_value, str, decimals);
@@ -5263,7 +5261,7 @@ String *Item_func_set_user_var::val_str(String *str)
my_decimal *Item_func_set_user_var::val_decimal(my_decimal *val)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
check(0);
update(); // Store expression
return m_var_entry->val_decimal(&null_value, val);
@@ -5272,7 +5270,7 @@ my_decimal *Item_func_set_user_var::val_decimal(my_decimal *val)
double Item_func_set_user_var::val_result()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
check(TRUE);
update(); // Store expression
return m_var_entry->val_real(&null_value);
@@ -5280,7 +5278,7 @@ double Item_func_set_user_var::val_result()
longlong Item_func_set_user_var::val_int_result()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
check(TRUE);
update(); // Store expression
return m_var_entry->val_int(&null_value);
@@ -5288,7 +5286,7 @@ longlong Item_func_set_user_var::val_int_result()
bool Item_func_set_user_var::val_bool_result()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
check(TRUE);
update(); // Store expression
return m_var_entry->val_int(&null_value) != 0;
@@ -5296,7 +5294,7 @@ bool Item_func_set_user_var::val_bool_result()
String *Item_func_set_user_var::str_result(String *str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
check(TRUE);
update(); // Store expression
return m_var_entry->val_str(&null_value, str, decimals);
@@ -5305,7 +5303,7 @@ String *Item_func_set_user_var::str_result(String *str)
my_decimal *Item_func_set_user_var::val_decimal_result(my_decimal *val)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
check(TRUE);
update(); // Store expression
return m_var_entry->val_decimal(&null_value, val);
@@ -5314,7 +5312,7 @@ my_decimal *Item_func_set_user_var::val_decimal_result(my_decimal *val)
bool Item_func_set_user_var::is_null_result()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
check(TRUE);
update(); // Store expression
return is_null();
@@ -5467,7 +5465,7 @@ int Item_func_set_user_var::save_in_field(Field *field, bool no_conversions,
String *
Item_func_get_user_var::val_str(String *str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
DBUG_ENTER("Item_func_get_user_var::val_str");
if (!m_var_entry)
DBUG_RETURN((String*) 0); // No such variable
@@ -5477,7 +5475,7 @@ Item_func_get_user_var::val_str(String *str)
double Item_func_get_user_var::val_real()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
if (!m_var_entry)
return 0.0; // No such variable
return (m_var_entry->val_real(&null_value));
@@ -5486,7 +5484,7 @@ double Item_func_get_user_var::val_real()
my_decimal *Item_func_get_user_var::val_decimal(my_decimal *dec)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
if (!m_var_entry)
return 0;
return m_var_entry->val_decimal(&null_value, dec);
@@ -5495,7 +5493,7 @@ my_decimal *Item_func_get_user_var::val_decimal(my_decimal *dec)
longlong Item_func_get_user_var::val_int()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
if (!m_var_entry)
return 0; // No such variable
return (m_var_entry->val_int(&null_value));
@@ -5648,7 +5646,7 @@ bool Item_func_get_user_var::fix_length_and_dec()
{
THD *thd=current_thd;
int error;
- maybe_null=1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
decimals=NOT_FIXED_DEC;
max_length=MAX_BLOB_WIDTH;
@@ -5858,7 +5856,7 @@ void Item_func_get_system_var::update_null_value()
bool Item_func_get_system_var::fix_length_and_dec()
{
char *cptr;
- maybe_null= TRUE;
+ flags|= ITEM_FLAG_MAYBE_NULL;
max_length= 0;
if (var->check_type(var_type))
@@ -6216,12 +6214,12 @@ bool Item_func_match::init_search(THD *thd, bool no_order)
bool Item_func_match::fix_fields(THD *thd, Item **ref)
{
- DBUG_ASSERT(fixed == 0);
+ DBUG_ASSERT(fixed() == 0);
Item *UNINIT_VAR(item); // Safe as arg_count is > 1
status_var_increment(thd->status_var.feature_fulltext);
- maybe_null=1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
join_key=0;
/*
@@ -6304,7 +6302,7 @@ bool Item_func_match::fix_index()
We will skip execution if the item is not fixed
with fix_field
*/
- if (!fixed)
+ if (!fixed())
return false;
if (key == NO_SUCH_KEY)
@@ -6316,7 +6314,8 @@ bool Item_func_match::fix_index()
for (keynr=0 ; keynr < table->s->keys ; keynr++)
{
if ((table->key_info[keynr].flags & HA_FULLTEXT) &&
- (match_flags & FT_BOOL ? table->keys_in_use_for_query.is_set(keynr) :
+ (match_flags & FT_BOOL ?
+ table->keys_in_use_for_query.is_set(keynr) :
table->s->usable_indexes(table->in_use).is_set(keynr)))
{
ft_to_key[fts]=keynr;
@@ -6407,7 +6406,7 @@ bool Item_func_match::eq(const Item *item, bool binary_cmp) const
double Item_func_match::val_real()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
DBUG_ENTER("Item_func_match::val");
if (ft_handler == NULL)
DBUG_RETURN(-1.0);
@@ -6543,7 +6542,7 @@ Item *get_system_var(THD *thd, enum_var_type var_type,
longlong Item_func_row_count::val_int()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
THD *thd= current_thd;
return thd->get_row_count_func();
@@ -6556,7 +6555,7 @@ Item_func_sp::Item_func_sp(THD *thd, Name_resolution_context *context_arg,
sp_name *name, const Sp_handler *sph):
Item_func(thd), Item_sp(thd, context_arg, name), m_handler(sph)
{
- maybe_null= 1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
}
@@ -6565,7 +6564,7 @@ Item_func_sp::Item_func_sp(THD *thd, Name_resolution_context *context_arg,
List<Item> &list):
Item_func(thd, list), Item_sp(thd, context_arg, name_arg), m_handler(sph)
{
- maybe_null= 1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
}
@@ -6621,7 +6620,7 @@ bool Item_func_sp::fix_length_and_dec()
Type_std_attributes::set(sp_result_field->type_std_attributes());
// There is a bug in the line below. See MDEV-11292 for details.
collation.derivation= DERIVATION_COERCIBLE;
- maybe_null= 1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
DBUG_RETURN(FALSE);
}
@@ -6663,14 +6662,14 @@ const Type_handler *Item_func_sp::type_handler() const
longlong Item_func_found_rows::val_int()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
return current_thd->found_rows();
}
longlong Item_func_oracle_sql_rowcount::val_int()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
THD *thd= current_thd;
/*
In case when a query like this:
@@ -6685,7 +6684,7 @@ longlong Item_func_oracle_sql_rowcount::val_int()
longlong Item_func_sqlcode::val_int()
{
- DBUG_ASSERT(fixed);
+ DBUG_ASSERT(fixed());
DBUG_ASSERT(!null_value);
Diagnostics_area::Sql_condition_iterator it=
current_thd->get_stmt_da()->sql_conditions();
@@ -6701,7 +6700,7 @@ Item_func_sp::fix_fields(THD *thd, Item **ref)
{
bool res;
DBUG_ENTER("Item_func_sp::fix_fields");
- DBUG_ASSERT(fixed == 0);
+ DBUG_ASSERT(fixed() == 0);
sp_head *sp= m_handler->sp_find_routine(thd, m_name, true);
/*
@@ -6753,7 +6752,7 @@ Item_func_sp::fix_fields(THD *thd, Item **ref)
to make m_sp and result_field members available to fix_length_and_dec(),
which is called from Item_func::fix_fields().
*/
- res= init_result_field(thd, max_length, maybe_null, &null_value, &name);
+ res= init_result_field(thd, max_length, maybe_null(), &null_value, &name);
if (res)
DBUG_RETURN(TRUE);
@@ -6886,7 +6885,7 @@ longlong Item_func_uuid_short::val_int()
void Item_func_last_value::evaluate_sideeffects()
{
- DBUG_ASSERT(fixed == 1 && arg_count > 0);
+ DBUG_ASSERT(fixed() && arg_count > 0);
for (uint i= 0; i < arg_count-1 ; i++)
args[i]->val_int();
}
@@ -6949,7 +6948,7 @@ bool Item_func_last_value::fix_length_and_dec()
{
last_value= args[arg_count -1];
Type_std_attributes::set(last_value);
- maybe_null= last_value->maybe_null;
+ set_maybe_null(last_value->maybe_null());
return FALSE;
}
diff --git a/sql/item_func.h b/sql/item_func.h
index 46e23170c71..7bef1f0d3dd 100644
--- a/sql/item_func.h
+++ b/sql/item_func.h
@@ -97,48 +97,45 @@ public:
virtual enum Functype functype() const { return UNKNOWN_FUNC; }
Item_func(THD *thd): Item_func_or_sum(thd)
{
- with_field= 0;
- with_param= 0;
+ flags&=(item_flags_t) ~(ITEM_FLAG_WITH_FIELD | ITEM_FLAG_WITH_FIELD);
}
Item_func(THD *thd, Item *a): Item_func_or_sum(thd, a)
{
- with_sum_func= a->with_sum_func;
- with_param= a->with_param;
- with_field= a->with_field;
+ copy_flags(a,
+ ITEM_FLAG_WITH_SUM_FUNC | ITEM_FLAG_WITH_FIELD |
+ ITEM_FLAG_WITH_PARAM);
}
Item_func(THD *thd, Item *a, Item *b):
Item_func_or_sum(thd, a, b)
{
- with_sum_func= a->with_sum_func || b->with_sum_func;
- with_param= a->with_param || b->with_param;
- with_field= a->with_field || b->with_field;
+ flags|= ((a->flags | b->flags) &
+ (ITEM_FLAG_WITH_SUM_FUNC |
+ ITEM_FLAG_WITH_PARAM |
+ ITEM_FLAG_WITH_FIELD));
}
Item_func(THD *thd, Item *a, Item *b, Item *c):
Item_func_or_sum(thd, a, b, c)
{
- with_sum_func= a->with_sum_func || b->with_sum_func || c->with_sum_func;
- with_field= a->with_field || b->with_field || c->with_field;
- with_param= a->with_param || b->with_param || c->with_param;
+ flags|= ((a->flags | b->flags | c->flags) &
+ (ITEM_FLAG_WITH_SUM_FUNC |
+ ITEM_FLAG_WITH_PARAM |
+ ITEM_FLAG_WITH_FIELD));
}
Item_func(THD *thd, Item *a, Item *b, Item *c, Item *d):
Item_func_or_sum(thd, a, b, c, d)
{
- with_sum_func= a->with_sum_func || b->with_sum_func ||
- c->with_sum_func || d->with_sum_func;
- with_field= a->with_field || b->with_field ||
- c->with_field || d->with_field;
- with_param= a->with_param || b->with_param ||
- c->with_param || d->with_param;
+ flags|= ((a->flags | b->flags | c->flags | d->flags) &
+ (ITEM_FLAG_WITH_SUM_FUNC |
+ ITEM_FLAG_WITH_PARAM |
+ ITEM_FLAG_WITH_FIELD));
}
Item_func(THD *thd, Item *a, Item *b, Item *c, Item *d, Item* e):
Item_func_or_sum(thd, a, b, c, d, e)
{
- with_sum_func= a->with_sum_func || b->with_sum_func ||
- c->with_sum_func || d->with_sum_func || e->with_sum_func;
- with_field= a->with_field || b->with_field ||
- c->with_field || d->with_field || e->with_field;
- with_param= a->with_param || b->with_param ||
- c->with_param || d->with_param || e->with_param;
+ flags|= ((a->flags | b->flags | c->flags | d->flags | e->flags) &
+ (ITEM_FLAG_WITH_SUM_FUNC |
+ ITEM_FLAG_WITH_PARAM |
+ ITEM_FLAG_WITH_FIELD));
}
Item_func(THD *thd, List<Item> &list):
Item_func_or_sum(thd, list)
@@ -204,7 +201,7 @@ public:
if (max_result_length >= MAX_BLOB_WIDTH)
{
max_length= MAX_BLOB_WIDTH;
- maybe_null= 1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
}
else
max_length= (uint32) max_result_length;
@@ -272,7 +269,7 @@ public:
bool has_timestamp_args()
{
- DBUG_ASSERT(fixed == TRUE);
+ DBUG_ASSERT(fixed());
for (uint i= 0; i < arg_count; i++)
{
if (args[i]->type() == Item::FIELD_ITEM &&
@@ -284,7 +281,7 @@ public:
bool has_date_args()
{
- DBUG_ASSERT(fixed == TRUE);
+ DBUG_ASSERT(fixed());
for (uint i= 0; i < arg_count; i++)
{
if (args[i]->type() == Item::FIELD_ITEM &&
@@ -297,7 +294,7 @@ public:
bool has_time_args()
{
- DBUG_ASSERT(fixed == TRUE);
+ DBUG_ASSERT(fixed());
for (uint i= 0; i < arg_count; i++)
{
if (args[i]->type() == Item::FIELD_ITEM &&
@@ -310,7 +307,7 @@ public:
bool has_datetime_args()
{
- DBUG_ASSERT(fixed == TRUE);
+ DBUG_ASSERT(fixed());
for (uint i= 0; i < arg_count; i++)
{
if (args[i]->type() == Item::FIELD_ITEM &&
@@ -418,7 +415,7 @@ public:
my_decimal *val_decimal(my_decimal *decimal_value);
longlong val_int()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
return Converter_double_to_longlong(val_real(), unsigned_flag).result();
}
bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate)
@@ -770,10 +767,10 @@ public:
}
Field *create_field_for_create_select(MEM_ROOT *root, TABLE *table)
{
- DBUG_ASSERT(fixed);
+ DBUG_ASSERT(fixed());
const Type_handler *h= m_func_handler->type_handler_for_create_select(this);
return h->make_and_init_table_field(root, &name,
- Record_addr(maybe_null),
+ Record_addr(maybe_null()),
*this, table);
}
String *val_str(String *to)
@@ -905,25 +902,25 @@ public:
double val_real()
{
- DBUG_ASSERT(fixed);
+ DBUG_ASSERT(fixed());
return Item_func_hybrid_field_type::type_handler()->
Item_func_hybrid_field_type_val_real(this);
}
longlong val_int()
{
- DBUG_ASSERT(fixed);
+ DBUG_ASSERT(fixed());
return Item_func_hybrid_field_type::type_handler()->
Item_func_hybrid_field_type_val_int(this);
}
my_decimal *val_decimal(my_decimal *dec)
{
- DBUG_ASSERT(fixed);
+ DBUG_ASSERT(fixed());
return Item_func_hybrid_field_type::type_handler()->
Item_func_hybrid_field_type_val_decimal(this, dec);
}
String *val_str(String*str)
{
- DBUG_ASSERT(fixed);
+ DBUG_ASSERT(fixed());
String *res= Item_func_hybrid_field_type::type_handler()->
Item_func_hybrid_field_type_val_str(this, str);
DBUG_ASSERT(null_value == (res == NULL));
@@ -931,14 +928,14 @@ public:
}
bool get_date(THD *thd, MYSQL_TIME *to, date_mode_t mode)
{
- DBUG_ASSERT(fixed);
+ DBUG_ASSERT(fixed());
return Item_func_hybrid_field_type::type_handler()->
Item_func_hybrid_field_type_get_date_with_warn(thd, this, to, mode);
}
bool val_native(THD *thd, Native *to)
{
- DBUG_ASSERT(fixed);
+ DBUG_ASSERT(fixed());
return native_op(thd, to);
}
@@ -1254,7 +1251,10 @@ class Item_func_cursor_rowcount: public Item_longlong_func,
{
public:
Item_func_cursor_rowcount(THD *thd, const LEX_CSTRING *name, uint offset)
- :Item_longlong_func(thd), Cursor_ref(name, offset) { maybe_null= true; }
+ :Item_longlong_func(thd), Cursor_ref(name, offset)
+ {
+ flags|= ITEM_FLAG_MAYBE_NULL;
+ }
const char *func_name() const { return "%ROWCOUNT"; }
longlong val_int();
bool check_vcol_func_processor(void *arg)
@@ -1280,7 +1280,7 @@ public:
const char *func_name() const { return "connection_id"; }
bool fix_length_and_dec();
bool fix_fields(THD *thd, Item **ref);
- longlong val_int() { DBUG_ASSERT(fixed == 1); return value; }
+ longlong val_int() { DBUG_ASSERT(fixed()); return value; }
bool check_vcol_func_processor(void *arg)
{
return mark_unsupported_function(func_name(), "()", arg, VCOL_SESSION_FUNC);
@@ -1431,7 +1431,10 @@ public:
}
bool need_parentheses_in_default() { return true; }
void print(String *str, enum_query_type query_type);
- void fix_length_and_dec_generic() { maybe_null= 1; }
+ void fix_length_and_dec_generic()
+ {
+ flags|= ITEM_FLAG_MAYBE_NULL;
+ }
};
@@ -1694,8 +1697,9 @@ class Item_dec_func :public Item_real_func
Item_dec_func(THD *thd, Item *a, Item *b): Item_real_func(thd, a, b) {}
bool fix_length_and_dec()
{
- decimals=NOT_FIXED_DEC; max_length=float_length(decimals);
- maybe_null=1;
+ decimals= NOT_FIXED_DEC;
+ max_length= float_length(decimals);
+ flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE;
}
};
@@ -1868,7 +1872,8 @@ public:
{
fix_attributes_datetime(0);
set_handler(&type_handler_datetime2);
- maybe_null= true; // E.g. CEILING(TIMESTAMP'0000-01-01 23:59:59.9')
+ // Thinks like CEILING(TIMESTAMP'0000-01-01 23:59:59.9') returns NULL
+ flags|= ITEM_FLAG_MAYBE_NULL;
}
bool fix_length_and_dec();
String *str_op(String *str) { DBUG_ASSERT(0); return 0; }
@@ -2059,31 +2064,31 @@ public:
double val_real()
{
- DBUG_ASSERT(fixed);
+ DBUG_ASSERT(fixed());
return Item_func_min_max::type_handler()->
Item_func_min_max_val_real(this);
}
longlong val_int()
{
- DBUG_ASSERT(fixed);
+ DBUG_ASSERT(fixed());
return Item_func_min_max::type_handler()->
Item_func_min_max_val_int(this);
}
String *val_str(String *str)
{
- DBUG_ASSERT(fixed);
+ DBUG_ASSERT(fixed());
return Item_func_min_max::type_handler()->
Item_func_min_max_val_str(this, str);
}
my_decimal *val_decimal(my_decimal *dec)
{
- DBUG_ASSERT(fixed);
+ DBUG_ASSERT(fixed());
return Item_func_min_max::type_handler()->
Item_func_min_max_val_decimal(this, dec);
}
bool get_date(THD *thd, MYSQL_TIME *res, date_mode_t fuzzydate)
{
- DBUG_ASSERT(fixed);
+ DBUG_ASSERT(fixed());
return Item_func_min_max::type_handler()->
Item_func_min_max_get_date(thd, this, res, fuzzydate);
}
@@ -2226,7 +2231,12 @@ public:
Item_func_coercibility(THD *thd, Item *a): Item_long_func(thd, a) {}
longlong val_int();
const char *func_name() const { return "coercibility"; }
- bool fix_length_and_dec() { max_length=10; maybe_null= 0; return FALSE; }
+ bool fix_length_and_dec()
+ {
+ max_length=10;
+ flags&= (item_flags_t) ~ITEM_FLAG_MAYBE_NULL;
+ return FALSE;
+ }
bool eval_not_null_tables(void *)
{
not_null_tables_cache= 0;
@@ -2484,7 +2494,12 @@ public:
{}
longlong val_int();
const char *func_name() const { return "benchmark"; }
- bool fix_length_and_dec() { max_length=1; maybe_null=0; return FALSE; }
+ bool fix_length_and_dec()
+ {
+ max_length=1;
+ flags&= (item_flags_t) ~ITEM_FLAG_MAYBE_NULL;
+ return FALSE;
+ }
virtual void print(String *str, enum_query_type query_type);
bool check_vcol_func_processor(void *arg)
{
@@ -2561,10 +2576,10 @@ public:
enum Functype functype() const { return UDF_FUNC; }
bool fix_fields(THD *thd, Item **ref)
{
- DBUG_ASSERT(fixed == 0);
+ DBUG_ASSERT(fixed() == 0);
bool res= udf.fix_fields(thd, this, arg_count, args);
set_non_deterministic_if_needed();
- fixed= 1;
+ flags|= ITEM_FLAG_FIXED;
return res;
}
void fix_num_length_and_dec();
@@ -2652,7 +2667,7 @@ class Item_func_udf_float :public Item_udf_func
Item_udf_func(thd, udf_arg, list) {}
longlong val_int()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
return Converter_double_to_longlong(Item_func_udf_float::val_real(),
unsigned_flag).result();
}
@@ -2774,7 +2789,7 @@ class Item_func_udf_float :public Item_real_func
Item_real_func(thd) {}
Item_func_udf_float(THD *thd, udf_func *udf_arg, List<Item> &list):
Item_real_func(thd, list) {}
- double val_real() { DBUG_ASSERT(fixed == 1); return 0.0; }
+ double val_real() { DBUG_ASSERT(fixed()); return 0.0; }
};
@@ -2786,7 +2801,7 @@ public:
Item_func_udf_int(THD *thd, udf_func *udf_arg, List<Item> &list):
Item_int_func(thd, list) {}
const Type_handler *type_handler() const { return &type_handler_slonglong; }
- longlong val_int() { DBUG_ASSERT(fixed == 1); return 0; }
+ longlong val_int() { DBUG_ASSERT(fixed()); return 0; }
};
@@ -2798,7 +2813,7 @@ public:
Item_func_udf_decimal(THD *thd, udf_func *udf_arg, List<Item> &list):
Item_int_func(thd, list) {}
const Type_handler *type_handler() const { return &type_handler_slonglong; }
- my_decimal *val_decimal(my_decimal *) { DBUG_ASSERT(fixed == 1); return 0; }
+ my_decimal *val_decimal(my_decimal *) { DBUG_ASSERT(fixed()); return 0; }
};
@@ -2810,10 +2825,10 @@ public:
Item_func_udf_str(THD *thd, udf_func *udf_arg, List<Item> &list):
Item_func(thd, list) {}
String *val_str(String *)
- { DBUG_ASSERT(fixed == 1); null_value=1; return 0; }
- double val_real() { DBUG_ASSERT(fixed == 1); null_value= 1; return 0.0; }
- longlong val_int() { DBUG_ASSERT(fixed == 1); null_value=1; return 0; }
- bool fix_length_and_dec() { maybe_null=1; max_length=0; return FALSE; }
+ { DBUG_ASSERT(fixed()); null_value=1; return 0; }
+ double val_real() { DBUG_ASSERT(fixed()); null_value= 1; return 0.0; }
+ longlong val_int() { DBUG_ASSERT(fixed()); null_value=1; return 0; }
+ bool fix_length_and_dec() { flags|= ITEM_FLAG_MAYBE_NULL; max_length=0; return FALSE; }
};
#endif /* HAVE_DLOPEN */
@@ -2853,7 +2868,12 @@ class Item_func_get_lock final :public Item_func_lock
Item_func_get_lock(THD *thd, Item *a, Item *b) :Item_func_lock(thd, a, b) {}
longlong val_int() final;
const char *func_name() const final { return "get_lock"; }
- bool fix_length_and_dec() { max_length= 1; maybe_null= 1; return FALSE; }
+ bool fix_length_and_dec()
+ {
+ max_length= 1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
+ return FALSE;
+ }
Item *get_copy(THD *thd) final
{ return get_item_copy<Item_func_get_lock>(thd, this); }
};
@@ -2880,7 +2900,12 @@ public:
Item_func_release_lock(THD *thd, Item *a): Item_func_lock(thd, a) {}
longlong val_int() final;
const char *func_name() const { return "release_lock"; }
- bool fix_length_and_dec() { max_length= 1; maybe_null= 1; return FALSE; }
+ bool fix_length_and_dec()
+ {
+ max_length= 1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
+ return FALSE;
+ }
Item *get_copy(THD *thd) final
{ return get_item_copy<Item_func_release_lock>(thd, this); }
};
@@ -2908,7 +2933,12 @@ public:
Item_longlong_func(thd, a, b, c, d) {}
longlong val_int();
const char *func_name() const { return "master_pos_wait"; }
- bool fix_length_and_dec() { max_length=21; maybe_null=1; return FALSE; }
+ bool fix_length_and_dec()
+ {
+ max_length=21;
+ flags|= ITEM_FLAG_MAYBE_NULL;
+ return FALSE;
+ }
bool check_vcol_func_processor(void *arg)
{
return mark_unsupported_function(func_name(), "()", arg, VCOL_IMPOSSIBLE);
@@ -2967,7 +2997,7 @@ public:
Field *create_tmp_field_ex(MEM_ROOT *root, TABLE *table, Tmp_field_src *src,
const Tmp_field_param *param)
{
- DBUG_ASSERT(fixed);
+ DBUG_ASSERT(fixed());
return create_tmp_field_ex_from_handler(root, table, src, param,
type_handler());
}
@@ -3273,7 +3303,7 @@ public:
bool fix_fields(THD *thd, Item **ref);
bool eq(const Item *, bool binary_cmp) const;
/* The following should be safe, even if we compare doubles */
- longlong val_int() { DBUG_ASSERT(fixed == 1); return val_real() != 0.0; }
+ longlong val_int() { DBUG_ASSERT(fixed()); return val_real() != 0.0; }
double val_real();
virtual void print(String *str, enum_query_type query_type);
@@ -3346,7 +3376,9 @@ public:
const char *func_name() const { return "is_free_lock"; }
bool fix_length_and_dec()
{
- decimals=0; max_length=1; maybe_null=1;
+ decimals=0;
+ max_length=1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE;
}
bool check_vcol_func_processor(void *arg)
@@ -3368,7 +3400,8 @@ public:
const char *func_name() const { return "is_used_lock"; }
bool fix_length_and_dec()
{
- decimals=0; max_length=10; maybe_null=1;
+ decimals=0; max_length=10;
+ flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE;
}
bool check_vcol_func_processor(void *arg)
@@ -3422,7 +3455,12 @@ public:
Item_func_row_count(THD *thd): Item_longlong_func(thd) {}
longlong val_int();
const char *func_name() const { return "row_count"; }
- bool fix_length_and_dec() { decimals= 0; maybe_null=0; return FALSE; }
+ bool fix_length_and_dec()
+ {
+ decimals= 0;
+ flags&= (item_flags_t) ~ITEM_FLAG_MAYBE_NULL;
+ return FALSE;
+ }
bool check_vcol_func_processor(void *arg)
{
return mark_unsupported_function(func_name(), "()", arg, VCOL_IMPOSSIBLE);
@@ -3587,7 +3625,12 @@ public:
Item_func_found_rows(THD *thd): Item_longlong_func(thd) {}
longlong val_int();
const char *func_name() const { return "found_rows"; }
- bool fix_length_and_dec() { decimals= 0; maybe_null=0; return FALSE; }
+ bool fix_length_and_dec()
+ {
+ decimals= 0;
+ flags&= (item_flags_t) ~ITEM_FLAG_MAYBE_NULL;
+ return FALSE;
+ }
bool check_vcol_func_processor(void *arg)
{
return mark_unsupported_function(func_name(), "()", arg, VCOL_IMPOSSIBLE);
@@ -3632,7 +3675,8 @@ public:
}
bool fix_length_and_dec()
{
- maybe_null= null_value= false;
+ flags&= (item_flags_t) ~ITEM_FLAG_MAYBE_NULL;
+ null_value= false;
max_length= 11;
return FALSE;
}
@@ -3691,7 +3735,7 @@ public:
void update_used_tables()
{
Item_func::update_used_tables();
- maybe_null= last_value->maybe_null;
+ copy_flags(last_value, ITEM_FLAG_MAYBE_NULL);
}
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_last_value>(thd, this); }
@@ -3714,7 +3758,7 @@ public:
{
unsigned_flag= 0;
max_length= MAX_BIGINT_WIDTH;
- maybe_null= 1; /* In case of errors */
+ flags|= ITEM_FLAG_MAYBE_NULL; /* In case of errors */
return FALSE;
}
/*
diff --git a/sql/item_geofunc.cc b/sql/item_geofunc.cc
index 9c776baa2fd..4c6b7417055 100644
--- a/sql/item_geofunc.cc
+++ b/sql/item_geofunc.cc
@@ -47,14 +47,14 @@ bool Item_geometry_func::fix_length_and_dec()
collation.set(&my_charset_bin);
decimals=0;
max_length= (uint32) UINT_MAX32;
- maybe_null= 1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE;
}
String *Item_func_geometry_from_text::val_str(String *str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
Geometry_buffer buffer;
String arg_val;
String *wkt= args[0]->val_str_ascii(&arg_val);
@@ -81,7 +81,7 @@ String *Item_func_geometry_from_text::val_str(String *str)
String *Item_func_geometry_from_wkb::val_str(String *str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
String arg_val;
String *wkb;
Geometry_buffer buffer;
@@ -117,7 +117,7 @@ String *Item_func_geometry_from_wkb::val_str(String *str)
String *Item_func_geometry_from_json::val_str(String *str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
Geometry_buffer buffer;
String *js= args[0]->val_str_ascii(&tmp_js);
uint32 srid= 0;
@@ -193,7 +193,7 @@ String *Item_func_geometry_from_json::val_str(String *str)
String *Item_func_as_wkt::val_str_ascii(String *str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
String arg_val;
String *swkb= args[0]->val_str(&arg_val);
Geometry_buffer buffer;
@@ -218,14 +218,14 @@ bool Item_func_as_wkt::fix_length_and_dec()
{
collation.set(default_charset(), DERIVATION_COERCIBLE, MY_REPERTOIRE_ASCII);
max_length= (uint32) UINT_MAX32;
- maybe_null= 1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE;
}
String *Item_func_as_wkb::val_str(String *str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
String arg_val;
String *swkb= args[0]->val_str(&arg_val);
Geometry_buffer buffer;
@@ -245,14 +245,14 @@ bool Item_func_as_geojson::fix_length_and_dec()
{
collation.set(default_charset(), DERIVATION_COERCIBLE, MY_REPERTOIRE_ASCII);
max_length=MAX_BLOB_WIDTH;
- maybe_null= 1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE;
}
String *Item_func_as_geojson::val_str_ascii(String *str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
String arg_val;
String *swkb= args[0]->val_str(&arg_val);
uint max_dec= FLOATING_POINT_DECIMALS;
@@ -306,7 +306,7 @@ error:
String *Item_func_geometry_type::val_str_ascii(String *str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
String *swkb= args[0]->val_str(str);
Geometry_buffer buffer;
Geometry *geom= NULL;
@@ -325,7 +325,7 @@ String *Item_func_geometry_type::val_str_ascii(String *str)
String *Item_func_envelope::val_str(String *str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
String arg_val;
String *swkb= args[0]->val_str(&arg_val);
Geometry_buffer buffer;
@@ -437,7 +437,7 @@ int Item_func_boundary::Transporter::start_collection(int n_objects)
String *Item_func_boundary::val_str(String *str_value)
{
DBUG_ENTER("Item_func_boundary::val_str");
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
String arg_val;
String *swkb= args[0]->val_str(&arg_val);
@@ -475,7 +475,7 @@ mem_error:
String *Item_func_centroid::val_str(String *str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
String arg_val;
String *swkb= args[0]->val_str(&arg_val);
Geometry_buffer buffer;
@@ -536,7 +536,7 @@ String *Item_func_convexhull::val_str(String *str_value)
Gcalc_heap::Info *cur_pi;
DBUG_ENTER("Item_func_convexhull::val_str");
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
String *swkb= args[0]->val_str(&tmp_value);
if ((null_value=
@@ -645,7 +645,7 @@ String *Item_func_convexhull::val_str(String *str_value)
ch_node *left_first, *left_cur, *right_first, *right_cur;
DBUG_ENTER("Item_func_convexhull::val_str");
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
String *swkb= args[0]->val_str(&tmp_value);
if ((null_value=
@@ -786,7 +786,7 @@ mem_error:
String *Item_func_spatial_decomp::val_str(String *str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
String arg_val;
String *swkb= args[0]->val_str(&arg_val);
Geometry_buffer buffer;
@@ -833,7 +833,7 @@ err:
String *Item_func_spatial_decomp_n::val_str(String *str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
String arg_val;
String *swkb= args[0]->val_str(&arg_val);
long n= (long) args[1]->val_int();
@@ -892,7 +892,7 @@ err:
String *Item_func_point::val_str(String *str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
double x= args[0]->val_real();
double y= args[1]->val_real();
uint32 srid= 0;
@@ -925,7 +925,7 @@ String *Item_func_point::val_str(String *str)
String *Item_func_spatial_collection::val_str(String *str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
String arg_value;
uint i;
uint32 srid= 0;
@@ -1155,7 +1155,7 @@ const char *Item_func_spatial_mbr_rel::func_name() const
longlong Item_func_spatial_mbr_rel::val_int()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
String *res1= args[0]->val_str(&tmp_value1);
String *res2= args[1]->val_str(&tmp_value2);
Geometry_buffer buffer1, buffer2;
@@ -1364,7 +1364,7 @@ public:
longlong Item_func_spatial_relate::val_int()
{
DBUG_ENTER("Item_func_spatial_relate::val_int");
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
Geometry_ptr_with_buffer_and_mbr g1, g2;
int result= 0;
@@ -1401,7 +1401,7 @@ exit:
longlong Item_func_spatial_precise_rel::val_int()
{
DBUG_ENTER("Item_func_spatial_precise_rel::val_int");
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
Geometry_ptr_with_buffer_and_mbr g1, g2;
int result= 0;
uint shape_a, shape_b;
@@ -1538,7 +1538,7 @@ Item_func_spatial_operation::~Item_func_spatial_operation()
String *Item_func_spatial_operation::val_str(String *str_value)
{
DBUG_ENTER("Item_func_spatial_operation::val_str");
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
Geometry_ptr_with_buffer_and_mbr g1, g2;
uint32 srid= 0;
Gcalc_operation_transporter trn(&func, &collector);
@@ -1990,7 +1990,7 @@ int Item_func_buffer::Transporter::complete_ring()
String *Item_func_buffer::val_str(String *str_value)
{
DBUG_ENTER("Item_func_buffer::val_str");
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
String *obj= args[0]->val_str(str_value);
double dist= args[1]->val_real();
Geometry_buffer buffer;
@@ -2065,7 +2065,7 @@ mem_error:
longlong Item_func_isempty::val_int()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
String tmp;
String *swkb= args[0]->val_str(&tmp);
Geometry_buffer buffer;
@@ -2087,7 +2087,7 @@ longlong Item_func_issimple::val_int()
const char *c_end;
DBUG_ENTER("Item_func_issimple::val_int");
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
null_value= 0;
if ((args[0]->null_value ||
@@ -2150,7 +2150,7 @@ mem_error:
longlong Item_func_isclosed::val_int()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
String tmp;
String *swkb= args[0]->val_str(&tmp);
Geometry_buffer buffer;
@@ -2174,7 +2174,7 @@ longlong Item_func_isclosed::val_int()
longlong Item_func_isring::val_int()
{
/* It's actually a combination of two functions - IsClosed and IsSimple */
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
String tmp;
String *swkb= args[0]->val_str(&tmp);
Geometry_buffer buffer;
@@ -2205,7 +2205,7 @@ longlong Item_func_isring::val_int()
longlong Item_func_dimension::val_int()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
uint32 dim= 0; // In case of error
String *swkb= args[0]->val_str(&value);
Geometry_buffer buffer;
@@ -2222,7 +2222,7 @@ longlong Item_func_dimension::val_int()
longlong Item_func_numinteriorring::val_int()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
uint32 num= 0; // In case of error
String *swkb= args[0]->val_str(&value);
Geometry_buffer buffer;
@@ -2238,7 +2238,7 @@ longlong Item_func_numinteriorring::val_int()
longlong Item_func_numgeometries::val_int()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
uint32 num= 0; // In case of errors
String *swkb= args[0]->val_str(&value);
Geometry_buffer buffer;
@@ -2254,7 +2254,7 @@ longlong Item_func_numgeometries::val_int()
longlong Item_func_numpoints::val_int()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
uint32 num= 0; // In case of errors
String *swkb= args[0]->val_str(&value);
Geometry_buffer buffer;
@@ -2271,7 +2271,7 @@ longlong Item_func_numpoints::val_int()
double Item_func_x::val_real()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
double res= 0.0; // In case of errors
String *swkb= args[0]->val_str(&value);
Geometry_buffer buffer;
@@ -2287,7 +2287,7 @@ double Item_func_x::val_real()
double Item_func_y::val_real()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
double res= 0; // In case of errors
String *swkb= args[0]->val_str(&value);
Geometry_buffer buffer;
@@ -2303,7 +2303,7 @@ double Item_func_y::val_real()
double Item_func_area::val_real()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
double res= 0; // In case of errors
String *swkb= args[0]->val_str(&value);
Geometry_buffer buffer;
@@ -2319,7 +2319,7 @@ double Item_func_area::val_real()
double Item_func_glength::val_real()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
double res= 0; // In case of errors
String *swkb= args[0]->val_str(&value);
Geometry_buffer buffer;
@@ -2336,7 +2336,7 @@ double Item_func_glength::val_real()
longlong Item_func_srid::val_int()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
String *swkb= args[0]->val_str(&value);
Geometry_buffer buffer;
@@ -2363,7 +2363,7 @@ double Item_func_distance::val_real()
Gcalc_operation_transporter trn(&func, &collector);
DBUG_ENTER("Item_func_distance::val_real");
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
String *res1= args[0]->val_str(&tmp_value1);
String *res2= args[1]->val_str(&tmp_value2);
Geometry_buffer buffer1, buffer2;
@@ -2660,9 +2660,6 @@ double Item_func_sphere_distance::spherical_distance_points(Geometry *g1,
String *Item_func_pointonsurface::val_str(String *str)
{
Gcalc_operation_transporter trn(&func, &collector);
-
- DBUG_ENTER("Item_func_pointonsurface::val_str");
- DBUG_ASSERT(fixed == 1);
String *res= args[0]->val_str(&tmp_value);
Geometry_buffer buffer;
Geometry *g;
@@ -2672,6 +2669,8 @@ String *Item_func_pointonsurface::val_str(String *str)
String *result= 0;
const Gcalc_scan_iterator::point *pprev= NULL;
uint32 srid;
+ DBUG_ENTER("Item_func_pointonsurface::val_str");
+ DBUG_ASSERT(fixed());
null_value= 1;
if ((args[0]->null_value ||
diff --git a/sql/item_geofunc.h b/sql/item_geofunc.h
index f50bb6316d7..d351b66ff50 100644
--- a/sql/item_geofunc.h
+++ b/sql/item_geofunc.h
@@ -284,7 +284,7 @@ public:
collation.set(&my_charset_bin);
decimals=0;
max_length= (uint32) UINT_MAX32;
- maybe_null= 1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE;
}
Item *get_copy(THD *thd)
@@ -326,7 +326,7 @@ public:
{
// "GeometryCollection" is the longest
fix_length_and_charset(20, default_charset());
- maybe_null= 1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE;
};
Item *get_copy(THD *thd)
@@ -675,7 +675,7 @@ public:
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)
{
- maybe_null= true;
+ flags|= ITEM_FLAG_MAYBE_NULL;
}
enum Functype functype() const { return spatial_rel; }
enum Functype rev_functype() const
@@ -856,7 +856,7 @@ public:
:Item_bool_func_args_geometry(thd, a) {}
longlong val_int();
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; }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_isempty>(thd, this); }
@@ -909,7 +909,7 @@ public:
:Item_long_func_args_geometry(thd, a) {}
longlong val_int();
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)
{ return get_item_copy<Item_func_dimension>(thd, this); }
};
@@ -925,7 +925,7 @@ public:
{
if (Item_real_func::fix_length_and_dec())
return TRUE;
- maybe_null= 1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE;
}
Item *get_copy(THD *thd)
@@ -943,7 +943,7 @@ public:
{
if (Item_real_func::fix_length_and_dec())
return TRUE;
- maybe_null= 1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE;
}
Item *get_copy(THD *thd)
@@ -958,7 +958,7 @@ public:
:Item_long_func_args_geometry(thd, a) {}
longlong val_int();
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)
{ return get_item_copy<Item_func_numgeometries>(thd, this); }
};
@@ -971,7 +971,7 @@ public:
:Item_long_func_args_geometry(thd, a) {}
longlong val_int();
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)
{ return get_item_copy<Item_func_numinteriorring>(thd, this); }
};
@@ -984,7 +984,7 @@ public:
:Item_long_func_args_geometry(thd, a) {}
longlong val_int();
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)
{ return get_item_copy<Item_func_numpoints>(thd, this); }
};
@@ -1000,7 +1000,7 @@ public:
{
if (Item_real_func::fix_length_and_dec())
return TRUE;
- maybe_null= 1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE;
}
Item *get_copy(THD *thd)
@@ -1020,7 +1020,7 @@ public:
{
if (Item_real_func::fix_length_and_dec())
return TRUE;
- maybe_null= 1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE;
}
Item *get_copy(THD *thd)
@@ -1035,7 +1035,7 @@ public:
:Item_long_func_args_geometry(thd, a) {}
longlong val_int();
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)
{ return get_item_copy<Item_func_srid>(thd, this); }
};
diff --git a/sql/item_jsonfunc.cc b/sql/item_jsonfunc.cc
index 4d7cd4bba50..41bcc98df2d 100644
--- a/sql/item_jsonfunc.cc
+++ b/sql/item_jsonfunc.cc
@@ -397,7 +397,7 @@ bool Item_func_json_exists::fix_length_and_dec()
{
if (Item_bool_func::fix_length_and_dec())
return TRUE;
- maybe_null= 1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
path.set_constant_flag(args[1]->const_item());
return FALSE;
}
@@ -451,7 +451,7 @@ bool Item_func_json_value::fix_length_and_dec()
collation.set(args[0]->collation);
max_length= args[0]->max_length;
set_constant_flag(args[1]->const_item());
- maybe_null= 1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE;
}
@@ -461,7 +461,7 @@ bool Item_func_json_query::fix_length_and_dec()
collation.set(args[0]->collation);
max_length= args[0]->max_length;
set_constant_flag(args[1]->const_item());
- maybe_null= 1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE;
}
@@ -609,7 +609,7 @@ bool Item_func_json_unquote::fix_length_and_dec()
collation.set(&my_charset_utf8mb3_general_ci,
DERIVATION_COERCIBLE, MY_REPERTOIRE_ASCII);
max_length= args[0]->max_length;
- maybe_null= 1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE;
}
@@ -730,7 +730,7 @@ bool Item_func_json_extract::fix_length_and_dec()
max_length= args[0]->max_length * (arg_count - 1);
mark_constant_paths(paths, args+1, arg_count-1);
- maybe_null= 1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE;
}
@@ -1000,7 +1000,7 @@ bool Item_func_json_contains::fix_length_and_dec()
{
a2_constant= args[1]->const_item();
a2_parsed= FALSE;
- maybe_null= 1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
if (arg_count > 2)
path.set_constant_flag(args[2]->const_item());
return Item_bool_func::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_parsed= FALSE;
- maybe_null= 1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
mark_constant_paths(paths, args+2, arg_count-2);
return Item_bool_func::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)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
uint n_arg;
str->length(0);
@@ -1642,7 +1642,7 @@ bool Item_func_json_array_append::fix_length_and_dec()
}
fix_char_length_ulonglong(char_length);
- maybe_null= 1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE;
}
@@ -1655,7 +1655,7 @@ String *Item_func_json_array_append::val_str(String *str)
size_t str_rest_len;
const uchar *ar_end;
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
if ((null_value= args[0]->null_value))
return 0;
@@ -1783,7 +1783,7 @@ String *Item_func_json_array_insert::val_str(String *str)
String *js= args[0]->val_json(&tmp_js);
uint n_arg, n_path;
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
if ((null_value= args[0]->null_value))
return 0;
@@ -1919,7 +1919,7 @@ return_null:
String *Item_func_json_object::val_str(String *str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
uint n_arg;
str->length(0);
@@ -2167,7 +2167,7 @@ continue_j2:
String *Item_func_json_merge::val_str(String *str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
json_engine_t je1, je2;
String *js1= args[0]->val_json(&tmp_js1), *js2=NULL;
uint n_arg;
@@ -2468,7 +2468,7 @@ continue_j2:
String *Item_func_json_merge_patch::val_str(String *str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
json_engine_t je1, je2;
String *js1= args[0]->val_json(&tmp_js1), *js2=NULL;
uint n_arg;
@@ -2561,7 +2561,7 @@ bool Item_func_json_length::fix_length_and_dec()
{
if (arg_count > 1)
path.set_constant_flag(args[1]->const_item());
- maybe_null= 1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
max_length= 10;
return FALSE;
}
@@ -2707,7 +2707,7 @@ bool Item_func_json_type::fix_length_and_dec()
{
collation.set(&my_charset_utf8mb3_general_ci);
max_length= 12;
- maybe_null= 1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE;
}
@@ -2776,7 +2776,7 @@ bool Item_func_json_insert::fix_length_and_dec()
}
fix_char_length_ulonglong(char_length);
- maybe_null= 1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE;
}
@@ -2788,7 +2788,7 @@ String *Item_func_json_insert::val_str(String *str)
uint n_arg, n_path;
json_string_t key_name;
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
if ((null_value= args[0]->null_value))
return 0;
@@ -3028,7 +3028,7 @@ bool Item_func_json_remove::fix_length_and_dec()
max_length= args[0]->max_length;
mark_constant_paths(paths, args+1, arg_count-1);
- maybe_null= 1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE;
}
@@ -3040,7 +3040,7 @@ String *Item_func_json_remove::val_str(String *str)
uint n_arg, n_path;
json_string_t key_name;
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
if (args[0]->null_value)
goto null_return;
@@ -3213,7 +3213,7 @@ bool Item_func_json_keys::fix_length_and_dec()
{
collation.set(args[0]->collation);
max_length= args[0]->max_length;
- maybe_null= 1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
if (arg_count > 1)
path.set_constant_flag(args[1]->const_item());
return FALSE;
@@ -3398,7 +3398,7 @@ bool Item_func_json_search::fix_length_and_dec()
if (arg_count > 4)
mark_constant_paths(paths, args+4, arg_count-4);
- maybe_null= 1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE;
}
@@ -3581,7 +3581,7 @@ bool Item_func_json_format::fix_length_and_dec()
{
decimals= 0;
max_length= args[0]->max_length;
- maybe_null= 1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE;
}
@@ -3782,14 +3782,14 @@ bool
Item_func_json_objectagg::fix_fields(THD *thd, Item **ref)
{
uint i; /* for loop variable */
- DBUG_ASSERT(fixed == 0);
+ DBUG_ASSERT(fixed() == 0);
memcpy(orig_args, args, sizeof(Item*) * arg_count);
if (init_sum_func_check(thd))
return TRUE;
- maybe_null= 1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
/*
Fix fields for select list and ORDER clause
@@ -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]))
return TRUE;
- with_subquery|= args[i]->with_subquery;
- with_param|= args[i]->with_param;
- with_window_func|= args[i]->with_window_func;
+ flags|= (args[i]->flags & (ITEM_FLAG_WITH_SUBQUERY |
+ ITEM_FLAG_WITH_PARAM |
+ ITEM_FLAG_WITH_WINDOW_FUNC));
}
/* skip charset aggregation for order columns */
@@ -3818,7 +3818,7 @@ Item_func_json_objectagg::fix_fields(THD *thd, Item **ref)
if (check_sum_func(thd, ref))
return TRUE;
- fixed= 1;
+ flags|= ITEM_FLAG_FIXED;
return FALSE;
}
@@ -3872,7 +3872,7 @@ bool Item_func_json_objectagg::add()
String* Item_func_json_objectagg::val_str(String* str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
if (null_value)
return 0;
diff --git a/sql/item_jsonfunc.h b/sql/item_jsonfunc.h
index 519bad3f6f3..af4221f0305 100644
--- a/sql/item_jsonfunc.h
+++ b/sql/item_jsonfunc.h
@@ -88,7 +88,7 @@ public:
{
if (Item_bool_func::fix_length_and_dec())
return TRUE;
- maybe_null= 1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE;
}
bool set_format_by_check_constraint(Send_field_extended_metadata *to) const
diff --git a/sql/item_row.cc b/sql/item_row.cc
index 4532b7575f2..5cbd2d4caa9 100644
--- a/sql/item_row.cc
+++ b/sql/item_row.cc
@@ -36,9 +36,10 @@ void Item_row::illegal_method_call(const char *method)
bool Item_row::fix_fields(THD *thd, Item **ref)
{
- DBUG_ASSERT(fixed == 0);
+ DBUG_ASSERT(fixed() == 0);
null_value= 0;
- maybe_null= 0;
+ flags&= (item_flags_t) ~ITEM_FLAG_MAYBE_NULL;
+
Item **arg, **arg_end;
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)
with_null|= 1;
}
}
- maybe_null|= item->maybe_null;
- with_sum_func= with_sum_func || item->with_sum_func;
- with_window_func = with_window_func || item->with_window_func;
- with_field= with_field || item->with_field;
- with_subquery|= item->with_subquery;
- with_param|= item->with_param;
+ flags|= (item->flags & (ITEM_FLAG_MAYBE_NULL |
+ ITEM_FLAG_WITH_SUM_FUNC |
+ ITEM_FLAG_WITH_WINDOW_FUNC |
+ ITEM_FLAG_WITH_FIELD |
+ ITEM_FLAG_WITH_SUBQUERY |
+ ITEM_FLAG_WITH_PARAM));
}
- fixed= 1;
+ flags|= ITEM_FLAG_FIXED;
return FALSE;
}
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index 5b4a7989f63..d4b6e28d96f 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -91,7 +91,7 @@ static uint32 max_length_for_string(Item *item)
*/
String *Item_func::val_str_from_val_str_ascii(String *str, String *ascii_buffer)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
if (!(collation.collation->state & MY_CS_NONASCII))
{
@@ -124,14 +124,14 @@ bool Item_str_func::fix_fields(THD *thd, Item **ref)
In Item_str_func::check_well_formed_result() we may set null_value
flag on the same condition as in test() below.
*/
- maybe_null= maybe_null || thd->is_strict_mode();
+ flags|= thd->is_strict_mode() ? ITEM_FLAG_MAYBE_NULL : 0;
return res;
}
my_decimal *Item_str_func::val_decimal(my_decimal *decimal_value)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
StringBuffer<64> tmp;
String *res= val_str(&tmp);
return res ? decimal_from_string_with_check(decimal_value, res) : 0;
@@ -140,7 +140,7 @@ my_decimal *Item_str_func::val_decimal(my_decimal *decimal_value)
double Item_str_func::val_real()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
StringBuffer<64> tmp;
String *res= val_str(&tmp);
return res ? double_from_string_with_check(res) : 0.0;
@@ -149,7 +149,7 @@ double Item_str_func::val_real()
longlong Item_str_func::val_int()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
StringBuffer<22> tmp;
String *res= val_str(&tmp);
return res ? longlong_from_string_with_check(res) : 0;
@@ -158,7 +158,7 @@ longlong Item_str_func::val_int()
String *Item_func_md5::val_str_ascii(String *str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
String * sptr= args[0]->val_str(str);
if (sptr)
{
@@ -183,7 +183,7 @@ String *Item_func_md5::val_str_ascii(String *str)
String *Item_func_sha::val_str_ascii(String *str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
String * sptr= args[0]->val_str(str);
if (sptr) /* If we got value different from NULL */
{
@@ -213,7 +213,7 @@ bool Item_func_sha::fix_length_and_dec()
String *Item_func_sha2::val_str_ascii(String *str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
unsigned char digest_buf[512/8]; // enough for SHA512
String *input_string;
const char *input_ptr;
@@ -286,7 +286,7 @@ String *Item_func_sha2::val_str_ascii(String *str)
bool Item_func_sha2::fix_length_and_dec()
{
- maybe_null= 1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
max_length = 0;
int sha_variant= (int)(args[1]->const_item() ? args[1]->val_int() : 512);
@@ -333,7 +333,7 @@ void Item_aes_crypt::create_key(String *user_key, uchar *real_key)
String *Item_aes_crypt::val_str(String *str2)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
StringBuffer<80> user_key_buf;
String *sptr= args[0]->val_str(&tmp_value);
String *user_key= args[1]->val_str(&user_key_buf);
@@ -374,7 +374,7 @@ bool Item_func_aes_encrypt::fix_length_and_dec()
bool Item_func_aes_decrypt::fix_length_and_dec()
{
max_length=args[0]->max_length;
- maybe_null= 1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
what= ENCRYPTION_FLAG_DECRYPT;
return FALSE;
}
@@ -382,11 +382,11 @@ bool Item_func_aes_decrypt::fix_length_and_dec()
bool Item_func_to_base64::fix_length_and_dec()
{
- maybe_null= args[0]->maybe_null;
+ flags|= args[0]->flags & ITEM_FLAG_MAYBE_NULL;
collation.set(default_charset(), DERIVATION_COERCIBLE, MY_REPERTOIRE_ASCII);
if (args[0]->max_length > (uint) my_base64_encode_max_arg_length())
{
- maybe_null= 1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
fix_char_length_ulonglong((ulonglong) my_base64_encode_max_arg_length());
}
else
@@ -442,7 +442,7 @@ bool Item_func_from_base64::fix_length_and_dec()
int length= my_base64_needed_decoded_length((int) args[0]->max_length);
fix_char_length_ulonglong((ulonglong) length);
}
- maybe_null= 1; // Can be NULL, e.g. in case of badly formed input string
+ flags|= ITEM_FLAG_MAYBE_NULL; // Can be NULL, e.g. in case of badly formed input string
return FALSE;
}
@@ -503,7 +503,7 @@ const char *representation_by_type[]= {"%.3f", "%.5f"};
String *Item_func_decode_histogram::val_str(String *str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
char buff[STRING_BUFFER_USUAL_SIZE];
String *res, tmp(buff, sizeof(buff), &my_charset_bin);
int type;
@@ -610,7 +610,7 @@ bool Item_func_concat::realloc_result(String *str, uint length) const
String *Item_func_concat::val_str(String *str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
THD *thd= current_thd;
String *res;
@@ -639,7 +639,7 @@ null:
String *Item_func_concat_operator_oracle::val_str(String *str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
THD *thd= current_thd;
String *res= NULL;
uint i;
@@ -719,7 +719,7 @@ bool Item_func_concat::fix_length_and_dec()
String *Item_func_des_encrypt::val_str(String *str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
#if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY)
uint code= ER_WRONG_PARAMETERS_TO_PROCEDURE;
DES_cblock ivec;
@@ -818,7 +818,7 @@ error:
String *Item_func_des_decrypt::val_str(String *str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
#if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY)
uint code= ER_WRONG_PARAMETERS_TO_PROCEDURE;
DES_cblock ivec;
@@ -909,7 +909,7 @@ wrong_key:
String *Item_func_concat_ws::val_str(String *str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
char tmp_str_buff[10];
String tmp_sep_str(tmp_str_buff, sizeof(tmp_str_buff),default_charset_info),
*sep_str, *res, *res2,*use_as_buff;
@@ -1077,7 +1077,7 @@ bool Item_func_concat_ws::fix_length_and_dec()
String *Item_func_reverse::val_str(String *str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
String *res= args[0]->val_str(&tmp_value);
const char *ptr, *end;
char *tmp;
@@ -1145,7 +1145,7 @@ bool Item_func_reverse::fix_length_and_dec()
String *Item_func_replace::val_str_internal(String *str,
String *empty_string_for_null)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
String *res,*res2,*res3;
int offset;
uint from_length,to_length;
@@ -1373,7 +1373,7 @@ bool Item_func_regexp_replace::append_replacement(String *str,
String *Item_func_regexp_replace::val_str(String *str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
char buff0[MAX_FIELD_WIDTH];
char buff2[MAX_FIELD_WIDTH];
String tmp0(buff0,sizeof(buff0),&my_charset_bin);
@@ -1452,7 +1452,7 @@ bool Item_func_regexp_substr::fix_length_and_dec()
String *Item_func_regexp_substr::val_str(String *str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
char buff0[MAX_FIELD_WIDTH];
String tmp0(buff0,sizeof(buff0),&my_charset_bin);
String *source= args[0]->val_str(&tmp0);
@@ -1489,7 +1489,7 @@ err:
String *Item_func_insert::val_str(String *str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
String *res,*res2;
longlong start, length; /* must be longlong to avoid truncation */
@@ -1570,7 +1570,7 @@ bool Item_func_insert::fix_length_and_dec()
String *Item_str_conv::val_str(String *str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
String *res;
size_t alloced_length, len;
@@ -1612,7 +1612,7 @@ bool Item_func_ucase::fix_length_and_dec()
String *Item_func_left::val_str(String *str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
String *res= args[0]->val_str(str);
/* must be longlong to avoid truncation */
@@ -1658,7 +1658,7 @@ bool Item_func_left::fix_length_and_dec()
String *Item_func_right::val_str(String *str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
String *res= args[0]->val_str(str);
/* must be longlong to avoid truncation */
longlong length= args[1]->val_int();
@@ -1694,7 +1694,7 @@ bool Item_func_right::fix_length_and_dec()
String *Item_func_substr::val_str(String *str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
String *res = args[0]->val_str(str);
/* must be longlong to avoid truncation */
longlong start= get_position();
@@ -1780,7 +1780,7 @@ bool Item_func_substr_index::fix_length_and_dec()
String *Item_func_substr_index::val_str(String *str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
char buff[MAX_FIELD_WIDTH];
String tmp(buff,sizeof(buff),system_charset_info);
String *res= args[0]->val_str(&tmp_value);
@@ -1930,7 +1930,7 @@ String *Item_func_substr_index::val_str(String *str)
String *Item_func_ltrim::val_str(String *str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
char buff[MAX_FIELD_WIDTH], *ptr, *end;
String tmp(buff,sizeof(buff),system_charset_info);
String *res, *remove_str;
@@ -1975,7 +1975,7 @@ String *Item_func_ltrim::val_str(String *str)
String *Item_func_rtrim::val_str(String *str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
char buff[MAX_FIELD_WIDTH], *ptr, *end;
String tmp(buff, sizeof(buff), system_charset_info);
String *res, *remove_str;
@@ -2054,7 +2054,7 @@ String *Item_func_rtrim::val_str(String *str)
String *Item_func_trim::val_str(String *str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
char buff[MAX_FIELD_WIDTH], *ptr, *end;
const char *r_ptr;
String tmp(buff, sizeof(buff), system_charset_info);
@@ -2162,7 +2162,7 @@ void Item_func_trim::print(String *str, enum_query_type query_type)
*/
Sql_mode_dependency Item_func_trim::value_depends_on_sql_mode() const
{
- DBUG_ASSERT(fixed);
+ DBUG_ASSERT(fixed());
if (arg_count == 1) // RTRIM(expr)
return (args[0]->value_depends_on_sql_mode() &
Sql_mode_dependency(~0, ~MODE_PAD_CHAR_TO_FULL_LENGTH)).
@@ -2201,7 +2201,7 @@ bool Item_func_password::fix_fields(THD *thd, Item **ref)
String *Item_func_password::val_str_ascii(String *str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
String *res= args[0]->val_str(str);
switch (alg){
case NEW:
@@ -2252,7 +2252,7 @@ char *Item_func_password::alloc(THD *thd, const char *password,
String *Item_func_encrypt::val_str(String *str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
#ifdef HAVE_CRYPT
String *res =args[0]->val_str(str);
char salt[3],*salt_ptr;
@@ -2311,7 +2311,7 @@ bool Item_func_encode::seed()
bool Item_func_encode::fix_length_and_dec()
{
max_length=args[0]->max_length;
- maybe_null=args[0]->maybe_null || args[1]->maybe_null;
+ flags|= (args[0]->flags | args[1]->flags) & ITEM_FLAG_MAYBE_NULL;
collation.set(&my_charset_bin);
/* Precompute the seed state if the item is constant. */
seeded= args[1]->const_item() &&
@@ -2322,7 +2322,7 @@ bool Item_func_encode::fix_length_and_dec()
String *Item_func_encode::val_str(String *str)
{
String *res;
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
if (!(res=args[0]->val_str(str)))
{
@@ -2358,7 +2358,7 @@ void Item_func_decode::crypto_transform(String *res)
String *Item_func_database::val_str(String *str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
THD *thd= current_thd;
if (thd->db.str == NULL)
{
@@ -2374,7 +2374,7 @@ String *Item_func_database::val_str(String *str)
String *Item_func_sqlerrm::val_str(String *str)
{
- DBUG_ASSERT(fixed);
+ DBUG_ASSERT(fixed());
DBUG_ASSERT(!null_value);
Diagnostics_area::Sql_condition_iterator it=
current_thd->get_stmt_da()->sql_conditions();
@@ -2398,7 +2398,7 @@ String *Item_func_sqlerrm::val_str(String *str)
*/
bool Item_func_user::init(const char *user, const char *host)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
// For system threads (e.g. replication SQL thread) user may be empty
if (user)
@@ -2475,11 +2475,11 @@ bool Item_func_current_role::fix_fields(THD *thd, Item **ref)
return 1;
str_value.mark_as_const();
null_value= 0;
- maybe_null= 0;
+ flags&= (item_flags_t) ~ITEM_FLAG_MAYBE_NULL;
return 0;
}
null_value= 1;
- maybe_null= 1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
return 0;
}
@@ -2535,7 +2535,7 @@ static bool my_uni_isalpha(int wc)
String *Item_func_soundex::val_str(String *str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
String *res= args[0]->val_str(&tmp_value);
char last_ch,ch;
CHARSET_INFO *cs= collation.collation;
@@ -2706,7 +2706,7 @@ String *Item_func_format::val_str_ascii(String *str)
/* Number of characters used to represent the decimals, including '.' */
uint32 dec_length;
const MY_LOCALE *lc;
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
dec= (int) args[1]->val_int();
if (args[1]->null_value)
@@ -2814,14 +2814,14 @@ bool Item_func_elt::fix_length_and_dec()
set_if_bigger(decimals,args[i]->decimals);
}
fix_char_length(char_length);
- maybe_null=1; // NULL if wrong first arg
+ flags|= ITEM_FLAG_MAYBE_NULL; // NULL if wrong first arg
return FALSE;
}
double Item_func_elt::val_real()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
uint tmp;
null_value=1;
if ((tmp=(uint) args[0]->val_int()) == 0 || tmp >= arg_count)
@@ -2834,7 +2834,7 @@ double Item_func_elt::val_real()
longlong Item_func_elt::val_int()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
uint tmp;
null_value=1;
if ((tmp=(uint) args[0]->val_int()) == 0 || tmp >= arg_count)
@@ -2848,7 +2848,7 @@ longlong Item_func_elt::val_int()
String *Item_func_elt::val_str(String *str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
uint tmp;
null_value=1;
if ((tmp=(uint) args[0]->val_int()) == 0 || tmp >= arg_count)
@@ -2878,7 +2878,7 @@ bool Item_func_make_set::fix_length_and_dec()
String *Item_func_make_set::val_str(String *str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
ulonglong bits;
bool first_found=0;
Item **ptr=args+1;
@@ -2945,7 +2945,7 @@ void Item_func_char::print(String *str, enum_query_type query_type)
String *Item_func_char::val_str(String *str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
str->length(0);
str->set_charset(collation.collation);
for (uint i=0 ; i < arg_count ; i++)
@@ -2987,7 +2987,7 @@ void Item_func_char::append_char(String *str, int32 num)
String *Item_func_chr::val_str(String *str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
str->length(0);
str->set_charset(collation.collation);
int32 num=(int32) args[0]->val_int();
@@ -3038,7 +3038,7 @@ bool Item_func_repeat::fix_length_and_dec()
return false;
}
max_length= MAX_BLOB_WIDTH;
- maybe_null= true;
+ flags|= ITEM_FLAG_MAYBE_NULL;
return false;
}
@@ -3049,7 +3049,7 @@ bool Item_func_repeat::fix_length_and_dec()
String *Item_func_repeat::val_str(String *str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
uint length,tot_length;
char *to;
/* must be longlong to avoid truncation */
@@ -3110,7 +3110,7 @@ bool Item_func_space::fix_length_and_dec()
return false;
}
max_length= MAX_BLOB_WIDTH;
- maybe_null= true;
+ flags|= ITEM_FLAG_MAYBE_NULL;
return false;
}
@@ -3165,14 +3165,14 @@ bool Item_func_binlog_gtid_pos::fix_length_and_dec()
{
collation.set(system_charset_info);
max_length= MAX_BLOB_WIDTH;
- maybe_null= 1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE;
}
String *Item_func_binlog_gtid_pos::val_str(String *str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
#ifndef HAVE_REPLICATION
null_value= 0;
str->copy("", 0, system_charset_info);
@@ -3208,7 +3208,7 @@ bool Item_func_pad::fix_length_and_dec()
{
String *str;
if (!args[2]->basic_const_item() || !(str= args[2]->val_str(&pad_str)) || !str->length())
- maybe_null= true;
+ flags|= ITEM_FLAG_MAYBE_NULL;
// Handle character set for args[0] and args[2].
if (agg_arg_charsets_for_string_result(collation, &args[0], 2, 2))
return TRUE;
@@ -3229,7 +3229,7 @@ bool Item_func_pad::fix_length_and_dec()
return false;
}
max_length= MAX_BLOB_WIDTH;
- maybe_null= true;
+ flags|= ITEM_FLAG_MAYBE_NULL;
return false;
}
@@ -3241,7 +3241,7 @@ bool Item_func_pad::fix_length_and_dec()
*/
Sql_mode_dependency Item_func_rpad::value_depends_on_sql_mode() const
{
- DBUG_ASSERT(fixed);
+ DBUG_ASSERT(fixed());
DBUG_ASSERT(arg_count == 3);
if (!args[1]->value_depends_on_sql_mode_const_item() ||
!args[2]->value_depends_on_sql_mode_const_item())
@@ -3268,7 +3268,7 @@ Sql_mode_dependency Item_func_rpad::value_depends_on_sql_mode() const
String *Item_func_rpad::val_str(String *str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
uint32 res_byte_length,res_char_length,pad_char_length,pad_byte_length;
char *to;
const char *ptr_pad;
@@ -3362,7 +3362,7 @@ String *Item_func_rpad::val_str(String *str)
String *Item_func_lpad::val_str(String *str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
uint32 res_char_length,pad_char_length;
/* must be longlong to avoid truncation */
longlong count= args[1]->val_int();
@@ -3454,7 +3454,7 @@ err:
String *Item_func_conv::val_str(String *str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
String *res= args[0]->val_str(str);
char *endptr,ans[65],*ptr;
longlong dec;
@@ -3505,7 +3505,7 @@ String *Item_func_conv::val_str(String *str)
String *Item_func_conv_charset::val_str(String *str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
if (use_cached_value)
return null_value ? 0 : &str_value;
String *arg= args[0]->val_str(&tmp_value);
@@ -3535,7 +3535,7 @@ void Item_func_conv_charset::print(String *str, enum_query_type query_type)
String *Item_func_set_collation::val_str(String *str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
str=args[0]->val_str(str);
if ((null_value=args[0]->null_value))
return 0;
@@ -3574,7 +3574,7 @@ void Item_func_set_collation::print(String *str, enum_query_type query_type)
String *Item_func_charset::val_str(String *str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
uint dummy_errors;
CHARSET_INFO *cs= args[0]->charset_for_protocol();
@@ -3586,7 +3586,7 @@ String *Item_func_charset::val_str(String *str)
String *Item_func_collation::val_str(String *str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
uint dummy_errors;
CHARSET_INFO *cs= args[0]->charset_for_protocol();
@@ -3614,7 +3614,7 @@ bool Item_func_weight_string::fix_length_and_dec()
args[0]->max_char_length() : nweights * cs->levels_for_order;
max_length= (uint32) cs->strnxfrmlen(char_length * cs->mbmaxlen);
}
- maybe_null= 1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE;
}
@@ -3625,7 +3625,7 @@ String *Item_func_weight_string::val_str(String *str)
String *res;
CHARSET_INFO *cs= args[0]->collation.collation;
size_t tmp_length, frm_length;
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
if (args[0]->result_type() != STRING_RESULT ||
!(res= args[0]->val_str(&tmp_value)))
@@ -3756,7 +3756,7 @@ String *Item_func_unhex::val_str(String *str)
char *to;
String *res;
uint length;
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
res= args[0]->val_str(&tmp_value);
if (!res || str->alloc(length= (1+res->length())/2))
@@ -3792,7 +3792,7 @@ String *Item_func_unhex::val_str(String *str)
#ifndef DBUG_OFF
String *Item_func_like_range::val_str(String *str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
longlong nbytes= args[1]->val_int();
String *res= args[0]->val_str(str);
size_t min_len, max_len;
@@ -3836,7 +3836,7 @@ void Item_func_binary::print(String *str, enum_query_type query_type)
String *Item_load_file::val_str(String *str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
String *file_name;
File file;
MY_STAT stat_info;
@@ -3901,7 +3901,7 @@ err:
String* Item_func_export_set::val_str(String* str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
String yes_buf, no_buf, sep_buf;
const ulonglong the_set = (ulonglong) args[0]->val_int();
const String *yes= args[1]->val_str(&yes_buf);
@@ -4021,7 +4021,7 @@ bool Item_func_export_set::fix_length_and_dec()
String *Item_func_quote::val_str(String *str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
/*
Bit mask that has 1 for set for the position of the following characters:
0, \, ' and ^Z
@@ -4163,7 +4163,7 @@ null:
longlong Item_func_uncompressed_length::val_int()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
String *res= args[0]->val_str(&value);
if (!res)
{
@@ -4200,7 +4200,7 @@ longlong Item_func_uncompressed_length::val_int()
longlong Item_func_crc32::val_int()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
String *res=args[0]->val_str(&value);
if (!res)
{
@@ -4221,7 +4221,7 @@ String *Item_func_compress::val_str(String *str)
String *res;
Byte *body;
char *tmp, *last_char;
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
if (!(res= args[0]->val_str(&tmp_value)))
{
@@ -4282,7 +4282,7 @@ String *Item_func_compress::val_str(String *str)
String *Item_func_uncompress::val_str(String *str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
String *res= args[0]->val_str(&tmp_value);
ulong new_size;
int err;
@@ -4342,7 +4342,7 @@ err:
String *Item_func_uuid::val_str(String *str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
uchar guid[MY_UUID_SIZE];
str->alloc(MY_UUID_STRING_LENGTH+1);
@@ -4397,7 +4397,7 @@ bool Item_func_dyncol_create::fix_fields(THD *thd, Item **ref)
bool Item_func_dyncol_create::fix_length_and_dec()
{
max_length= MAX_BLOB_WIDTH;
- maybe_null= TRUE;
+ flags|= ITEM_FLAG_MAYBE_NULL;
collation.set(&my_charset_bin);
decimals= 0;
return FALSE;
diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h
index 201022f4611..2501a6d99fb 100644
--- a/sql/item_strfunc.h
+++ b/sql/item_strfunc.h
@@ -299,7 +299,7 @@ public:
{
collation.set(system_charset_info);
max_length= MAX_BLOB_WIDTH;
- maybe_null= 1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE;
}
const char *func_name() const { return "decode_histogram"; }
@@ -511,7 +511,7 @@ public:
bool fix_length_and_dec()
{
bool res= Item_func_substr::fix_length_and_dec();
- maybe_null= true;
+ flags|= ITEM_FLAG_MAYBE_NULL;
return res;
}
const char *func_name() const { return "substr_oracle"; }
@@ -586,7 +586,7 @@ public:
bool fix_length_and_dec()
{
bool res= Item_func_trim::fix_length_and_dec();
- maybe_null= true;
+ flags|= ITEM_FLAG_MAYBE_NULL;
return res;
}
Item *get_copy(THD *thd)
@@ -625,7 +625,7 @@ public:
bool fix_length_and_dec()
{
bool res= Item_func_ltrim::fix_length_and_dec();
- maybe_null= true;
+ flags|= ITEM_FLAG_MAYBE_NULL;
return res;
}
Item *get_copy(THD *thd)
@@ -660,7 +660,7 @@ public:
bool fix_length_and_dec()
{
bool res= Item_func_rtrim::fix_length_and_dec();
- maybe_null= true;
+ flags|= ITEM_FLAG_MAYBE_NULL;
return res;
}
Item *get_copy(THD *thd)
@@ -719,7 +719,7 @@ public:
String *val_str(String *);
bool fix_length_and_dec()
{
- maybe_null=1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
/* 9 = MAX ((8- (arg_len % 8)) + 1) */
max_length = args[0]->max_length + 9;
return FALSE;
@@ -740,7 +740,7 @@ public:
String *val_str(String *);
bool fix_length_and_dec()
{
- maybe_null=1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
/* 9 = MAX ((8- (arg_len % 8)) + 1) */
max_length= args[0]->max_length;
if (max_length >= 9U)
@@ -778,7 +778,12 @@ public:
constructor_helper();
}
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"; }
bool check_vcol_func_processor(void *arg)
{
@@ -855,7 +860,7 @@ public:
bool fix_length_and_dec()
{
max_length= MAX_FIELD_NAME * system_charset_info->mbmaxlen;
- maybe_null=1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE;
}
const char *func_name() const { return "database"; }
@@ -880,7 +885,7 @@ public:
{
max_length= 512 * system_charset_info->mbmaxlen;
null_value= false;
- maybe_null= false;
+ flags&= (item_flags_t) ~ITEM_FLAG_MAYBE_NULL;
return FALSE;
}
Item *get_copy(THD *thd)
@@ -900,7 +905,7 @@ public:
}
String *val_str(String *)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
return (null_value ? 0 : &str_value);
}
bool fix_fields(THD *thd, Item **ref);
@@ -959,7 +964,7 @@ public:
const char *fully_qualified_func_name() const { return "current_role()"; }
String *val_str(String *)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
return null_value ? NULL : &str_value;
}
bool check_vcol_func_processor(void *arg)
@@ -1155,7 +1160,7 @@ public:
bool fix_length_and_dec()
{
bool res= Item_func_rpad::fix_length_and_dec();
- maybe_null= true;
+ flags|= ITEM_FLAG_MAYBE_NULL;
return res;
}
const char *func_name() const { return "rpad_oracle"; }
@@ -1190,7 +1195,7 @@ public:
bool fix_length_and_dec()
{
bool res= Item_func_lpad::fix_length_and_dec();
- maybe_null= true;
+ flags|= ITEM_FLAG_MAYBE_NULL;
return res;
}
const char *func_name() const { return "lpad_oracle"; }
@@ -1210,7 +1215,7 @@ public:
{
collation.set(default_charset());
fix_char_length(64);
- maybe_null= 1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE;
}
Item *get_copy(THD *thd)
@@ -1238,7 +1243,7 @@ public:
String *val_str_ascii_from_val_str(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);
}
bool fix_length_and_dec()
@@ -1260,7 +1265,7 @@ public:
Item_func_unhex(THD *thd, Item *a): Item_str_func(thd, a)
{
/* there can be bad hex strings */
- maybe_null= 1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
}
const char *func_name() const { return "unhex"; }
String *val_str(String *);
@@ -1286,7 +1291,9 @@ protected:
public:
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)
- { maybe_null= 1; }
+ {
+ flags|= ITEM_FLAG_MAYBE_NULL;
+ }
String *val_str(String *);
bool fix_length_and_dec()
{
@@ -1327,7 +1334,7 @@ public:
Item_func_binary(THD *thd, Item *a): Item_str_func(thd, a) {}
String *val_str(String *a)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
String *tmp=args[0]->val_str(a);
null_value=args[0]->null_value;
if (tmp)
@@ -1358,7 +1365,7 @@ public:
bool fix_length_and_dec()
{
collation.set(&my_charset_bin, DERIVATION_COERCIBLE);
- maybe_null=1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
max_length=MAX_BLOB_WIDTH;
return FALSE;
}
@@ -1532,7 +1539,7 @@ public:
{
collation.set(system_charset_info);
max_length= 64 * collation.collation->mbmaxlen; // should be enough
- maybe_null= 0;
+ flags&= (item_flags_t) ~ITEM_FLAG_MAYBE_NULL;
return FALSE;
};
table_map not_null_tables() const { return 0; }
@@ -1622,7 +1629,11 @@ public:
Item_func_uncompressed_length(THD *thd, Item *a)
:Item_long_func_length(thd, a) {}
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();
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_uncompressed_length>(thd, this); }
@@ -1659,7 +1670,8 @@ public:
:Item_str_binary_checksum_func(thd, a) {}
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;
}
const char *func_name() const{return "uncompress";}
@@ -1738,7 +1750,7 @@ public:
bool fix_length_and_dec()
{
max_length= MAX_BLOB_WIDTH;
- maybe_null= 1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
decimals= 0;
return FALSE;
}
@@ -1756,7 +1768,11 @@ public:
Item_dyncol_get(THD *thd, Item *str, Item *num): Item_str_func(thd, str, num)
{}
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 */
bool dynamic_result() { return 1; }
@@ -1795,7 +1811,11 @@ public:
Item_func_dyncol_list(THD *thd, Item *str): Item_str_func(thd, str)
{collation.set(DYNCOL_UTF);}
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"; }
String *val_str(String *);
Item *get_copy(THD *thd)
@@ -1836,7 +1856,7 @@ public:
bool fix_length_and_dec()
{
max_length= WSREP_GTID_STR_LEN;
- maybe_null= true;
+ flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE;
}
Item *get_copy(THD *thd)
@@ -1853,7 +1873,7 @@ public:
bool fix_length_and_dec()
{
max_length= WSREP_GTID_STR_LEN;
- maybe_null= true;
+ flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE;
}
Item *get_copy(THD *thd)
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc
index 467138e364d..58e9a5acd7b 100644
--- a/sql/item_subselect.cc
+++ b/sql/item_subselect.cc
@@ -67,7 +67,7 @@ Item_subselect::Item_subselect(THD *thd_arg):
#ifndef DBUG_OFF
exec_counter= 0;
#endif
- with_subquery= 1;
+ flags|= ITEM_FLAG_WITH_SUBQUERY;
reset();
/*
Item value is NULL if select_result_interceptor didn't change this value
@@ -256,7 +256,7 @@ bool Item_subselect::fix_fields(THD *thd_param, Item **ref)
status_var_increment(thd_param->status_var.feature_subquery);
- DBUG_ASSERT(fixed == 0);
+ DBUG_ASSERT(fixed() == 0);
engine->set_thd((thd= thd_param));
if (!done_first_fix_fields)
{
@@ -343,7 +343,7 @@ bool Item_subselect::fix_fields(THD *thd_param, Item **ref)
if (uncacheable & UNCACHEABLE_RAND)
used_tables_cache|= RAND_TABLE_BIT;
}
- fixed= 1;
+ flags|= ITEM_FLAG_FIXED;
end:
done_first_fix_fields= FALSE;
@@ -820,7 +820,7 @@ bool Item_subselect::exec()
subselect_engine *org_engine= engine;
DBUG_ENTER("Item_subselect::exec");
- DBUG_ASSERT(fixed);
+ DBUG_ASSERT(fixed());
DBUG_EXECUTE_IF("Item_subselect",
Item::Print print(this,
@@ -878,7 +878,7 @@ int Item_in_subselect::optimize(double *out_rows, double *cost)
{
int res;
DBUG_ENTER("Item_in_subselect::optimize");
- DBUG_ASSERT(fixed);
+ DBUG_ASSERT(fixed());
SELECT_LEX *save_select= thd->lex->current_select;
JOIN *join= unit->first_select()->join;
@@ -995,7 +995,7 @@ bool Item_in_subselect::expr_cache_is_needed(THD *thd)
bool Item_in_subselect::exec()
{
DBUG_ENTER("Item_in_subselect::exec");
- DBUG_ASSERT(fixed);
+ DBUG_ASSERT(fixed());
/*
Initialize the cache of the left predicate operand. This has to be done as
late as now, because Cached_item directly contains a resolved field (not
@@ -1060,7 +1060,7 @@ bool Item_subselect::const_item() const
Item *Item_subselect::get_tmp_table_item(THD *thd_arg)
{
- if (!with_sum_func && !const_item())
+ if (!with_sum_func() && !const_item())
return new (thd->mem_root) Item_temptable_field(thd_arg, result_field);
return copy_or_same(thd_arg);
}
@@ -1114,7 +1114,7 @@ Item_singlerow_subselect::Item_singlerow_subselect(THD *thd, st_select_lex *sele
{
DBUG_ENTER("Item_singlerow_subselect::Item_singlerow_subselect");
init(select_lex, new (thd->mem_root) select_singlerow_subselect(thd, this));
- maybe_null= 1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
max_columns= UINT_MAX;
DBUG_VOID_RETURN;
}
@@ -1151,7 +1151,7 @@ Item_maxmin_subselect::Item_maxmin_subselect(THD *thd,
new (thd->mem_root) select_max_min_finder_subselect(thd,
this, max_arg, parent->substype() == Item_subselect::ALL_SUBS));
max_columns= 1;
- maybe_null= 1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
max_columns= 1;
/*
@@ -1263,7 +1263,7 @@ Item_singlerow_subselect::select_transformer(JOIN *join)
if (!select_lex->master_unit()->is_unit_op() &&
!select_lex->table_list.elements &&
select_lex->item_list.elements == 1 &&
- !select_lex->item_list.head()->with_sum_func &&
+ !select_lex->item_list.head()->with_sum_func() &&
/*
We can't change name of Item_field or Item_ref, because it will
prevent its correct resolving, but we should save name of
@@ -1335,11 +1335,11 @@ bool Item_singlerow_subselect::fix_length_and_dec()
always can be NULL if there are not records fetched).
*/
if (engine->no_tables())
- maybe_null= engine->may_be_null();
+ set_maybe_null(engine->may_be_null());
else
{
for (uint i= 0; i < max_columns; i++)
- row[i]->maybe_null= TRUE;
+ row[i]->flags|= ITEM_FLAG_MAYBE_NULL;
}
return FALSE;
}
@@ -1428,7 +1428,7 @@ void Item_singlerow_subselect::bring_value()
double Item_singlerow_subselect::val_real()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
if (forced_const)
return value->val_real();
if (!exec() && !value->null_value)
@@ -1445,7 +1445,7 @@ double Item_singlerow_subselect::val_real()
longlong Item_singlerow_subselect::val_int()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
if (forced_const)
{
longlong val= value->val_int();
@@ -1467,7 +1467,7 @@ longlong Item_singlerow_subselect::val_int()
String *Item_singlerow_subselect::val_str(String *str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
if (forced_const)
{
String *res= value->val_str(str);
@@ -1490,7 +1490,7 @@ String *Item_singlerow_subselect::val_str(String *str)
bool Item_singlerow_subselect::val_native(THD *thd, Native *to)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
if (forced_const)
return value->val_native(thd, to);
if (!exec() && !value->null_value)
@@ -1508,7 +1508,7 @@ bool Item_singlerow_subselect::val_native(THD *thd, Native *to)
my_decimal *Item_singlerow_subselect::val_decimal(my_decimal *decimal_value)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
if (forced_const)
{
my_decimal *val= value->val_decimal(decimal_value);
@@ -1531,7 +1531,7 @@ my_decimal *Item_singlerow_subselect::val_decimal(my_decimal *decimal_value)
bool Item_singlerow_subselect::val_bool()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
if (forced_const)
{
bool val= value->val_bool();
@@ -1554,7 +1554,7 @@ bool Item_singlerow_subselect::val_bool()
bool Item_singlerow_subselect::get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
if (forced_const)
{
bool val= value->get_date(thd, ltime, fuzzydate);
@@ -1586,7 +1586,7 @@ Item_exists_subselect::Item_exists_subselect(THD *thd,
init(select_lex, new (thd->mem_root) select_exists_subselect(thd, this));
max_columns= UINT_MAX;
null_value= FALSE; //can't be NULL
- maybe_null= 0; //can't be NULL
+ flags&= (item_flags_t) ~ITEM_FLAG_MAYBE_NULL; //can't be NULL
value= 0;
DBUG_VOID_RETURN;
}
@@ -1635,7 +1635,7 @@ Item_in_subselect::Item_in_subselect(THD *thd, Item * left_exp,
func= &eq_creator;
init(select_lex, new (thd->mem_root) select_exists_subselect(thd, this));
max_columns= UINT_MAX;
- maybe_null= 1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
reset();
//if test_limit will fail then error will be reported to client
test_limit(select_lex->master_unit());
@@ -1775,7 +1775,7 @@ void Item_exists_subselect::no_rows_in_result()
double Item_exists_subselect::val_real()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
if (!forced_const && exec())
{
reset();
@@ -1786,7 +1786,7 @@ double Item_exists_subselect::val_real()
longlong Item_exists_subselect::val_int()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
if (!forced_const && exec())
{
reset();
@@ -1811,7 +1811,7 @@ longlong Item_exists_subselect::val_int()
String *Item_exists_subselect::val_str(String *str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
if (!forced_const && exec())
reset();
str->set((ulonglong)value,&my_charset_bin);
@@ -1834,7 +1834,7 @@ String *Item_exists_subselect::val_str(String *str)
my_decimal *Item_exists_subselect::val_decimal(my_decimal *decimal_value)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
if (!forced_const && exec())
reset();
int2my_decimal(E_DEC_FATAL_ERROR, value, 0, decimal_value);
@@ -1844,7 +1844,7 @@ my_decimal *Item_exists_subselect::val_decimal(my_decimal *decimal_value)
bool Item_exists_subselect::val_bool()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
if (!forced_const && exec())
{
reset();
@@ -1861,7 +1861,7 @@ double Item_in_subselect::val_real()
method should not be used
*/
DBUG_ASSERT(0);
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
if (forced_const)
return value;
DBUG_ASSERT((engine->uncacheable() & ~UNCACHEABLE_EXPLAIN) ||
@@ -1885,7 +1885,7 @@ longlong Item_in_subselect::val_int()
method should not be used
*/
DBUG_ASSERT(0);
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
if (forced_const)
return value;
DBUG_ASSERT((engine->uncacheable() & ~UNCACHEABLE_EXPLAIN) ||
@@ -1909,7 +1909,7 @@ String *Item_in_subselect::val_str(String *str)
method should not be used
*/
DBUG_ASSERT(0);
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
if (forced_const)
goto value_is_ready;
DBUG_ASSERT((engine->uncacheable() & ~UNCACHEABLE_EXPLAIN) ||
@@ -1933,7 +1933,7 @@ value_is_ready:
bool Item_in_subselect::val_bool()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
if (forced_const)
return value;
DBUG_ASSERT((engine->uncacheable() & ~UNCACHEABLE_EXPLAIN) ||
@@ -1961,7 +1961,7 @@ my_decimal *Item_in_subselect::val_decimal(my_decimal *decimal_value)
DBUG_ASSERT((engine->uncacheable() & ~UNCACHEABLE_EXPLAIN) ||
! engine->is_executed());
null_value= was_null= FALSE;
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
if (exec())
{
reset();
@@ -2127,13 +2127,13 @@ bool Item_allany_subselect::transform_into_max_min(JOIN *join)
3 There is tables
4 It is not ALL subquery with possible NULLs in the SELECT list
*/
- if (!select_lex->group_list.elements && /*1*/
- !select_lex->having && /*1*/
- !select_lex->with_sum_func && /*1*/
- !(select_lex->next_select()) && /*2*/
- select_lex->table_list.elements && /*3*/
- (!select_lex->ref_pointer_array[0]->maybe_null || /*4*/
- substype() != Item_subselect::ALL_SUBS)) /*4*/
+ if (!select_lex->group_list.elements && /*1*/
+ !select_lex->having && /*1*/
+ !select_lex->with_sum_func && /*1*/
+ !(select_lex->next_select()) && /*2*/
+ select_lex->table_list.elements && /*3*/
+ (!select_lex->ref_pointer_array[0]->maybe_null() || /*4*/
+ substype() != Item_subselect::ALL_SUBS)) /*4*/
{
Item_sum_min_max *item;
nesting_map save_allow_sum_func;
@@ -2310,7 +2310,7 @@ Item_in_subselect::create_single_in_to_exists_cond(JOIN *join,
ref_pointer_array[0],
{STRING_WITH_LEN("<ref>")},
field_name));
- if (!abort_on_null && left_expr->maybe_null)
+ if (!abort_on_null && left_expr->maybe_null())
{
/*
We can encounter "NULL IN (SELECT ...)". Wrap the added condition
@@ -2342,10 +2342,10 @@ Item_in_subselect::create_single_in_to_exists_cond(JOIN *join,
Item *orig_item= item;
item= func->create(thd, expr, item);
- if (!abort_on_null && orig_item->maybe_null)
+ if (!abort_on_null && orig_item->maybe_null())
{
having= new (thd->mem_root) Item_is_not_null_test(thd, this, having);
- if (left_expr->maybe_null)
+ if (left_expr->maybe_null())
{
disable_cond_guard_for_const_null_left_expr(0);
if (!(having= new (thd->mem_root) Item_func_trig_cond(thd, having,
@@ -2364,7 +2364,7 @@ Item_in_subselect::create_single_in_to_exists_cond(JOIN *join,
If we may encounter NULL IN (SELECT ...) and care whether subquery
result is NULL or FALSE, wrap condition in a trig_cond.
*/
- if (!abort_on_null && left_expr->maybe_null)
+ if (!abort_on_null && left_expr->maybe_null())
{
disable_cond_guard_for_const_null_left_expr(0);
if (!(item= new (thd->mem_root) Item_func_trig_cond(thd, item,
@@ -2395,7 +2395,7 @@ Item_in_subselect::create_single_in_to_exists_cond(JOIN *join,
&select_lex->ref_pointer_array[0],
no_matter_name,
field_name));
- if (!abort_on_null && left_expr->maybe_null)
+ if (!abort_on_null && left_expr->maybe_null())
{
disable_cond_guard_for_const_null_left_expr(0);
if (!(new_having= new (thd->mem_root) Item_func_trig_cond(thd, new_having,
@@ -2596,7 +2596,7 @@ Item_in_subselect::create_row_in_to_exists_cond(JOIN * join,
list_ref));
Item *col_item= new (thd->mem_root)
Item_cond_or(thd, item_eq, item_isnull);
- if (!abort_on_null && left_expr->element_index(i)->maybe_null &&
+ if (!abort_on_null && left_expr->element_index(i)->maybe_null() &&
get_cond_guard(i))
{
disable_cond_guard_for_const_null_left_expr(i);
@@ -2615,7 +2615,7 @@ Item_in_subselect::create_row_in_to_exists_cond(JOIN * join,
ref_pointer_array[i],
no_matter_name,
list_ref));
- if (!abort_on_null && left_expr->element_index(i)->maybe_null &&
+ if (!abort_on_null && left_expr->element_index(i)->maybe_null() &&
get_cond_guard(i) )
{
disable_cond_guard_for_const_null_left_expr(i);
@@ -2656,7 +2656,7 @@ Item_in_subselect::create_row_in_to_exists_cond(JOIN * join,
ref_pointer_array[i],
no_matter_name,
list_ref));
- if (!abort_on_null && select_lex->ref_pointer_array[i]->maybe_null)
+ if (!abort_on_null && select_lex->ref_pointer_array[i]->maybe_null())
{
Item *having_col_item=
new (thd->mem_root)
@@ -2676,7 +2676,7 @@ Item_in_subselect::create_row_in_to_exists_cond(JOIN * join,
no_matter_name,
list_ref));
item= new (thd->mem_root) Item_cond_or(thd, item, item_isnull);
- if (left_expr->element_index(i)->maybe_null && get_cond_guard(i))
+ if (left_expr->element_index(i)->maybe_null() && get_cond_guard(i))
{
disable_cond_guard_for_const_null_left_expr(i);
if (!(item= new (thd->mem_root)
@@ -2688,7 +2688,7 @@ Item_in_subselect::create_row_in_to_exists_cond(JOIN * join,
}
*having_item= and_items(thd, *having_item, having_col_item);
}
- if (!abort_on_null && left_expr->element_index(i)->maybe_null &&
+ if (!abort_on_null && left_expr->element_index(i)->maybe_null() &&
get_cond_guard(i))
{
if (!(item= new (thd->mem_root)
@@ -2945,7 +2945,7 @@ static bool check_equality_for_exist2in(Item_func *func,
if (args[0]->real_type() == Item::FIELD_ITEM &&
args[0]->all_used_tables() != OUTER_REF_TABLE_BIT &&
args[1]->all_used_tables() == OUTER_REF_TABLE_BIT &&
- (allow_subselect || !args[1]->with_subquery))
+ (allow_subselect || !args[1]->with_subquery()))
{
/* It is Item_field or Item_direct_view_ref) */
DBUG_ASSERT(args[0]->type() == Item::FIELD_ITEM ||
@@ -2957,7 +2957,7 @@ static bool check_equality_for_exist2in(Item_func *func,
else if (args[1]->real_type() == Item::FIELD_ITEM &&
args[1]->all_used_tables() != OUTER_REF_TABLE_BIT &&
args[0]->all_used_tables() == OUTER_REF_TABLE_BIT &&
- (allow_subselect || !args[0]->with_subquery))
+ (allow_subselect || !args[0]->with_subquery()))
{
/* It is Item_field or Item_direct_view_ref) */
DBUG_ASSERT(args[1]->type() == Item::FIELD_ITEM ||
@@ -3164,7 +3164,7 @@ bool Item_exists_subselect::exists2in_processor(void *opt_arg)
first_select->ref_pointer_array[i]= (Item *)local_field;
/* remove the parts from condition */
- if (!upper_not || !local_field->maybe_null)
+ if (!upper_not || !local_field->maybe_null())
*eq_ref= new (thd->mem_root) Item_int(thd, 1);
else
{
@@ -3302,7 +3302,7 @@ bool Item_exists_subselect::exists2in_processor(void *opt_arg)
Item *exp;
if (eqs.elements() == 1)
{
- exp= (optimizer->arguments()[0]->maybe_null ?
+ exp= (optimizer->arguments()[0]->maybe_null() ?
(Item*) new (thd->mem_root)
Item_cond_and(thd,
new (thd->mem_root)
@@ -3326,7 +3326,7 @@ bool Item_exists_subselect::exists2in_processor(void *opt_arg)
}
for (size_t i= 0; i < eqs.elements(); i++)
{
- if (optimizer->arguments()[0]->maybe_null)
+ if (optimizer->arguments()[0]->maybe_null())
{
and_list->
push_front(new (thd->mem_root)
@@ -3538,7 +3538,7 @@ bool Item_in_subselect::fix_fields(THD *thd_arg, Item **ref)
else
if (Item_subselect::fix_fields(thd_arg, ref))
goto err;
- fixed= TRUE;
+ flags|= ITEM_FLAG_FIXED;
thd->where= save_where;
DBUG_RETURN(FALSE);
@@ -3657,7 +3657,7 @@ bool Item_in_subselect::init_cond_guards()
DBUG_ASSERT(thd);
uint cols_num= left_expr->cols();
if (!abort_on_null && !pushed_cond_guards &&
- (left_expr->maybe_null || cols_num > 1))
+ (left_expr->maybe_null() || cols_num > 1))
{
if (!(pushed_cond_guards= (bool*)thd->alloc(sizeof(bool) * cols_num)))
return TRUE;
@@ -3939,7 +3939,7 @@ bool subselect_engine::set_row(List<Item> &item_list, Item_cache **row)
set_handler(sel_item->type_handler());
item->decimals= sel_item->decimals;
item->unsigned_flag= sel_item->unsigned_flag;
- maybe_null= sel_item->maybe_null;
+ maybe_null= sel_item->maybe_null();
if (!(row[i]= sel_item->get_cache(thd)))
return TRUE;
row[i]->setup(thd, sel_item);
@@ -4884,7 +4884,7 @@ subselect_hash_sj_engine::get_strategy_using_schema()
outer_col= item_in->left_expr->element_index(i);
inner_col= inner_col_it++;
- if (!inner_col->maybe_null && !outer_col->maybe_null)
+ if (!inner_col->maybe_null() && !outer_col->maybe_null())
bitmap_set_bit(&non_null_key_parts, i);
else
{
@@ -4938,7 +4938,7 @@ subselect_hash_sj_engine::get_strategy_using_data()
If column 'i' doesn't contain NULLs, and the corresponding outer reference
cannot have a NULL value, then 'i' is a non-nullable column.
*/
- if (result_sink->get_null_count_of_col(i) == 0 && !outer_col->maybe_null)
+ if (result_sink->get_null_count_of_col(i) == 0 && !outer_col->maybe_null())
{
bitmap_clear_bit(&partial_match_key_parts, i);
bitmap_set_bit(&non_null_key_parts, i);
diff --git a/sql/item_sum.cc b/sql/item_sum.cc
index 8875fb9bc0a..6acf7bb234b 100644
--- a/sql/item_sum.cc
+++ b/sql/item_sum.cc
@@ -168,7 +168,7 @@ bool Item_sum::check_sum_func(THD *thd, Item **ref)
Aggregation happes before window function computation, so there
are no values to aggregate over.
*/
- if (with_window_func)
+ if (with_window_func())
{
my_message(ER_SUM_FUNC_WITH_WINDOW_FUNC_AS_ARG,
ER_THD(thd, ER_SUM_FUNC_WITH_WINDOW_FUNC_AS_ARG),
@@ -407,7 +407,7 @@ bool Item_sum::register_sum_func(THD *thd, Item **ref)
for (sl= thd->lex->current_select;
sl && sl != aggr_sel && sl->master_unit()->item;
sl= sl->master_unit()->outer_select() )
- sl->master_unit()->item->with_sum_func= 1;
+ sl->master_unit()->item->flags|= ITEM_FLAG_WITH_SUM_FUNC;
}
thd->lex->current_select->mark_as_dependent(thd, aggr_sel, NULL);
@@ -488,8 +488,7 @@ void Item_sum::mark_as_sum_func()
cur_select->n_sum_items++;
cur_select->with_sum_func= 1;
const_item_cache= false;
- with_sum_func= 1;
- with_field= 0;
+ flags= (flags | ITEM_FLAG_WITH_SUM_FUNC) & ~ITEM_FLAG_WITH_FIELD;
window_func_sum_expr_flag= false;
}
@@ -497,7 +496,7 @@ void Item_sum::mark_as_sum_func()
void Item_sum::print(String *str, enum_query_type query_type)
{
/* orig_args is not filled with valid values until fix_fields() */
- Item **pargs= fixed ? orig_args : args;
+ Item **pargs= fixed() ? orig_args : args;
str->append(func_name());
/*
TODO:
@@ -892,7 +891,7 @@ bool Aggregator_distinct::setup(THD *thd)
*/
item_sum->null_value= 1;
- item_sum->maybe_null= 1;
+ item_sum->flags|= ITEM_FLAG_MAYBE_NULL;
item_sum->quick_group= 0;
DBUG_ASSERT(item_sum->get_arg(0)->is_fixed());
@@ -1052,7 +1051,7 @@ void Aggregator_distinct::endup()
if (item_sum->sum_func() == Item_sum::COUNT_FUNC ||
item_sum->sum_func() == Item_sum::COUNT_DISTINCT_FUNC)
{
- DBUG_ASSERT(item_sum->fixed == 1);
+ DBUG_ASSERT(item_sum->fixed());
Item_sum_count *sum= (Item_sum_count *)item_sum;
if (tree && tree->elements == 0)
{
@@ -1112,21 +1111,21 @@ my_decimal *Item_sum_int::val_decimal(my_decimal *decimal_value)
bool
Item_sum_num::fix_fields(THD *thd, Item **ref)
{
- DBUG_ASSERT(fixed == 0);
+ DBUG_ASSERT(fixed() == 0);
if (init_sum_func_check(thd))
return TRUE;
decimals=0;
- maybe_null= sum_func() != COUNT_FUNC;
+ set_maybe_null(sum_func() != COUNT_FUNC);
for (uint i=0 ; i < arg_count ; i++)
{
if (args[i]->fix_fields_if_needed_for_scalar(thd, &args[i]))
return TRUE;
set_if_bigger(decimals, args[i]->decimals);
- with_subquery|= args[i]->with_subquery;
- with_param|= args[i]->with_param;
- with_window_func|= args[i]->with_window_func;
+ flags|= (args[i]->flags & (ITEM_FLAG_WITH_SUBQUERY |
+ ITEM_FLAG_WITH_PARAM |
+ ITEM_FLAG_WITH_WINDOW_FUNC));
}
result_field=0;
max_length=float_length(decimals);
@@ -1137,7 +1136,7 @@ Item_sum_num::fix_fields(THD *thd, Item **ref)
if (arg_count)
memcpy (orig_args, args, sizeof (Item *) * arg_count);
- fixed= 1;
+ flags|= ITEM_FLAG_FIXED;
return FALSE;
}
@@ -1146,7 +1145,7 @@ bool
Item_sum_min_max::fix_fields(THD *thd, Item **ref)
{
DBUG_ENTER("Item_sum_min_max::fix_fields");
- DBUG_ASSERT(fixed == 0);
+ DBUG_ASSERT(fixed() == 0);
if (init_sum_func_check(thd))
DBUG_RETURN(TRUE);
@@ -1155,9 +1154,9 @@ Item_sum_min_max::fix_fields(THD *thd, Item **ref)
if (args[0]->fix_fields_if_needed_for_scalar(thd, &args[0]))
DBUG_RETURN(TRUE);
- with_subquery= args[0]->with_subquery;
- with_param= args[0]->with_param;
- with_window_func|= args[0]->with_window_func;
+ flags|= (args[0]->flags & (ITEM_FLAG_WITH_SUBQUERY |
+ ITEM_FLAG_WITH_PARAM |
+ ITEM_FLAG_WITH_WINDOW_FUNC));
if (fix_length_and_dec())
DBUG_RETURN(TRUE);
@@ -1170,7 +1169,7 @@ Item_sum_min_max::fix_fields(THD *thd, Item **ref)
DBUG_RETURN(TRUE);
orig_args[0]= args[0];
- fixed= 1;
+ flags|= ITEM_FLAG_FIXED;
DBUG_RETURN(FALSE);
}
@@ -1240,7 +1239,8 @@ bool Item_sum_min_max::fix_length_and_dec()
DBUG_ASSERT(args[0]->field_type() == args[0]->real_item()->field_type());
DBUG_ASSERT(args[0]->result_type() == args[0]->real_item()->result_type());
/* MIN/MAX can return NULL for empty set indepedent of the used column */
- maybe_null= null_value= true;
+ flags|= ITEM_FLAG_MAYBE_NULL;
+ null_value= true;
return args[0]->type_handler()->Item_sum_hybrid_fix_length_and_dec(this);
}
@@ -1311,7 +1311,7 @@ Item_sum_sp::Item_sum_sp(THD *thd, Name_resolution_context *context_arg,
sp_name *name_arg, sp_head *sp, List<Item> &list)
:Item_sum(thd, list), Item_sp(thd, context_arg, name_arg)
{
- maybe_null= 1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
quick_group= 0;
m_sp= sp;
}
@@ -1320,7 +1320,7 @@ Item_sum_sp::Item_sum_sp(THD *thd, Name_resolution_context *context_arg,
sp_name *name_arg, sp_head *sp)
:Item_sum(thd), Item_sp(thd, context_arg, name_arg)
{
- maybe_null= 1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
quick_group= 0;
m_sp= sp;
}
@@ -1328,14 +1328,14 @@ Item_sum_sp::Item_sum_sp(THD *thd, Name_resolution_context *context_arg,
Item_sum_sp::Item_sum_sp(THD *thd, Item_sum_sp *item):
Item_sum(thd, item), Item_sp(thd, item)
{
- maybe_null= item->maybe_null;
+ flags|= (item->flags & ITEM_FLAG_MAYBE_NULL);
quick_group= item->quick_group;
}
bool
Item_sum_sp::fix_fields(THD *thd, Item **ref)
{
- DBUG_ASSERT(fixed == 0);
+ DBUG_ASSERT(fixed() == 0);
if (init_sum_func_check(thd))
return TRUE;
decimals= 0;
@@ -1349,7 +1349,7 @@ Item_sum_sp::fix_fields(THD *thd, Item **ref)
return TRUE;
}
- if (init_result_field(thd, max_length, maybe_null, &null_value, &name))
+ if (init_result_field(thd, max_length, maybe_null(), &null_value, &name))
return TRUE;
for (uint i= 0 ; i < arg_count ; i++)
@@ -1357,8 +1357,8 @@ Item_sum_sp::fix_fields(THD *thd, Item **ref)
if (args[i]->fix_fields_if_needed_for_scalar(thd, &args[i]))
return TRUE;
set_if_bigger(decimals, args[i]->decimals);
- with_subquery|= args[i]->with_subquery;
- with_window_func|= args[i]->with_window_func;
+ flags|= (args[i]->flags & (ITEM_FLAG_WITH_SUBQUERY |
+ ITEM_FLAG_WITH_WINDOW_FUNC));
}
result_field= NULL;
max_length= float_length(decimals);
@@ -1371,7 +1371,7 @@ Item_sum_sp::fix_fields(THD *thd, Item **ref)
if (arg_count)
memcpy(orig_args, args, sizeof(Item *) * arg_count);
- fixed= 1;
+ flags|= ITEM_FLAG_FIXED;
return FALSE;
}
@@ -1469,7 +1469,7 @@ Item_sum_sp::func_name() const
Item* Item_sum_sp::copy_or_same(THD *thd)
{
Item_sum_sp *copy_item= new (thd->mem_root) Item_sum_sp(thd, this);
- copy_item->init_result_field(thd, max_length, maybe_null,
+ copy_item->init_result_field(thd, max_length, maybe_null(),
&copy_item->null_value, &copy_item->name);
return copy_item;
}
@@ -1555,7 +1555,8 @@ void Item_sum_sum::fix_length_and_dec_decimal()
bool Item_sum_sum::fix_length_and_dec()
{
DBUG_ENTER("Item_sum_sum::fix_length_and_dec");
- maybe_null=null_value=1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
+ null_value=1;
if (args[0]->cast_to_int_type_handler()->
Item_sum_sum_fix_length_and_dec(this))
DBUG_RETURN(TRUE);
@@ -1696,7 +1697,7 @@ void Item_sum_sum::add_helper(bool perform_removal)
longlong Item_sum_sum::val_int()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
if (aggr)
aggr->endup();
if (result_type() == DECIMAL_RESULT)
@@ -1707,7 +1708,7 @@ longlong Item_sum_sum::val_int()
double Item_sum_sum::val_real()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
if (aggr)
aggr->endup();
if (result_type() == DECIMAL_RESULT)
@@ -1831,7 +1832,7 @@ bool Aggregator_simple::arg_is_null(bool use_null_value)
{
for (uint i= 0; i < item_count; i++)
{
- if (item[i]->maybe_null && item[i]->is_null())
+ if (item[i]->maybe_null() && item[i]->is_null())
return true;
}
}
@@ -1863,7 +1864,7 @@ bool Aggregator_distinct::arg_is_null(bool use_null_value)
}
return use_null_value ?
item_sum->args[0]->null_value :
- (item_sum->args[0]->maybe_null && item_sum->args[0]->is_null());
+ (item_sum->args[0]->maybe_null() && item_sum->args[0]->is_null());
}
@@ -1928,7 +1929,7 @@ void Item_sum_count::remove()
longlong Item_sum_count::val_int()
{
DBUG_ENTER("Item_sum_count::val_int");
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
if (aggr)
aggr->endup();
DBUG_RETURN((longlong)count);
@@ -1977,7 +1978,8 @@ bool Item_sum_avg::fix_length_and_dec()
{
DBUG_ENTER("Item_sum_avg::fix_length_and_dec");
prec_increment= current_thd->variables.div_precincrement;
- maybe_null=null_value=1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
+ null_value=1;
if (args[0]->cast_to_int_type_handler()->
Item_sum_avg_fix_length_and_dec(this))
DBUG_RETURN(TRUE);
@@ -2043,7 +2045,7 @@ void Item_sum_avg::remove()
double Item_sum_avg::val_real()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
if (aggr)
aggr->endup();
if (!count)
@@ -2059,7 +2061,7 @@ my_decimal *Item_sum_avg::val_decimal(my_decimal *val)
{
my_decimal cnt;
const my_decimal *sum_dec;
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
if (aggr)
aggr->endup();
if (!count)
@@ -2098,7 +2100,7 @@ String *Item_sum_avg::val_str(String *str)
double Item_sum_std::val_real()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
double nr= Item_sum_variance::val_real();
if (std::isnan(nr))
{
@@ -2207,7 +2209,8 @@ void Item_sum_variance::fix_length_and_dec_decimal()
bool Item_sum_variance::fix_length_and_dec()
{
DBUG_ENTER("Item_sum_variance::fix_length_and_dec");
- maybe_null= null_value= 1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
+ null_value= 1;
prec_increment= current_thd->variables.div_precincrement;
/*
@@ -2250,7 +2253,7 @@ Field *Item_sum_variance::create_tmp_field(MEM_ROOT *root,
&name, &my_charset_bin);
}
else
- field= new (root) Field_double(max_length, maybe_null, &name, decimals,
+ field= new (root) Field_double(max_length, maybe_null(), &name, decimals,
TRUE);
if (field != NULL)
@@ -2280,7 +2283,7 @@ bool Item_sum_variance::add()
double Item_sum_variance::val_real()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
/*
'sample' is a 1/0 boolean value. If it is 1/true, id est this is a sample
@@ -2370,7 +2373,7 @@ void Item_sum_min_max::clear()
bool
Item_sum_min_max::get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
if (null_value)
return true;
bool retval= value->get_date(thd, ltime, fuzzydate);
@@ -2393,7 +2396,7 @@ void Item_sum_min_max::direct_add(Item *item)
double Item_sum_min_max::val_real()
{
DBUG_ENTER("Item_sum_min_max::val_real");
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
if (null_value)
DBUG_RETURN(0.0);
double retval= value->val_real();
@@ -2405,7 +2408,7 @@ double Item_sum_min_max::val_real()
longlong Item_sum_min_max::val_int()
{
DBUG_ENTER("Item_sum_min_max::val_int");
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
if (null_value)
DBUG_RETURN(0);
longlong retval= value->val_int();
@@ -2418,7 +2421,7 @@ longlong Item_sum_min_max::val_int()
my_decimal *Item_sum_min_max::val_decimal(my_decimal *val)
{
DBUG_ENTER("Item_sum_min_max::val_decimal");
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
if (null_value)
DBUG_RETURN(0);
my_decimal *retval= value->val_decimal(val);
@@ -2432,7 +2435,7 @@ String *
Item_sum_min_max::val_str(String *str)
{
DBUG_ENTER("Item_sum_min_max::val_str");
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
if (null_value)
DBUG_RETURN(0);
String *retval= value->val_str(str);
@@ -2444,7 +2447,7 @@ Item_sum_min_max::val_str(String *str)
bool Item_sum_min_max::val_native(THD *thd, Native *to)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
if (null_value)
return true;
return val_native_from_item(thd, value, to);
@@ -2577,7 +2580,7 @@ bool Item_sum_max::add()
longlong Item_sum_bit::val_int()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
return (longlong) bits;
}
@@ -2764,7 +2767,7 @@ void Item_sum_min_max::reset_field()
{
longlong nr= arg0->val_int();
- if (maybe_null)
+ if (maybe_null())
{
if (arg0->null_value)
{
@@ -2782,7 +2785,7 @@ void Item_sum_min_max::reset_field()
{
double nr= arg0->val_real();
- if (maybe_null)
+ if (maybe_null())
{
if (arg0->null_value)
{
@@ -2799,7 +2802,7 @@ void Item_sum_min_max::reset_field()
{
VDec arg_dec(arg0);
- if (maybe_null)
+ if (maybe_null())
{
if (arg_dec.is_null())
result_field->set_null();
@@ -2874,7 +2877,7 @@ void Item_sum_count::reset_field()
direct_counted= FALSE;
direct_reseted_field= TRUE;
}
- else if (!args[0]->maybe_null || !args[0]->is_null())
+ else if (!args[0]->maybe_null() || !args[0]->is_null())
nr= 1;
DBUG_PRINT("info", ("nr: %lld", nr));
int8store(res,nr);
@@ -3009,7 +3012,7 @@ void Item_sum_count::update_field()
direct_counted= direct_reseted_field= FALSE;
nr+= direct_count;
}
- else if (!args[0]->maybe_null || !args[0]->is_null())
+ else if (!args[0]->maybe_null() || !args[0]->is_null())
nr++;
DBUG_PRINT("info", ("nr: %lld", nr));
int8store(res,nr);
@@ -3386,7 +3389,7 @@ double Item_sum_udf_float::val_real()
{
my_bool tmp_null_value;
double res;
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
DBUG_ENTER("Item_sum_udf_float::val");
DBUG_PRINT("enter",("result_type: %d arg_count: %d",
args[0]->result_type(), arg_count));
@@ -3412,7 +3415,7 @@ my_decimal *Item_sum_udf_decimal::val_decimal(my_decimal *dec_buf)
{
my_decimal *res;
my_bool tmp_null_value;
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
DBUG_ENTER("Item_func_udf_decimal::val_decimal");
DBUG_PRINT("enter",("result_type: %d arg_count: %d",
args[0]->result_type(), arg_count));
@@ -3438,7 +3441,7 @@ longlong Item_sum_udf_int::val_int()
{
my_bool tmp_null_value;
longlong res;
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
DBUG_ENTER("Item_sum_udf_int::val_int");
DBUG_PRINT("enter",("result_type: %d arg_count: %d",
args[0]->result_type(), arg_count));
@@ -3484,7 +3487,7 @@ my_decimal *Item_sum_udf_str::val_decimal(my_decimal *dec)
String *Item_sum_udf_str::val_str(String *str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
DBUG_ENTER("Item_sum_udf_str::str");
String *res=udf.val_str(str,&str_value);
null_value = !res;
@@ -4214,12 +4217,12 @@ bool
Item_func_group_concat::fix_fields(THD *thd, Item **ref)
{
uint i; /* for loop variable */
- DBUG_ASSERT(fixed == 0);
+ DBUG_ASSERT(fixed() == 0);
if (init_sum_func_check(thd))
return TRUE;
- maybe_null= 1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
/*
Fix fields for select list and ORDER clause
@@ -4229,9 +4232,9 @@ Item_func_group_concat::fix_fields(THD *thd, Item **ref)
{
if (args[i]->fix_fields_if_needed_for_scalar(thd, &args[i]))
return TRUE;
- with_subquery|= args[i]->with_subquery;
- with_param|= args[i]->with_param;
- with_window_func|= args[i]->with_window_func;
+ flags|= (args[i]->flags & (ITEM_FLAG_WITH_SUBQUERY |
+ ITEM_FLAG_WITH_PARAM |
+ ITEM_FLAG_WITH_WINDOW_FUNC));
}
/* skip charset aggregation for order columns */
@@ -4270,7 +4273,7 @@ Item_func_group_concat::fix_fields(THD *thd, Item **ref)
if (check_sum_func(thd, ref))
return TRUE;
- fixed= 1;
+ flags|= ITEM_FLAG_FIXED;
return FALSE;
}
@@ -4433,7 +4436,7 @@ void Item_func_group_concat::make_unique()
String* Item_func_group_concat::val_str(String* str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
if (null_value)
return 0;
diff --git a/sql/item_sum.h b/sql/item_sum.h
index 2be2645005f..9c9ee34037d 100644
--- a/sql/item_sum.h
+++ b/sql/item_sum.h
@@ -462,7 +462,11 @@ public:
*/
virtual void update_field()=0;
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);
void update_used_tables ();
@@ -531,7 +535,7 @@ public:
Item *get_arg(uint i) const { return args[i]; }
Item *set_arg(uint i, THD *thd, Item *new_val);
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 */
void init_aggregator()
@@ -771,7 +775,7 @@ public:
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, 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);
my_decimal *val_decimal(my_decimal *);
bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate)
@@ -779,7 +783,12 @@ public:
return get_date_from_int(thd, ltime, fuzzydate);
}
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 @@ public:
{
if (args[0]->check_type_can_return_int(func_name()))
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;
}
void cleanup()
@@ -1459,7 +1470,7 @@ public:
:Item(thd), field(item->result_field)
{
name= item->name;
- maybe_null= true;
+ flags|= ITEM_FLAG_MAYBE_NULL;
decimals= item->decimals;
max_length= item->max_length;
unsigned_flag= item->unsigned_flag;
@@ -1598,12 +1609,12 @@ public:
const char *func_name() const { return udf.name(); }
bool fix_fields(THD *thd, Item **ref)
{
- DBUG_ASSERT(fixed == 0);
+ DBUG_ASSERT(fixed() == 0);
if (init_sum_func_check(thd))
return TRUE;
- fixed= 1;
+ flags|= ITEM_FLAG_FIXED;
/*
We set const_item_cache to false in constructors.
It can be later changed to "true", in a Item_sum::make_const() call.
@@ -1678,7 +1689,7 @@ public:
:Item_udf_sum(thd, item) {}
longlong val_int();
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);
my_decimal *val_decimal(my_decimal *);
const Type_handler *type_handler() const
@@ -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_double(thd, item) {}
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() {}
bool add() { return 0; }
void reset_field() { DBUG_ASSERT(0); };
@@ -1794,8 +1805,8 @@ public:
Item_sum_udf_int(THD *thd, Item_sum_udf_int *item)
:Item_sum_double(thd, item) {}
enum Sumfunctype sum_func () const { return UDF_SUM_FUNC; }
- longlong val_int() { DBUG_ASSERT(fixed == 1); return 0; }
- double val_real() { DBUG_ASSERT(fixed == 1); return 0; }
+ longlong val_int() { DBUG_ASSERT(fixed()); return 0; }
+ double val_real() { DBUG_ASSERT(fixed()); return 0; }
void clear() {}
bool add() { return 0; }
void reset_field() { DBUG_ASSERT(0); };
@@ -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_double(thd, item) {}
enum Sumfunctype sum_func () const { return UDF_SUM_FUNC; }
- double val_real() { DBUG_ASSERT(fixed == 1); return 0.0; }
- my_decimal *val_decimal(my_decimal *) { DBUG_ASSERT(fixed == 1); return 0; }
+ double val_real() { DBUG_ASSERT(fixed()); return 0.0; }
+ my_decimal *val_decimal(my_decimal *) { DBUG_ASSERT(fixed()); return 0; }
void clear() {}
bool add() { return 0; }
void reset_field() { DBUG_ASSERT(0); };
@@ -1832,10 +1843,10 @@ public:
Item_sum_udf_str(THD *thd, Item_sum_udf_str *item)
:Item_sum_double(thd, item) {}
String *val_str(String *)
- { DBUG_ASSERT(fixed == 1); null_value=1; return 0; }
- double val_real() { DBUG_ASSERT(fixed == 1); null_value=1; return 0.0; }
- longlong val_int() { DBUG_ASSERT(fixed == 1); null_value=1; return 0; }
- bool fix_length_and_dec() { maybe_null=1; max_length=0; return FALSE; }
+ { DBUG_ASSERT(fixed()); null_value=1; return 0; }
+ double val_real() { DBUG_ASSERT(fixed()); null_value=1; return 0.0; }
+ longlong val_int() { DBUG_ASSERT(fixed()); null_value=1; return 0; }
+ bool fix_length_and_dec() { flags|= ITEM_FLAG_MAYBE_NULL; max_length=0; return FALSE; }
enum Sumfunctype sum_func () const { return UDF_SUM_FUNC; }
void clear() {}
bool add() { return 0; }
diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc
index 3707811f3f6..031866798ef 100644
--- a/sql/item_timefunc.cc
+++ b/sql/item_timefunc.cc
@@ -788,7 +788,7 @@ static bool get_interval_info(const char *str, size_t length,CHARSET_INFO *cs,
longlong Item_func_period_add::val_int()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
ulong period=(ulong) args[0]->val_int();
int months=(int) args[1]->val_int();
@@ -803,7 +803,7 @@ longlong Item_func_period_add::val_int()
longlong Item_func_period_diff::val_int()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
ulong period1=(ulong) args[0]->val_int();
ulong period2=(ulong) args[1]->val_int();
@@ -817,7 +817,7 @@ longlong Item_func_period_diff::val_int()
longlong Item_func_to_days::val_int()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
THD *thd= current_thd;
Datetime d(thd, args[0], Datetime::Options(TIME_NO_ZEROS, thd));
return (null_value= !d.is_valid_datetime()) ? 0 : d.daynr();
@@ -827,7 +827,7 @@ longlong Item_func_to_days::val_int()
longlong Item_func_to_seconds::val_int_endpoint(bool left_endp,
bool *incl_endp)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
// val_int_endpoint() is called only if args[0] is a temporal Item_field
Datetime_from_temporal dt(current_thd, args[0], TIME_FUZZY_DATES);
if ((null_value= !dt.is_valid_datetime()))
@@ -845,7 +845,7 @@ longlong Item_func_to_seconds::val_int_endpoint(bool left_endp,
longlong Item_func_to_seconds::val_int()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
THD *thd= current_thd;
/*
Unlike val_int_endpoint(), we cannot use Datetime_from_temporal here.
@@ -895,7 +895,7 @@ enum_monotonicity_info Item_func_to_seconds::get_monotonicity_info() const
longlong Item_func_to_days::val_int_endpoint(bool left_endp, bool *incl_endp)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
// val_int_endpoint() is only called if args[0] is a temporal Item_field
Datetime_from_temporal dt(current_thd, args[0], TIME_CONV_NONE);
longlong res;
@@ -949,7 +949,7 @@ longlong Item_func_to_days::val_int_endpoint(bool left_endp, bool *incl_endp)
longlong Item_func_dayofyear::val_int()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
THD *thd= current_thd;
Datetime d(thd, args[0], Datetime::Options(TIME_NO_ZEROS, thd));
return (null_value= !d.is_valid_datetime()) ? 0 : d.dayofyear();
@@ -957,7 +957,7 @@ longlong Item_func_dayofyear::val_int()
longlong Item_func_dayofmonth::val_int()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
THD *thd= current_thd;
Datetime d(thd, args[0], Datetime::Options(TIME_CONV_NONE, thd));
return (null_value= !d.is_valid_datetime()) ? 0 : d.get_mysql_time()->day;
@@ -965,7 +965,7 @@ longlong Item_func_dayofmonth::val_int()
longlong Item_func_month::val_int()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
THD *thd= current_thd;
Datetime d(thd, args[0], Datetime::Options(TIME_CONV_NONE, thd));
return (null_value= !d.is_valid_datetime()) ? 0 : d.get_mysql_time()->month;
@@ -980,14 +980,14 @@ bool Item_func_monthname::fix_length_and_dec()
collation.set(cs, DERIVATION_COERCIBLE, locale->repertoire());
decimals=0;
max_length= locale->max_month_name_length * collation.collation->mbmaxlen;
- maybe_null=1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE;
}
String* Item_func_monthname::val_str(String* str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
const char *month_name;
uint err;
THD *thd= current_thd;
@@ -1008,7 +1008,7 @@ String* Item_func_monthname::val_str(String* str)
longlong Item_func_quarter::val_int()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
THD *thd= current_thd;
Datetime d(thd, args[0], Datetime::Options(TIME_CONV_NONE, thd));
return (null_value= !d.is_valid_datetime()) ? 0 : d.quarter();
@@ -1016,7 +1016,7 @@ longlong Item_func_quarter::val_int()
longlong Item_func_hour::val_int()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
THD *thd= current_thd;
Time tm(thd, args[0], Time::Options_for_cast(thd));
return (null_value= !tm.is_valid_time()) ? 0 : tm.get_mysql_time()->hour;
@@ -1024,7 +1024,7 @@ longlong Item_func_hour::val_int()
longlong Item_func_minute::val_int()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
THD *thd= current_thd;
Time tm(thd, args[0], Time::Options_for_cast(thd));
return (null_value= !tm.is_valid_time()) ? 0 : tm.get_mysql_time()->minute;
@@ -1035,7 +1035,7 @@ longlong Item_func_minute::val_int()
*/
longlong Item_func_second::val_int()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
THD *thd= current_thd;
Time tm(thd, args[0], Time::Options_for_cast(thd));
return (null_value= !tm.is_valid_time()) ? 0 : tm.get_mysql_time()->second;
@@ -1083,7 +1083,7 @@ uint week_mode(uint mode)
longlong Item_func_week::val_int()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
uint week_format;
THD *thd= current_thd;
Datetime d(thd, args[0], Datetime::Options(TIME_NO_ZEROS, thd));
@@ -1099,7 +1099,7 @@ longlong Item_func_week::val_int()
longlong Item_func_yearweek::val_int()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
THD *thd= current_thd;
Datetime d(thd, args[0], Datetime::Options(TIME_NO_ZEROS, thd));
return (null_value= !d.is_valid_datetime()) ? 0 :
@@ -1109,7 +1109,7 @@ longlong Item_func_yearweek::val_int()
longlong Item_func_weekday::val_int()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
THD *thd= current_thd;
Datetime dt(thd, args[0], Datetime::Options(TIME_NO_ZEROS, thd));
if ((null_value= !dt.is_valid_datetime()))
@@ -1125,14 +1125,14 @@ bool Item_func_dayname::fix_length_and_dec()
collation.set(cs, DERIVATION_COERCIBLE, locale->repertoire());
decimals=0;
max_length= locale->max_day_name_length * collation.collation->mbmaxlen;
- maybe_null=1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE;
}
String* Item_func_dayname::val_str(String* str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
const char *day_name;
uint err;
THD *thd= current_thd;
@@ -1150,7 +1150,7 @@ String* Item_func_dayname::val_str(String* str)
longlong Item_func_year::val_int()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
THD *thd= current_thd;
Datetime d(thd, args[0], Datetime::Options(TIME_CONV_NONE, thd));
return (null_value= !d.is_valid_datetime()) ? 0 : d.get_mysql_time()->year;
@@ -1183,7 +1183,7 @@ enum_monotonicity_info Item_func_year::get_monotonicity_info() const
longlong Item_func_year::val_int_endpoint(bool left_endp, bool *incl_endp)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
// val_int_endpoint() is cally only if args[0] is a temporal Item_field
Datetime_from_temporal dt(current_thd, args[0], TIME_CONV_NONE);
if ((null_value= !dt.is_valid_datetime()))
@@ -1216,7 +1216,7 @@ longlong Item_func_year::val_int_endpoint(bool left_endp, bool *incl_endp)
bool Item_func_unix_timestamp::get_timestamp_value(my_time_t *seconds,
ulong *second_part)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
if (args[0]->type() == FIELD_ITEM)
{ // Optimize timestamp field
Field *field=((Item_field*) args[0])->field;
@@ -1276,7 +1276,7 @@ enum_monotonicity_info Item_func_unix_timestamp::get_monotonicity_info() const
longlong Item_func_unix_timestamp::val_int_endpoint(bool left_endp, bool *incl_endp)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
DBUG_ASSERT(arg_count == 1 &&
args[0]->type() == Item::FIELD_ITEM &&
args[0]->field_type() == MYSQL_TYPE_TIMESTAMP);
@@ -1291,7 +1291,7 @@ longlong Item_func_unix_timestamp::val_int_endpoint(bool left_endp, bool *incl_e
longlong Item_func_time_to_sec::int_op()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
THD *thd= current_thd;
Time tm(thd, args[0], Time::Options_for_cast(thd));
return ((null_value= !tm.is_valid_time())) ? 0 : tm.to_seconds();
@@ -1300,7 +1300,7 @@ longlong Item_func_time_to_sec::int_op()
my_decimal *Item_func_time_to_sec::decimal_op(my_decimal* buf)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
THD *thd= current_thd;
Time tm(thd, args[0], Time::Options_for_cast(thd));
if ((null_value= !tm.is_valid_time()))
@@ -1726,7 +1726,7 @@ bool Item_func_sysdate_local::get_date(THD *thd, MYSQL_TIME *res,
bool Item_func_sec_to_time::get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
VSec9 sec(thd, args[0], "seconds", LONGLONG_MAX);
if ((null_value= sec.is_null()))
return true;
@@ -1774,7 +1774,7 @@ bool Item_func_date_format::fix_length_and_dec()
collation.collation->mbmaxlen;
set_if_smaller(max_length,MAX_BLOB_WIDTH);
}
- maybe_null=1; // If wrong date
+ flags|= ITEM_FLAG_MAYBE_NULL; // If wrong date
return FALSE;
}
@@ -1888,7 +1888,7 @@ String *Item_func_date_format::val_str(String *str)
MYSQL_TIME l_time;
uint size;
const MY_LOCALE *lc= 0;
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
date_conv_mode_t mode= is_time_format ? TIME_TIME_ONLY : TIME_CONV_NONE;
THD *thd= current_thd;
@@ -1937,7 +1937,7 @@ bool Item_func_from_unixtime::fix_length_and_dec()
Type_temporal_attributes_not_fixed_dec(MAX_DATETIME_WIDTH,
args[0]->decimals, false),
DTCollation_numeric());
- maybe_null= true;
+ flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE;
}
@@ -2064,7 +2064,7 @@ bool Item_date_add_interval::fix_length_and_dec()
{
set_func_handler(&func_handler_date_add_interval_string);
}
- maybe_null= true;
+ flags|= ITEM_FLAG_MAYBE_NULL;
return m_func_handler->fix_length_and_dec(this);
}
@@ -2141,7 +2141,7 @@ bool Item_extract::check_arguments() const
bool Item_extract::fix_length_and_dec()
{
- maybe_null=1; // If wrong date
+ flags|= ITEM_FLAG_MAYBE_NULL; // If wrong date
uint32 daylen= args[0]->cmp_type() == TIME_RESULT ? 2 :
TIME_MAX_INTERVAL_DAY_CHAR_LENGTH;
switch (int_type) {
@@ -2182,7 +2182,7 @@ uint Extract_source::week(THD *thd) const
longlong Item_extract::val_int()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
THD *thd= current_thd;
Extract_source dt(thd, args[0], m_date_mode);
if ((null_value= !dt.is_valid_extract_source()))
@@ -2356,7 +2356,7 @@ uint Item_char_typecast::adjusted_length_with_warn(uint length)
String *Item_char_typecast::val_str_generic(String *str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
String *res;
if (has_explicit_length())
@@ -2412,7 +2412,7 @@ end:
String *Item_char_typecast::val_str_binary_from_native(String *str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
DBUG_ASSERT(cast_cs == &my_charset_bin);
NativeBuffer<STRING_BUFFER_USUAL_SIZE> native;
@@ -2504,7 +2504,7 @@ Item_char_typecast::fix_length_and_dec_native_to_binary(uint32 octet_length)
{
collation.set(&my_charset_bin, DERIVATION_IMPLICIT);
max_length= has_explicit_length() ? (uint32) cast_length : octet_length;
- maybe_null|= current_thd->is_strict_mode();
+ flags|= (current_thd->is_strict_mode() ? ITEM_FLAG_MAYBE_NULL : 0);
}
@@ -2549,7 +2549,7 @@ void Item_char_typecast::fix_length_and_dec_internal(CHARSET_INFO *from_cs)
args[0]->collation.collation->mbmaxlen));
max_length= char_length * cast_cs->mbmaxlen;
// Add NULL-ability in strict mode. See Item_str_func::fix_fields()
- maybe_null= maybe_null || current_thd->is_strict_mode();
+ flags|= (current_thd->is_strict_mode() ? ITEM_FLAG_MAYBE_NULL : 0);
}
@@ -2610,7 +2610,7 @@ Sql_mode_dependency Item_datetime_typecast::value_depends_on_sql_mode() const
bool Item_func_makedate::get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
long year, days, daynr= (long) args[1]->val_int();
VYear vyear(args[0]);
@@ -2673,7 +2673,7 @@ bool Item_func_add_time::fix_length_and_dec()
&func_handler_add_time_string_sub);
}
- maybe_null= true;
+ flags|= ITEM_FLAG_MAYBE_NULL;
return m_func_handler->fix_length_and_dec(this);
}
@@ -2688,7 +2688,7 @@ bool Item_func_add_time::fix_length_and_dec()
bool Item_func_timediff::get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
int l_sign= 1;
MYSQL_TIME l_time1,l_time2,l_time3;
ErrConvTime str(&l_time3);
@@ -2721,7 +2721,7 @@ bool Item_func_timediff::get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzy
bool Item_func_maketime::get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
Longlong_hybrid hour(args[0]->val_int(), args[0]->unsigned_flag);
longlong minute= args[1]->val_int();
VSec9 sec(thd, args[2], "seconds", 59);
@@ -2762,7 +2762,7 @@ bool Item_func_maketime::get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzy
longlong Item_func_microsecond::val_int()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
THD *thd= current_thd;
Time tm(thd, args[0], Time::Options_for_cast(thd));
return ((null_value= !tm.is_valid_time())) ?
@@ -2926,7 +2926,7 @@ void Item_func_timestamp_diff::print(String *str, enum_query_type query_type)
String *Item_func_get_format::val_str_ascii(String *str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
const char *format_name;
KNOWN_DATE_TIME_FORMAT *format;
String *val= args[0]->val_str_ascii(str);
@@ -3059,7 +3059,7 @@ bool Item_func_str_to_date::fix_length_and_dec()
if (collation.collation->mbminlen > 1)
internal_charset= &my_charset_utf8mb4_general_ci;
- maybe_null= true;
+ flags|= ITEM_FLAG_MAYBE_NULL;
set_func_handler(&func_handler_str_to_date_datetime_usec);
if ((const_item= args[1]->const_item()))
diff --git a/sql/item_timefunc.h b/sql/item_timefunc.h
index 107c3372a15..83ed1ea5e8c 100644
--- a/sql/item_timefunc.h
+++ b/sql/item_timefunc.h
@@ -97,7 +97,7 @@ public:
{
decimals=0;
max_length=6*MY_CHARSET_BIN_MB_MAXLEN;
- maybe_null=1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE;
}
enum_monotonicity_info get_monotonicity_info() const;
@@ -125,7 +125,7 @@ public:
{
decimals=0;
fix_char_length(12);
- maybe_null= 1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE;
}
enum_monotonicity_info get_monotonicity_info() const;
@@ -152,7 +152,7 @@ public:
{
decimals=0;
max_length=2*MY_CHARSET_BIN_MB_MAXLEN;
- maybe_null=1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE;
}
bool check_partition_func_processor(void *int_arg) {return FALSE;}
@@ -177,7 +177,7 @@ public:
{
decimals= 0;
fix_char_length(2);
- maybe_null=1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE;
}
bool check_partition_func_processor(void *int_arg) {return FALSE;}
@@ -223,7 +223,7 @@ public:
{
decimals= 0;
fix_char_length(3);
- maybe_null=1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE;
}
bool check_partition_func_processor(void *int_arg) {return FALSE;}
@@ -247,7 +247,7 @@ public:
{
decimals=0;
max_length=2*MY_CHARSET_BIN_MB_MAXLEN;
- maybe_null=1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE;
}
bool check_partition_func_processor(void *int_arg) {return FALSE;}
@@ -271,7 +271,7 @@ public:
{
decimals=0;
max_length=2*MY_CHARSET_BIN_MB_MAXLEN;
- maybe_null=1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE;
}
bool check_partition_func_processor(void *int_arg) {return FALSE;}
@@ -295,7 +295,7 @@ public:
{
decimals=0;
max_length=1*MY_CHARSET_BIN_MB_MAXLEN;
- maybe_null=1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE;
}
bool check_partition_func_processor(void *int_arg) {return FALSE;}
@@ -319,7 +319,7 @@ public:
{
decimals=0;
max_length=2*MY_CHARSET_BIN_MB_MAXLEN;
- maybe_null=1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE;
}
bool check_partition_func_processor(void *int_arg) {return FALSE;}
@@ -349,7 +349,7 @@ public:
{
decimals=0;
max_length=2*MY_CHARSET_BIN_MB_MAXLEN;
- maybe_null=1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE;
}
bool check_vcol_func_processor(void *arg)
@@ -382,7 +382,7 @@ public:
{
decimals=0;
max_length=6*MY_CHARSET_BIN_MB_MAXLEN;
- maybe_null=1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE;
}
bool check_partition_func_processor(void *int_arg) {return FALSE;}
@@ -408,7 +408,7 @@ public:
{
decimals=0;
max_length=4*MY_CHARSET_BIN_MB_MAXLEN;
- maybe_null=1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE;
}
bool check_partition_func_processor(void *int_arg) {return FALSE;}
@@ -441,7 +441,7 @@ public:
{
decimals= 0;
fix_char_length(1);
- maybe_null=1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE;
}
bool check_partition_func_processor(void *int_arg) {return FALSE;}
@@ -487,7 +487,7 @@ public:
DBUG_ASSERT(dec <= TIME_SECOND_PART_DIGITS);
decimals= dec;
max_length=17 + (decimals ? decimals + 1 : 0);
- maybe_null= true;
+ flags|= ITEM_FLAG_MAYBE_NULL;
if (decimals)
set_handler(&type_handler_newdecimal);
else
@@ -580,7 +580,7 @@ public:
bool fix_length_and_dec()
{
fix_attributes_date();
- maybe_null= (arg_count > 0);
+ set_maybe_null(arg_count > 0);
return FALSE;
}
};
@@ -906,7 +906,7 @@ class Item_func_convert_tz :public Item_datetimefunc
bool fix_length_and_dec()
{
fix_attributes_datetime(args[0]->datetime_precision(current_thd));
- maybe_null= true;
+ flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE;
}
bool get_date(THD *thd, MYSQL_TIME *res, date_mode_t fuzzydate);
@@ -926,7 +926,7 @@ public:
bool fix_length_and_dec()
{
fix_attributes_time(args[0]->decimals);
- maybe_null= true;
+ flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE;
}
const char *func_name() const { return "sec_to_time"; }
@@ -1214,7 +1214,7 @@ public:
uint dec0= args[0]->datetime_precision(thd);
uint dec1= Interval_DDhhmmssff::fsp(thd, args[1]);
fix_attributes_datetime(MY_MAX(dec0, dec1));
- maybe_null= true;
+ flags|= ITEM_FLAG_MAYBE_NULL;
return false;
}
bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate)
@@ -1274,7 +1274,7 @@ public:
uint dec= MY_MAX(args[0]->time_precision(thd),
args[1]->time_precision(thd));
fix_attributes_time(dec);
- maybe_null= true;
+ flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE;
}
bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate);
@@ -1296,7 +1296,7 @@ public:
bool fix_length_and_dec()
{
fix_attributes_time(args[2]->decimals);
- maybe_null= true;
+ flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE;
}
const char *func_name() const { return "maketime"; }
@@ -1315,7 +1315,7 @@ public:
bool fix_length_and_dec()
{
decimals=0;
- maybe_null=1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
fix_char_length(6);
return FALSE;
}
@@ -1346,7 +1346,7 @@ public:
bool fix_length_and_dec()
{
decimals=0;
- maybe_null=1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
return FALSE;
}
virtual void print(String *str, enum_query_type query_type);
@@ -1371,7 +1371,7 @@ public:
const char *func_name() const { return "get_format"; }
bool fix_length_and_dec()
{
- maybe_null= 1;
+ flags|= ITEM_FLAG_MAYBE_NULL;
decimals=0;
fix_length_and_charset(17, default_charset());
return FALSE;
diff --git a/sql/item_vers.cc b/sql/item_vers.cc
index 792c434b8c3..aa505f2111d 100644
--- a/sql/item_vers.cc
+++ b/sql/item_vers.cc
@@ -29,7 +29,7 @@
bool Item_func_history::val_bool()
{
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);
return !f->field->is_max();
}
diff --git a/sql/item_vers.h b/sql/item_vers.h
index 0799d04a0bc..99cc4e2d024 100644
--- a/sql/item_vers.h
+++ b/sql/item_vers.h
@@ -40,7 +40,7 @@ public:
}
bool fix_length_and_dec()
{
- maybe_null= 0;
+ set_maybe_null(0);
null_value= 0;
decimals= 0;
max_length= 1;
diff --git a/sql/item_windowfunc.cc b/sql/item_windowfunc.cc
index 8b9157f8377..cdf8ebf9879 100644
--- a/sql/item_windowfunc.cc
+++ b/sql/item_windowfunc.cc
@@ -84,7 +84,7 @@ Item_window_func::update_used_tables()
bool
Item_window_func::fix_fields(THD *thd, Item **ref)
{
- DBUG_ASSERT(fixed == 0);
+ DBUG_ASSERT(fixed() == 0);
if (!thd->lex->current_select ||
(thd->lex->current_select->context_analysis_place != SELECT_LIST &&
@@ -119,16 +119,16 @@ Item_window_func::fix_fields(THD *thd, Item **ref)
return true;
const_item_cache= false;
- with_window_func= true;
- with_sum_func= false;
+
+ flags= (flags & ~ITEM_FLAG_WITH_SUM_FUNC) | ITEM_FLAG_WITH_WINDOW_FUNC;
if (fix_length_and_dec())
return TRUE;
max_length= window_func()->max_length;
- maybe_null= window_func()->maybe_null;
+ set_maybe_null(window_func()->maybe_null());
- fixed= 1;
+ flags|= ITEM_FLAG_FIXED;
set_phase_to_initial();
return false;
}
@@ -335,7 +335,7 @@ void Item_sum_percent_rank::setup_window_func(THD *thd, Window_spec *window_spec
bool Item_sum_hybrid_simple::fix_fields(THD *thd, Item **ref)
{
- DBUG_ASSERT(fixed == 0);
+ DBUG_ASSERT(fixed() == 0);
if (init_sum_func_check(thd))
return TRUE;
@@ -344,8 +344,8 @@ bool Item_sum_hybrid_simple::fix_fields(THD *thd, Item **ref)
{
if (args[i]->fix_fields_if_needed_for_scalar(thd, &args[i]))
return TRUE;
- with_window_func|= args[i]->with_window_func;
- with_subquery|= args[i]->with_subquery;
+ flags|= (args[i]->flags & (ITEM_FLAG_WITH_WINDOW_FUNC |
+ ITEM_FLAG_WITH_SUBQUERY));
}
if (fix_length_and_dec())
@@ -357,17 +357,17 @@ bool Item_sum_hybrid_simple::fix_fields(THD *thd, Item **ref)
if (check_sum_func(thd, ref))
return TRUE;
for (uint i= 0; i < arg_count; i++)
- {
orig_args[i]= args[i];
- }
- fixed= 1;
+
+ flags|= ITEM_FLAG_FIXED;
return FALSE;
}
bool Item_sum_hybrid_simple::fix_length_and_dec()
{
- maybe_null= null_value= true;
+ flags|= ITEM_FLAG_MAYBE_NULL;
+ null_value= true;
return args[0]->type_handler()->Item_sum_hybrid_fix_length_and_dec(this);
}
@@ -393,7 +393,7 @@ void Item_sum_hybrid_simple::setup_hybrid(THD *thd, Item *item)
double Item_sum_hybrid_simple::val_real()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
if (null_value)
return 0.0;
double retval= value->val_real();
@@ -404,7 +404,7 @@ double Item_sum_hybrid_simple::val_real()
longlong Item_sum_hybrid_simple::val_int()
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
if (null_value)
return 0;
longlong retval= value->val_int();
@@ -415,7 +415,7 @@ longlong Item_sum_hybrid_simple::val_int()
my_decimal *Item_sum_hybrid_simple::val_decimal(my_decimal *val)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
if (null_value)
return 0;
my_decimal *retval= value->val_decimal(val);
@@ -427,7 +427,7 @@ my_decimal *Item_sum_hybrid_simple::val_decimal(my_decimal *val)
String *
Item_sum_hybrid_simple::val_str(String *str)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
if (null_value)
return 0;
String *retval= value->val_str(str);
@@ -438,7 +438,7 @@ Item_sum_hybrid_simple::val_str(String *str)
bool Item_sum_hybrid_simple::val_native(THD *thd, Native *to)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
if (null_value)
return true;
return val_native_from_item(thd, value, to);
@@ -446,7 +446,7 @@ bool Item_sum_hybrid_simple::val_native(THD *thd, Native *to)
bool Item_sum_hybrid_simple::get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate)
{
- DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(fixed());
if (null_value)
return true;
bool retval= value->get_date(thd, ltime, fuzzydate);
@@ -487,7 +487,7 @@ void Item_sum_hybrid_simple::reset_field()
{
longlong nr=args[0]->val_int();
- if (maybe_null)
+ if (maybe_null())
{
if (args[0]->null_value)
{
@@ -504,7 +504,7 @@ void Item_sum_hybrid_simple::reset_field()
{
double nr= args[0]->val_real();
- if (maybe_null)
+ if (maybe_null())
{
if (args[0]->null_value)
{
@@ -521,7 +521,7 @@ void Item_sum_hybrid_simple::reset_field()
{
VDec arg_dec(args[0]);
- if (maybe_null)
+ if (maybe_null())
{
if (arg_dec.is_null())
result_field->set_null();
diff --git a/sql/item_xmlfunc.h b/sql/item_xmlfunc.h
index 806739d1139..3369304d79c 100644
--- a/sql/item_xmlfunc.h
+++ b/sql/item_xmlfunc.h
@@ -110,12 +110,12 @@ protected:
public:
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_str_func(thd, a, b, c)
{
- maybe_null= TRUE;
+ flags|= ITEM_FLAG_MAYBE_NULL;
}
bool fix_fields(THD *thd, Item **ref);
bool fix_length_and_dec();
diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc
index ebc42b26490..ec1954bd3bd 100644
--- a/sql/opt_subselect.cc
+++ b/sql/opt_subselect.cc
@@ -966,7 +966,7 @@ bool make_in_exists_conversion(THD *thd, JOIN *join, Item_in_subselect *item)
call.
*/
item->changed= 0;
- item->fixed= 0;
+ item->flags|= ITEM_FLAG_FIXED;
SELECT_LEX *save_select_lex= thd->lex->current_select;
thd->lex->current_select= item->unit->first_select();
@@ -979,7 +979,7 @@ bool make_in_exists_conversion(THD *thd, JOIN *join, Item_in_subselect *item)
DBUG_RETURN(TRUE);
item->changed= 1;
- item->fixed= 1;
+ DBUG_ASSERT(item->fixed());
Item *substitute= item->substitution;
bool do_fix_fields= !item->substitution->is_fixed();
@@ -1318,7 +1318,7 @@ bool convert_join_subqueries_to_semijoins(JOIN *join)
{
JOIN *child_join= in_subq->unit->first_select()->join;
in_subq->changed= 0;
- in_subq->fixed= 0;
+ in_subq->flags|= ITEM_FLAG_FIXED;
SELECT_LEX *save_select_lex= thd->lex->current_select;
thd->lex->current_select= in_subq->unit->first_select();
@@ -1331,7 +1331,7 @@ bool convert_join_subqueries_to_semijoins(JOIN *join)
DBUG_RETURN(TRUE);
in_subq->changed= 1;
- in_subq->fixed= 1;
+ DBUG_ASSERT(in_subq->fixed());
Item *substitute= in_subq->substitution;
bool do_fix_fields= !in_subq->substitution->is_fixed();
@@ -2714,7 +2714,7 @@ bool find_eq_ref_candidate(TABLE *table, table_map sj_inner_tables)
*/
if (!(keyuse->used_tables & sj_inner_tables) &&
!(keyuse->optimize & KEY_OPTIMIZE_REF_OR_NULL) &&
- (keyuse->null_rejecting || !keyuse->val->maybe_null))
+ (keyuse->null_rejecting || !keyuse->val->maybe_null()))
{
bound_parts |= 1 << keyuse->keypart;
}
diff --git a/sql/opt_sum.cc b/sql/opt_sum.cc
index 27360d4a10c..edefbc83787 100644
--- a/sql/opt_sum.cc
+++ b/sql/opt_sum.cc
@@ -342,7 +342,7 @@ int opt_sum_query(THD *thd,
to the number of rows in the tables if this number is exact and
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 &&
((item->used_tables() & OUTER_REF_TABLE_BIT) == 0))
{
diff --git a/sql/sp_head.cc b/sql/sp_head.cc
index 329c8e42c30..50670c126f2 100644
--- a/sql/sp_head.cc
+++ b/sql/sp_head.cc
@@ -2994,7 +2994,7 @@ sp_head::show_create_routine_get_fields(THD *thd, const Sp_handler *sph,
Item_empty_string *stmt_fld=
new (mem_root) Item_empty_string(thd, col3_caption, 1024);
- stmt_fld->maybe_null= TRUE;
+ stmt_fld->flags|= ITEM_FLAG_MAYBE_NULL;
fields->push_back(stmt_fld, mem_root);
}
@@ -3070,7 +3070,7 @@ sp_head::show_create_routine(THD *thd, const Sp_handler *sph)
new (mem_root) Item_empty_string(thd, col3_caption,
(uint)MY_MAX(m_defstr.length, 1024));
- stmt_fld->maybe_null= TRUE;
+ stmt_fld->flags|= ITEM_FLAG_MAYBE_NULL;
fields.push_back(stmt_fld, thd->mem_root);
}
diff --git a/sql/sql_admin.cc b/sql/sql_admin.cc
index 35682f104d9..e660f72ab66 100644
--- a/sql/sql_admin.cc
+++ b/sql/sql_admin.cc
@@ -510,18 +510,18 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
field_list.push_back(item= new (thd->mem_root)
Item_empty_string(thd, "Table",
NAME_CHAR_LEN * 2), thd->mem_root);
- item->maybe_null = 1;
+ item->flags|= ITEM_FLAG_MAYBE_NULL;
field_list.push_back(item= new (thd->mem_root)
Item_empty_string(thd, "Op", 10), thd->mem_root);
- item->maybe_null = 1;
+ item->flags|= ITEM_FLAG_MAYBE_NULL;
field_list.push_back(item= new (thd->mem_root)
Item_empty_string(thd, "Msg_type", 10), thd->mem_root);
- item->maybe_null = 1;
+ item->flags|= ITEM_FLAG_MAYBE_NULL;
field_list.push_back(item= new (thd->mem_root)
Item_empty_string(thd, "Msg_text",
SQL_ADMIN_MSG_TEXT_SIZE),
thd->mem_root);
- item->maybe_null = 1;
+ item->flags|= ITEM_FLAG_MAYBE_NULL;
if (protocol->send_result_set_metadata(&field_list,
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
DBUG_RETURN(TRUE);
diff --git a/sql/sql_analyse.cc b/sql/sql_analyse.cc
index edcc8aeeda6..090fd724873 100644
--- a/sql/sql_analyse.cc
+++ b/sql/sql_analyse.cc
@@ -1165,16 +1165,16 @@ bool analyse::change_columns(THD *thd, List<Item> &field_list)
func_items[0]= new (mem_root) Item_proc_string(thd, "Field_name", 255);
func_items[1]= new (mem_root) Item_proc_string(thd, "Min_value", 255);
- func_items[1]->maybe_null = 1;
+ func_items[1]->flags|= ITEM_FLAG_MAYBE_NULL;
func_items[2]= new (mem_root) Item_proc_string(thd, "Max_value", 255);
- func_items[2]->maybe_null = 1;
+ func_items[2]->flags|= ITEM_FLAG_MAYBE_NULL;
func_items[3]= new (mem_root) Item_proc_int(thd, "Min_length");
func_items[4]= new (mem_root) Item_proc_int(thd, "Max_length");
func_items[5]= new (mem_root) Item_proc_int(thd, "Empties_or_zeros");
func_items[6]= new (mem_root) Item_proc_int(thd, "Nulls");
func_items[7]= new (mem_root) Item_proc_string(thd, "Avg_value_or_avg_length", 255);
func_items[8]= new (mem_root) Item_proc_string(thd, "Std", 255);
- func_items[8]->maybe_null = 1;
+ func_items[8]->flags|= ITEM_FLAG_MAYBE_NULL;
func_items[9]= new (mem_root) Item_proc_string(thd, "Optimal_fieldtype",
MY_MAX(64,
output_str_length));
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 7977dddd54e..b35c8fe21db 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -5849,7 +5849,7 @@ find_field_in_view(THD *thd, TABLE_LIST *table_list,
replace. If the item was aliased by the user, set the alias to
the replacing item.
*/
- if (*ref && !(*ref)->is_autogenerated_name)
+ if (*ref && !(*ref)->is_autogenerated_name())
item->set_name(thd, (*ref)->name);
if (register_tree_change)
thd->change_item_tree(ref, item);
@@ -5940,7 +5940,7 @@ find_field_in_natural_join(THD *thd, TABLE_LIST *table_ref, const char *name, si
replace. If the item was aliased by the user, set the alias to
the replacing item.
*/
- if (*ref && !(*ref)->is_autogenerated_name)
+ if (*ref && !(*ref)->is_autogenerated_name())
item->set_name(thd, (*ref)->name);
if (register_tree_change && arena)
thd->restore_active_arena(arena, &backup);
@@ -7711,8 +7711,8 @@ bool setup_fields(THD *thd, Ref_ptr_array ref_pointer_array,
Item_window_func::split_sum_func.
*/
if (sum_func_list &&
- ((item->with_sum_func && item->type() != Item::SUM_FUNC_ITEM) ||
- item->with_window_func))
+ ((item->with_sum_func() && item->type() != Item::SUM_FUNC_ITEM) ||
+ item->with_window_func()))
{
item->split_sum_func(thd, ref_pointer_array, *sum_func_list,
SPLIT_SUM_SELECT);
@@ -7937,7 +7937,7 @@ bool setup_tables(THD *thd, Name_resolution_context *context,
if (table_list->jtbm_subselect)
{
Item *item= table_list->jtbm_subselect->optimizer;
- if (!table_list->jtbm_subselect->optimizer->fixed &&
+ if (!table_list->jtbm_subselect->optimizer->fixed() &&
table_list->jtbm_subselect->optimizer->fix_fields(thd, &item))
{
my_error(ER_TOO_MANY_TABLES,MYF(0), static_cast<int>(MAX_TABLES)); /* psergey-todo: WHY ER_TOO_MANY_TABLES ???*/
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 5b4eb35ea27..aa621d4b7f1 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -2711,45 +2711,45 @@ void THD::make_explain_field_list(List<Item> &field_list, uint8 explain_flags,
field_list.push_back(item= new (mem_root)
Item_return_int(this, "id", 3,
MYSQL_TYPE_LONGLONG), mem_root);
- item->maybe_null= 1;
+ item->flags|= ITEM_FLAG_MAYBE_NULL;
field_list.push_back(new (mem_root)
Item_empty_string(this, "select_type", 19, cs),
mem_root);
field_list.push_back(item= new (mem_root)
Item_empty_string(this, "table", NAME_CHAR_LEN, cs),
mem_root);
- item->maybe_null= 1;
+ item->flags|= ITEM_FLAG_MAYBE_NULL;
if (explain_flags & DESCRIBE_PARTITIONS)
{
/* Maximum length of string that make_used_partitions_str() can produce */
item= new (mem_root) Item_empty_string(this, "partitions",
MAX_PARTITIONS * (1 + FN_LEN), cs);
field_list.push_back(item, mem_root);
- item->maybe_null= 1;
+ item->flags|= ITEM_FLAG_MAYBE_NULL;
}
field_list.push_back(item= new (mem_root)
Item_empty_string(this, "type", 10, cs),
mem_root);
- item->maybe_null= 1;
+ item->flags|= ITEM_FLAG_MAYBE_NULL;
field_list.push_back(item= new (mem_root)
Item_empty_string(this, "possible_keys",
NAME_CHAR_LEN*MAX_KEY, cs),
mem_root);
- item->maybe_null=1;
+ item->flags|= ITEM_FLAG_MAYBE_NULL;
field_list.push_back(item=new (mem_root)
Item_empty_string(this, "key", NAME_CHAR_LEN, cs),
mem_root);
- item->maybe_null=1;
+ item->flags|= ITEM_FLAG_MAYBE_NULL;
field_list.push_back(item=new (mem_root)
Item_empty_string(this, "key_len",
NAME_CHAR_LEN*MAX_KEY),
mem_root);
- item->maybe_null=1;
+ item->flags|= ITEM_FLAG_MAYBE_NULL;
field_list.push_back(item=new (mem_root)
Item_empty_string(this, "ref",
NAME_CHAR_LEN*MAX_REF_PARTS, cs),
mem_root);
- item->maybe_null=1;
+ item->flags|= ITEM_FLAG_MAYBE_NULL;
field_list.push_back(item=new (mem_root)
Item_empty_string(this, "rows", NAME_CHAR_LEN, cs),
mem_root);
@@ -2758,7 +2758,7 @@ void THD::make_explain_field_list(List<Item> &field_list, uint8 explain_flags,
field_list.push_back(item= new (mem_root)
Item_empty_string(this, "r_rows", NAME_CHAR_LEN, cs),
mem_root);
- item->maybe_null=1;
+ item->flags|= ITEM_FLAG_MAYBE_NULL;
}
if (is_analyze || (explain_flags & DESCRIBE_EXTENDED))
@@ -2766,7 +2766,7 @@ void THD::make_explain_field_list(List<Item> &field_list, uint8 explain_flags,
field_list.push_back(item= new (mem_root)
Item_float(this, "filtered", 0.1234, 2, 4),
mem_root);
- item->maybe_null=1;
+ item->flags|= ITEM_FLAG_MAYBE_NULL;
}
if (is_analyze)
@@ -2774,10 +2774,10 @@ void THD::make_explain_field_list(List<Item> &field_list, uint8 explain_flags,
field_list.push_back(item= new (mem_root)
Item_float(this, "r_filtered", 0.1234, 2, 4),
mem_root);
- item->maybe_null=1;
+ item->flags|= ITEM_FLAG_MAYBE_NULL;
}
- item->maybe_null= 1;
+ item->flags|= ITEM_FLAG_MAYBE_NULL;
field_list.push_back(new (mem_root)
Item_empty_string(this, "Extra", 255, cs),
mem_root);
diff --git a/sql/sql_class.h b/sql/sql_class.h
index a6a0d9097f9..8a0463f9f8e 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -7605,7 +7605,7 @@ public:
bool aggregate_attributes(THD *thd)
{
for (uint i= 0; i < arg_count; i++)
- m_maybe_null|= args[i]->maybe_null;
+ m_maybe_null|= args[i]->maybe_null();
return
type_handler()->Item_hybrid_func_fix_attributes(thd,
"UNION", this, this,
diff --git a/sql/sql_cte.cc b/sql/sql_cte.cc
index f53590d6625..6f62a38b231 100644
--- a/sql/sql_cte.cc
+++ b/sql/sql_cte.cc
@@ -993,7 +993,7 @@ With_element::process_columns_of_derived_unit(THD *thd,
while ((item= it++, name= nm++))
{
item->set_name(thd, *name);
- item->is_autogenerated_name= 0;
+ item->flags&= ~ITEM_FLAG_IS_AUTOGENERATED_NAME;
}
if (arena)
@@ -1036,7 +1036,7 @@ With_element::process_columns_of_derived_unit(THD *thd,
my_error(ER_BAD_FIELD_ERROR, MYF(0), name->str, "CYCLE clause");
return true;
}
- item->is_in_with_cycle= 1;
+ item->flags|= ITEM_FLAG_IS_IN_WITH_CYCLE;
}
}
unit->columns_are_renamed= true;
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index 381d0be4384..e0c8eae7f50 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -4424,7 +4424,7 @@ TABLE *select_create::create_table_from_items(THD *thd, List<Item> *items,
if (!cr_field)
DBUG_RETURN(NULL);
- if (item->maybe_null)
+ if (item->maybe_null())
cr_field->flags &= ~NOT_NULL_FLAG;
alter_info->create_list.push_back(cr_field, thd->mem_root);
}
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index f937e9ba583..faaeb57310a 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -4854,7 +4854,7 @@ bool st_select_lex::optimize_unflattened_subqueries(bool const_only)
if (subquery_predicate)
{
- if (!subquery_predicate->fixed)
+ if (!subquery_predicate->fixed())
{
/*
This subquery was excluded as part of some expression so it is
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index a47ef297a7f..48f18ecd64f 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -1233,9 +1233,9 @@ JOIN::prepare(TABLE_LIST *tables_init, COND *conds_init, uint og_num,
while ((select_el= select_it++))
{
- if (select_el->with_sum_func)
+ if (select_el->with_sum_func())
found_sum_func_elem= true;
- if (select_el->with_field)
+ if (select_el->with_field())
found_field_elem= true;
if (found_sum_func_elem && found_field_elem)
{
@@ -1361,7 +1361,7 @@ JOIN::prepare(TABLE_LIST *tables_init, COND *conds_init, uint og_num,
DBUG_RETURN(-1); /* purecov: inspected */
thd->lex->allow_sum_func= save_allow_sum_func;
- if (having->with_window_func)
+ if (having->with_window_func())
{
my_error(ER_WRONG_PLACEMENT_OF_WINDOW_FUNCTION, MYF(0));
DBUG_RETURN(-1);
@@ -1379,7 +1379,7 @@ JOIN::prepare(TABLE_LIST *tables_init, COND *conds_init, uint og_num,
Item *item;
while ((item= it++))
{
- if (item->with_window_func)
+ if (item->with_window_func())
item->update_used_tables();
}
}
@@ -1437,13 +1437,13 @@ JOIN::prepare(TABLE_LIST *tables_init, COND *conds_init, uint og_num,
((Item_field *) item)->field->sort_length()) &&
/* AND not a zero length NOT NULL string function. */
(item->type() != Item::FUNC_ITEM ||
- item->maybe_null ||
+ item->maybe_null() ||
item->result_type() != STRING_RESULT ||
item->max_length)))
requires_sorting= TRUE;
- if ((item->with_sum_func && item->type() != Item::SUM_FUNC_ITEM) ||
- item->with_window_func)
+ if ((item->with_sum_func() && item->type() != Item::SUM_FUNC_ITEM) ||
+ item->with_window_func())
item->split_sum_func(thd, ref_ptrs, all_fields, SPLIT_SUM_SELECT);
}
/* Drop the ORDER BY clause if none of the columns contain any data that
@@ -1461,7 +1461,7 @@ JOIN::prepare(TABLE_LIST *tables_init, COND *conds_init, uint og_num,
}
}
- if (having && having->with_sum_func)
+ if (having && having->with_sum_func())
having->split_sum_func2(thd, ref_ptrs, all_fields,
&having, SPLIT_SUM_SKIP_REGISTERED);
if (select_lex->inner_sum_func_list)
@@ -2927,7 +2927,7 @@ int JOIN::optimize_stage2()
elements may be lost during further having
condition transformation in JOIN::exec.
*/
- if (having && const_table_map && !having->with_sum_func)
+ if (having && const_table_map && !having->with_sum_func())
{
having->update_used_tables();
having= having->remove_eq_conds(thd, &select_lex->having_value, true);
@@ -6195,7 +6195,7 @@ add_key_field(JOIN *join,
{
if ((cond->functype() == Item_func::EQ_FUNC ||
cond->functype() == Item_func::MULT_EQUAL_FUNC) &&
- ((*value)->maybe_null || field->real_maybe_null()))
+ ((*value)->maybe_null() || field->real_maybe_null()))
(*key_fields)->null_rejecting= true;
else
(*key_fields)->null_rejecting= false;
@@ -7642,7 +7642,7 @@ best_access_path(JOIN *join,
if (!(keyuse->used_tables & ~join->const_table_map))
const_part|= keyuse->keypart_map;
- if (!keyuse->val->maybe_null || keyuse->null_rejecting)
+ if (!keyuse->val->maybe_null() || keyuse->null_rejecting)
notnull_part|=keyuse->keypart_map;
double tmp2= prev_record_reads(join_positions, idx,
@@ -10984,7 +10984,7 @@ static bool create_ref_for_key(JOIN *join, JOIN_TAB *j,
j->ref.items[i]=keyuse->val; // Save for cond removal
j->ref.cond_guards[i]= keyuse->cond_guard;
- if (!keyuse->val->maybe_null || keyuse->null_rejecting)
+ if (!keyuse->val->maybe_null() || keyuse->null_rejecting)
not_null_keyparts++;
/*
Set ref.null_rejecting to true only if we are going to inject a
@@ -14290,7 +14290,7 @@ static void update_depend_map_for_order(JOIN *join, ORDER *order)
order->used= 0;
// Not item_sum(), RAND() and no reference to table outside of sub select
if (!(order->depend_map & (OUTER_REF_TABLE_BIT | RAND_TABLE_BIT))
- && !order->item[0]->with_sum_func &&
+ && !order->item[0]->with_sum_func() &&
join->join_tab)
{
for (JOIN_TAB **tab=join->map2table;
@@ -14397,8 +14397,8 @@ remove_const(JOIN *join,ORDER *first_order, COND *cond,
for (order=first_order; order ; order=order->next)
{
table_map order_tables=order->item[0]->used_tables();
- if (order->item[0]->with_sum_func ||
- order->item[0]->with_window_func ||
+ if (order->item[0]->with_sum_func() ||
+ order->item[0]->with_window_func() ||
/*
If the outer table of an outer join is const (either by itself or
after applying WHERE condition), grouping on a field from such a
@@ -14545,7 +14545,7 @@ ORDER *simple_remove_const(ORDER *order, COND *where)
ORDER *first= NULL, *prev= NULL;
for (; order; order= order->next)
{
- DBUG_ASSERT(!order->item[0]->with_sum_func); // should never happen
+ DBUG_ASSERT(!order->item[0]->with_sum_func()); // should never happen
if (!const_expression_in_where(where, order->item[0]))
{
if (!first)
@@ -17756,7 +17756,7 @@ Item_bool_func2::remove_eq_conds(THD *thd, Item::cond_result *cond_value,
if (args[0]->eq(args[1], true))
{
if (*cond_value == Item::COND_FALSE ||
- !args[0]->maybe_null || functype() == Item_func::EQUAL_FUNC)
+ !args[0]->maybe_null() || functype() == Item_func::EQUAL_FUNC)
return (COND*) 0; // Compare of identical items
}
}
@@ -18049,7 +18049,7 @@ Field *Item::create_tmp_field_int(MEM_ROOT *root, TABLE *table,
h= &type_handler_slonglong;
if (unsigned_flag)
h= h->type_handler_unsigned();
- return h->make_and_init_table_field(root, &name, Record_addr(maybe_null),
+ return h->make_and_init_table_field(root, &name, Record_addr(maybe_null()),
*this, table);
}
@@ -18083,7 +18083,7 @@ Field *Item_sum::create_tmp_field(MEM_ROOT *root, bool group, TABLE *table)
case REAL_RESULT:
{
new_field= new (root)
- Field_double(max_char_length(), maybe_null, &name, decimals, TRUE);
+ Field_double(max_char_length(), maybe_null(), &name, decimals, TRUE);
break;
}
case INT_RESULT:
@@ -18119,9 +18119,9 @@ Item_field::create_tmp_field_from_item_field(MEM_ROOT *root, TABLE *new_table,
If item have to be able to store NULLs but underlaid field can't do it,
create_tmp_field_from_field() can't be used for tmp field creation.
*/
- if (((maybe_null && in_rollup) ||
+ if (((maybe_null() && in_rollup()) ||
(new_table->in_use->create_tmp_table_for_derived && /* for mat. view/dt */
- orig_item && orig_item->maybe_null)) &&
+ orig_item && orig_item->maybe_null())) &&
!field->maybe_null())
{
/*
@@ -18130,7 +18130,7 @@ Item_field::create_tmp_field_from_item_field(MEM_ROOT *root, TABLE *new_table,
when the outer query decided at some point after name resolution phase
that this field might be null. Take this into account here.
*/
- Record_addr rec(orig_item ? orig_item->maybe_null : maybe_null);
+ Record_addr rec(orig_item ? orig_item->maybe_null() : maybe_null());
const Type_handler *handler= type_handler()->
type_handler_for_tmp_table(this);
result= handler->make_and_init_table_field(root,
@@ -18143,13 +18143,13 @@ Item_field::create_tmp_field_from_item_field(MEM_ROOT *root, TABLE *new_table,
const Type_handler *handler=
Type_handler::type_handler_long_or_longlong(max_char_length(), true);
result= handler->make_and_init_table_field(root, &name,
- Record_addr(maybe_null),
+ Record_addr(maybe_null()),
*this, new_table);
}
else
{
LEX_CSTRING *tmp= orig_item ? &orig_item->name : &name;
- bool tmp_maybe_null= param->modify_item() ? maybe_null :
+ bool tmp_maybe_null= param->modify_item() ? maybe_null() :
field->maybe_null();
result= field->create_tmp_field(root, new_table, tmp_maybe_null);
if (result)
@@ -18251,13 +18251,13 @@ Item_result_field::create_tmp_field_ex_from_handler(
- Item_func
- Item_subselect
*/
- DBUG_ASSERT(fixed);
+ DBUG_ASSERT(fixed());
DBUG_ASSERT(is_result_field());
DBUG_ASSERT(type() != NULL_ITEM);
get_tmp_field_src(src, param);
Field *result;
if ((result= h->make_and_init_table_field(root, &name,
- Record_addr(maybe_null),
+ Record_addr(maybe_null()),
*this, table)) &&
param->modify_item())
result_field= result;
@@ -18644,7 +18644,7 @@ bool Create_tmp_table::add_fields(THD *thd,
Item *item;
Field **tmp_from_field= m_from_field;
while (!m_with_cycle && (item= li++))
- if (item->is_in_with_cycle)
+ if (item->is_in_with_cycle())
{
m_with_cycle= true;
/*
@@ -18662,7 +18662,7 @@ bool Create_tmp_table::add_fields(THD *thd,
uint uneven_delta;
current_counter= (((param->hidden_field_count < (fieldnr + 1)) &&
distinct_record_structure &&
- (!m_with_cycle || item->is_in_with_cycle)) ?
+ (!m_with_cycle || item->is_in_with_cycle())) ?
distinct :
other);
Item::Type type= item->type();
@@ -18673,7 +18673,7 @@ bool Create_tmp_table::add_fields(THD *thd,
}
if (not_all_columns)
{
- if (item->with_sum_func && type != Item::SUM_FUNC_ITEM)
+ if (item->with_sum_func() && type != Item::SUM_FUNC_ITEM)
{
if (item->used_tables() & OUTER_REF_TABLE_BIT)
item->update_used_tables();
@@ -18730,7 +18730,7 @@ bool Create_tmp_table::add_fields(THD *thd,
new_field->maybe_null() is still false, it will be
changed below. But we have to setup Item_field correctly
*/
- arg->maybe_null=1;
+ arg->flags|= ITEM_FLAG_MAYBE_NULL;
}
if (current_counter == distinct)
new_field->flags|= FIELD_PART_OF_TMP_UNIQUE;
@@ -18806,7 +18806,7 @@ bool Create_tmp_table::add_fields(THD *thd,
m_field_count[current_counter]++;
m_uneven_bit[current_counter]+= (m_uneven_bit_length - uneven_delta);
- if (item->marker == 4 && item->maybe_null)
+ if (item->marker == 4 && item->maybe_null())
{
m_group_null_items++;
new_field->flags|= GROUP_FLAG;
@@ -19103,7 +19103,7 @@ bool Create_tmp_table::finalize(THD *thd,
{
Field *field=(*cur_group->item)->get_tmp_table_field();
DBUG_ASSERT(field->table == table);
- bool maybe_null=(*cur_group->item)->maybe_null;
+ bool maybe_null=(*cur_group->item)->maybe_null();
m_key_part_info->null_bit=0;
m_key_part_info->field= field;
m_key_part_info->fieldnr= field->field_index + 1;
@@ -19131,7 +19131,8 @@ bool Create_tmp_table::finalize(THD *thd,
We solve this by marking the item as !maybe_null to ensure
that the key,field and item definition match.
*/
- (*cur_group->item)->maybe_null= maybe_null= 0;
+ maybe_null= 0;
+ (*cur_group->item)->flags&= (Item::item_flags_t) ~ITEM_FLAG_MAYBE_NULL;
}
if (!(cur_group->field= field->new_key_field(thd->mem_root,table,
@@ -22397,7 +22398,7 @@ end_update(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)),
}
item->save_org_in_field(group->field, group->fast_field_copier_func);
/* Store in the used key if the field was 0 */
- if (item->maybe_null)
+ if (item->maybe_null())
group->buff[-1]= (char) group->field->is_null();
}
if (!table->file->ha_index_read_map(table->record[1],
@@ -24777,14 +24778,14 @@ int setup_order(THD *thd, Ref_ptr_array ref_pointer_array, TABLE_LIST *tables,
if (find_order_in_list(thd, ref_pointer_array, tables, order, fields,
all_fields, false, true, from_window_spec))
return 1;
- if ((*order->item)->with_window_func &&
+ if ((*order->item)->with_window_func() &&
context_analysis_place != IN_ORDER_BY)
{
my_error(ER_WINDOW_FUNCTION_IN_WINDOW_SPEC, MYF(0));
return 1;
}
- if (!(*order->item)->with_sum_func)
+ if (!(*order->item)->with_sum_func())
continue;
/*
@@ -24855,12 +24856,12 @@ setup_group(THD *thd, Ref_ptr_array ref_pointer_array, TABLE_LIST *tables,
all_fields, true, true, from_window_spec))
return 1;
(*ord->item)->marker= UNDEF_POS; /* Mark found */
- if ((*ord->item)->with_sum_func && context_analysis_place == IN_GROUP_BY)
+ if ((*ord->item)->with_sum_func() && context_analysis_place == IN_GROUP_BY)
{
my_error(ER_WRONG_GROUP_FIELD, MYF(0), (*ord->item)->full_name());
return 1;
}
- if ((*ord->item)->with_window_func)
+ if ((*ord->item)->with_window_func())
{
if (context_analysis_place == IN_GROUP_BY)
my_error(ER_WRONG_PLACEMENT_OF_WINDOW_FUNCTION, MYF(0));
@@ -24868,7 +24869,7 @@ setup_group(THD *thd, Ref_ptr_array ref_pointer_array, TABLE_LIST *tables,
my_error(ER_WINDOW_FUNCTION_IN_WINDOW_SPEC, MYF(0));
return 1;
}
- if (from_window_spec && (*ord->item)->with_sum_func &&
+ if (from_window_spec && (*ord->item)->with_sum_func() &&
(*ord->item)->type() != Item::SUM_FUNC_ITEM)
(*ord->item)->split_sum_func(thd, ref_pointer_array,
all_fields, SPLIT_SUM_SELECT);
@@ -25018,7 +25019,7 @@ create_distinct_group(THD *thd, Ref_ptr_array ref_pointer_array,
li.rewind();
while ((item=li++))
{
- if (!item->const_item() && !item->with_sum_func && !item->marker)
+ if (!item->const_item() && !item->with_sum_func() && !item->marker)
{
/*
Don't put duplicate columns from the SELECT list into the
@@ -25117,7 +25118,7 @@ count_field_types(SELECT_LEX *select_lex, TMP_TABLE_PARAM *param,
{
param->func_count++;
if (reset_with_sum_func)
- field->with_sum_func=0;
+ field->flags&= ~ITEM_FLAG_WITH_SUM_FUNC;
}
}
}
@@ -25277,7 +25278,7 @@ void calc_group_buffer(TMP_TABLE_PARAM *param, ORDER *group)
}
}
parts++;
- if (group_item->maybe_null)
+ if (group_item->maybe_null())
null_parts++;
}
param->group_length= key_length + null_parts;
@@ -25539,7 +25540,7 @@ setup_copy_fields(THD *thd, TMP_TABLE_PARAM *param,
real_pos->real_type() == Item::SUBSELECT_ITEM ||
real_pos->type() == Item::CACHE_ITEM ||
real_pos->type() == Item::COND_ITEM) &&
- !real_pos->with_sum_func)
+ !real_pos->with_sum_func())
{ // Save for send fields
LEX_CSTRING real_name= pos->name;
pos= real_pos;
@@ -25748,8 +25749,8 @@ change_to_use_tmp_fields(THD *thd, Ref_ptr_array ref_pointer_array,
for (uint i= 0; (item= it++); i++)
{
Field *field;
- if ((item->with_sum_func && item->type() != Item::SUM_FUNC_ITEM) ||
- item->with_window_func)
+ if ((item->with_sum_func() && item->type() != Item::SUM_FUNC_ITEM) ||
+ item->with_window_func())
item_field= item;
else if (item->type() == Item::FIELD_ITEM)
{
@@ -26012,7 +26013,7 @@ copy_funcs(Item **func_ptr, const THD *thd)
for (; (func = *func_ptr) ; func_ptr++)
{
if (func->type() == Item::FUNC_ITEM &&
- ((Item_func *) func)->with_window_func)
+ ((Item_func *) func)->with_window_func())
continue;
func->save_in_result_field(1);
/*
@@ -26188,8 +26189,7 @@ static bool change_group_ref(THD *thd, Item_func *expr, ORDER *group_list,
}
if (arg_changed)
{
- expr->maybe_null= 1;
- expr->in_rollup= 1;
+ expr->flags|= ITEM_FLAG_MAYBE_NULL | ITEM_FLAG_IN_ROLLUP;
*changed= TRUE;
}
}
@@ -26260,8 +26260,7 @@ bool JOIN::rollup_init()
{
if (*group_tmp->item == item)
{
- item->maybe_null= 1;
- item->in_rollup= 1;
+ item->flags|= ITEM_FLAG_MAYBE_NULL | ITEM_FLAG_IN_ROLLUP;
found_in_group= 1;
break;
}
@@ -26277,7 +26276,7 @@ bool JOIN::rollup_init()
Marking the expression item as 'with_sum_func' will ensure this.
*/
if (changed)
- item->with_sum_func= 1;
+ item->flags|= ITEM_FLAG_WITH_SUM_FUNC;
}
}
return 0;
@@ -26447,7 +26446,7 @@ bool JOIN::rollup_make_fields(List<Item> &fields_arg, List<Item> &sel_fields,
Item_null_result *null_item= new (thd->mem_root) Item_null_result(thd);
if (!null_item)
return 1;
- item->maybe_null= 1; // Value will be null sometimes
+ item->flags|= ITEM_FLAG_MAYBE_NULL; // Value will be null sometimes
null_item->result_field= item->get_tmp_table_field();
item= null_item;
break;
@@ -27990,7 +27989,7 @@ void st_select_lex::print(THD *thd, String *str, enum_query_type query_type)
else
str->append(',');
- if (is_subquery_function() && item->is_autogenerated_name)
+ if (is_subquery_function() && item->is_autogenerated_name())
{
/*
Do not print auto-generated aliases in subqueries. It has no purpose
diff --git a/sql/sql_select.h b/sql/sql_select.h
index 89e0c735450..95d896c8cd4 100644
--- a/sql/sql_select.h
+++ b/sql/sql_select.h
@@ -2005,7 +2005,7 @@ public:
store_key_item(THD *thd, Field *to_field_arg, uchar *ptr,
uchar *null_ptr_arg, uint length, Item *item_arg, bool val)
:store_key(thd, to_field_arg, ptr,
- null_ptr_arg ? null_ptr_arg : item_arg->maybe_null ?
+ null_ptr_arg ? null_ptr_arg : item_arg->maybe_null() ?
&err : (uchar*) 0, length), item(item_arg), use_value(val)
{}
store_key_item(store_key &arg, Item *new_item, bool val)
@@ -2058,7 +2058,7 @@ public:
uchar *null_ptr_arg, uint length,
Item *item_arg)
:store_key_item(thd, to_field_arg, ptr,
- null_ptr_arg ? null_ptr_arg : item_arg->maybe_null ?
+ null_ptr_arg ? null_ptr_arg : item_arg->maybe_null() ?
&err : (uchar*) 0, length, item_arg, FALSE), inited(0)
{
}
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 617caf12aa3..c5084c4dff4 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -2865,7 +2865,7 @@ void mysqld_list_processes(THD *thd,const char *user, bool verbose)
field_list.push_back(field=new (mem_root)
Item_empty_string(thd, "db", NAME_CHAR_LEN),
mem_root);
- field->maybe_null=1;
+ field->flags|= ITEM_FLAG_MAYBE_NULL;;
field_list.push_back(new (mem_root) Item_empty_string(thd, "Command", 16),
mem_root);
field_list.push_back(field= new (mem_root)
@@ -2875,18 +2875,18 @@ void mysqld_list_processes(THD *thd,const char *user, bool verbose)
field_list.push_back(field=new (mem_root)
Item_empty_string(thd, "State", 30),
mem_root);
- field->maybe_null=1;
+ field->flags|= ITEM_FLAG_MAYBE_NULL;;
field_list.push_back(field=new (mem_root)
Item_empty_string(thd, "Info", arg.max_query_length),
mem_root);
- field->maybe_null=1;
+ field->flags|= ITEM_FLAG_MAYBE_NULL;;
if (!thd->variables.old_mode &&
!(thd->variables.old_behavior & OLD_MODE_NO_PROGRESS_INFO))
{
field_list.push_back(field= new (mem_root)
Item_float(thd, "Progress", 0.0, 3, 7),
mem_root);
- field->maybe_null= 0;
+ field->flags&= (Item::item_flags_t) ~ITEM_FLAG_MAYBE_NULL;
}
if (protocol->send_result_set_metadata(&field_list,
Protocol::SEND_NUM_ROWS |
@@ -9767,7 +9767,7 @@ static bool show_create_trigger_impl(THD *thd, Trigger *trigger)
(uint)MY_MAX(trg_sql_original_stmt.length,
1024));
- stmt_fld->maybe_null= TRUE;
+ stmt_fld->flags|= ITEM_FLAG_MAYBE_NULL;
fields.push_back(stmt_fld, mem_root);
}
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 209c799dc59..81c599f24cb 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -11816,12 +11816,12 @@ bool mysql_checksum_table(THD *thd, TABLE_LIST *tables,
field_list.push_back(item= new (thd->mem_root)
Item_empty_string(thd, "Table", NAME_LEN*2),
thd->mem_root);
- item->maybe_null= 1;
+ item->flags|= ITEM_FLAG_MAYBE_NULL;
field_list.push_back(item= new (thd->mem_root)
Item_int(thd, "Checksum", (longlong) 1,
MY_INT64_NUM_DECIMAL_DIGITS),
thd->mem_root);
- item->maybe_null= 1;
+ item->flags|= ITEM_FLAG_MAYBE_NULL;
if (protocol->send_result_set_metadata(&field_list,
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
DBUG_RETURN(TRUE);
diff --git a/sql/sql_type.cc b/sql/sql_type.cc
index 8ee4572a422..b2128d1dfce 100644
--- a/sql/sql_type.cc
+++ b/sql/sql_type.cc
@@ -2248,8 +2248,8 @@ Type_handler::make_num_distinct_aggregator_field(MEM_ROOT *mem_root,
{
return new(mem_root)
Field_double(NULL, item->max_length,
- (uchar *) (item->maybe_null ? "" : 0),
- item->maybe_null ? 1 : 0, Field::NONE,
+ (uchar *) (item->maybe_null() ? "" : 0),
+ item->maybe_null() ? 1 : 0, Field::NONE,
&item->name, (uint8) item->decimals,
0, item->unsigned_flag);
}
@@ -2262,8 +2262,8 @@ Type_handler_float::make_num_distinct_aggregator_field(MEM_ROOT *mem_root,
{
return new(mem_root)
Field_float(NULL, item->max_length,
- (uchar *) (item->maybe_null ? "" : 0),
- item->maybe_null ? 1 : 0, Field::NONE,
+ (uchar *) (item->maybe_null() ? "" : 0),
+ item->maybe_null() ? 1 : 0, Field::NONE,
&item->name, (uint8) item->decimals,
0, item->unsigned_flag);
}
@@ -2278,8 +2278,8 @@ Type_handler_decimal_result::make_num_distinct_aggregator_field(
DBUG_ASSERT(item->decimals <= DECIMAL_MAX_SCALE);
return new (mem_root)
Field_new_decimal(NULL, item->max_length,
- (uchar *) (item->maybe_null ? "" : 0),
- item->maybe_null ? 1 : 0, Field::NONE,
+ (uchar *) (item->maybe_null() ? "" : 0),
+ item->maybe_null() ? 1 : 0, Field::NONE,
&item->name, (uint8) item->decimals,
0, item->unsigned_flag);
}
@@ -2296,8 +2296,8 @@ Type_handler_int_result::make_num_distinct_aggregator_field(MEM_ROOT *mem_root,
*/
return new(mem_root)
Field_longlong(NULL, item->max_length,
- (uchar *) (item->maybe_null ? "" : 0),
- item->maybe_null ? 1 : 0, Field::NONE,
+ (uchar *) (item->maybe_null() ? "" : 0),
+ item->maybe_null() ? 1 : 0, Field::NONE,
&item->name, 0, item->unsigned_flag);
}
@@ -4761,7 +4761,7 @@ bool Type_handler_temporal_result::
set_if_bigger(func->decimals, deci);
}
- if (rc || func->maybe_null)
+ if (rc || func->maybe_null())
return rc;
/*
LEAST/GREATES(non-temporal, temporal) can return NULL.
@@ -4784,7 +4784,7 @@ bool Type_handler_temporal_result::
continue; // No conversion.
if (ha->cmp_type() != TIME_RESULT)
{
- func->maybe_null= true; // Conversion from non-temporal is not safe
+ func->flags|= ITEM_FLAG_MAYBE_NULL; // Conversion from non-temporal is not safe
break;
}
timestamp_type tf= hf->mysql_timestamp_type();
@@ -4835,7 +4835,7 @@ bool Type_handler_temporal_result::
DBUG_ASSERT(hf->field_type() == MYSQL_TYPE_DATETIME);
if (!(thd->variables.old_behavior & OLD_MODE_ZERO_DATE_TIME_CAST))
continue;
- func->maybe_null= true;
+ func->flags|= ITEM_FLAG_MAYBE_NULL;
break;
}
return rc;
@@ -4847,10 +4847,11 @@ bool Type_handler_date_common::
Item **items, uint nitems) const
{
func->fix_attributes_date();
- if (func->maybe_null)
+ if (func->maybe_null())
return false;
/*
- We cannot trust the generic maybe_null value calculated during fix_fields().
+ We cannot trust the generic maybe_null value calculated during
+ fix_fields().
If a conversion from non-temoral types to DATE happens,
then the result can be NULL (even if all arguments are not NULL).
*/
@@ -4858,7 +4859,7 @@ bool Type_handler_date_common::
{
if (items[i]->type_handler()->cmp_type() != TIME_RESULT)
{
- func->maybe_null= true;
+ func->flags|= ITEM_FLAG_MAYBE_NULL;
break;
}
}
@@ -6740,7 +6741,7 @@ bool Type_handler::
item->arguments()[0]->time_precision(current_thd) :
item->decimals;
item->fix_attributes_temporal(MIN_TIME_WIDTH, dec);
- item->maybe_null= true;
+ item->flags|= ITEM_FLAG_MAYBE_NULL;
return false;
}
@@ -6749,7 +6750,7 @@ bool Type_handler::
Item_date_typecast_fix_length_and_dec(Item_date_typecast *item) const
{
item->fix_attributes_temporal(MAX_DATE_WIDTH, 0);
- item->maybe_null= true;
+ item->flags|= ITEM_FLAG_MAYBE_NULL;
return false;
}
@@ -6762,7 +6763,7 @@ bool Type_handler::
item->arguments()[0]->datetime_precision(current_thd) :
item->decimals;
item->fix_attributes_temporal(MAX_DATETIME_WIDTH, dec);
- item->maybe_null= true;
+ item->flags|= ITEM_FLAG_MAYBE_NULL;
return false;
}
diff --git a/sql/sql_view.cc b/sql/sql_view.cc
index 71e2f0351d2..11ee44d5c5f 100644
--- a/sql/sql_view.cc
+++ b/sql/sql_view.cc
@@ -137,7 +137,7 @@ bool check_duplicate_names(THD *thd, List<Item> &item_list, bool gen_unique_view
Item *check;
/* treat underlying fields like set by user names */
if (item->real_item()->type() == Item::FIELD_ITEM)
- item->is_autogenerated_name= 0;
+ item->flags&= ~ITEM_FLAG_IS_AUTOGENERATED_NAME;
itc.rewind();
while ((check= itc++) && check != item)
{
@@ -145,9 +145,9 @@ bool check_duplicate_names(THD *thd, List<Item> &item_list, bool gen_unique_view
{
if (!gen_unique_view_name)
goto err;
- if (item->is_autogenerated_name)
+ if (item->is_autogenerated_name())
make_unique_view_field_name(thd, item, item_list, item);
- else if (check->is_autogenerated_name)
+ else if (check->is_autogenerated_name())
make_unique_view_field_name(thd, check, item_list, item);
else
goto err;
@@ -179,7 +179,7 @@ void make_valid_column_names(THD *thd, List<Item> &item_list)
for (uint column_no= 1; (item= it++); column_no++)
{
- if (!item->is_autogenerated_name || !check_column_name(item->name.str))
+ if (!item->is_autogenerated_name() || !check_column_name(item->name.str))
continue;
name_len= my_snprintf(buff, NAME_LEN, "Name_exp_%u", column_no);
item->orig_name= item->name.str;
@@ -566,7 +566,7 @@ bool mysql_create_view(THD *thd, TABLE_LIST *views,
while ((item= it++, name= nm++))
{
item->set_name(thd, *name);
- item->is_autogenerated_name= 0;
+ item->flags&= ~ITEM_FLAG_IS_AUTOGENERATED_NAME;
}
}
diff --git a/sql/sql_window.cc b/sql/sql_window.cc
index af6a73006a8..621a4b24227 100644
--- a/sql/sql_window.cc
+++ b/sql/sql_window.cc
@@ -2497,7 +2497,7 @@ void add_special_frame_cursors(THD *thd, Cursor_manager *cursor_manager,
cursor_manager->add_cursor(bottom_bound);
cursor_manager->add_cursor(top_bound);
cursor_manager->add_cursor(current_row_pos);
- DBUG_ASSERT(item_sum->fixed);
+ DBUG_ASSERT(item_sum->fixed());
bool negative_offset= item_sum->sum_func() == Item_sum::LAG_FUNC;
fc= new Frame_positional_cursor(*current_row_pos,
*top_bound, *bottom_bound,
@@ -2513,7 +2513,7 @@ void add_special_frame_cursors(THD *thd, Cursor_manager *cursor_manager,
Frame_cursor *top_bound= get_frame_cursor(thd, spec, true);
cursor_manager->add_cursor(bottom_bound);
cursor_manager->add_cursor(top_bound);
- DBUG_ASSERT(item_sum->fixed);
+ DBUG_ASSERT(item_sum->fixed());
Item *offset_item= new (thd->mem_root) Item_int(thd, 0);
offset_item->fix_fields(thd, &offset_item);
fc= new Frame_positional_cursor(*top_bound,
@@ -2529,7 +2529,7 @@ void add_special_frame_cursors(THD *thd, Cursor_manager *cursor_manager,
Frame_cursor *top_bound= get_frame_cursor(thd, spec, true);
cursor_manager->add_cursor(bottom_bound);
cursor_manager->add_cursor(top_bound);
- DBUG_ASSERT(item_sum->fixed);
+ DBUG_ASSERT(item_sum->fixed());
Item *offset_item= new (thd->mem_root) Item_int(thd, 0);
offset_item->fix_fields(thd, &offset_item);
fc= new Frame_positional_cursor(*bottom_bound,
@@ -2545,7 +2545,7 @@ void add_special_frame_cursors(THD *thd, Cursor_manager *cursor_manager,
Frame_cursor *top_bound= get_frame_cursor(thd, spec, true);
cursor_manager->add_cursor(bottom_bound);
cursor_manager->add_cursor(top_bound);
- DBUG_ASSERT(item_sum->fixed);
+ DBUG_ASSERT(item_sum->fixed());
Item *int_item= new (thd->mem_root) Item_int(thd, 1);
Item *offset_func= new (thd->mem_root)
Item_func_minus(thd, item_sum->get_arg(1),
@@ -2734,7 +2734,7 @@ bool save_window_function_values(List<Item_window_func>& window_functions,
Item *func;
for (; (func = *func_ptr) ; func_ptr++)
{
- if (func->with_window_func && func->type() != Item::WINDOW_FUNC_ITEM)
+ if (func->with_window_func() && func->type() != Item::WINDOW_FUNC_ITEM)
func->save_in_result_field(true);
}
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index c0668959757..6e6d73cee0f 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -9223,7 +9223,7 @@ select_item:
if (unlikely(Lex->sql_command == SQLCOM_CREATE_VIEW &&
check_column_name($4.str)))
my_yyabort_error((ER_WRONG_COLUMN_NAME, MYF(0), $4.str));
- $2->is_autogenerated_name= 0;
+ $2->flags&= ~ITEM_FLAG_IS_AUTOGENERATED_NAME;
$2->set_name(thd, $4);
}
else if (!$2->name.str || $2->name.str == item_empty_name)
@@ -10801,7 +10801,7 @@ udf_expr:
*/
if ($4.str)
{
- $2->is_autogenerated_name= 0;
+ $2->flags&= ~ITEM_FLAG_IS_AUTOGENERATED_NAME;
$2->set_name(thd, $4);
}
/*
diff --git a/sql/table.cc b/sql/table.cc
index 125e4f81a1b..91009d9f3ec 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -6854,7 +6854,7 @@ Item *create_view_field(THD *thd, TABLE_LIST *view, Item **field_ref,
views/derived tables.
*/
if (view->table && view->table->maybe_null)
- item->maybe_null= TRUE;
+ item->flags|= ITEM_FLAG_MAYBE_NULL;
/* Save item in case we will need to fall back to materialization. */
view->used_items.push_front(item, thd->mem_root);
/*
@@ -9485,6 +9485,8 @@ bool TABLE_LIST::change_refs_to_fields()
*/
thd->change_item_tree((Item **)&ref->ref,
(Item*)(materialized_items + idx));
+ /* Inform Item_direct_ref that what it points to has changed */
+ ref->ref_changed();
}
return FALSE;
diff --git a/storage/spider/spd_table.cc b/storage/spider/spd_table.cc
index c93404f476a..4d1258d2963 100644
--- a/storage/spider/spd_table.cc
+++ b/storage/spider/spd_table.cc
@@ -9595,7 +9595,7 @@ int spider_set_direct_limit_offset(
#ifdef SPIDER_has_Item_has_subquery
if (select_lex->where && select_lex->where->has_subquery())
#else
- if (select_lex->where && select_lex->where->with_subquery)
+ if (select_lex->where && select_lex->where->with_subquery())
#endif
DBUG_RETURN(FALSE);