summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMonty <monty@mariadb.org>2020-09-02 03:13:32 +0300
committerMonty <monty@mariadb.org>2021-01-19 20:17:36 +0200
commitb45380e159c2a0a52684c1bacef0148ff89aff93 (patch)
tree54c880051ebed0450c1f8333e57da236dfbc2968
parentd8358ceeeb0f0240071622ab0546602404133b17 (diff)
downloadmariadb-git-b45380e159c2a0a52684c1bacef0148ff89aff93.tar.gz
Split item->flags into base_flags and with_flags
This was done to simplify copying of with_* flags Other things: - Changed Flags to C++ enums, which enables gdb to print out bit values for the flags. This also enables compiler errors if one tries to manipulate a non existing bit in a variable. - Added set_maybe_null() as a shortcut as setting the MAYBE_NULL flags was used in a LOT of places. - Renamed PARAM flag to SP_VAR to ensure it's not confused with persistent statement parameters.
-rw-r--r--plugin/func_test/plugin.cc2
-rw-r--r--plugin/type_inet/item_inetfunc.h8
-rw-r--r--plugin/type_inet/sql_type_inet.cc2
-rw-r--r--sql/item.cc92
-rw-r--r--sql/item.h215
-rw-r--r--sql/item_cmpfunc.cc60
-rw-r--r--sql/item_cmpfunc.h10
-rw-r--r--sql/item_func.cc52
-rw-r--r--sql/item_func.h76
-rw-r--r--sql/item_geofunc.cc6
-rw-r--r--sql/item_geofunc.h58
-rw-r--r--sql/item_jsonfunc.cc38
-rw-r--r--sql/item_jsonfunc.h2
-rw-r--r--sql/item_row.cc12
-rw-r--r--sql/item_strfunc.cc40
-rw-r--r--sql/item_strfunc.h48
-rw-r--r--sql/item_subselect.cc16
-rw-r--r--sql/item_sum.cc50
-rw-r--r--sql/item_sum.h13
-rw-r--r--sql/item_timefunc.cc22
-rw-r--r--sql/item_timefunc.h44
-rw-r--r--sql/item_windowfunc.cc11
-rw-r--r--sql/item_xmlfunc.h4
-rw-r--r--sql/opt_subselect.cc4
-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_class.cc24
-rw-r--r--sql/sql_cte.cc4
-rw-r--r--sql/sql_select.cc15
-rw-r--r--sql/sql_show.cc10
-rw-r--r--sql/sql_table.cc4
-rw-r--r--sql/sql_type.cc13
-rw-r--r--sql/sql_view.cc4
-rw-r--r--sql/sql_yacc.yy4
-rw-r--r--sql/table.cc2
36 files changed, 523 insertions, 460 deletions
diff --git a/plugin/func_test/plugin.cc b/plugin/func_test/plugin.cc
index 827c627dece..5e1f1a66fa2 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;
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
return false;
}
const char *func_name() const { return "sysconst_test"; }
diff --git a/plugin/type_inet/item_inetfunc.h b/plugin/type_inet/item_inetfunc.h
index 2a4605065da..f74eadb717c 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;
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
unsigned_flag= 1;
return FALSE;
}
@@ -61,7 +61,7 @@ public:
{
decimals= 0;
fix_length_and_charset(3 * 8 + 7, default_charset());
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
return FALSE;
}
Item *get_copy(THD *thd)
@@ -105,7 +105,7 @@ public:
{
decimals= 0;
fix_length_and_charset(16, &my_charset_bin);
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_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());
- flags|= ITEM_FLAG_MAYBE_NULL;;
+ set_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 58aa9ed6bde..a3e7a4d6ca1 100644
--- a/plugin/type_inet/sql_type_inet.cc
+++ b/plugin/type_inet/sql_type_inet.cc
@@ -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]))
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
return false;
}
String *val_str(String *to) override
diff --git a/sql/item.cc b/sql/item.cc
index 8a1ac5e0a33..539ffabbe17 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -412,7 +412,8 @@ int Item::save_str_value_in_field(Field *field, String *result)
Item::Item(THD *thd):
name(null_clex_str), orig_name(0), is_expensive_cache(-1)
{
- flags= ITEM_FLAG_FIXED | ITEM_FLAG_IS_AUTOGENERATED_NAME;
+ base_flags= item_base_t::FIXED | item_base_t::IS_AUTOGENERATED_NAME;
+ with_flags= item_with_t::NONE;
null_value= 0;
marker= 0;
@@ -461,13 +462,13 @@ Item::Item(THD *thd, Item *item):
str_value(item->str_value),
name(item->name),
orig_name(item->orig_name),
+ base_flags(item->base_flags & ~item_base_t::FIXED),
+ with_flags(item->with_flags),
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;
}
@@ -1587,9 +1588,10 @@ 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;
- flags|= ITEM_FLAG_WITH_PARAM | ITEM_FLAG_FIXED;
+ base_flags|= item_base_t::FIXED;
+ with_flags|= item_with_t::SP_VAR;
if (thd->lex->current_select && thd->lex->current_select->master_unit()->item)
- thd->lex->current_select->master_unit()->item->flags|= ITEM_FLAG_WITH_PARAM;
+ thd->lex->current_select->master_unit()->item->with_flags|= item_with_t::SP_VAR;
collation.set(it->collation.collation, it->collation.derivation);
return FALSE;
@@ -1711,7 +1713,7 @@ Item_splocal::Item_splocal(THD *thd,
m_var_idx(sp_var_idx),
m_type(handler == &type_handler_row ? ROW_ITEM : CONST_ITEM)
{
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
}
@@ -2074,7 +2076,7 @@ Item_name_const::Item_name_const(THD *thd, Item *name_arg, Item *val):
StringBuffer<128> name_buffer;
String *name_str;
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_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);
@@ -2128,7 +2130,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;
- flags|= ITEM_FLAG_FIXED;
+ base_flags|= item_base_t::FIXED;
return FALSE;
}
@@ -2945,7 +2947,7 @@ Item_field::Item_field(THD *thd, Field *f)
*/
orig_table_name= table_name;
orig_field_name= field_name;
- flags|= ITEM_FLAG_WITH_FIELD;
+ with_flags|= item_with_t::FIELD;
}
@@ -2995,7 +2997,7 @@ Item_field::Item_field(THD *thd, Name_resolution_context *context_arg,
name= orig_field_name;
}
set_field(f);
- flags|= ITEM_FLAG_WITH_FIELD;
+ with_flags|= item_with_t::FIELD;
}
@@ -3011,7 +3013,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++;
- flags|= ITEM_FLAG_WITH_FIELD;
+ with_flags|= item_with_t::FIELD;
}
/**
@@ -3026,7 +3028,7 @@ Item_field::Item_field(THD *thd, Item_field *item)
any_privileges(item->any_privileges)
{
collation.set(DERIVATION_IMPLICIT);
- flags|= ITEM_FLAG_WITH_FIELD;
+ with_flags|= item_with_t::FIELD;
}
@@ -3051,7 +3053,7 @@ void Item_field::set_field(Field *field_par)
db_name= field_par->table->s->db;
alias_name_used= field_par->table->alias_name_used;
- flags|= ITEM_FLAG_FIXED;
+ base_flags|= item_base_t::FIXED;
if (field->table->s->tmp_table == SYSTEM_TMP_TABLE)
any_privileges= 0;
}
@@ -3958,7 +3960,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.
*/
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
}
@@ -3990,7 +3992,7 @@ void Item_param::sync_clones()
{
Item_param *c= *c_ptr;
/* Scalar-type members: */
- c->copy_flags(this, ITEM_FLAG_MAYBE_NULL);
+ c->copy_flags(this, item_base_t::MAYBE_NULL);
c->null_value= null_value;
c->Type_std_attributes::operator=(*this);
c->Type_handler_hybrid_field_type::operator=(*this);
@@ -4042,7 +4044,7 @@ void Item_param::set_int(longlong i, uint32 max_length_arg)
collation= DTCollation_numeric();
max_length= max_length_arg;
decimals= 0;
- flags&= (item_flags_t) ~ITEM_FLAG_MAYBE_NULL;
+ base_flags&= ~item_base_t::MAYBE_NULL;
null_value= 0;
DBUG_VOID_RETURN;
}
@@ -4056,7 +4058,7 @@ void Item_param::set_double(double d)
collation= DTCollation_numeric();
max_length= DBL_DIG + 8;
decimals= NOT_FIXED_DEC;
- flags&= (item_flags_t) ~ITEM_FLAG_MAYBE_NULL;
+ base_flags&= ~item_base_t::MAYBE_NULL;
null_value= 0;
DBUG_VOID_RETURN;
}
@@ -4088,7 +4090,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);
- flags&= (item_flags_t) ~ITEM_FLAG_MAYBE_NULL;
+ base_flags&= ~item_base_t::MAYBE_NULL;
null_value= 0;
DBUG_VOID_RETURN;
}
@@ -4105,7 +4107,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);
- flags&= (item_flags_t) ~ITEM_FLAG_MAYBE_NULL;
+ base_flags&= ~item_base_t::MAYBE_NULL;
null_value= 0;
}
@@ -4116,7 +4118,7 @@ void Item_param::fix_temporal(uint32 max_length_arg, uint decimals_arg)
collation= DTCollation_numeric();
max_length= max_length_arg;
decimals= decimals_arg;
- flags&= (item_flags_t) ~ITEM_FLAG_MAYBE_NULL;
+ base_flags&= ~item_base_t::MAYBE_NULL;
null_value= 0;
}
@@ -4126,7 +4128,7 @@ void Item_param::set_time(const MYSQL_TIME *tm,
{
DBUG_ASSERT(value.type_handler()->cmp_type() == TIME_RESULT);
value.time= *tm;
- flags&= (item_flags_t) ~ITEM_FLAG_MAYBE_NULL;
+ base_flags&= ~item_base_t::MAYBE_NULL;
null_value= 0;
fix_temporal(max_length_arg, decimals_arg);
}
@@ -4161,7 +4163,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);
}
- flags&= (item_flags_t) ~ITEM_FLAG_MAYBE_NULL;
+ base_flags&= ~item_base_t::MAYBE_NULL;
null_value= 0;
fix_temporal(max_length_arg,
tm->second_part > 0 ? TIME_SECOND_PART_DIGITS : 0);
@@ -4198,7 +4200,7 @@ bool Item_param::set_str(const char *str, ulong length,
state= SHORT_DATA_VALUE;
collation.set(tocs, DERIVATION_COERCIBLE);
max_length= length;
- flags&= (item_flags_t) ~ITEM_FLAG_MAYBE_NULL;
+ base_flags&= ~item_base_t::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 */
@@ -4233,7 +4235,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;
- flags&= (item_flags_t) ~ITEM_FLAG_MAYBE_NULL;
+ base_flags&= ~item_base_t::MAYBE_NULL;
null_value= 0;
DBUG_RETURN(FALSE);
@@ -4334,7 +4336,7 @@ void Item_param::reset()
value.m_string.set_charset(&my_charset_bin);
collation.set(&my_charset_bin, DERIVATION_COERCIBLE);
state= NO_VALUE;
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
null_value= 0;
DBUG_VOID_RETURN;
}
@@ -4793,7 +4795,7 @@ Item_param::set_param_type_and_swap_value(Item_param *src)
Type_std_attributes::set(src);
set_handler(src->type_handler());
- copy_flags(src, ITEM_FLAG_MAYBE_NULL);
+ copy_flags(src, item_base_t::MAYBE_NULL);
null_value= src->null_value;
state= src->state;
@@ -5613,7 +5615,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);
- flags|= ITEM_FLAG_FIXED;
+ base_flags|= item_base_t::FIXED;
mark_as_dependent(thd, last_checked_context->select_lex,
context->select_lex, this,
((ref_type == REF_ITEM ||
@@ -6029,7 +6031,7 @@ bool Item_field::fix_fields(THD *thd, Item **reference)
}
}
#endif
- flags|= ITEM_FLAG_FIXED;
+ base_flags|= item_base_t::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 &&
@@ -8049,20 +8051,10 @@ void Item_ref::set_properties()
We have to remember if we refer to a sum function, to ensure that
split_sum_func() doesn't try to change the reference.
*/
- /* 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)));
+ with_flags= (*ref)->with_flags;
+ base_flags|= (item_base_t::FIXED |
+ ((*ref)->base_flags & item_base_t::MAYBE_NULL));
+
if (alias_name_used)
return;
if ((*ref)->type() == FIELD_ITEM)
@@ -8524,14 +8516,10 @@ Item_cache_wrapper::Item_cache_wrapper(THD *thd, Item *item_arg):
DBUG_ASSERT(orig_item->fixed());
Type_std_attributes::set(orig_item);
- 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));
-
+ base_flags|= (item_base_t::FIXED |
+ (orig_item->base_flags & item_base_t::MAYBE_NULL));
+ with_flags|= orig_item->with_flags;
+
name= item_arg->name;
if ((expr_value= orig_item->get_cache(thd)))
@@ -8989,7 +8977,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)
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
set_null_ref_table();
return FALSE;
}
@@ -9698,7 +9686,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);
- flags|= ITEM_FLAG_FIXED;
+ base_flags|= item_base_t::FIXED;
return FALSE;
}
diff --git a/sql/item.h b/sql/item.h
index 0c8fed43807..beda47f87fa 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -716,28 +716,94 @@ 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)
+
+/* Base flags (including IN) for an item */
+
+
+typedef uint8 item_flags_t;
+
+enum class item_base_t : item_flags_t
+{
+ NONE= 0,
+#define ITEM_FLAGS_MAYBE_NULL_SHIFT 0 // Must match MAYBE_NULL
+ MAYBE_NULL= (1<<0), // May be NULL.
+ IN_ROLLUP= (1<<1), // Appears in GROUP BY list
+ // of a query with ROLLUP.
+ FIXED= (1<<2), // Was fixed with fix_fields().
+ IS_AUTOGENERATED_NAME= (1<<3), // The name if this Item was
+ // generated or set by the user.
+ IS_IN_WITH_CYCLE= (1<<4) // This item is in CYCLE clause
+ // of WITH.
+};
+
+
+/* Flags that tells us what kind of items the item contains */
+
+enum class item_with_t : item_flags_t
+{
+ NONE= 0,
+ SP_VAR= (1<<0), // If Item contains a stored procedure variable
+ WINDOW_FUNC= (1<<1), // If item contains a window func
+ FIELD= (1<<2), // If any item except Item_sum contains a field.
+ SUM_FUNC= (1<<3), // If item contains a sum func
+ SUBQUERY= (1<<4) // If item containts a sub query
+};
+
+
+/* Make operations in item_base_t and item_with_t work like 'int' */
+static inline item_base_t operator&(const item_base_t a, const item_base_t b)
+{
+ return (item_base_t) (((item_flags_t) a) & ((item_flags_t) b));
+}
+
+static inline item_base_t & operator&=(item_base_t &a, item_base_t b)
+{
+ a= (item_base_t) (((item_flags_t) a) & (item_flags_t) b);
+ return a;
+}
+
+static inline item_base_t operator|(const item_base_t a, const item_base_t b)
+{
+ return (item_base_t) (((item_flags_t) a) | ((item_flags_t) b));
+}
+
+static inline item_base_t & operator|=(item_base_t &a, item_base_t b)
+{
+ a= (item_base_t) (((item_flags_t) a) | (item_flags_t) b);
+ return a;
+}
+
+static inline item_base_t operator~(const item_base_t a)
+{
+ return (item_base_t) ~(item_flags_t) a;
+}
+
+static inline item_with_t operator&(const item_with_t a, const item_with_t b)
+{
+ return (item_with_t) (((item_flags_t) a) & ((item_flags_t) b));
+}
+
+static inline item_with_t & operator&=(item_with_t &a, item_with_t b)
+{
+ a= (item_with_t) (((item_flags_t) a) & (item_flags_t) b);
+ return a;
+}
+
+static inline item_with_t operator|(const item_with_t a, const item_with_t b)
+{
+ return (item_with_t) (((item_flags_t) a) | ((item_flags_t) b));
+}
+
+static inline item_with_t & operator|=(item_with_t &a, item_with_t b)
+{
+ a= (item_with_t) (((item_flags_t) a) | (item_flags_t) b);
+ return a;
+}
+
+static inline item_with_t operator~(const item_with_t a)
+{
+ return (item_with_t) ~(item_flags_t) a;
+}
class Item :public Value_source,
@@ -931,8 +997,8 @@ public:
const char *orig_name;
/* All common bool variables for an Item is stored here */
- typedef uint16 item_flags_t;
- item_flags_t flags;
+ item_base_t base_flags;
+ item_with_t with_flags;
/* Marker is used in some functions to temporary mark an item */
int16 marker;
@@ -957,19 +1023,40 @@ public:
*/
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_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));
+ inline bool maybe_null() const
+ { return (bool) (base_flags & item_base_t::MAYBE_NULL); }
+ inline bool in_rollup() const
+ { return (bool) (base_flags & item_base_t::IN_ROLLUP); }
+ inline bool fixed() const
+ { return (bool) (base_flags & item_base_t::FIXED); }
+ inline bool is_autogenerated_name() const
+ { return (bool) (base_flags & item_base_t::IS_AUTOGENERATED_NAME); }
+ inline bool is_in_with_cycle() const
+ { return (bool) (base_flags & item_base_t::IS_IN_WITH_CYCLE); }
+
+ inline bool with_sp_var() const
+ { return (bool) (with_flags & item_with_t::SP_VAR); }
+ inline bool with_window_func() const
+ { return (bool) (with_flags & item_with_t::WINDOW_FUNC); }
+ inline bool with_field() const
+ { return (bool) (with_flags & item_with_t::FIELD); }
+ inline bool with_sum_func() const
+ { return (bool) (with_flags & item_with_t::SUM_FUNC); }
+ inline bool with_subquery() const
+ { return (bool) (with_flags & item_with_t::SUBQUERY); }
+ inline void copy_flags(const Item *org, item_base_t mask)
+ {
+ base_flags= (item_base_t) (((item_flags_t) base_flags &
+ ~(item_flags_t) mask) |
+ ((item_flags_t) org->base_flags &
+ (item_flags_t) mask));
+ }
+ inline void copy_flags(const Item *org, item_with_t mask)
+ {
+ with_flags= (item_with_t) (((item_flags_t) with_flags &
+ ~(item_flags_t) mask) |
+ ((item_flags_t) org->with_flags &
+ (item_flags_t) mask));
}
// alloc & destruct is done as start of select on THD::mem_root
@@ -1006,7 +1093,7 @@ public:
void share_name_with(const Item *item)
{
name= item->name;
- copy_flags(item, ITEM_FLAG_IS_AUTOGENERATED_NAME);
+ copy_flags(item, item_base_t::IS_AUTOGENERATED_NAME);
}
virtual void cleanup();
virtual void make_send_field(THD *thd, Send_field *field);
@@ -1167,19 +1254,26 @@ public:
{
return type_handler()->max_display_length(this);
}
- const TYPELIB *get_typelib() const { return NULL; }
+ const TYPELIB *get_typelib() const override { return NULL; }
+ /* optimized setting of maybe_null without jumps. Minimizes code size */
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))));
+ base_flags= ((item_base_t) ((base_flags & ~item_base_t::MAYBE_NULL)) |
+ (item_base_t) (maybe_null_arg <<
+ ITEM_FLAGS_MAYBE_NULL_SHIFT));
+ }
+ /* This is used a lot, so make it simpler to use */
+ void set_maybe_null()
+ {
+ base_flags|= item_base_t::MAYBE_NULL;
}
/* This is used when calling Type_all_attributes::set_type_maybe_null() */
void set_type_maybe_null(bool maybe_null_arg) override
{
set_maybe_null(maybe_null_arg);
}
- void set_typelib(const TYPELIB *typelib)
+
+ void set_typelib(const TYPELIB *typelib) override
{
// Non-field Items (e.g. hybrid functions) never have ENUM/SET types yet.
DBUG_ASSERT(0);
@@ -1209,7 +1303,8 @@ public:
{ return NON_MONOTONIC; }
/*
- Convert "func_arg $CMP$ const" half-interval into "FUNC(func_arg) $CMP2$ const2"
+ Convert "func_arg $CMP$ const" half-interval into
+ "FUNC(func_arg) $CMP2$ const2"
SYNOPSIS
val_int_endpoint()
@@ -2713,26 +2808,28 @@ class Item_fixed_hybrid: public Item
public:
Item_fixed_hybrid(THD *thd): Item(thd)
{
- flags&= (item_flags_t) ~ITEM_FLAG_FIXED;
+ base_flags&= ~item_base_t::FIXED;
}
Item_fixed_hybrid(THD *thd, Item_fixed_hybrid *item)
:Item(thd, item)
{
- flags|= (item_flags_t) (item->flags & ITEM_FLAG_FIXED);
+ base_flags|= (item->base_flags & item_base_t::FIXED);
}
bool fix_fields(THD *thd, Item **ref) override
{
DBUG_ASSERT(!fixed());
- flags|= ITEM_FLAG_FIXED;
+ base_flags|= item_base_t::FIXED;
return false;
}
void cleanup() override
{
Item::cleanup();
- flags&= (item_flags_t) ~ITEM_FLAG_FIXED;
+ base_flags&= ~item_base_t::FIXED;
}
- void quick_fix_field() override { flags|= ITEM_FLAG_FIXED; }
- void unfix_fields() override { flags&= (item_flags_t) ~ITEM_FLAG_FIXED; }
+ void quick_fix_field() override
+ { base_flags|= item_base_t::FIXED; }
+ void unfix_fields() override
+ { base_flags&= ~item_base_t::FIXED; }
};
@@ -3641,7 +3738,7 @@ public:
Item_null(THD *thd, const char *name_par=0, CHARSET_INFO *cs= &my_charset_bin):
Item_basic_constant(thd)
{
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
null_value= TRUE;
max_length= 0;
name.str= name_par ? name_par : "NULL";
@@ -5032,7 +5129,7 @@ public:
Item_date_literal_for_invalid_dates(THD *thd, const Date *ltime)
:Item_date_literal(thd, ltime)
{
- flags&= (item_flags_t) ~ITEM_FLAG_MAYBE_NULL;
+ base_flags&= ~item_base_t::MAYBE_NULL;
}
bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate)
{
@@ -5053,7 +5150,7 @@ public:
const Datetime *ltime, uint dec_arg)
:Item_datetime_literal(thd, ltime, dec_arg)
{
- flags&= (item_flags_t) ~ITEM_FLAG_MAYBE_NULL;
+ base_flags&= ~item_base_t::MAYBE_NULL;
}
bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate)
{
@@ -5965,7 +6062,7 @@ public:
ref= &outer_ref;
set_properties();
/* reset flag set in set_properties() */
- flags&= (item_flags_t) ~ITEM_FLAG_FIXED;
+ base_flags&= ~item_base_t::FIXED;
}
Item_outer_ref(THD *thd, Name_resolution_context *context_arg, Item **item,
const LEX_CSTRING &table_name_arg, LEX_CSTRING &field_name_arg,
@@ -6112,7 +6209,7 @@ protected:
DBUG_ASSERT(org->fixed());
item= org;
null_value= item->maybe_null();
- copy_flags(item, ITEM_FLAG_MAYBE_NULL);
+ copy_flags(item, item_base_t::MAYBE_NULL);
Type_std_attributes::set(item);
name= item->name;
set_handler(item->type_handler());
@@ -6718,7 +6815,7 @@ public:
value_cached(0),
used_table_map(0)
{
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
null_value= 1;
}
protected:
@@ -6729,7 +6826,7 @@ protected:
value_cached(0),
used_table_map(0)
{
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
null_value= 1;
}
@@ -7278,8 +7375,8 @@ public:
Type_std_attributes::set(*attr);
set_maybe_null(maybe_null_arg);
copy_flags(item,
- ITEM_FLAG_IS_AUTOGENERATED_NAME |
- ITEM_FLAG_IS_IN_WITH_CYCLE);
+ item_base_t::IS_AUTOGENERATED_NAME |
+ item_base_t::IS_IN_WITH_CYCLE);
}
const Type_handler *type_handler() const
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index 7efd76aa895..a01516cb81b 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -1142,7 +1142,7 @@ int Arg_comparator::compare_e_str_json()
bool Item_func_truth::fix_length_and_dec()
{
- flags&= (item_flags_t) ~ITEM_FLAG_MAYBE_NULL;
+ base_flags&= ~item_base_t::MAYBE_NULL;
null_value= 0;
decimals= 0;
max_length= 1;
@@ -1336,10 +1336,8 @@ bool Item_in_optimizer::fix_left(THD *thd)
used_tables_cache= args[0]->used_tables();
}
eval_not_null_tables(NULL);
- flags|= ((args[0]->flags & (ITEM_FLAG_WITH_SUM_FUNC | ITEM_FLAG_WITH_PARAM |
- ITEM_FLAG_WITH_FIELD)) |
- (args[1]->flags & (ITEM_FLAG_WITH_PARAM)));
-
+ with_flags|= (args[0]->with_flags |
+ (args[1]->with_flags & item_with_t::SP_VAR));
if ((const_item_cache= args[0]->const_item()))
{
cache->store(args[0]);
@@ -1349,7 +1347,7 @@ bool Item_in_optimizer::fix_left(THD *thd)
{
/* to avoid overriding is called to update left expression */
used_tables_and_const_cache_join(args[1]);
- flags|= args[1]->flags & ITEM_FLAG_WITH_SUM_FUNC;
+ with_flags|= args[1]->with_flags & item_with_t::SUM_FUNC;
}
DBUG_RETURN(0);
}
@@ -1371,7 +1369,7 @@ bool Item_in_optimizer::fix_fields(THD *thd, Item **ref)
if (fix_left(thd))
return TRUE;
if (args[0]->maybe_null())
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
if (args[1]->fix_fields_if_needed(thd, args + 1))
return TRUE;
@@ -1383,12 +1381,11 @@ bool Item_in_optimizer::fix_fields(THD *thd, Item **ref)
return TRUE;
}
- 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));
+ base_flags|= (item_base_t::FIXED |
+ (args[1]->base_flags & item_base_t::MAYBE_NULL));
+ with_flags|= (item_with_t::SUBQUERY |
+ args[1]->with_flags |
+ (args[0]->with_flags & item_with_t::SP_VAR));
used_tables_and_const_cache_join(args[1]);
return FALSE;
}
@@ -1777,7 +1774,7 @@ longlong Item_func_eq::val_int()
bool Item_func_equal::fix_length_and_dec()
{
bool rc= Item_bool_rowready_func2::fix_length_and_dec();
- flags&= (item_flags_t) ~ITEM_FLAG_MAYBE_NULL;
+ base_flags&= ~item_base_t::MAYBE_NULL;
null_value=0;
return rc;
}
@@ -1931,13 +1928,11 @@ bool Item_func_interval::fix_length_and_dec()
}
}
}
- flags&= (item_flags_t) ~ITEM_FLAG_MAYBE_NULL;
+ base_flags&= ~item_base_t::MAYBE_NULL;
max_length= 2;
used_tables_and_const_cache_join(row);
not_null_tables_cache= row->not_null_tables();
- flags|= (row->flags & (ITEM_FLAG_WITH_SUM_FUNC |
- ITEM_FLAG_WITH_PARAM |
- ITEM_FLAG_WITH_FIELD));
+ with_flags|= row->with_flags;
return FALSE;
}
@@ -2722,7 +2717,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());
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
m_arg0= args[0];
if (setup_args_and_comparator(thd, &cmp))
return TRUE;
@@ -3137,7 +3132,7 @@ bool Item_func_case::fix_fields(THD *thd, Item **ref)
Item **pos= else_expr_addr();
if (!pos || pos[0]->maybe_null())
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
return res;
}
@@ -4898,7 +4893,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_sp_var() &&
!item->is_expensive() && !cond_has_datetime_is_null(item))
{
if (item->eval_const_cond() == is_and_cond && top_level())
@@ -4934,17 +4929,12 @@ Item_cond::fix_fields(THD *thd, Item **ref)
const_item_cache= FALSE;
}
-
- 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));
+ base_flags|= item->base_flags & item_base_t::MAYBE_NULL;
+ with_flags|= item->with_flags;
}
if (fix_length_and_dec())
return TRUE;
- flags|= ITEM_FLAG_FIXED;
+ base_flags|= item_base_t::FIXED;
return FALSE;
}
@@ -4960,7 +4950,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_sp_var() &&
!item->is_expensive() && !cond_has_datetime_is_null(item))
{
if (item->eval_const_cond() == is_and_cond && top_level())
@@ -6086,14 +6076,14 @@ void Regexp_processor_pcre::fix_owner(Item_func *owner,
{
if (compile(pattern_arg, true))
{
- owner->flags|= ITEM_FLAG_MAYBE_NULL; // Will always return NULL
+ owner->set_maybe_null(); // Will always return NULL
return;
}
set_const(true);
- owner->flags|= subject_arg->flags & ITEM_FLAG_MAYBE_NULL;
+ owner->base_flags|= subject_arg->base_flags & item_base_t::MAYBE_NULL;
}
else
- owner->flags|= ITEM_FLAG_MAYBE_NULL;
+ owner->set_maybe_null();
}
@@ -7052,7 +7042,7 @@ bool Item_equal::fix_fields(THD *thd, Item **ref)
not_null_tables_cache|= tmp_table_map;
DBUG_ASSERT(!item->with_sum_func() && !item->with_subquery());
if (item->maybe_null())
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
if (!item->get_item_equal())
item->set_item_equal(this);
if (link_equal_fields && item->real_item()->type() == FIELD_ITEM)
@@ -7069,7 +7059,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;
- flags|= ITEM_FLAG_FIXED;
+ base_flags|= item_base_t::FIXED;
return FALSE;
}
diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h
index ac4aaa09ba3..5743a6f78ee 100644
--- a/sql/item_cmpfunc.h
+++ b/sql/item_cmpfunc.h
@@ -368,7 +368,7 @@ public:
Item_bool_func(thd, a, b), cache(0), expr_cache(0),
save_cache(0), result_for_null_param(UNKNOWN)
{
- flags|= ITEM_FLAG_WITH_SUBQUERY;
+ with_flags|= item_with_t::SUBQUERY;
}
bool fix_fields(THD *, Item **) override;
bool fix_left(THD *thd);
@@ -1130,7 +1130,7 @@ public:
IFNULL(inet6_not_null_expr, 'foo') -> INET6 NULL
IFNULL(inet6_not_null_expr, '::1') -> INET6 NOT NULL
*/
- copy_flags(args[1], ITEM_FLAG_MAYBE_NULL);
+ copy_flags(args[1], item_base_t::MAYBE_NULL);
if (Item_func_case_abbreviation2::fix_length_and_dec2(args))
return TRUE;
return FALSE;
@@ -2571,7 +2571,7 @@ public:
{
decimals=0;
max_length=1;
- flags&= (item_flags_t) ~ITEM_FLAG_MAYBE_NULL;
+ base_flags&= ~item_base_t::MAYBE_NULL;
return FALSE;
}
bool count_sargable_conds(void *arg);
@@ -3468,7 +3468,7 @@ public:
Item_func_cursor_found(THD *thd, const LEX_CSTRING *name, uint offset)
:Item_func_cursor_bool_attr(thd, name, offset)
{
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
}
const char *func_name() const { return "%FOUND"; }
longlong val_int();
@@ -3483,7 +3483,7 @@ public:
Item_func_cursor_notfound(THD *thd, const LEX_CSTRING *name, uint offset)
:Item_func_cursor_bool_attr(thd, name, offset)
{
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
}
const char *func_name() const { return "%NOTFOUND"; }
longlong val_int();
diff --git a/sql/item_func.cc b/sql/item_func.cc
index a5538a4f2d5..b518ffec53b 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -133,12 +133,7 @@ void Item_func::sync_with_sum_func_and_with_field(List<Item> &list)
List_iterator_fast<Item> li(list);
Item *item;
while ((item= li++))
- {
- flags|= (item->flags & (ITEM_FLAG_WITH_SUM_FUNC |
- ITEM_FLAG_WITH_WINDOW_FUNC |
- ITEM_FLAG_WITH_FIELD |
- ITEM_FLAG_WITH_PARAM));
- }
+ with_flags|= item->with_flags;
}
@@ -353,8 +348,8 @@ Item_func::fix_fields(THD *thd, Item **ref)
return TRUE; /* purecov: inspected */
item= *arg;
- flags|= item->flags & ~(ITEM_FLAG_IS_AUTOGENERATED_NAME |
- ITEM_FLAG_IS_IN_WITH_CYCLE);
+ base_flags|= item->base_flags & item_base_t::MAYBE_NULL;
+ with_flags|= item->with_flags;
used_tables_and_const_cache_join(item);
not_null_tables_cache|= item->not_null_tables();
}
@@ -363,7 +358,7 @@ Item_func::fix_fields(THD *thd, Item **ref)
return true;
if (fix_length_and_dec())
return TRUE;
- flags|= ITEM_FLAG_FIXED;
+ base_flags|= item_base_t::FIXED;
return FALSE;
}
@@ -379,7 +374,7 @@ Item_func::quick_fix_field()
(*arg)->quick_fix_field();
}
}
- flags|= ITEM_FLAG_FIXED;
+ base_flags|= item_base_t::FIXED;
}
@@ -593,9 +588,12 @@ void Item_func::split_sum_func(THD *thd, Ref_ptr_array ref_pointer_array,
List<Item> &fields, uint flags)
{
Item **arg, **arg_end;
+ DBUG_ENTER("Item_func::split_sum_func");
+
for (arg= args, arg_end= args+arg_count; arg != arg_end ; arg++)
(*arg)->split_sum_func2(thd, ref_pointer_array, fields, arg,
flags | SPLIT_SUM_SKIP_REGISTERED);
+ DBUG_VOID_RETURN;
}
@@ -1557,7 +1555,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;
- flags|= ITEM_FLAG_MAYBE_NULL; // division by zero
+ set_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;);
@@ -1635,7 +1633,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);
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
unsigned_flag=args[0]->unsigned_flag | args[1]->unsigned_flag;
return false;
}
@@ -1715,7 +1713,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()));
- flags|= ITEM_FLAG_MAYBE_NULL; // division by zero
+ set_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());
@@ -2524,7 +2522,7 @@ void Item_func_round::fix_arg_datetime()
return NULL.
*/
if (!truncate)
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
fix_arg_temporal(&type_handler_datetime2, MAX_DATETIME_WIDTH);
}
@@ -3205,7 +3203,7 @@ longlong Item_func_field::val_int()
bool Item_func_field::fix_length_and_dec()
{
- flags&= (item_flags_t) ~ITEM_FLAG_MAYBE_NULL;
+ base_flags&= ~item_base_t::MAYBE_NULL;
max_length=3;
cmp_type= args[0]->result_type();
for (uint i=1; i < arg_count ; i++)
@@ -3449,7 +3447,7 @@ udf_handler::fix_fields(THD *thd, Item_func_or_sum *func,
args=arguments;
/* Fix all arguments */
- func->flags&= (Item::item_flags_t) ~ITEM_FLAG_MAYBE_NULL;
+ func->base_flags&= ~item_base_t::MAYBE_NULL;
func->used_tables_and_const_cache_init();
if ((f_args.arg_count=arg_count))
@@ -3484,12 +3482,8 @@ 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->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->base_flags|= item->base_flags & item_base_t::MAYBE_NULL;
+ func->with_flags|= item->with_flags;
func->used_tables_and_const_cache_join(item);
f_args.arg_type[i]=item->result_type();
}
@@ -4759,7 +4753,7 @@ bool Item_func_set_user_var::fix_fields(THD *thd, Item **ref)
bool
Item_func_set_user_var::fix_length_and_dec()
{
- flags|= (args[0]->flags & ITEM_FLAG_MAYBE_NULL);
+ base_flags|= (args[0]->base_flags & item_base_t::MAYBE_NULL);
decimals=args[0]->decimals;
if (args[0]->collation.derivation == DERIVATION_NUMERIC)
{
@@ -5616,7 +5610,7 @@ bool Item_func_get_user_var::fix_length_and_dec()
{
THD *thd=current_thd;
int error;
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
decimals=NOT_FIXED_DEC;
max_length=MAX_BLOB_WIDTH;
@@ -5826,7 +5820,7 @@ void Item_func_get_system_var::update_null_value()
bool Item_func_get_system_var::fix_length_and_dec()
{
char *cptr;
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
max_length= 0;
if (var->check_type(var_type))
@@ -6189,7 +6183,7 @@ bool Item_func_match::fix_fields(THD *thd, Item **ref)
status_var_increment(thd->status_var.feature_fulltext);
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
join_key=0;
/*
@@ -6525,7 +6519,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)
{
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
}
@@ -6534,7 +6528,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)
{
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
}
@@ -6590,7 +6584,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;
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
DBUG_RETURN(FALSE);
}
diff --git a/sql/item_func.h b/sql/item_func.h
index bc1d9ae8cc3..75d07b7fa4b 100644
--- a/sql/item_func.h
+++ b/sql/item_func.h
@@ -97,45 +97,33 @@ public:
virtual enum Functype functype() const { return UNKNOWN_FUNC; }
Item_func(THD *thd): Item_func_or_sum(thd)
{
- flags&=(item_flags_t) ~(ITEM_FLAG_WITH_FIELD | ITEM_FLAG_WITH_FIELD);
+ DBUG_ASSERT(with_flags == item_with_t::NONE);
+ with_flags= item_with_t::NONE;
}
Item_func(THD *thd, Item *a): Item_func_or_sum(thd, a)
{
- copy_flags(a,
- ITEM_FLAG_WITH_SUM_FUNC | ITEM_FLAG_WITH_FIELD |
- ITEM_FLAG_WITH_PARAM);
+ with_flags= a->with_flags;
}
Item_func(THD *thd, Item *a, Item *b):
Item_func_or_sum(thd, a, b)
{
- flags|= ((a->flags | b->flags) &
- (ITEM_FLAG_WITH_SUM_FUNC |
- ITEM_FLAG_WITH_PARAM |
- ITEM_FLAG_WITH_FIELD));
+ with_flags= a->with_flags | b->with_flags;
}
Item_func(THD *thd, Item *a, Item *b, Item *c):
Item_func_or_sum(thd, a, b, c)
{
- flags|= ((a->flags | b->flags | c->flags) &
- (ITEM_FLAG_WITH_SUM_FUNC |
- ITEM_FLAG_WITH_PARAM |
- ITEM_FLAG_WITH_FIELD));
+ with_flags|= a->with_flags | b->with_flags | c->with_flags;
}
Item_func(THD *thd, Item *a, Item *b, Item *c, Item *d):
Item_func_or_sum(thd, a, b, c, d)
{
- flags|= ((a->flags | b->flags | c->flags | d->flags) &
- (ITEM_FLAG_WITH_SUM_FUNC |
- ITEM_FLAG_WITH_PARAM |
- ITEM_FLAG_WITH_FIELD));
+ with_flags= a->with_flags | b->with_flags | c->with_flags | d->with_flags;
}
Item_func(THD *thd, Item *a, Item *b, Item *c, Item *d, Item* e):
Item_func_or_sum(thd, a, b, c, d, e)
{
- flags|= ((a->flags | b->flags | c->flags | d->flags | e->flags) &
- (ITEM_FLAG_WITH_SUM_FUNC |
- ITEM_FLAG_WITH_PARAM |
- ITEM_FLAG_WITH_FIELD));
+ with_flags= (a->with_flags | b->with_flags | c->with_flags | d->with_flags |
+ e->with_flags);
}
Item_func(THD *thd, List<Item> &list):
Item_func_or_sum(thd, list)
@@ -153,10 +141,11 @@ public:
Item_func_or_sum::cleanup();
used_tables_and_const_cache_init();
}
- void fix_after_pullout(st_select_lex *new_parent, Item **ref, bool merge);
- void quick_fix_field();
- table_map not_null_tables() const;
- void update_used_tables()
+ void fix_after_pullout(st_select_lex *new_parent, Item **ref, bool merge)
+ override;
+ void quick_fix_field() override;
+ table_map not_null_tables() const override;
+ void update_used_tables() override
{
used_tables_and_const_cache_init();
used_tables_and_const_cache_update_and_join(arg_count, args);
@@ -201,7 +190,7 @@ public:
if (max_result_length >= MAX_BLOB_WIDTH)
{
max_length= MAX_BLOB_WIDTH;
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
}
else
max_length= (uint32) max_result_length;
@@ -1253,7 +1242,7 @@ public:
Item_func_cursor_rowcount(THD *thd, const LEX_CSTRING *name, uint offset)
:Item_longlong_func(thd), Cursor_ref(name, offset)
{
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
}
const char *func_name() const { return "%ROWCOUNT"; }
longlong val_int();
@@ -1432,7 +1421,7 @@ public:
void print(String *str, enum_query_type query_type);
void fix_length_and_dec_generic()
{
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
}
};
@@ -1697,7 +1686,7 @@ class Item_dec_func :public Item_real_func
{
decimals= NOT_FIXED_DEC;
max_length= float_length(decimals);
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
return FALSE;
}
};
@@ -1871,7 +1860,7 @@ public:
fix_attributes_datetime(0);
set_handler(&type_handler_datetime2);
// Thinks like CEILING(TIMESTAMP'0000-01-01 23:59:59.9') returns NULL
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
}
bool fix_length_and_dec();
String *str_op(String *str) { DBUG_ASSERT(0); return 0; }
@@ -2232,7 +2221,7 @@ public:
bool fix_length_and_dec()
{
max_length=10;
- flags&= (item_flags_t) ~ITEM_FLAG_MAYBE_NULL;
+ base_flags&= ~item_base_t::MAYBE_NULL;
return FALSE;
}
bool eval_not_null_tables(void *)
@@ -2495,7 +2484,7 @@ public:
bool fix_length_and_dec()
{
max_length=1;
- flags&= (item_flags_t) ~ITEM_FLAG_MAYBE_NULL;
+ base_flags&= ~item_base_t::MAYBE_NULL;
return FALSE;
}
virtual void print(String *str, enum_query_type query_type);
@@ -2577,7 +2566,7 @@ public:
DBUG_ASSERT(fixed() == 0);
bool res= udf.fix_fields(thd, this, arg_count, args);
set_non_deterministic_if_needed();
- flags|= ITEM_FLAG_FIXED;
+ base_flags|= item_base_t::FIXED;
return res;
}
void fix_num_length_and_dec();
@@ -2826,7 +2815,8 @@ public:
{ 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; }
+ bool fix_length_and_dec() override
+ { base_flags|= item_base_t::MAYBE_NULL; max_length=0; return FALSE; }
};
#endif /* HAVE_DLOPEN */
@@ -2869,7 +2859,7 @@ class Item_func_get_lock final :public Item_func_lock
bool fix_length_and_dec()
{
max_length= 1;
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
return FALSE;
}
Item *get_copy(THD *thd) final
@@ -2901,7 +2891,7 @@ public:
bool fix_length_and_dec()
{
max_length= 1;
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
return FALSE;
}
Item *get_copy(THD *thd) final
@@ -2934,7 +2924,7 @@ public:
bool fix_length_and_dec()
{
max_length=21;
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
return FALSE;
}
bool check_vcol_func_processor(void *arg)
@@ -3376,7 +3366,7 @@ public:
{
decimals=0;
max_length=1;
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
return FALSE;
}
bool check_vcol_func_processor(void *arg)
@@ -3399,7 +3389,7 @@ public:
bool fix_length_and_dec()
{
decimals=0; max_length=10;
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
return FALSE;
}
bool check_vcol_func_processor(void *arg)
@@ -3456,7 +3446,7 @@ public:
bool fix_length_and_dec()
{
decimals= 0;
- flags&= (item_flags_t) ~ITEM_FLAG_MAYBE_NULL;
+ base_flags&= ~item_base_t::MAYBE_NULL;
return FALSE;
}
bool check_vcol_func_processor(void *arg)
@@ -3626,7 +3616,7 @@ public:
bool fix_length_and_dec()
{
decimals= 0;
- flags&= (item_flags_t) ~ITEM_FLAG_MAYBE_NULL;
+ base_flags&= ~item_base_t::MAYBE_NULL;
return FALSE;
}
bool check_vcol_func_processor(void *arg)
@@ -3673,7 +3663,7 @@ public:
}
bool fix_length_and_dec()
{
- flags&= (item_flags_t) ~ITEM_FLAG_MAYBE_NULL;
+ base_flags&= ~item_base_t::MAYBE_NULL;
null_value= false;
max_length= 11;
return FALSE;
@@ -3733,7 +3723,7 @@ public:
void update_used_tables()
{
Item_func::update_used_tables();
- copy_flags(last_value, ITEM_FLAG_MAYBE_NULL);
+ copy_flags(last_value, item_base_t::MAYBE_NULL);
}
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_last_value>(thd, this); }
@@ -3756,7 +3746,7 @@ public:
{
unsigned_flag= 0;
max_length= MAX_BIGINT_WIDTH;
- flags|= ITEM_FLAG_MAYBE_NULL; /* In case of errors */
+ set_maybe_null(); /* In case of errors */
return FALSE;
}
/*
diff --git a/sql/item_geofunc.cc b/sql/item_geofunc.cc
index e6a522a0d85..0edc9a8e08a 100644
--- a/sql/item_geofunc.cc
+++ b/sql/item_geofunc.cc
@@ -47,7 +47,7 @@ bool Item_geometry_func::fix_length_and_dec()
collation.set(&my_charset_bin);
decimals=0;
max_length= (uint32) UINT_MAX32;
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
return FALSE;
}
@@ -221,7 +221,7 @@ bool Item_func_as_wkt::fix_length_and_dec()
{
collation.set(default_charset(), DERIVATION_COERCIBLE, MY_REPERTOIRE_ASCII);
max_length= (uint32) UINT_MAX32;
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
return FALSE;
}
@@ -248,7 +248,7 @@ bool Item_func_as_geojson::fix_length_and_dec()
{
collation.set(default_charset(), DERIVATION_COERCIBLE, MY_REPERTOIRE_ASCII);
max_length=MAX_BLOB_WIDTH;
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
return FALSE;
}
diff --git a/sql/item_geofunc.h b/sql/item_geofunc.h
index aba255df349..2ead0a884fe 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;
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_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());
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_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)
{
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
}
enum Functype functype() const { return spatial_rel; }
enum Functype rev_functype() const
@@ -854,11 +854,12 @@ class Item_func_isempty: public Item_bool_func_args_geometry
public:
Item_func_isempty(THD *thd, Item *a)
:Item_bool_func_args_geometry(thd, a) {}
- longlong val_int();
+ longlong val_int() override;
const char *func_name() const { return "st_isempty"; }
- bool fix_length_and_dec() { flags|= ITEM_FLAG_MAYBE_NULL; return FALSE; }
- bool need_parentheses_in_default() { return false; }
- Item *get_copy(THD *thd)
+ bool fix_length_and_dec() override
+ { set_maybe_null(); return FALSE; }
+ bool need_parentheses_in_default() override { return false; }
+ Item *get_copy(THD *thd) override
{ return get_item_copy<Item_func_isempty>(thd, this); }
};
@@ -907,10 +908,11 @@ class Item_func_dimension: public Item_long_func_args_geometry
public:
Item_func_dimension(THD *thd, Item *a)
:Item_long_func_args_geometry(thd, a) {}
- longlong val_int();
+ longlong val_int() override;
const char *func_name() const { return "st_dimension"; }
- bool fix_length_and_dec() { max_length= 10; flags|= ITEM_FLAG_MAYBE_NULL; return FALSE; }
- Item *get_copy(THD *thd)
+ bool fix_length_and_dec() override
+ { max_length= 10; set_maybe_null(); return FALSE; }
+ Item *get_copy(THD *thd) override
{ return get_item_copy<Item_func_dimension>(thd, this); }
};
@@ -925,7 +927,7 @@ public:
{
if (Item_real_func::fix_length_and_dec())
return TRUE;
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
return FALSE;
}
Item *get_copy(THD *thd)
@@ -943,7 +945,7 @@ public:
{
if (Item_real_func::fix_length_and_dec())
return TRUE;
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
return FALSE;
}
Item *get_copy(THD *thd)
@@ -956,10 +958,11 @@ class Item_func_numgeometries: public Item_long_func_args_geometry
public:
Item_func_numgeometries(THD *thd, Item *a)
:Item_long_func_args_geometry(thd, a) {}
- longlong val_int();
+ longlong val_int() override;
const char *func_name() const { return "st_numgeometries"; }
- bool fix_length_and_dec() { max_length= 10; flags|= ITEM_FLAG_MAYBE_NULL; return FALSE; }
- Item *get_copy(THD *thd)
+ bool fix_length_and_dec() override
+ { max_length= 10; set_maybe_null(); return FALSE; }
+ Item *get_copy(THD *thd) override
{ return get_item_copy<Item_func_numgeometries>(thd, this); }
};
@@ -969,10 +972,11 @@ class Item_func_numinteriorring: public Item_long_func_args_geometry
public:
Item_func_numinteriorring(THD *thd, Item *a)
:Item_long_func_args_geometry(thd, a) {}
- longlong val_int();
+ longlong val_int() override;
const char *func_name() const { return "st_numinteriorrings"; }
- bool fix_length_and_dec() { max_length= 10; flags|= ITEM_FLAG_MAYBE_NULL; return FALSE; }
- Item *get_copy(THD *thd)
+ bool fix_length_and_dec() override
+ { max_length= 10; set_maybe_null(); return FALSE; }
+ Item *get_copy(THD *thd) override
{ return get_item_copy<Item_func_numinteriorring>(thd, this); }
};
@@ -982,10 +986,11 @@ class Item_func_numpoints: public Item_long_func_args_geometry
public:
Item_func_numpoints(THD *thd, Item *a)
:Item_long_func_args_geometry(thd, a) {}
- longlong val_int();
+ longlong val_int() override;
const char *func_name() const { return "st_numpoints"; }
- bool fix_length_and_dec() { max_length= 10; flags|= ITEM_FLAG_MAYBE_NULL; return FALSE; }
- Item *get_copy(THD *thd)
+ bool fix_length_and_dec() override
+ { max_length= 10; set_maybe_null(); return FALSE; }
+ Item *get_copy(THD *thd) override
{ return get_item_copy<Item_func_numpoints>(thd, this); }
};
@@ -1000,7 +1005,7 @@ public:
{
if (Item_real_func::fix_length_and_dec())
return TRUE;
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
return FALSE;
}
Item *get_copy(THD *thd)
@@ -1020,7 +1025,7 @@ public:
{
if (Item_real_func::fix_length_and_dec())
return TRUE;
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
return FALSE;
}
Item *get_copy(THD *thd)
@@ -1033,10 +1038,11 @@ class Item_func_srid: public Item_long_func_args_geometry
public:
Item_func_srid(THD *thd, Item *a)
:Item_long_func_args_geometry(thd, a) {}
- longlong val_int();
+ longlong val_int() override;
const char *func_name() const { return "srid"; }
- bool fix_length_and_dec() { max_length= 10; flags|= ITEM_FLAG_MAYBE_NULL; return FALSE; }
- Item *get_copy(THD *thd)
+ bool fix_length_and_dec() override
+ { max_length= 10; set_maybe_null(); return FALSE; }
+ Item *get_copy(THD *thd) override
{ return get_item_copy<Item_func_srid>(thd, this); }
};
diff --git a/sql/item_jsonfunc.cc b/sql/item_jsonfunc.cc
index f0dc8acab30..0788c374475 100644
--- a/sql/item_jsonfunc.cc
+++ b/sql/item_jsonfunc.cc
@@ -386,7 +386,7 @@ bool Item_func_json_exists::fix_length_and_dec()
{
if (Item_bool_func::fix_length_and_dec())
return TRUE;
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
path.set_constant_flag(args[1]->const_item());
return FALSE;
}
@@ -440,7 +440,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());
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
return FALSE;
}
@@ -450,7 +450,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());
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
return FALSE;
}
@@ -598,7 +598,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;
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
return FALSE;
}
@@ -721,7 +721,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);
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
return FALSE;
}
@@ -990,7 +990,7 @@ bool Item_func_json_contains::fix_length_and_dec()
{
a2_constant= args[1]->const_item();
a2_parsed= FALSE;
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
if (arg_count > 2)
path.set_constant_flag(args[2]->const_item());
return Item_bool_func::fix_length_and_dec();
@@ -1241,7 +1241,7 @@ bool Item_func_json_contains_path::fix_length_and_dec()
{
ooa_constant= args[1]->const_item();
ooa_parsed= FALSE;
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
mark_constant_paths(paths, args+2, arg_count-2);
return Item_bool_func::fix_length_and_dec();
}
@@ -1632,7 +1632,7 @@ bool Item_func_json_array_append::fix_length_and_dec()
}
fix_char_length_ulonglong(char_length);
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
return FALSE;
}
@@ -2551,7 +2551,7 @@ bool Item_func_json_length::fix_length_and_dec()
{
if (arg_count > 1)
path.set_constant_flag(args[1]->const_item());
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
max_length= 10;
return FALSE;
}
@@ -2697,7 +2697,7 @@ bool Item_func_json_type::fix_length_and_dec()
{
collation.set(&my_charset_utf8mb3_general_ci);
max_length= 12;
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
return FALSE;
}
@@ -2766,7 +2766,7 @@ bool Item_func_json_insert::fix_length_and_dec()
}
fix_char_length_ulonglong(char_length);
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
return FALSE;
}
@@ -3018,7 +3018,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);
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
return FALSE;
}
@@ -3203,7 +3203,7 @@ bool Item_func_json_keys::fix_length_and_dec()
{
collation.set(args[0]->collation);
max_length= args[0]->max_length;
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
if (arg_count > 1)
path.set_constant_flag(args[1]->const_item());
return FALSE;
@@ -3388,7 +3388,7 @@ bool Item_func_json_search::fix_length_and_dec()
if (arg_count > 4)
mark_constant_paths(paths, args+4, arg_count-4);
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
return FALSE;
}
@@ -3571,7 +3571,7 @@ bool Item_func_json_format::fix_length_and_dec()
{
decimals= 0;
max_length= args[0]->max_length;
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
return FALSE;
}
@@ -3779,7 +3779,7 @@ Item_func_json_objectagg::fix_fields(THD *thd, Item **ref)
if (init_sum_func_check(thd))
return TRUE;
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
/*
Fix fields for select list and ORDER clause
@@ -3789,9 +3789,7 @@ Item_func_json_objectagg::fix_fields(THD *thd, Item **ref)
{
if (args[i]->fix_fields_if_needed_for_scalar(thd, &args[i]))
return TRUE;
- flags|= (args[i]->flags & (ITEM_FLAG_WITH_SUBQUERY |
- ITEM_FLAG_WITH_PARAM |
- ITEM_FLAG_WITH_WINDOW_FUNC));
+ with_flags|= args[i]->with_flags;
}
/* skip charset aggregation for order columns */
@@ -3808,7 +3806,7 @@ Item_func_json_objectagg::fix_fields(THD *thd, Item **ref)
if (check_sum_func(thd, ref))
return TRUE;
- flags|= ITEM_FLAG_FIXED;
+ base_flags|= item_base_t::FIXED;
return FALSE;
}
diff --git a/sql/item_jsonfunc.h b/sql/item_jsonfunc.h
index 724f45a9d62..11b3db4f952 100644
--- a/sql/item_jsonfunc.h
+++ b/sql/item_jsonfunc.h
@@ -81,7 +81,7 @@ public:
{
if (Item_bool_func::fix_length_and_dec())
return TRUE;
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_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 5cbd2d4caa9..3981392b0ae 100644
--- a/sql/item_row.cc
+++ b/sql/item_row.cc
@@ -38,7 +38,7 @@ bool Item_row::fix_fields(THD *thd, Item **ref)
{
DBUG_ASSERT(fixed() == 0);
null_value= 0;
- flags&= (item_flags_t) ~ITEM_FLAG_MAYBE_NULL;
+ base_flags&= ~item_base_t::MAYBE_NULL;
Item **arg, **arg_end;
for (arg= args, arg_end= args + arg_count; arg != arg_end ; arg++)
@@ -61,14 +61,10 @@ bool Item_row::fix_fields(THD *thd, Item **ref)
with_null|= 1;
}
}
- 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));
+ base_flags|= (item->base_flags & item_base_t::MAYBE_NULL);
+ with_flags|= item->with_flags;
}
- flags|= ITEM_FLAG_FIXED;
+ base_flags|= item_base_t::FIXED;
return FALSE;
}
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index ff6c221c9cb..5c0cf872a9b 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -124,7 +124,8 @@ 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.
*/
- flags|= thd->is_strict_mode() ? ITEM_FLAG_MAYBE_NULL : 0;
+ if (thd->is_strict_mode())
+ set_maybe_null();
return res;
}
@@ -286,7 +287,7 @@ String *Item_func_sha2::val_str_ascii(String *str)
bool Item_func_sha2::fix_length_and_dec()
{
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
max_length = 0;
int sha_variant= (int)(args[1]->const_item() ? args[1]->val_int() : 512);
@@ -374,7 +375,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;
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
what= ENCRYPTION_FLAG_DECRYPT;
return FALSE;
}
@@ -382,11 +383,11 @@ bool Item_func_aes_decrypt::fix_length_and_dec()
bool Item_func_to_base64::fix_length_and_dec()
{
- flags|= args[0]->flags & ITEM_FLAG_MAYBE_NULL;
+ base_flags|= args[0]->base_flags & item_base_t::MAYBE_NULL;
collation.set(default_charset(), DERIVATION_COERCIBLE, MY_REPERTOIRE_ASCII);
if (args[0]->max_length > (uint) my_base64_encode_max_arg_length())
{
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
fix_char_length_ulonglong((ulonglong) my_base64_encode_max_arg_length());
}
else
@@ -442,7 +443,8 @@ 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);
}
- flags|= ITEM_FLAG_MAYBE_NULL; // Can be NULL, e.g. in case of badly formed input string
+ // Can be NULL, e.g. in case of badly formed input string
+ set_maybe_null();
return FALSE;
}
@@ -2310,7 +2312,8 @@ bool Item_func_encode::seed()
bool Item_func_encode::fix_length_and_dec()
{
max_length=args[0]->max_length;
- flags|= (args[0]->flags | args[1]->flags) & ITEM_FLAG_MAYBE_NULL;
+ base_flags|= ((args[0]->base_flags | args[1]->base_flags) &
+ item_base_t::MAYBE_NULL);
collation.set(&my_charset_bin);
/* Precompute the seed state if the item is constant. */
seeded= args[1]->const_item() &&
@@ -2474,11 +2477,11 @@ bool Item_func_current_role::fix_fields(THD *thd, Item **ref)
return 1;
str_value.mark_as_const();
null_value= 0;
- flags&= (item_flags_t) ~ITEM_FLAG_MAYBE_NULL;
+ base_flags&= ~item_base_t::MAYBE_NULL;
return 0;
}
null_value= 1;
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
return 0;
}
@@ -2813,7 +2816,7 @@ bool Item_func_elt::fix_length_and_dec()
set_if_bigger(decimals,args[i]->decimals);
}
fix_char_length(char_length);
- flags|= ITEM_FLAG_MAYBE_NULL; // NULL if wrong first arg
+ set_maybe_null(); // NULL if wrong first arg
return FALSE;
}
@@ -3037,7 +3040,7 @@ bool Item_func_repeat::fix_length_and_dec()
return false;
}
max_length= MAX_BLOB_WIDTH;
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
return false;
}
@@ -3109,7 +3112,7 @@ bool Item_func_space::fix_length_and_dec()
return false;
}
max_length= MAX_BLOB_WIDTH;
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
return false;
}
@@ -3164,7 +3167,7 @@ bool Item_func_binlog_gtid_pos::fix_length_and_dec()
{
collation.set(system_charset_info);
max_length= MAX_BLOB_WIDTH;
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
return FALSE;
}
@@ -3206,8 +3209,9 @@ bool Item_func_pad::fix_length_and_dec()
if (arg_count == 3)
{
String *str;
- if (!args[2]->basic_const_item() || !(str= args[2]->val_str(&pad_str)) || !str->length())
- flags|= ITEM_FLAG_MAYBE_NULL;
+ if (!args[2]->basic_const_item() || !(str= args[2]->val_str(&pad_str)) ||
+ !str->length())
+ set_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;
@@ -3228,7 +3232,7 @@ bool Item_func_pad::fix_length_and_dec()
return false;
}
max_length= MAX_BLOB_WIDTH;
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
return false;
}
@@ -3613,7 +3617,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);
}
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
return FALSE;
}
@@ -4397,7 +4401,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;
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
collation.set(&my_charset_bin);
decimals= 0;
return FALSE;
diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h
index 71d63ff9939..71701be3837 100644
--- a/sql/item_strfunc.h
+++ b/sql/item_strfunc.h
@@ -294,7 +294,7 @@ public:
{
collation.set(system_charset_info);
max_length= MAX_BLOB_WIDTH;
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
return FALSE;
}
const char *func_name() const { return "decode_histogram"; }
@@ -506,7 +506,7 @@ public:
bool fix_length_and_dec()
{
bool res= Item_func_substr::fix_length_and_dec();
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
return res;
}
const char *func_name() const { return "substr_oracle"; }
@@ -581,7 +581,7 @@ public:
bool fix_length_and_dec()
{
bool res= Item_func_trim::fix_length_and_dec();
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
return res;
}
Item *get_copy(THD *thd)
@@ -620,7 +620,7 @@ public:
bool fix_length_and_dec()
{
bool res= Item_func_ltrim::fix_length_and_dec();
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
return res;
}
Item *get_copy(THD *thd)
@@ -655,7 +655,7 @@ public:
bool fix_length_and_dec()
{
bool res= Item_func_rtrim::fix_length_and_dec();
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
return res;
}
Item *get_copy(THD *thd)
@@ -714,7 +714,7 @@ public:
String *val_str(String *);
bool fix_length_and_dec()
{
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
/* 9 = MAX ((8- (arg_len % 8)) + 1) */
max_length = args[0]->max_length + 9;
return FALSE;
@@ -735,7 +735,7 @@ public:
String *val_str(String *);
bool fix_length_and_dec()
{
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
/* 9 = MAX ((8- (arg_len % 8)) + 1) */
max_length= args[0]->max_length;
if (max_length >= 9U)
@@ -775,7 +775,7 @@ public:
String *val_str(String *);
bool fix_length_and_dec()
{
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
max_length = 13;
return FALSE;
}
@@ -855,7 +855,7 @@ public:
bool fix_length_and_dec()
{
max_length= MAX_FIELD_NAME * system_charset_info->mbmaxlen;
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
return FALSE;
}
const char *func_name() const { return "database"; }
@@ -880,7 +880,7 @@ public:
{
max_length= 512 * system_charset_info->mbmaxlen;
null_value= false;
- flags&= (item_flags_t) ~ITEM_FLAG_MAYBE_NULL;
+ base_flags&= ~item_base_t::MAYBE_NULL;
return FALSE;
}
Item *get_copy(THD *thd)
@@ -1155,7 +1155,7 @@ public:
bool fix_length_and_dec()
{
bool res= Item_func_rpad::fix_length_and_dec();
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
return res;
}
const char *func_name() const { return "rpad_oracle"; }
@@ -1190,7 +1190,7 @@ public:
bool fix_length_and_dec()
{
bool res= Item_func_lpad::fix_length_and_dec();
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
return res;
}
const char *func_name() const { return "lpad_oracle"; }
@@ -1210,7 +1210,7 @@ public:
{
collation.set(default_charset());
fix_char_length(64);
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
return FALSE;
}
Item *get_copy(THD *thd)
@@ -1260,7 +1260,7 @@ public:
Item_func_unhex(THD *thd, Item *a): Item_str_func(thd, a)
{
/* there can be bad hex strings */
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
}
const char *func_name() const { return "unhex"; }
String *val_str(String *);
@@ -1287,7 +1287,7 @@ 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)
{
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
}
String *val_str(String *);
bool fix_length_and_dec()
@@ -1360,7 +1360,7 @@ public:
bool fix_length_and_dec()
{
collation.set(&my_charset_bin, DERIVATION_COERCIBLE);
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
max_length=MAX_BLOB_WIDTH;
return FALSE;
}
@@ -1534,7 +1534,7 @@ public:
{
collation.set(system_charset_info);
max_length= 64 * collation.collation->mbmaxlen; // should be enough
- flags&= (item_flags_t) ~ITEM_FLAG_MAYBE_NULL;
+ base_flags&= ~item_base_t::MAYBE_NULL;
return FALSE;
};
table_map not_null_tables() const { return 0; }
@@ -1627,7 +1627,7 @@ public:
bool fix_length_and_dec()
{
max_length=10;
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
return FALSE; }
longlong val_int();
Item *get_copy(THD *thd)
@@ -1665,7 +1665,7 @@ public:
:Item_str_binary_checksum_func(thd, a) {}
bool fix_length_and_dec()
{
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
max_length= MAX_BLOB_WIDTH;
return FALSE;
}
@@ -1745,7 +1745,7 @@ public:
bool fix_length_and_dec()
{
max_length= MAX_BLOB_WIDTH;
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
decimals= 0;
return FALSE;
}
@@ -1764,7 +1764,7 @@ public:
{}
bool fix_length_and_dec()
{
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
max_length= MAX_BLOB_WIDTH;
return FALSE;
}
@@ -1807,7 +1807,7 @@ public:
{collation.set(DYNCOL_UTF);}
bool fix_length_and_dec()
{
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
max_length= MAX_BLOB_WIDTH;
return FALSE;
}
@@ -1851,7 +1851,7 @@ public:
bool fix_length_and_dec()
{
max_length= WSREP_GTID_STR_LEN;
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
return FALSE;
}
Item *get_copy(THD *thd)
@@ -1868,7 +1868,7 @@ public:
bool fix_length_and_dec()
{
max_length= WSREP_GTID_STR_LEN;
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
return FALSE;
}
Item *get_copy(THD *thd)
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc
index 1e2c3591918..581427c34eb 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
- flags|= ITEM_FLAG_WITH_SUBQUERY;
+ with_flags|= item_with_t::SUBQUERY;
reset();
/*
Item value is NULL if select_result_interceptor didn't change this value
@@ -342,7 +342,7 @@ bool Item_subselect::fix_fields(THD *thd_param, Item **ref)
if (uncacheable & UNCACHEABLE_RAND)
used_tables_cache|= RAND_TABLE_BIT;
}
- flags|= ITEM_FLAG_FIXED;
+ base_flags|= item_base_t::FIXED;
end:
done_first_fix_fields= FALSE;
@@ -1052,7 +1052,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));
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
max_columns= UINT_MAX;
DBUG_VOID_RETURN;
}
@@ -1089,7 +1089,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;
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
max_columns= 1;
/*
@@ -1277,7 +1277,7 @@ bool Item_singlerow_subselect::fix_length_and_dec()
else
{
for (uint i= 0; i < max_columns; i++)
- row[i]->flags|= ITEM_FLAG_MAYBE_NULL;
+ row[i]->set_maybe_null();
}
return FALSE;
}
@@ -1489,7 +1489,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
- flags&= (item_flags_t) ~ITEM_FLAG_MAYBE_NULL; //can't be NULL
+ base_flags&= ~item_base_t::MAYBE_NULL; //can't be NULL
value= 0;
DBUG_VOID_RETURN;
}
@@ -1538,7 +1538,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;
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
reset();
//if test_limit will fail then error will be reported to client
test_limit(select_lex->master_unit());
@@ -3441,7 +3441,7 @@ bool Item_in_subselect::fix_fields(THD *thd_arg, Item **ref)
else
if (Item_subselect::fix_fields(thd_arg, ref))
goto err;
- flags|= ITEM_FLAG_FIXED;
+ base_flags|= item_base_t::FIXED;
thd->where= save_where;
DBUG_RETURN(FALSE);
diff --git a/sql/item_sum.cc b/sql/item_sum.cc
index 1c52611e280..64106e4e516 100644
--- a/sql/item_sum.cc
+++ b/sql/item_sum.cc
@@ -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->flags|= ITEM_FLAG_WITH_SUM_FUNC;
+ sl->master_unit()->item->with_flags|= item_with_t::SUM_FUNC;
}
thd->lex->current_select->mark_as_dependent(thd, aggr_sel, NULL);
@@ -488,7 +488,7 @@ void Item_sum::mark_as_sum_func()
cur_select->n_sum_items++;
cur_select->with_sum_func= 1;
const_item_cache= false;
- flags= (flags | ITEM_FLAG_WITH_SUM_FUNC) & ~ITEM_FLAG_WITH_FIELD;
+ with_flags= (with_flags | item_with_t::SUM_FUNC) & ~item_with_t::FIELD;
window_func_sum_expr_flag= false;
}
@@ -892,7 +892,7 @@ bool Aggregator_distinct::setup(THD *thd)
*/
item_sum->null_value= 1;
- item_sum->flags|= ITEM_FLAG_MAYBE_NULL;
+ item_sum->set_maybe_null();
item_sum->quick_group= 0;
DBUG_ASSERT(item_sum->get_arg(0)->fixed());
@@ -1125,9 +1125,8 @@ Item_sum_num::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);
- flags|= (args[i]->flags & (ITEM_FLAG_WITH_SUBQUERY |
- ITEM_FLAG_WITH_PARAM |
- ITEM_FLAG_WITH_WINDOW_FUNC));
+ /* We should ignore FIELD's in arguments to sum functions */
+ with_flags|= (args[i]->with_flags & ~item_with_t::FIELD);
}
result_field=0;
max_length=float_length(decimals);
@@ -1138,7 +1137,7 @@ Item_sum_num::fix_fields(THD *thd, Item **ref)
if (arg_count)
memcpy (orig_args, args, sizeof (Item *) * arg_count);
- flags|= ITEM_FLAG_FIXED;
+ base_flags|= item_base_t::FIXED;
return FALSE;
}
@@ -1156,10 +1155,8 @@ 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);
- flags|= (args[0]->flags & (ITEM_FLAG_WITH_SUBQUERY |
- ITEM_FLAG_WITH_PARAM |
- ITEM_FLAG_WITH_WINDOW_FUNC));
-
+ /* We should ignore FIELD's in arguments to sum functions */
+ with_flags|= (args[0]->with_flags & ~item_with_t::FIELD);
if (fix_length_and_dec())
DBUG_RETURN(TRUE);
@@ -1171,7 +1168,7 @@ Item_sum_min_max::fix_fields(THD *thd, Item **ref)
DBUG_RETURN(TRUE);
orig_args[0]= args[0];
- flags|= ITEM_FLAG_FIXED;
+ base_flags|= item_base_t::FIXED;
DBUG_RETURN(FALSE);
}
@@ -1241,7 +1238,7 @@ 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 */
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
null_value= true;
return args[0]->type_handler()->Item_sum_hybrid_fix_length_and_dec(this);
}
@@ -1313,7 +1310,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)
{
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
quick_group= 0;
m_sp= sp;
}
@@ -1322,7 +1319,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)
{
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
quick_group= 0;
m_sp= sp;
}
@@ -1330,7 +1327,7 @@ 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)
{
- flags|= (item->flags & ITEM_FLAG_MAYBE_NULL);
+ base_flags|= (item->base_flags & item_base_t::MAYBE_NULL);
quick_group= item->quick_group;
}
@@ -1359,8 +1356,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);
- flags|= (args[i]->flags & (ITEM_FLAG_WITH_SUBQUERY |
- ITEM_FLAG_WITH_WINDOW_FUNC));
+ /* We should ignore FIELD's in arguments to sum functions */
+ with_flags|= (args[i]->with_flags & ~item_with_t::FIELD);
}
result_field= NULL;
max_length= float_length(decimals);
@@ -1373,7 +1370,7 @@ Item_sum_sp::fix_fields(THD *thd, Item **ref)
if (arg_count)
memcpy(orig_args, args, sizeof(Item *) * arg_count);
- flags|= ITEM_FLAG_FIXED;
+ base_flags|= item_base_t::FIXED;
return FALSE;
}
@@ -1557,7 +1554,7 @@ 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");
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
null_value=1;
if (args[0]->cast_to_int_type_handler()->
Item_sum_sum_fix_length_and_dec(this))
@@ -1980,7 +1977,7 @@ bool Item_sum_avg::fix_length_and_dec()
{
DBUG_ENTER("Item_sum_avg::fix_length_and_dec");
prec_increment= current_thd->variables.div_precincrement;
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
null_value=1;
if (args[0]->cast_to_int_type_handler()->
Item_sum_avg_fix_length_and_dec(this))
@@ -2211,7 +2208,7 @@ 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");
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
null_value= 1;
prec_increment= current_thd->variables.div_precincrement;
@@ -4224,7 +4221,7 @@ Item_func_group_concat::fix_fields(THD *thd, Item **ref)
if (init_sum_func_check(thd))
return TRUE;
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
/*
Fix fields for select list and ORDER clause
@@ -4234,9 +4231,8 @@ Item_func_group_concat::fix_fields(THD *thd, Item **ref)
{
if (args[i]->fix_fields_if_needed_for_scalar(thd, &args[i]))
return TRUE;
- flags|= (args[i]->flags & (ITEM_FLAG_WITH_SUBQUERY |
- ITEM_FLAG_WITH_PARAM |
- ITEM_FLAG_WITH_WINDOW_FUNC));
+ /* We should ignore FIELD's in arguments to sum functions */
+ with_flags|= (args[i]->with_flags & ~item_with_t::FIELD);
}
/* skip charset aggregation for order columns */
@@ -4275,7 +4271,7 @@ Item_func_group_concat::fix_fields(THD *thd, Item **ref)
if (check_sum_func(thd, ref))
return TRUE;
- flags|= ITEM_FLAG_FIXED;
+ base_flags|= item_base_t::FIXED;
return FALSE;
}
diff --git a/sql/item_sum.h b/sql/item_sum.h
index 02da520048b..14672af6ef6 100644
--- a/sql/item_sum.h
+++ b/sql/item_sum.h
@@ -463,7 +463,7 @@ public:
virtual void update_field()=0;
virtual bool fix_length_and_dec()
{
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
null_value=1;
return FALSE;
}
@@ -786,7 +786,7 @@ public:
{
decimals=0;
max_length=21;
- flags&= (item_flags_t) ~ITEM_FLAG_MAYBE_NULL;
+ base_flags&= ~item_base_t::MAYBE_NULL;
null_value=0;
return FALSE; }
};
@@ -1219,7 +1219,7 @@ public:
if (args[0]->check_type_can_return_int(func_name()))
return true;
decimals= 0; max_length=21; unsigned_flag= 1;
- flags&= (item_flags_t) ~ITEM_FLAG_MAYBE_NULL;
+ base_flags&= ~item_base_t::MAYBE_NULL;
null_value= 0;
return FALSE;
}
@@ -1470,7 +1470,7 @@ public:
:Item(thd), field(item->result_field)
{
name= item->name;
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
decimals= item->decimals;
max_length= item->max_length;
unsigned_flag= item->unsigned_flag;
@@ -1614,7 +1614,7 @@ public:
if (init_sum_func_check(thd))
return TRUE;
- flags|= ITEM_FLAG_FIXED;
+ base_flags|= item_base_t::FIXED;
/*
We set const_item_cache to false in constructors.
It can be later changed to "true", in a Item_sum::make_const() call.
@@ -1846,7 +1846,8 @@ public:
{ 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; }
+ bool fix_length_and_dec() override
+ { base_flags|= item_base_t::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 07bfbcddd14..89e5ead8270 100644
--- a/sql/item_timefunc.cc
+++ b/sql/item_timefunc.cc
@@ -967,7 +967,7 @@ 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;
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
return FALSE;
}
@@ -1112,7 +1112,7 @@ 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;
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
return FALSE;
}
@@ -1761,7 +1761,7 @@ bool Item_func_date_format::fix_length_and_dec()
collation.collation->mbmaxlen;
set_if_smaller(max_length,MAX_BLOB_WIDTH);
}
- flags|= ITEM_FLAG_MAYBE_NULL; // If wrong date
+ set_maybe_null(); // If wrong date
return FALSE;
}
@@ -1924,7 +1924,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());
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
return FALSE;
}
@@ -2051,7 +2051,7 @@ bool Item_date_add_interval::fix_length_and_dec()
{
set_func_handler(&func_handler_date_add_interval_string);
}
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
return m_func_handler->fix_length_and_dec(this);
}
@@ -2128,7 +2128,7 @@ bool Item_extract::check_arguments() const
bool Item_extract::fix_length_and_dec()
{
- flags|= ITEM_FLAG_MAYBE_NULL; // If wrong date
+ set_maybe_null(); // If wrong date
uint32 daylen= args[0]->cmp_type() == TIME_RESULT ? 2 :
TIME_MAX_INTERVAL_DAY_CHAR_LENGTH;
switch (int_type) {
@@ -2491,7 +2491,8 @@ 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;
- flags|= (current_thd->is_strict_mode() ? ITEM_FLAG_MAYBE_NULL : 0);
+ if (current_thd->is_strict_mode())
+ set_maybe_null();
}
@@ -2536,7 +2537,8 @@ 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()
- flags|= (current_thd->is_strict_mode() ? ITEM_FLAG_MAYBE_NULL : 0);
+ if (current_thd->is_strict_mode())
+ set_maybe_null();
}
@@ -2660,7 +2662,7 @@ bool Item_func_add_time::fix_length_and_dec()
&func_handler_add_time_string_sub);
}
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
return m_func_handler->fix_length_and_dec(this);
}
@@ -3046,7 +3048,7 @@ bool Item_func_str_to_date::fix_length_and_dec()
if (collation.collation->mbminlen > 1)
internal_charset= &my_charset_utf8mb4_general_ci;
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_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 26501dbd077..c717a7bde98 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;
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
return FALSE;
}
enum_monotonicity_info get_monotonicity_info() const;
@@ -125,7 +125,7 @@ public:
{
decimals=0;
fix_char_length(12);
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_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;
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_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);
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_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);
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_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;
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_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;
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_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;
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_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;
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_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;
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_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;
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_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;
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_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);
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_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);
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
if (decimals)
set_handler(&type_handler_newdecimal);
else
@@ -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));
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_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);
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_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));
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_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);
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_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);
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
return FALSE;
}
const char *func_name() const { return "maketime"; }
@@ -1315,7 +1315,7 @@ public:
bool fix_length_and_dec()
{
decimals=0;
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
fix_char_length(6);
return FALSE;
}
@@ -1346,7 +1346,7 @@ public:
bool fix_length_and_dec()
{
decimals=0;
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_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()
{
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
decimals=0;
fix_length_and_charset(17, default_charset());
return FALSE;
diff --git a/sql/item_windowfunc.cc b/sql/item_windowfunc.cc
index cdf8ebf9879..262481d019b 100644
--- a/sql/item_windowfunc.cc
+++ b/sql/item_windowfunc.cc
@@ -120,7 +120,7 @@ Item_window_func::fix_fields(THD *thd, Item **ref)
const_item_cache= false;
- flags= (flags & ~ITEM_FLAG_WITH_SUM_FUNC) | ITEM_FLAG_WITH_WINDOW_FUNC;
+ with_flags= (with_flags & ~item_with_t::SUM_FUNC) | item_with_t::WINDOW_FUNC;
if (fix_length_and_dec())
return TRUE;
@@ -128,7 +128,7 @@ Item_window_func::fix_fields(THD *thd, Item **ref)
max_length= window_func()->max_length;
set_maybe_null(window_func()->maybe_null());
- flags|= ITEM_FLAG_FIXED;
+ base_flags|= item_base_t::FIXED;
set_phase_to_initial();
return false;
}
@@ -344,8 +344,7 @@ 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;
- flags|= (args[i]->flags & (ITEM_FLAG_WITH_WINDOW_FUNC |
- ITEM_FLAG_WITH_SUBQUERY));
+ with_flags|= args[i]->with_flags;
}
if (fix_length_and_dec())
@@ -359,14 +358,14 @@ bool Item_sum_hybrid_simple::fix_fields(THD *thd, Item **ref)
for (uint i= 0; i < arg_count; i++)
orig_args[i]= args[i];
- flags|= ITEM_FLAG_FIXED;
+ base_flags|= item_base_t::FIXED;
return FALSE;
}
bool Item_sum_hybrid_simple::fix_length_and_dec()
{
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
null_value= true;
return args[0]->type_handler()->Item_sum_hybrid_fix_length_and_dec(this);
}
diff --git a/sql/item_xmlfunc.h b/sql/item_xmlfunc.h
index 3369304d79c..1d2b6e70995 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)
{
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
}
Item_xml_str_func(THD *thd, Item *a, Item *b, Item *c):
Item_str_func(thd, a, b, c)
{
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_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 84741adc3fd..3a30fd93e95 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->flags|= ITEM_FLAG_FIXED;
+ item->base_flags|= item_base_t::FIXED;
SELECT_LEX *save_select_lex= thd->lex->current_select;
thd->lex->current_select= item->unit->first_select();
@@ -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->flags|= ITEM_FLAG_FIXED;
+ in_subq->base_flags|= item_base_t::FIXED;
SELECT_LEX *save_select_lex= thd->lex->current_select;
thd->lex->current_select= in_subq->unit->first_select();
diff --git a/sql/sp_head.cc b/sql/sp_head.cc
index 46a9141899e..e3b212ff3b4 100644
--- a/sql/sp_head.cc
+++ b/sql/sp_head.cc
@@ -2992,7 +2992,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->flags|= ITEM_FLAG_MAYBE_NULL;
+ stmt_fld->set_maybe_null();
fields->push_back(stmt_fld, mem_root);
}
@@ -3068,7 +3068,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->flags|= ITEM_FLAG_MAYBE_NULL;
+ stmt_fld->set_maybe_null();
fields.push_back(stmt_fld, thd->mem_root);
}
diff --git a/sql/sql_admin.cc b/sql/sql_admin.cc
index 1ee21954945..c18ca6286fa 100644
--- a/sql/sql_admin.cc
+++ b/sql/sql_admin.cc
@@ -509,18 +509,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->flags|= ITEM_FLAG_MAYBE_NULL;
+ item->set_maybe_null();
field_list.push_back(item= new (thd->mem_root)
Item_empty_string(thd, "Op", 10), thd->mem_root);
- item->flags|= ITEM_FLAG_MAYBE_NULL;
+ item->set_maybe_null();
field_list.push_back(item= new (thd->mem_root)
Item_empty_string(thd, "Msg_type", 10), thd->mem_root);
- item->flags|= ITEM_FLAG_MAYBE_NULL;
+ item->set_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->flags|= ITEM_FLAG_MAYBE_NULL;
+ item->set_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 090fd724873..a6fc7c25e55 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]->flags|= ITEM_FLAG_MAYBE_NULL;
+ func_items[1]->set_maybe_null();
func_items[2]= new (mem_root) Item_proc_string(thd, "Max_value", 255);
- func_items[2]->flags|= ITEM_FLAG_MAYBE_NULL;
+ func_items[2]->set_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]->flags|= ITEM_FLAG_MAYBE_NULL;
+ func_items[8]->set_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_class.cc b/sql/sql_class.cc
index 8c3bc955a5a..4a3d8cdc2b0 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -2748,45 +2748,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->flags|= ITEM_FLAG_MAYBE_NULL;
+ item->set_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->flags|= ITEM_FLAG_MAYBE_NULL;
+ item->set_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->flags|= ITEM_FLAG_MAYBE_NULL;
+ item->set_maybe_null();
}
field_list.push_back(item= new (mem_root)
Item_empty_string(this, "type", 10, cs),
mem_root);
- item->flags|= ITEM_FLAG_MAYBE_NULL;
+ item->set_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->flags|= ITEM_FLAG_MAYBE_NULL;
+ item->set_maybe_null();
field_list.push_back(item=new (mem_root)
Item_empty_string(this, "key", NAME_CHAR_LEN, cs),
mem_root);
- item->flags|= ITEM_FLAG_MAYBE_NULL;
+ item->set_maybe_null();
field_list.push_back(item=new (mem_root)
Item_empty_string(this, "key_len",
NAME_CHAR_LEN*MAX_KEY),
mem_root);
- item->flags|= ITEM_FLAG_MAYBE_NULL;
+ item->set_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->flags|= ITEM_FLAG_MAYBE_NULL;
+ item->set_maybe_null();
field_list.push_back(item=new (mem_root)
Item_empty_string(this, "rows", NAME_CHAR_LEN, cs),
mem_root);
@@ -2795,7 +2795,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->flags|= ITEM_FLAG_MAYBE_NULL;
+ item->set_maybe_null();
}
if (is_analyze || (explain_flags & DESCRIBE_EXTENDED))
@@ -2803,7 +2803,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->flags|= ITEM_FLAG_MAYBE_NULL;
+ item->set_maybe_null();
}
if (is_analyze)
@@ -2811,10 +2811,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->flags|= ITEM_FLAG_MAYBE_NULL;
+ item->set_maybe_null();
}
- item->flags|= ITEM_FLAG_MAYBE_NULL;
+ item->set_maybe_null();
field_list.push_back(new (mem_root)
Item_empty_string(this, "Extra", 255, cs),
mem_root);
diff --git a/sql/sql_cte.cc b/sql/sql_cte.cc
index c262adc763d..faa2b424f12 100644
--- a/sql/sql_cte.cc
+++ b/sql/sql_cte.cc
@@ -992,7 +992,7 @@ With_element::process_columns_of_derived_unit(THD *thd,
while ((item= it++, name= nm++))
{
item->set_name(thd, *name);
- item->flags&= ~ITEM_FLAG_IS_AUTOGENERATED_NAME;
+ item->base_flags&= ~item_base_t::IS_AUTOGENERATED_NAME;
}
if (arena)
@@ -1035,7 +1035,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->flags|= ITEM_FLAG_IS_IN_WITH_CYCLE;
+ item->base_flags|= item_base_t::IS_IN_WITH_CYCLE;
}
}
unit->columns_are_renamed= true;
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 732cc0b28a9..881eaa034ee 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -18500,7 +18500,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->flags|= ITEM_FLAG_MAYBE_NULL;
+ arg->set_maybe_null();
}
if (current_counter == distinct)
new_field->flags|= FIELD_PART_OF_TMP_UNIQUE;
@@ -18890,7 +18890,7 @@ bool Create_tmp_table::finalize(THD *thd,
that the key,field and item definition match.
*/
maybe_null= 0;
- (*cur_group->item)->flags&= (Item::item_flags_t) ~ITEM_FLAG_MAYBE_NULL;
+ (*cur_group->item)->base_flags&= ~item_base_t::MAYBE_NULL;
}
if (!(cur_group->field= field->new_key_field(thd->mem_root,table,
@@ -24812,7 +24812,7 @@ count_field_types(SELECT_LEX *select_lex, TMP_TABLE_PARAM *param,
{
param->func_count++;
if (reset_with_sum_func)
- field->flags&= ~ITEM_FLAG_WITH_SUM_FUNC;
+ field->with_flags&= ~item_with_t::SUM_FUNC;
}
}
}
@@ -25867,7 +25867,7 @@ static bool change_group_ref(THD *thd, Item_func *expr, ORDER *group_list,
}
if (arg_changed)
{
- expr->flags|= ITEM_FLAG_MAYBE_NULL | ITEM_FLAG_IN_ROLLUP;
+ expr->base_flags|= item_base_t::MAYBE_NULL | item_base_t::IN_ROLLUP;
*changed= TRUE;
}
}
@@ -25938,7 +25938,7 @@ bool JOIN::rollup_init()
{
if (*group_tmp->item == item)
{
- item->flags|= ITEM_FLAG_MAYBE_NULL | ITEM_FLAG_IN_ROLLUP;
+ item->base_flags|= item_base_t::MAYBE_NULL | item_base_t::IN_ROLLUP;
found_in_group= 1;
break;
}
@@ -25954,7 +25954,7 @@ bool JOIN::rollup_init()
Marking the expression item as 'with_sum_func' will ensure this.
*/
if (changed)
- item->flags|= ITEM_FLAG_WITH_SUM_FUNC;
+ item->with_flags|= item_with_t::SUM_FUNC;
}
}
return 0;
@@ -26124,7 +26124,8 @@ 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->flags|= ITEM_FLAG_MAYBE_NULL; // Value will be null sometimes
+ // Value will be null sometimes
+ item->set_maybe_null();
null_item->result_field= item->get_tmp_table_field();
item= null_item;
break;
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index df5d844e46b..978843234bc 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -2858,7 +2858,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->flags|= ITEM_FLAG_MAYBE_NULL;;
+ field->set_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)
@@ -2868,18 +2868,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->flags|= ITEM_FLAG_MAYBE_NULL;;
+ field->set_maybe_null();;
field_list.push_back(field=new (mem_root)
Item_empty_string(thd, "Info", arg.max_query_length),
mem_root);
- field->flags|= ITEM_FLAG_MAYBE_NULL;;
+ field->set_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->flags&= (Item::item_flags_t) ~ITEM_FLAG_MAYBE_NULL;
+ field->base_flags&= ~item_base_t::MAYBE_NULL;
}
if (protocol->send_result_set_metadata(&field_list,
Protocol::SEND_NUM_ROWS |
@@ -9723,7 +9723,7 @@ static bool show_create_trigger_impl(THD *thd, Trigger *trigger)
(uint)MY_MAX(trg_sql_original_stmt.length,
1024));
- stmt_fld->flags|= ITEM_FLAG_MAYBE_NULL;
+ stmt_fld->set_maybe_null();
fields.push_back(stmt_fld, mem_root);
}
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 696982ae617..23c9f5198ca 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -11668,12 +11668,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->flags|= ITEM_FLAG_MAYBE_NULL;
+ item->set_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->flags|= ITEM_FLAG_MAYBE_NULL;
+ item->set_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 7e1d4f05238..8f27dbedd89 100644
--- a/sql/sql_type.cc
+++ b/sql/sql_type.cc
@@ -4717,7 +4717,8 @@ bool Type_handler_temporal_result::
continue; // No conversion.
if (ha->cmp_type() != TIME_RESULT)
{
- func->flags|= ITEM_FLAG_MAYBE_NULL; // Conversion from non-temporal is not safe
+ // Conversion from non-temporal is not safe
+ func->set_maybe_null();
break;
}
timestamp_type tf= hf->mysql_timestamp_type();
@@ -4768,7 +4769,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->flags|= ITEM_FLAG_MAYBE_NULL;
+ func->set_maybe_null();
break;
}
return rc;
@@ -4792,7 +4793,7 @@ bool Type_handler_date_common::
{
if (items[i]->type_handler()->cmp_type() != TIME_RESULT)
{
- func->flags|= ITEM_FLAG_MAYBE_NULL;
+ func->set_maybe_null();
break;
}
}
@@ -6674,7 +6675,7 @@ bool Type_handler::
item->arguments()[0]->time_precision(current_thd) :
item->decimals;
item->fix_attributes_temporal(MIN_TIME_WIDTH, dec);
- item->flags|= ITEM_FLAG_MAYBE_NULL;
+ item->set_maybe_null();
return false;
}
@@ -6683,7 +6684,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->flags|= ITEM_FLAG_MAYBE_NULL;
+ item->set_maybe_null();
return false;
}
@@ -6696,7 +6697,7 @@ bool Type_handler::
item->arguments()[0]->datetime_precision(current_thd) :
item->decimals;
item->fix_attributes_temporal(MAX_DATETIME_WIDTH, dec);
- item->flags|= ITEM_FLAG_MAYBE_NULL;
+ item->set_maybe_null();
return false;
}
diff --git a/sql/sql_view.cc b/sql/sql_view.cc
index 57c0c2e2ccd..dd41cfd3e84 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->flags&= ~ITEM_FLAG_IS_AUTOGENERATED_NAME;
+ item->base_flags&= ~item_base_t::IS_AUTOGENERATED_NAME;
itc.rewind();
while ((check= itc++) && check != item)
{
@@ -566,7 +566,7 @@ bool mysql_create_view(THD *thd, TABLE_LIST *views,
while ((item= it++, name= nm++))
{
item->set_name(thd, *name);
- item->flags&= ~ITEM_FLAG_IS_AUTOGENERATED_NAME;
+ item->base_flags&= ~item_base_t::IS_AUTOGENERATED_NAME;
}
}
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 499d02c0d74..d9b28610748 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -9154,7 +9154,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->flags&= ~ITEM_FLAG_IS_AUTOGENERATED_NAME;
+ $2->base_flags&= ~item_base_t::IS_AUTOGENERATED_NAME;
$2->set_name(thd, $4);
}
else if (!$2->name.str || $2->name.str == item_empty_name)
@@ -10732,7 +10732,7 @@ udf_expr:
*/
if ($4.str)
{
- $2->flags&= ~ITEM_FLAG_IS_AUTOGENERATED_NAME;
+ $2->base_flags&= ~item_base_t::IS_AUTOGENERATED_NAME;
$2->set_name(thd, $4);
}
/*
diff --git a/sql/table.cc b/sql/table.cc
index aae2bda2b4a..200e4830b94 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -6765,7 +6765,7 @@ Item *create_view_field(THD *thd, TABLE_LIST *view, Item **field_ref,
views/derived tables.
*/
if (view->table && view->table->maybe_null)
- item->flags|= ITEM_FLAG_MAYBE_NULL;
+ item->set_maybe_null();
/* Save item in case we will need to fall back to materialization. */
view->used_items.push_front(item, thd->mem_root);
/*