1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

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.
This commit is contained in:
Monty
2020-09-02 03:13:32 +03:00
committed by Sergei Golubchik
parent 7ca4e381f7
commit 6079b46d8d
37 changed files with 522 additions and 460 deletions

View File

@@ -32,7 +32,7 @@ public:
bool fix_length_and_dec() bool fix_length_and_dec()
{ {
max_length= MAX_FIELD_NAME * system_charset_info->mbmaxlen; max_length= MAX_FIELD_NAME * system_charset_info->mbmaxlen;
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
return false; return false;
} }
const char *func_name() const { return "sysconst_test"; } const char *func_name() const { return "sysconst_test"; }

View File

@@ -37,7 +37,7 @@ public:
{ {
decimals= 0; decimals= 0;
max_length= 21; max_length= 21;
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
unsigned_flag= 1; unsigned_flag= 1;
return FALSE; return FALSE;
} }
@@ -61,7 +61,7 @@ public:
{ {
decimals= 0; decimals= 0;
fix_length_and_charset(3 * 8 + 7, default_charset()); fix_length_and_charset(3 * 8 + 7, default_charset());
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
return FALSE; return FALSE;
} }
Item *get_copy(THD *thd) Item *get_copy(THD *thd)
@@ -105,7 +105,7 @@ public:
{ {
decimals= 0; decimals= 0;
fix_length_and_charset(16, &my_charset_bin); fix_length_and_charset(16, &my_charset_bin);
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
return FALSE; return FALSE;
} }
Item *get_copy(THD *thd) Item *get_copy(THD *thd)
@@ -139,7 +139,7 @@ public:
// 4 symbols per group // 4 symbols per group
fix_length_and_charset(8 * 4 + 7, default_charset()); fix_length_and_charset(8 * 4 + 7, default_charset());
flags|= ITEM_FLAG_MAYBE_NULL;; set_maybe_null();;
return FALSE; return FALSE;
} }
String *val_str_ascii(String *to); String *val_str_ascii(String *to);

View File

@@ -1055,7 +1055,7 @@ public:
{ {
Type_std_attributes::operator=(Type_std_attributes_inet6()); Type_std_attributes::operator=(Type_std_attributes_inet6());
if (Inet6::fix_fields_maybe_null_on_conversion_to_inet6(args[0])) if (Inet6::fix_fields_maybe_null_on_conversion_to_inet6(args[0]))
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
return false; return false;
} }
String *val_str(String *to) override String *val_str(String *to) override

View File

@@ -413,7 +413,8 @@ Item::Item(THD *thd):
name(null_clex_str), orig_name(0), is_expensive_cache(-1) name(null_clex_str), orig_name(0), is_expensive_cache(-1)
{ {
DBUG_ASSERT(thd); DBUG_ASSERT(thd);
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; null_value= 0;
marker= 0; marker= 0;
@@ -445,7 +446,8 @@ Item::Item():
name(null_clex_str), orig_name(0), is_expensive_cache(-1) name(null_clex_str), orig_name(0), is_expensive_cache(-1)
{ {
DBUG_ASSERT(my_progname == NULL); // before main() DBUG_ASSERT(my_progname == NULL); // before main()
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; null_value= 0;
marker= 0; marker= 0;
join_tab_idx= MAX_TABLES; join_tab_idx= MAX_TABLES;
@@ -473,13 +475,13 @@ Item::Item(THD *thd, Item *item):
str_value(item->str_value), str_value(item->str_value),
name(item->name), name(item->name),
orig_name(item->orig_name), orig_name(item->orig_name),
base_flags(item->base_flags & ~item_base_t::FIXED),
with_flags(item->with_flags),
marker(item->marker), marker(item->marker),
null_value(item->null_value), null_value(item->null_value),
is_expensive_cache(-1), is_expensive_cache(-1),
join_tab_idx(item->join_tab_idx) join_tab_idx(item->join_tab_idx)
{ {
flags= item->flags & (item_flags_t) ~ITEM_FLAG_FIXED;
next= thd->free_list; // Put in free list next= thd->free_list; // Put in free list
thd->free_list= this; thd->free_list= this;
} }
@@ -1599,9 +1601,10 @@ bool Item_sp_variable::fix_fields_from_item(THD *thd, Item **, const Item *it)
max_length= it->max_length; max_length= it->max_length;
decimals= it->decimals; decimals= it->decimals;
unsigned_flag= it->unsigned_flag; 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) 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); collation.set(it->collation.collation, it->collation.derivation);
return FALSE; return FALSE;
@@ -1723,7 +1726,7 @@ Item_splocal::Item_splocal(THD *thd,
m_var_idx(sp_var_idx), m_var_idx(sp_var_idx),
m_type(handler == &type_handler_row ? ROW_ITEM : CONST_ITEM) m_type(handler == &type_handler_row ? ROW_ITEM : CONST_ITEM)
{ {
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
} }
@@ -2086,7 +2089,7 @@ Item_name_const::Item_name_const(THD *thd, Item *name_arg, Item *val):
StringBuffer<128> name_buffer; StringBuffer<128> name_buffer;
String *name_str; String *name_str;
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
if (name_item->basic_const_item() && if (name_item->basic_const_item() &&
(name_str= name_item->val_str(&name_buffer))) // Can't have a NULL name (name_str= name_item->val_str(&name_buffer))) // Can't have a NULL name
set_name(thd, name_str); set_name(thd, name_str);
@@ -2140,7 +2143,7 @@ bool Item_name_const::fix_fields(THD *thd, Item **ref)
max_length= value_item->max_length; max_length= value_item->max_length;
decimals= value_item->decimals; decimals= value_item->decimals;
unsigned_flag= value_item->unsigned_flag; unsigned_flag= value_item->unsigned_flag;
flags|= ITEM_FLAG_FIXED; base_flags|= item_base_t::FIXED;
return FALSE; return FALSE;
} }
@@ -2959,7 +2962,7 @@ Item_field::Item_field(THD *thd, Field *f)
*/ */
orig_table_name= table_name; orig_table_name= table_name;
orig_field_name= field_name; orig_field_name= field_name;
flags|= ITEM_FLAG_WITH_FIELD; with_flags|= item_with_t::FIELD;
} }
@@ -3009,7 +3012,7 @@ Item_field::Item_field(THD *thd, Name_resolution_context *context_arg,
name= orig_field_name; name= orig_field_name;
} }
set_field(f); set_field(f);
flags|= ITEM_FLAG_WITH_FIELD; with_flags|= item_with_t::FIELD;
} }
@@ -3025,7 +3028,7 @@ Item_field::Item_field(THD *thd, Name_resolution_context *context_arg,
collation.set(DERIVATION_IMPLICIT); collation.set(DERIVATION_IMPLICIT);
if (select && select->parsing_place != IN_HAVING) if (select && select->parsing_place != IN_HAVING)
select->select_n_where_fields++; select->select_n_where_fields++;
flags|= ITEM_FLAG_WITH_FIELD; with_flags|= item_with_t::FIELD;
} }
/** /**
@@ -3040,7 +3043,7 @@ Item_field::Item_field(THD *thd, Item_field *item)
any_privileges(item->any_privileges) any_privileges(item->any_privileges)
{ {
collation.set(DERIVATION_IMPLICIT); collation.set(DERIVATION_IMPLICIT);
flags|= ITEM_FLAG_WITH_FIELD; with_flags|= item_with_t::FIELD;
} }
@@ -3065,7 +3068,7 @@ void Item_field::set_field(Field *field_par)
db_name= field_par->table->s->db; db_name= field_par->table->s->db;
alias_name_used= field_par->table->alias_name_used; 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) if (field->table->s->tmp_table == SYSTEM_TMP_TABLE)
any_privileges= 0; any_privileges= 0;
} }
@@ -3959,7 +3962,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 before mysql_stmt_execute(), so we assuming that it can be NULL until
value is set. value is set.
*/ */
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
} }
@@ -3991,7 +3994,7 @@ void Item_param::sync_clones()
{ {
Item_param *c= *c_ptr; Item_param *c= *c_ptr;
/* Scalar-type members: */ /* 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->null_value= null_value;
c->Type_std_attributes::operator=(*this); c->Type_std_attributes::operator=(*this);
c->Type_handler_hybrid_field_type::operator=(*this); c->Type_handler_hybrid_field_type::operator=(*this);
@@ -4043,7 +4046,7 @@ void Item_param::set_int(longlong i, uint32 max_length_arg)
collation= DTCollation_numeric(); collation= DTCollation_numeric();
max_length= max_length_arg; max_length= max_length_arg;
decimals= 0; decimals= 0;
flags&= (item_flags_t) ~ITEM_FLAG_MAYBE_NULL; base_flags&= ~item_base_t::MAYBE_NULL;
null_value= 0; null_value= 0;
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
@@ -4057,7 +4060,7 @@ void Item_param::set_double(double d)
collation= DTCollation_numeric(); collation= DTCollation_numeric();
max_length= DBL_DIG + 8; max_length= DBL_DIG + 8;
decimals= NOT_FIXED_DEC; decimals= NOT_FIXED_DEC;
flags&= (item_flags_t) ~ITEM_FLAG_MAYBE_NULL; base_flags&= ~item_base_t::MAYBE_NULL;
null_value= 0; null_value= 0;
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
@@ -4089,7 +4092,7 @@ void Item_param::set_decimal(const char *str, ulong length)
max_length= max_length=
my_decimal_precision_to_length_no_truncation(value.m_decimal.precision(), my_decimal_precision_to_length_no_truncation(value.m_decimal.precision(),
decimals, unsigned_flag); decimals, unsigned_flag);
flags&= (item_flags_t) ~ITEM_FLAG_MAYBE_NULL; base_flags&= ~item_base_t::MAYBE_NULL;
null_value= 0; null_value= 0;
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
@@ -4106,7 +4109,7 @@ void Item_param::set_decimal(const my_decimal *dv, bool unsigned_arg)
unsigned_flag= unsigned_arg; unsigned_flag= unsigned_arg;
max_length= my_decimal_precision_to_length(value.m_decimal.intg + decimals, max_length= my_decimal_precision_to_length(value.m_decimal.intg + decimals,
decimals, unsigned_flag); decimals, unsigned_flag);
flags&= (item_flags_t) ~ITEM_FLAG_MAYBE_NULL; base_flags&= ~item_base_t::MAYBE_NULL;
null_value= 0; null_value= 0;
} }
@@ -4117,7 +4120,7 @@ void Item_param::fix_temporal(uint32 max_length_arg, uint decimals_arg)
collation= DTCollation_numeric(); collation= DTCollation_numeric();
max_length= max_length_arg; max_length= max_length_arg;
decimals= decimals_arg; decimals= decimals_arg;
flags&= (item_flags_t) ~ITEM_FLAG_MAYBE_NULL; base_flags&= ~item_base_t::MAYBE_NULL;
null_value= 0; null_value= 0;
} }
@@ -4127,7 +4130,7 @@ void Item_param::set_time(const MYSQL_TIME *tm,
{ {
DBUG_ASSERT(value.type_handler()->cmp_type() == TIME_RESULT); DBUG_ASSERT(value.type_handler()->cmp_type() == TIME_RESULT);
value.time= *tm; value.time= *tm;
flags&= (item_flags_t) ~ITEM_FLAG_MAYBE_NULL; base_flags&= ~item_base_t::MAYBE_NULL;
null_value= 0; null_value= 0;
fix_temporal(max_length_arg, decimals_arg); fix_temporal(max_length_arg, decimals_arg);
} }
@@ -4162,7 +4165,7 @@ void Item_param::set_time(MYSQL_TIME *tm, timestamp_type time_type,
&str, time_type, NULL, NULL, NULL); &str, time_type, NULL, NULL, NULL);
set_zero_time(&value.time, time_type); 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; null_value= 0;
fix_temporal(max_length_arg, fix_temporal(max_length_arg,
tm->second_part > 0 ? TIME_SECOND_PART_DIGITS : 0); tm->second_part > 0 ? TIME_SECOND_PART_DIGITS : 0);
@@ -4199,7 +4202,7 @@ bool Item_param::set_str(const char *str, ulong length,
state= SHORT_DATA_VALUE; state= SHORT_DATA_VALUE;
collation.set(tocs, DERIVATION_COERCIBLE); collation.set(tocs, DERIVATION_COERCIBLE);
max_length= length; max_length= length;
flags&= (item_flags_t) ~ITEM_FLAG_MAYBE_NULL; base_flags&= ~item_base_t::MAYBE_NULL;
null_value= 0; null_value= 0;
/* max_length and decimals are set after charset conversion */ /* max_length and decimals are set after charset conversion */
/* sic: str may be not null-terminated, don't add DBUG_PRINT here */ /* sic: str may be not null-terminated, don't add DBUG_PRINT here */
@@ -4234,7 +4237,7 @@ bool Item_param::set_longdata(const char *str, ulong length)
if (value.m_string.append(str, length, &my_charset_bin)) if (value.m_string.append(str, length, &my_charset_bin))
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
state= LONG_DATA_VALUE; state= LONG_DATA_VALUE;
flags&= (item_flags_t) ~ITEM_FLAG_MAYBE_NULL; base_flags&= ~item_base_t::MAYBE_NULL;
null_value= 0; null_value= 0;
DBUG_RETURN(FALSE); DBUG_RETURN(FALSE);
@@ -4335,7 +4338,7 @@ void Item_param::reset()
value.m_string.set_charset(&my_charset_bin); value.m_string.set_charset(&my_charset_bin);
collation.set(&my_charset_bin, DERIVATION_COERCIBLE); collation.set(&my_charset_bin, DERIVATION_COERCIBLE);
state= NO_VALUE; state= NO_VALUE;
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
null_value= 0; null_value= 0;
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
@@ -4794,7 +4797,7 @@ Item_param::set_param_type_and_swap_value(Item_param *src)
Type_std_attributes::set(src); Type_std_attributes::set(src);
set_handler(src->type_handler()); 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; null_value= src->null_value;
state= src->state; state= src->state;
@@ -5629,7 +5632,7 @@ Item_field::fix_outer_field(THD *thd, Field **from_field, Item **reference)
set_if_bigger(thd->lex->in_sum_func->max_arg_level, set_if_bigger(thd->lex->in_sum_func->max_arg_level,
select->nest_level); select->nest_level);
set_field(*from_field); set_field(*from_field);
flags|= ITEM_FLAG_FIXED; base_flags|= item_base_t::FIXED;
mark_as_dependent(thd, last_checked_context->select_lex, mark_as_dependent(thd, last_checked_context->select_lex,
context->select_lex, this, context->select_lex, this,
((ref_type == REF_ITEM || ((ref_type == REF_ITEM ||
@@ -6049,7 +6052,7 @@ bool Item_field::fix_fields(THD *thd, Item **reference)
} }
} }
#endif #endif
flags|= ITEM_FLAG_FIXED; base_flags|= item_base_t::FIXED;
if (field->vcol_info) if (field->vcol_info)
fix_session_vcol_expr_for_read(thd, field, field->vcol_info); fix_session_vcol_expr_for_read(thd, field, field->vcol_info);
if (thd->variables.sql_mode & MODE_ONLY_FULL_GROUP_BY && if (thd->variables.sql_mode & MODE_ONLY_FULL_GROUP_BY &&
@@ -8072,20 +8075,10 @@ void Item_ref::set_properties()
We have to remember if we refer to a sum function, to ensure that We have to remember if we refer to a sum function, to ensure that
split_sum_func() doesn't try to change the reference. split_sum_func() doesn't try to change the reference.
*/ */
/* Reset flags if called from update_ref() */ with_flags= (*ref)->with_flags;
flags&= ~ (ITEM_FLAG_WITH_SUM_FUNC | base_flags|= (item_base_t::FIXED |
ITEM_FLAG_WITH_PARAM | ((*ref)->base_flags & item_base_t::MAYBE_NULL));
ITEM_FLAG_WITH_WINDOW_FUNC |
ITEM_FLAG_WITH_SUBQUERY |
ITEM_FLAG_WITH_FIELD);
flags|= (ITEM_FLAG_FIXED |
((*ref)->flags & (ITEM_FLAG_MAYBE_NULL |
ITEM_FLAG_WITH_SUM_FUNC |
ITEM_FLAG_WITH_PARAM |
ITEM_FLAG_WITH_WINDOW_FUNC |
ITEM_FLAG_WITH_SUBQUERY |
ITEM_FLAG_WITH_FIELD)));
if (alias_name_used) if (alias_name_used)
return; return;
if ((*ref)->type() == FIELD_ITEM) if ((*ref)->type() == FIELD_ITEM)
@@ -8563,13 +8556,9 @@ Item_cache_wrapper::Item_cache_wrapper(THD *thd, Item *item_arg):
DBUG_ASSERT(orig_item->fixed()); DBUG_ASSERT(orig_item->fixed());
Type_std_attributes::set(orig_item); Type_std_attributes::set(orig_item);
flags|= ITEM_FLAG_FIXED | base_flags|= (item_base_t::FIXED |
(orig_item->flags & (orig_item->base_flags & item_base_t::MAYBE_NULL));
(ITEM_FLAG_MAYBE_NULL | with_flags|= orig_item->with_flags;
ITEM_FLAG_WITH_SUM_FUNC |
ITEM_FLAG_WITH_SUBQUERY |
ITEM_FLAG_WITH_PARAM |
ITEM_FLAG_WITH_FIELD));
name= item_arg->name; name= item_arg->name;
@@ -9029,7 +9018,7 @@ bool Item_direct_view_ref::fix_fields(THD *thd, Item **reference)
if (Item_direct_ref::fix_fields(thd, reference)) if (Item_direct_ref::fix_fields(thd, reference))
return TRUE; return TRUE;
if (view->table && view->table->maybe_null) if (view->table && view->table->maybe_null)
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
set_null_ref_table(); set_null_ref_table();
return FALSE; return FALSE;
} }
@@ -9789,7 +9778,7 @@ bool Item_trigger_field::fix_fields(THD *thd, Item **items)
field= (row_version == OLD_ROW) ? triggers->old_field[field_idx] : field= (row_version == OLD_ROW) ? triggers->old_field[field_idx] :
triggers->new_field[field_idx]; triggers->new_field[field_idx];
set_field(field); set_field(field);
flags|= ITEM_FLAG_FIXED; base_flags|= item_base_t::FIXED;
return FALSE; return FALSE;
} }

View File

@@ -726,28 +726,92 @@ public:
#define STOP_PTR ((void *) 1) #define STOP_PTR ((void *) 1)
/* Bits used in Item.flags */ /* Base flags (including IN) for an item */
/* If item may be null */
#define ITEM_FLAG_MAYBE_NULL_SHIFT 0 typedef uint8 item_flags_t;
#define ITEM_FLAG_MAYBE_NULL (1<<ITEM_FLAG_MAYBE_NULL_SHIFT)
/* If used in GROUP BY list of a query with ROLLUP */ enum class item_base_t : item_flags_t
#define ITEM_FLAG_IN_ROLLUP (1<<1) {
/* If Item contains an SP parameter */ NONE= 0,
#define ITEM_FLAG_WITH_PARAM (1<<2) #define ITEM_FLAGS_MAYBE_NULL_SHIFT 0 // Must match MAYBE_NULL
/* If item contains a window func */ MAYBE_NULL= (1<<0), // May be NULL.
#define ITEM_FLAG_WITH_WINDOW_FUNC (1<<3) IN_ROLLUP= (1<<1), // Appears in GROUP BY list
/* True if any item except Item_sum contains a field. Set during parsing. */ // of a query with ROLLUP.
#define ITEM_FLAG_WITH_FIELD (1<<4) FIXED= (1<<2), // Was fixed with fix_fields().
/* If item was fixed with fix_fields */ IS_AUTOGENERATED_NAME= (1<<3), // The name if this Item was
#define ITEM_FLAG_FIXED (1<<5) // generated or set by the user.
/* Indicates that name of this Item autogenerated or set by user */ IS_IN_WITH_CYCLE= (1<<4) // This item is in CYCLE clause
#define ITEM_FLAG_IS_AUTOGENERATED_NAME (1 << 6) // of WITH.
/* 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) /* Flags that tells us what kind of items the item contains */
/* True if item containts a sub query */
#define ITEM_FLAG_WITH_SUBQUERY (1<< 9) 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, class Item :public Value_source,
@@ -941,8 +1005,8 @@ public:
const char *orig_name; const char *orig_name;
/* All common bool variables for an Item is stored here */ /* All common bool variables for an Item is stored here */
typedef uint16 item_flags_t; item_base_t base_flags;
item_flags_t flags; item_with_t with_flags;
/* Marker is used in some functions to temporary mark an item */ /* Marker is used in some functions to temporary mark an item */
int16 marker; int16 marker;
@@ -967,19 +1031,40 @@ public:
*/ */
uint8 join_tab_idx; uint8 join_tab_idx;
inline bool maybe_null() const { return (flags & ITEM_FLAG_MAYBE_NULL); } inline bool maybe_null() const
inline bool in_rollup() const { return (flags & ITEM_FLAG_IN_ROLLUP); } { return (bool) (base_flags & item_base_t::MAYBE_NULL); }
inline bool with_param() const { return (flags & ITEM_FLAG_WITH_PARAM); } inline bool in_rollup() const
inline bool with_window_func() const { return (flags & ITEM_FLAG_WITH_WINDOW_FUNC); } { return (bool) (base_flags & item_base_t::IN_ROLLUP); }
inline bool with_field() const { return (flags & ITEM_FLAG_WITH_FIELD); } inline bool fixed() const
inline bool fixed() const { return (flags & ITEM_FLAG_FIXED); } { return (bool) (base_flags & item_base_t::FIXED); }
inline bool is_autogenerated_name() const { return (flags & ITEM_FLAG_IS_AUTOGENERATED_NAME); } inline bool is_autogenerated_name() const
inline bool is_in_with_cycle() const { return (flags & ITEM_FLAG_IS_IN_WITH_CYCLE); } { return (bool) (base_flags & item_base_t::IS_AUTOGENERATED_NAME); }
inline bool with_sum_func() const { return (flags & ITEM_FLAG_WITH_SUM_FUNC); } inline bool is_in_with_cycle() const
inline bool with_subquery() const { return (flags & ITEM_FLAG_WITH_SUBQUERY); } { return (bool) (base_flags & item_base_t::IS_IN_WITH_CYCLE); }
inline void copy_flags(const Item *org, item_flags_t mask)
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)
{ {
flags= (item_flags_t) ((flags & ~mask) | (org->flags & 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 // alloc & destruct is done as start of select on THD::mem_root
@@ -1017,7 +1102,7 @@ public:
void share_name_with(const Item *item) void share_name_with(const Item *item)
{ {
name= item->name; 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 cleanup();
virtual void make_send_field(THD *thd, Send_field *field); virtual void make_send_field(THD *thd, Send_field *field);
@@ -1178,19 +1263,26 @@ public:
{ {
return type_handler()->max_display_length(this); 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) inline void set_maybe_null(bool maybe_null_arg)
{ {
flags= ((item_flags_t) base_flags= ((item_base_t) ((base_flags & ~item_base_t::MAYBE_NULL)) |
((flags & (item_flags_t) ~ITEM_FLAG_MAYBE_NULL) | (item_base_t) (maybe_null_arg <<
((maybe_null_arg << ITEM_FLAG_MAYBE_NULL_SHIFT)))); 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() */ /* This is used when calling Type_all_attributes::set_type_maybe_null() */
void set_type_maybe_null(bool maybe_null_arg) override void set_type_maybe_null(bool maybe_null_arg) override
{ {
set_maybe_null(maybe_null_arg); 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. // Non-field Items (e.g. hybrid functions) never have ENUM/SET types yet.
DBUG_ASSERT(0); DBUG_ASSERT(0);
@@ -1220,7 +1312,8 @@ public:
{ return NON_MONOTONIC; } { 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 SYNOPSIS
val_int_endpoint() val_int_endpoint()
@@ -2742,26 +2835,28 @@ class Item_fixed_hybrid: public Item
public: public:
Item_fixed_hybrid(THD *thd): Item(thd) 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_fixed_hybrid(THD *thd, Item_fixed_hybrid *item)
:Item(thd, 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 bool fix_fields(THD *thd, Item **ref) override
{ {
DBUG_ASSERT(!fixed()); DBUG_ASSERT(!fixed());
flags|= ITEM_FLAG_FIXED; base_flags|= item_base_t::FIXED;
return false; return false;
} }
void cleanup() override void cleanup() override
{ {
Item::cleanup(); 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 quick_fix_field() override
void unfix_fields() override { flags&= (item_flags_t) ~ITEM_FLAG_FIXED; } { base_flags|= item_base_t::FIXED; }
void unfix_fields() override
{ base_flags&= ~item_base_t::FIXED; }
}; };
@@ -3685,7 +3780,7 @@ public:
Item_null(THD *thd, const char *name_par=0, CHARSET_INFO *cs= &my_charset_bin): Item_null(THD *thd, const char *name_par=0, CHARSET_INFO *cs= &my_charset_bin):
Item_basic_constant(thd) Item_basic_constant(thd)
{ {
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
null_value= TRUE; null_value= TRUE;
max_length= 0; max_length= 0;
name.str= name_par ? name_par : "NULL"; name.str= name_par ? name_par : "NULL";
@@ -5099,7 +5194,7 @@ public:
Item_date_literal_for_invalid_dates(THD *thd, const Date *ltime) Item_date_literal_for_invalid_dates(THD *thd, const Date *ltime)
:Item_date_literal(thd, 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) bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate)
{ {
@@ -5121,7 +5216,7 @@ public:
decimal_digits_t dec_arg) decimal_digits_t dec_arg)
:Item_datetime_literal(thd, ltime, 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) bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate)
{ {
@@ -6046,7 +6141,7 @@ public:
ref= &outer_ref; ref= &outer_ref;
set_properties(); set_properties();
/* reset flag set in 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, Item_outer_ref(THD *thd, Name_resolution_context *context_arg, Item **item,
const LEX_CSTRING &table_name_arg, LEX_CSTRING &field_name_arg, const LEX_CSTRING &table_name_arg, LEX_CSTRING &field_name_arg,
@@ -6194,7 +6289,7 @@ protected:
DBUG_ASSERT(org->fixed()); DBUG_ASSERT(org->fixed());
item= org; item= org;
null_value= item->maybe_null(); 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); Type_std_attributes::set(item);
name= item->name; name= item->name;
set_handler(item->type_handler()); set_handler(item->type_handler());
@@ -6821,7 +6916,7 @@ public:
value_cached(0), value_cached(0),
used_table_map(0) used_table_map(0)
{ {
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
null_value= 1; null_value= 1;
null_value_inside= true; null_value_inside= true;
} }
@@ -6833,7 +6928,7 @@ protected:
value_cached(0), value_cached(0),
used_table_map(0) used_table_map(0)
{ {
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
null_value= 1; null_value= 1;
null_value_inside= true; null_value_inside= true;
} }
@@ -7385,8 +7480,8 @@ public:
Type_std_attributes::set(*attr); Type_std_attributes::set(*attr);
set_maybe_null(maybe_null_arg); set_maybe_null(maybe_null_arg);
copy_flags(item, copy_flags(item,
ITEM_FLAG_IS_AUTOGENERATED_NAME | item_base_t::IS_AUTOGENERATED_NAME |
ITEM_FLAG_IS_IN_WITH_CYCLE); item_base_t::IS_IN_WITH_CYCLE);
} }
const Type_handler *type_handler() const override const Type_handler *type_handler() const override

View File

@@ -1142,7 +1142,7 @@ int Arg_comparator::compare_e_str_json()
bool Item_func_truth::fix_length_and_dec() 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; null_value= 0;
decimals= 0; decimals= 0;
max_length= 1; max_length= 1;
@@ -1336,10 +1336,8 @@ bool Item_in_optimizer::fix_left(THD *thd)
used_tables_cache= args[0]->used_tables(); used_tables_cache= args[0]->used_tables();
} }
eval_not_null_tables(NULL); eval_not_null_tables(NULL);
flags|= ((args[0]->flags & (ITEM_FLAG_WITH_SUM_FUNC | ITEM_FLAG_WITH_PARAM | with_flags|= (args[0]->with_flags |
ITEM_FLAG_WITH_FIELD)) | (args[1]->with_flags & item_with_t::SP_VAR));
(args[1]->flags & (ITEM_FLAG_WITH_PARAM)));
if ((const_item_cache= args[0]->const_item())) if ((const_item_cache= args[0]->const_item()))
{ {
cache->store(args[0]); 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 */ /* to avoid overriding is called to update left expression */
used_tables_and_const_cache_join(args[1]); 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); DBUG_RETURN(0);
} }
@@ -1371,7 +1369,7 @@ bool Item_in_optimizer::fix_fields(THD *thd, Item **ref)
if (fix_left(thd)) if (fix_left(thd))
return TRUE; return TRUE;
if (args[0]->maybe_null()) if (args[0]->maybe_null())
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
if (args[1]->fix_fields_if_needed(thd, args + 1)) if (args[1]->fix_fields_if_needed(thd, args + 1))
return TRUE; return TRUE;
@@ -1383,12 +1381,11 @@ bool Item_in_optimizer::fix_fields(THD *thd, Item **ref)
return TRUE; return TRUE;
} }
flags|= (ITEM_FLAG_FIXED | ITEM_FLAG_WITH_SUBQUERY | base_flags|= (item_base_t::FIXED |
(args[1]->flags & (ITEM_FLAG_MAYBE_NULL | (args[1]->base_flags & item_base_t::MAYBE_NULL));
ITEM_FLAG_WITH_SUM_FUNC | with_flags|= (item_with_t::SUBQUERY |
ITEM_FLAG_WITH_FIELD | args[1]->with_flags |
ITEM_FLAG_WITH_PARAM)) | (args[0]->with_flags & item_with_t::SP_VAR));
(args[0]->flags & ITEM_FLAG_WITH_PARAM));
used_tables_and_const_cache_join(args[1]); used_tables_and_const_cache_join(args[1]);
return FALSE; return FALSE;
} }
@@ -1777,7 +1774,7 @@ longlong Item_func_eq::val_int()
bool Item_func_equal::fix_length_and_dec() bool Item_func_equal::fix_length_and_dec()
{ {
bool rc= Item_bool_rowready_func2::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; null_value=0;
return rc; 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; max_length= 2;
used_tables_and_const_cache_join(row); used_tables_and_const_cache_join(row);
not_null_tables_cache= row->not_null_tables(); not_null_tables_cache= row->not_null_tables();
flags|= (row->flags & (ITEM_FLAG_WITH_SUM_FUNC | with_flags|= row->with_flags;
ITEM_FLAG_WITH_PARAM |
ITEM_FLAG_WITH_FIELD));
return FALSE; return FALSE;
} }
@@ -2722,7 +2717,7 @@ Item_func_nullif::fix_length_and_dec()
decimals= args[2]->decimals; decimals= args[2]->decimals;
unsigned_flag= args[2]->unsigned_flag; unsigned_flag= args[2]->unsigned_flag;
fix_char_length(args[2]->max_char_length()); fix_char_length(args[2]->max_char_length());
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
m_arg0= args[0]; m_arg0= args[0];
if (setup_args_and_comparator(thd, &cmp)) if (setup_args_and_comparator(thd, &cmp))
return TRUE; return TRUE;
@@ -3137,7 +3132,7 @@ bool Item_func_case::fix_fields(THD *thd, Item **ref)
Item **pos= else_expr_addr(); Item **pos= else_expr_addr();
if (!pos || pos[0]->maybe_null()) if (!pos || pos[0]->maybe_null())
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
return res; return res;
} }
@@ -4898,7 +4893,7 @@ Item_cond::fix_fields(THD *thd, Item **ref)
return TRUE; /* purecov: inspected */ return TRUE; /* purecov: inspected */
item= *li.ref(); // item can be substituted in fix_fields item= *li.ref(); // item can be substituted in fix_fields
used_tables_cache|= item->used_tables(); 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)) !item->is_expensive() && !cond_has_datetime_is_null(item))
{ {
if (item->eval_const_cond() == is_and_cond && top_level()) 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; const_item_cache= FALSE;
} }
base_flags|= item->base_flags & item_base_t::MAYBE_NULL;
flags|= (item->flags & (ITEM_FLAG_WITH_SUM_FUNC | with_flags|= item->with_flags;
ITEM_FLAG_WITH_PARAM |
ITEM_FLAG_WITH_FIELD |
ITEM_FLAG_WITH_SUBQUERY |
ITEM_FLAG_WITH_WINDOW_FUNC |
ITEM_FLAG_MAYBE_NULL));
} }
if (fix_length_and_dec()) if (fix_length_and_dec())
return TRUE; return TRUE;
flags|= ITEM_FLAG_FIXED; base_flags|= item_base_t::FIXED;
return FALSE; return FALSE;
} }
@@ -4960,7 +4950,7 @@ Item_cond::eval_not_null_tables(void *opt_arg)
while ((item=li++)) while ((item=li++))
{ {
table_map tmp_table_map; 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)) !item->is_expensive() && !cond_has_datetime_is_null(item))
{ {
if (item->eval_const_cond() == is_and_cond && top_level()) if (item->eval_const_cond() == is_and_cond && top_level())
@@ -6090,14 +6080,14 @@ void Regexp_processor_pcre::fix_owner(Item_func *owner,
{ {
if (compile(pattern_arg, true)) if (compile(pattern_arg, true))
{ {
owner->flags|= ITEM_FLAG_MAYBE_NULL; // Will always return NULL owner->set_maybe_null(); // Will always return NULL
return; return;
} }
set_const(true); 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 else
owner->flags|= ITEM_FLAG_MAYBE_NULL; owner->set_maybe_null();
} }
@@ -7056,7 +7046,7 @@ bool Item_equal::fix_fields(THD *thd, Item **ref)
not_null_tables_cache|= tmp_table_map; not_null_tables_cache|= tmp_table_map;
DBUG_ASSERT(!item->with_sum_func() && !item->with_subquery()); DBUG_ASSERT(!item->with_sum_func() && !item->with_subquery());
if (item->maybe_null()) if (item->maybe_null())
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
if (!item->get_item_equal()) if (!item->get_item_equal())
item->set_item_equal(this); item->set_item_equal(this);
if (link_equal_fields && item->real_item()->type() == FIELD_ITEM) if (link_equal_fields && item->real_item()->type() == FIELD_ITEM)
@@ -7073,7 +7063,7 @@ bool Item_equal::fix_fields(THD *thd, Item **ref)
last_equal_field->next_equal_field= first_equal_field; last_equal_field->next_equal_field= first_equal_field;
if (fix_length_and_dec()) if (fix_length_and_dec())
return TRUE; return TRUE;
flags|= ITEM_FLAG_FIXED; base_flags|= item_base_t::FIXED;
return FALSE; return FALSE;
} }

View File

@@ -368,7 +368,7 @@ public:
Item_bool_func(thd, a, b), cache(0), expr_cache(0), Item_bool_func(thd, a, b), cache(0), expr_cache(0),
save_cache(0), result_for_null_param(UNKNOWN) save_cache(0), result_for_null_param(UNKNOWN)
{ {
flags|= ITEM_FLAG_WITH_SUBQUERY; with_flags|= item_with_t::SUBQUERY;
} }
bool fix_fields(THD *, Item **) override; bool fix_fields(THD *, Item **) override;
bool fix_left(THD *thd); bool fix_left(THD *thd);
@@ -1126,7 +1126,7 @@ public:
IFNULL(inet6_not_null_expr, 'foo') -> INET6 NULL IFNULL(inet6_not_null_expr, 'foo') -> INET6 NULL
IFNULL(inet6_not_null_expr, '::1') -> INET6 NOT NULL IFNULL(inet6_not_null_expr, '::1') -> INET6 NOT NULL
*/ */
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)) if (Item_func_case_abbreviation2::fix_length_and_dec2(args))
return TRUE; return TRUE;
return FALSE; return FALSE;
@@ -2567,7 +2567,7 @@ public:
{ {
decimals=0; decimals=0;
max_length=1; max_length=1;
flags&= (item_flags_t) ~ITEM_FLAG_MAYBE_NULL; base_flags&= ~item_base_t::MAYBE_NULL;
return FALSE; return FALSE;
} }
bool count_sargable_conds(void *arg); bool count_sargable_conds(void *arg);
@@ -3464,7 +3464,7 @@ public:
Item_func_cursor_found(THD *thd, const LEX_CSTRING *name, uint offset) Item_func_cursor_found(THD *thd, const LEX_CSTRING *name, uint offset)
:Item_func_cursor_bool_attr(thd, name, offset) :Item_func_cursor_bool_attr(thd, name, offset)
{ {
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
} }
const char *func_name() const { return "%FOUND"; } const char *func_name() const { return "%FOUND"; }
longlong val_int(); longlong val_int();
@@ -3479,7 +3479,7 @@ public:
Item_func_cursor_notfound(THD *thd, const LEX_CSTRING *name, uint offset) Item_func_cursor_notfound(THD *thd, const LEX_CSTRING *name, uint offset)
:Item_func_cursor_bool_attr(thd, name, offset) :Item_func_cursor_bool_attr(thd, name, offset)
{ {
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
} }
const char *func_name() const { return "%NOTFOUND"; } const char *func_name() const { return "%NOTFOUND"; }
longlong val_int(); longlong val_int();

View File

@@ -133,12 +133,7 @@ void Item_func::sync_with_sum_func_and_with_field(List<Item> &list)
List_iterator_fast<Item> li(list); List_iterator_fast<Item> li(list);
Item *item; Item *item;
while ((item= li++)) while ((item= li++))
{ with_flags|= item->with_flags;
flags|= (item->flags & (ITEM_FLAG_WITH_SUM_FUNC |
ITEM_FLAG_WITH_WINDOW_FUNC |
ITEM_FLAG_WITH_FIELD |
ITEM_FLAG_WITH_PARAM));
}
} }
@@ -353,8 +348,8 @@ Item_func::fix_fields(THD *thd, Item **ref)
return TRUE; /* purecov: inspected */ return TRUE; /* purecov: inspected */
item= *arg; item= *arg;
flags|= item->flags & ~(ITEM_FLAG_IS_AUTOGENERATED_NAME | base_flags|= item->base_flags & item_base_t::MAYBE_NULL;
ITEM_FLAG_IS_IN_WITH_CYCLE); with_flags|= item->with_flags;
used_tables_and_const_cache_join(item); used_tables_and_const_cache_join(item);
not_null_tables_cache|= item->not_null_tables(); not_null_tables_cache|= item->not_null_tables();
} }
@@ -363,7 +358,7 @@ Item_func::fix_fields(THD *thd, Item **ref)
return true; return true;
if (fix_length_and_dec()) if (fix_length_and_dec())
return TRUE; return TRUE;
flags|= ITEM_FLAG_FIXED; base_flags|= item_base_t::FIXED;
return FALSE; return FALSE;
} }
@@ -379,7 +374,7 @@ Item_func::quick_fix_field()
(*arg)->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) List<Item> &fields, uint flags)
{ {
Item **arg, **arg_end; Item **arg, **arg_end;
DBUG_ENTER("Item_func::split_sum_func");
for (arg= args, arg_end= args+arg_count; arg != arg_end ; arg++) for (arg= args, arg_end= args+arg_count; arg != arg_end ; arg++)
(*arg)->split_sum_func2(thd, ref_pointer_array, fields, arg, (*arg)->split_sum_func2(thd, ref_pointer_array, fields, arg,
flags | SPLIT_SUM_SKIP_REGISTERED); flags | SPLIT_SUM_SKIP_REGISTERED);
DBUG_VOID_RETURN;
} }
@@ -1586,7 +1584,7 @@ bool Item_func_div::fix_length_and_dec()
DBUG_ENTER("Item_func_div::fix_length_and_dec"); DBUG_ENTER("Item_func_div::fix_length_and_dec");
DBUG_PRINT("info", ("name %s", func_name())); DBUG_PRINT("info", ("name %s", func_name()));
prec_increment= current_thd->variables.div_precincrement; 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; 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;); DBUG_EXECUTE_IF("num_op", aggregator= &type_handler_data->m_type_aggregator_non_commutative_test;);
@@ -1664,7 +1662,7 @@ bool Item_func_int_div::fix_length_and_dec()
uint32 prec= args[0]->decimal_int_part(); uint32 prec= args[0]->decimal_int_part();
set_if_smaller(prec, MY_INT64_NUM_DECIMAL_DIGITS); set_if_smaller(prec, MY_INT64_NUM_DECIMAL_DIGITS);
fix_char_length(prec); fix_char_length(prec);
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
unsigned_flag=args[0]->unsigned_flag | args[1]->unsigned_flag; unsigned_flag=args[0]->unsigned_flag | args[1]->unsigned_flag;
return false; return false;
} }
@@ -1744,7 +1742,7 @@ bool Item_func_mod::fix_length_and_dec()
{ {
DBUG_ENTER("Item_func_mod::fix_length_and_dec"); DBUG_ENTER("Item_func_mod::fix_length_and_dec");
DBUG_PRINT("info", ("name %s", func_name())); 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; 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_EXECUTE_IF("num_op", aggregator= &type_handler_data->m_type_aggregator_non_commutative_test;);
DBUG_ASSERT(!aggregator->is_commutative()); DBUG_ASSERT(!aggregator->is_commutative());
@@ -2553,7 +2551,7 @@ void Item_func_round::fix_arg_datetime()
return NULL. return NULL.
*/ */
if (!truncate) if (!truncate)
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
fix_arg_temporal(&type_handler_datetime2, MAX_DATETIME_WIDTH); fix_arg_temporal(&type_handler_datetime2, MAX_DATETIME_WIDTH);
} }
@@ -3235,7 +3233,7 @@ longlong Item_func_field::val_int()
bool Item_func_field::fix_length_and_dec() 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; max_length=3;
cmp_type= args[0]->result_type(); cmp_type= args[0]->result_type();
for (uint i=1; i < arg_count ; i++) for (uint i=1; i < arg_count ; i++)
@@ -3479,7 +3477,7 @@ udf_handler::fix_fields(THD *thd, Item_func_or_sum *func,
args=arguments; args=arguments;
/* Fix all 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(); func->used_tables_and_const_cache_init();
if ((f_args.arg_count=arg_count)) if ((f_args.arg_count=arg_count))
@@ -3514,12 +3512,8 @@ udf_handler::fix_fields(THD *thd, Item_func_or_sum *func,
*/ */
if (item->collation.collation->state & MY_CS_BINSORT) if (item->collation.collation->state & MY_CS_BINSORT)
func->collation.set(&my_charset_bin); func->collation.set(&my_charset_bin);
func->flags|= (item->flags & (ITEM_FLAG_MAYBE_NULL | func->base_flags|= item->base_flags & item_base_t::MAYBE_NULL;
ITEM_FLAG_WITH_SUM_FUNC | func->with_flags|= item->with_flags;
ITEM_FLAG_WITH_WINDOW_FUNC |
ITEM_FLAG_WITH_FIELD |
ITEM_FLAG_WITH_PARAM |
ITEM_FLAG_WITH_SUBQUERY));
func->used_tables_and_const_cache_join(item); func->used_tables_and_const_cache_join(item);
f_args.arg_type[i]=item->result_type(); f_args.arg_type[i]=item->result_type();
} }
@@ -4789,7 +4783,7 @@ bool Item_func_set_user_var::fix_fields(THD *thd, Item **ref)
bool bool
Item_func_set_user_var::fix_length_and_dec() 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; decimals=args[0]->decimals;
if (args[0]->collation.derivation == DERIVATION_NUMERIC) if (args[0]->collation.derivation == DERIVATION_NUMERIC)
{ {
@@ -5646,7 +5640,7 @@ bool Item_func_get_user_var::fix_length_and_dec()
{ {
THD *thd=current_thd; THD *thd=current_thd;
int error; int error;
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
decimals=NOT_FIXED_DEC; decimals=NOT_FIXED_DEC;
max_length=MAX_BLOB_WIDTH; max_length=MAX_BLOB_WIDTH;
@@ -5856,7 +5850,7 @@ void Item_func_get_system_var::update_null_value()
bool Item_func_get_system_var::fix_length_and_dec() bool Item_func_get_system_var::fix_length_and_dec()
{ {
char *cptr; char *cptr;
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
max_length= 0; max_length= 0;
if (var->check_type(var_type)) if (var->check_type(var_type))
@@ -6219,7 +6213,7 @@ bool Item_func_match::fix_fields(THD *thd, Item **ref)
status_var_increment(thd->status_var.feature_fulltext); status_var_increment(thd->status_var.feature_fulltext);
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
join_key=0; join_key=0;
/* /*
@@ -6555,7 +6549,7 @@ Item_func_sp::Item_func_sp(THD *thd, Name_resolution_context *context_arg,
sp_name *name, const Sp_handler *sph): sp_name *name, const Sp_handler *sph):
Item_func(thd), Item_sp(thd, context_arg, name), m_handler(sph) Item_func(thd), Item_sp(thd, context_arg, name), m_handler(sph)
{ {
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
} }
@@ -6564,7 +6558,7 @@ Item_func_sp::Item_func_sp(THD *thd, Name_resolution_context *context_arg,
List<Item> &list): List<Item> &list):
Item_func(thd, list), Item_sp(thd, context_arg, name_arg), m_handler(sph) Item_func(thd, list), Item_sp(thd, context_arg, name_arg), m_handler(sph)
{ {
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
} }
@@ -6620,7 +6614,7 @@ bool Item_func_sp::fix_length_and_dec()
Type_std_attributes::set(sp_result_field->type_std_attributes()); Type_std_attributes::set(sp_result_field->type_std_attributes());
// There is a bug in the line below. See MDEV-11292 for details. // There is a bug in the line below. See MDEV-11292 for details.
collation.derivation= DERIVATION_COERCIBLE; collation.derivation= DERIVATION_COERCIBLE;
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
DBUG_RETURN(FALSE); DBUG_RETURN(FALSE);
} }

View File

@@ -97,45 +97,33 @@ public:
virtual enum Functype functype() const { return UNKNOWN_FUNC; } virtual enum Functype functype() const { return UNKNOWN_FUNC; }
Item_func(THD *thd): Item_func_or_sum(thd) 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) Item_func(THD *thd, Item *a): Item_func_or_sum(thd, a)
{ {
copy_flags(a, with_flags= a->with_flags;
ITEM_FLAG_WITH_SUM_FUNC | ITEM_FLAG_WITH_FIELD |
ITEM_FLAG_WITH_PARAM);
} }
Item_func(THD *thd, Item *a, Item *b): Item_func(THD *thd, Item *a, Item *b):
Item_func_or_sum(thd, a, b) Item_func_or_sum(thd, a, b)
{ {
flags|= ((a->flags | b->flags) & with_flags= a->with_flags | b->with_flags;
(ITEM_FLAG_WITH_SUM_FUNC |
ITEM_FLAG_WITH_PARAM |
ITEM_FLAG_WITH_FIELD));
} }
Item_func(THD *thd, Item *a, Item *b, Item *c): Item_func(THD *thd, Item *a, Item *b, Item *c):
Item_func_or_sum(thd, a, b, c) Item_func_or_sum(thd, a, b, c)
{ {
flags|= ((a->flags | b->flags | c->flags) & with_flags|= a->with_flags | b->with_flags | c->with_flags;
(ITEM_FLAG_WITH_SUM_FUNC |
ITEM_FLAG_WITH_PARAM |
ITEM_FLAG_WITH_FIELD));
} }
Item_func(THD *thd, Item *a, Item *b, Item *c, Item *d): Item_func(THD *thd, Item *a, Item *b, Item *c, Item *d):
Item_func_or_sum(thd, a, b, c, d) Item_func_or_sum(thd, a, b, c, d)
{ {
flags|= ((a->flags | b->flags | c->flags | d->flags) & with_flags= a->with_flags | b->with_flags | c->with_flags | d->with_flags;
(ITEM_FLAG_WITH_SUM_FUNC |
ITEM_FLAG_WITH_PARAM |
ITEM_FLAG_WITH_FIELD));
} }
Item_func(THD *thd, Item *a, Item *b, Item *c, Item *d, Item* e): Item_func(THD *thd, Item *a, Item *b, Item *c, Item *d, Item* e):
Item_func_or_sum(thd, a, b, c, d, e) Item_func_or_sum(thd, a, b, c, d, e)
{ {
flags|= ((a->flags | b->flags | c->flags | d->flags | e->flags) & with_flags= (a->with_flags | b->with_flags | c->with_flags | d->with_flags |
(ITEM_FLAG_WITH_SUM_FUNC | e->with_flags);
ITEM_FLAG_WITH_PARAM |
ITEM_FLAG_WITH_FIELD));
} }
Item_func(THD *thd, List<Item> &list): Item_func(THD *thd, List<Item> &list):
Item_func_or_sum(thd, list) Item_func_or_sum(thd, list)
@@ -153,10 +141,11 @@ public:
Item_func_or_sum::cleanup(); Item_func_or_sum::cleanup();
used_tables_and_const_cache_init(); used_tables_and_const_cache_init();
} }
void fix_after_pullout(st_select_lex *new_parent, Item **ref, bool merge); void fix_after_pullout(st_select_lex *new_parent, Item **ref, bool merge)
void quick_fix_field(); override;
table_map not_null_tables() const; void quick_fix_field() override;
void update_used_tables() table_map not_null_tables() const override;
void update_used_tables() override
{ {
used_tables_and_const_cache_init(); used_tables_and_const_cache_init();
used_tables_and_const_cache_update_and_join(arg_count, args); used_tables_and_const_cache_update_and_join(arg_count, args);
@@ -201,7 +190,7 @@ public:
if (max_result_length >= MAX_BLOB_WIDTH) if (max_result_length >= MAX_BLOB_WIDTH)
{ {
max_length= MAX_BLOB_WIDTH; max_length= MAX_BLOB_WIDTH;
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
} }
else else
max_length= (uint32) max_result_length; max_length= (uint32) max_result_length;
@@ -1253,7 +1242,7 @@ public:
Item_func_cursor_rowcount(THD *thd, const LEX_CSTRING *name, uint offset) Item_func_cursor_rowcount(THD *thd, const LEX_CSTRING *name, uint offset)
:Item_longlong_func(thd), Cursor_ref(name, offset) :Item_longlong_func(thd), Cursor_ref(name, offset)
{ {
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
} }
const char *func_name() const { return "%ROWCOUNT"; } const char *func_name() const { return "%ROWCOUNT"; }
longlong val_int(); longlong val_int();
@@ -1433,7 +1422,7 @@ public:
void print(String *str, enum_query_type query_type); void print(String *str, enum_query_type query_type);
void fix_length_and_dec_generic() void fix_length_and_dec_generic()
{ {
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
} }
}; };
@@ -1699,7 +1688,7 @@ class Item_dec_func :public Item_real_func
{ {
decimals= NOT_FIXED_DEC; decimals= NOT_FIXED_DEC;
max_length= float_length(decimals); max_length= float_length(decimals);
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
return FALSE; return FALSE;
} }
}; };
@@ -1873,7 +1862,7 @@ public:
fix_attributes_datetime(0); fix_attributes_datetime(0);
set_handler(&type_handler_datetime2); set_handler(&type_handler_datetime2);
// Thinks like CEILING(TIMESTAMP'0000-01-01 23:59:59.9') returns NULL // 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(); bool fix_length_and_dec();
String *str_op(String *str) { DBUG_ASSERT(0); return 0; } String *str_op(String *str) { DBUG_ASSERT(0); return 0; }
@@ -2234,7 +2223,7 @@ public:
bool fix_length_and_dec() bool fix_length_and_dec()
{ {
max_length=10; max_length=10;
flags&= (item_flags_t) ~ITEM_FLAG_MAYBE_NULL; base_flags&= ~item_base_t::MAYBE_NULL;
return FALSE; return FALSE;
} }
bool eval_not_null_tables(void *) bool eval_not_null_tables(void *)
@@ -2497,7 +2486,7 @@ public:
bool fix_length_and_dec() bool fix_length_and_dec()
{ {
max_length=1; max_length=1;
flags&= (item_flags_t) ~ITEM_FLAG_MAYBE_NULL; base_flags&= ~item_base_t::MAYBE_NULL;
return FALSE; return FALSE;
} }
virtual void print(String *str, enum_query_type query_type); virtual void print(String *str, enum_query_type query_type);
@@ -2579,7 +2568,7 @@ public:
DBUG_ASSERT(fixed() == 0); DBUG_ASSERT(fixed() == 0);
bool res= udf.fix_fields(thd, this, arg_count, args); bool res= udf.fix_fields(thd, this, arg_count, args);
set_non_deterministic_if_needed(); set_non_deterministic_if_needed();
flags|= ITEM_FLAG_FIXED; base_flags|= item_base_t::FIXED;
return res; return res;
} }
void fix_num_length_and_dec(); void fix_num_length_and_dec();
@@ -2828,7 +2817,8 @@ public:
{ DBUG_ASSERT(fixed()); null_value=1; return 0; } { DBUG_ASSERT(fixed()); null_value=1; return 0; }
double val_real() { DBUG_ASSERT(fixed()); null_value= 1; return 0.0; } double val_real() { DBUG_ASSERT(fixed()); null_value= 1; return 0.0; }
longlong val_int() { DBUG_ASSERT(fixed()); null_value=1; return 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 */ #endif /* HAVE_DLOPEN */
@@ -2871,7 +2861,7 @@ class Item_func_get_lock final :public Item_func_lock
bool fix_length_and_dec() bool fix_length_and_dec()
{ {
max_length= 1; max_length= 1;
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
return FALSE; return FALSE;
} }
Item *get_copy(THD *thd) final Item *get_copy(THD *thd) final
@@ -2903,7 +2893,7 @@ public:
bool fix_length_and_dec() bool fix_length_and_dec()
{ {
max_length= 1; max_length= 1;
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
return FALSE; return FALSE;
} }
Item *get_copy(THD *thd) final Item *get_copy(THD *thd) final
@@ -2936,7 +2926,7 @@ public:
bool fix_length_and_dec() bool fix_length_and_dec()
{ {
max_length=21; max_length=21;
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
return FALSE; return FALSE;
} }
bool check_vcol_func_processor(void *arg) bool check_vcol_func_processor(void *arg)
@@ -3378,7 +3368,7 @@ public:
{ {
decimals=0; decimals=0;
max_length=1; max_length=1;
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
return FALSE; return FALSE;
} }
bool check_vcol_func_processor(void *arg) bool check_vcol_func_processor(void *arg)
@@ -3401,7 +3391,7 @@ public:
bool fix_length_and_dec() bool fix_length_and_dec()
{ {
decimals=0; max_length=10; decimals=0; max_length=10;
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
return FALSE; return FALSE;
} }
bool check_vcol_func_processor(void *arg) bool check_vcol_func_processor(void *arg)
@@ -3458,7 +3448,7 @@ public:
bool fix_length_and_dec() bool fix_length_and_dec()
{ {
decimals= 0; decimals= 0;
flags&= (item_flags_t) ~ITEM_FLAG_MAYBE_NULL; base_flags&= ~item_base_t::MAYBE_NULL;
return FALSE; return FALSE;
} }
bool check_vcol_func_processor(void *arg) bool check_vcol_func_processor(void *arg)
@@ -3628,7 +3618,7 @@ public:
bool fix_length_and_dec() bool fix_length_and_dec()
{ {
decimals= 0; decimals= 0;
flags&= (item_flags_t) ~ITEM_FLAG_MAYBE_NULL; base_flags&= ~item_base_t::MAYBE_NULL;
return FALSE; return FALSE;
} }
bool check_vcol_func_processor(void *arg) bool check_vcol_func_processor(void *arg)
@@ -3675,7 +3665,7 @@ public:
} }
bool fix_length_and_dec() bool fix_length_and_dec()
{ {
flags&= (item_flags_t) ~ITEM_FLAG_MAYBE_NULL; base_flags&= ~item_base_t::MAYBE_NULL;
null_value= false; null_value= false;
max_length= 11; max_length= 11;
return FALSE; return FALSE;
@@ -3735,7 +3725,7 @@ public:
void update_used_tables() void update_used_tables()
{ {
Item_func::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) Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_last_value>(thd, this); } { return get_item_copy<Item_func_last_value>(thd, this); }
@@ -3758,7 +3748,7 @@ public:
{ {
unsigned_flag= 0; unsigned_flag= 0;
max_length= MAX_BIGINT_WIDTH; max_length= MAX_BIGINT_WIDTH;
flags|= ITEM_FLAG_MAYBE_NULL; /* In case of errors */ set_maybe_null(); /* In case of errors */
return FALSE; return FALSE;
} }
/* /*

View File

@@ -47,7 +47,7 @@ bool Item_geometry_func::fix_length_and_dec()
collation.set(&my_charset_bin); collation.set(&my_charset_bin);
decimals=0; decimals=0;
max_length= (uint32) UINT_MAX32; max_length= (uint32) UINT_MAX32;
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
return FALSE; return FALSE;
} }
@@ -218,7 +218,7 @@ bool Item_func_as_wkt::fix_length_and_dec()
{ {
collation.set(default_charset(), DERIVATION_COERCIBLE, MY_REPERTOIRE_ASCII); collation.set(default_charset(), DERIVATION_COERCIBLE, MY_REPERTOIRE_ASCII);
max_length= (uint32) UINT_MAX32; max_length= (uint32) UINT_MAX32;
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
return FALSE; return FALSE;
} }
@@ -245,7 +245,7 @@ bool Item_func_as_geojson::fix_length_and_dec()
{ {
collation.set(default_charset(), DERIVATION_COERCIBLE, MY_REPERTOIRE_ASCII); collation.set(default_charset(), DERIVATION_COERCIBLE, MY_REPERTOIRE_ASCII);
max_length=MAX_BLOB_WIDTH; max_length=MAX_BLOB_WIDTH;
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
return FALSE; return FALSE;
} }

View File

@@ -284,7 +284,7 @@ public:
collation.set(&my_charset_bin); collation.set(&my_charset_bin);
decimals=0; decimals=0;
max_length= (uint32) UINT_MAX32; max_length= (uint32) UINT_MAX32;
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
return FALSE; return FALSE;
} }
Item *get_copy(THD *thd) Item *get_copy(THD *thd)
@@ -326,7 +326,7 @@ public:
{ {
// "GeometryCollection" is the longest // "GeometryCollection" is the longest
fix_length_and_charset(20, default_charset()); fix_length_and_charset(20, default_charset());
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
return FALSE; return FALSE;
}; };
Item *get_copy(THD *thd) 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_func_spatial_rel(THD *thd, Item *a, Item *b, enum Functype sp_rel):
Item_bool_func2_with_rev(thd, a, b), spatial_rel(sp_rel) Item_bool_func2_with_rev(thd, a, b), spatial_rel(sp_rel)
{ {
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
} }
enum Functype functype() const { return spatial_rel; } enum Functype functype() const { return spatial_rel; }
enum Functype rev_functype() const enum Functype rev_functype() const
@@ -854,11 +854,12 @@ class Item_func_isempty: public Item_bool_func_args_geometry
public: public:
Item_func_isempty(THD *thd, Item *a) Item_func_isempty(THD *thd, Item *a)
:Item_bool_func_args_geometry(thd, a) {} :Item_bool_func_args_geometry(thd, a) {}
longlong val_int(); longlong val_int() override;
const char *func_name() const { return "st_isempty"; } const char *func_name() const { return "st_isempty"; }
bool fix_length_and_dec() { flags|= ITEM_FLAG_MAYBE_NULL; return FALSE; } bool fix_length_and_dec() override
bool need_parentheses_in_default() { return false; } { set_maybe_null(); return FALSE; }
Item *get_copy(THD *thd) bool need_parentheses_in_default() override { return false; }
Item *get_copy(THD *thd) override
{ return get_item_copy<Item_func_isempty>(thd, this); } { return get_item_copy<Item_func_isempty>(thd, this); }
}; };
@@ -907,10 +908,11 @@ class Item_func_dimension: public Item_long_func_args_geometry
public: public:
Item_func_dimension(THD *thd, Item *a) Item_func_dimension(THD *thd, Item *a)
:Item_long_func_args_geometry(thd, a) {} :Item_long_func_args_geometry(thd, a) {}
longlong val_int(); longlong val_int() override;
const char *func_name() const { return "st_dimension"; } const char *func_name() const { return "st_dimension"; }
bool fix_length_and_dec() { max_length= 10; flags|= ITEM_FLAG_MAYBE_NULL; return FALSE; } bool fix_length_and_dec() override
Item *get_copy(THD *thd) { max_length= 10; set_maybe_null(); return FALSE; }
Item *get_copy(THD *thd) override
{ return get_item_copy<Item_func_dimension>(thd, this); } { return get_item_copy<Item_func_dimension>(thd, this); }
}; };
@@ -925,7 +927,7 @@ public:
{ {
if (Item_real_func::fix_length_and_dec()) if (Item_real_func::fix_length_and_dec())
return TRUE; return TRUE;
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
return FALSE; return FALSE;
} }
Item *get_copy(THD *thd) Item *get_copy(THD *thd)
@@ -943,7 +945,7 @@ public:
{ {
if (Item_real_func::fix_length_and_dec()) if (Item_real_func::fix_length_and_dec())
return TRUE; return TRUE;
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
return FALSE; return FALSE;
} }
Item *get_copy(THD *thd) Item *get_copy(THD *thd)
@@ -956,10 +958,11 @@ class Item_func_numgeometries: public Item_long_func_args_geometry
public: public:
Item_func_numgeometries(THD *thd, Item *a) Item_func_numgeometries(THD *thd, Item *a)
:Item_long_func_args_geometry(thd, a) {} :Item_long_func_args_geometry(thd, a) {}
longlong val_int(); longlong val_int() override;
const char *func_name() const { return "st_numgeometries"; } const char *func_name() const { return "st_numgeometries"; }
bool fix_length_and_dec() { max_length= 10; flags|= ITEM_FLAG_MAYBE_NULL; return FALSE; } bool fix_length_and_dec() override
Item *get_copy(THD *thd) { max_length= 10; set_maybe_null(); return FALSE; }
Item *get_copy(THD *thd) override
{ return get_item_copy<Item_func_numgeometries>(thd, this); } { return get_item_copy<Item_func_numgeometries>(thd, this); }
}; };
@@ -969,10 +972,11 @@ class Item_func_numinteriorring: public Item_long_func_args_geometry
public: public:
Item_func_numinteriorring(THD *thd, Item *a) Item_func_numinteriorring(THD *thd, Item *a)
:Item_long_func_args_geometry(thd, a) {} :Item_long_func_args_geometry(thd, a) {}
longlong val_int(); longlong val_int() override;
const char *func_name() const { return "st_numinteriorrings"; } const char *func_name() const { return "st_numinteriorrings"; }
bool fix_length_and_dec() { max_length= 10; flags|= ITEM_FLAG_MAYBE_NULL; return FALSE; } bool fix_length_and_dec() override
Item *get_copy(THD *thd) { max_length= 10; set_maybe_null(); return FALSE; }
Item *get_copy(THD *thd) override
{ return get_item_copy<Item_func_numinteriorring>(thd, this); } { return get_item_copy<Item_func_numinteriorring>(thd, this); }
}; };
@@ -982,10 +986,11 @@ class Item_func_numpoints: public Item_long_func_args_geometry
public: public:
Item_func_numpoints(THD *thd, Item *a) Item_func_numpoints(THD *thd, Item *a)
:Item_long_func_args_geometry(thd, a) {} :Item_long_func_args_geometry(thd, a) {}
longlong val_int(); longlong val_int() override;
const char *func_name() const { return "st_numpoints"; } const char *func_name() const { return "st_numpoints"; }
bool fix_length_and_dec() { max_length= 10; flags|= ITEM_FLAG_MAYBE_NULL; return FALSE; } bool fix_length_and_dec() override
Item *get_copy(THD *thd) { max_length= 10; set_maybe_null(); return FALSE; }
Item *get_copy(THD *thd) override
{ return get_item_copy<Item_func_numpoints>(thd, this); } { return get_item_copy<Item_func_numpoints>(thd, this); }
}; };
@@ -1000,7 +1005,7 @@ public:
{ {
if (Item_real_func::fix_length_and_dec()) if (Item_real_func::fix_length_and_dec())
return TRUE; return TRUE;
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
return FALSE; return FALSE;
} }
Item *get_copy(THD *thd) Item *get_copy(THD *thd)
@@ -1020,7 +1025,7 @@ public:
{ {
if (Item_real_func::fix_length_and_dec()) if (Item_real_func::fix_length_and_dec())
return TRUE; return TRUE;
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
return FALSE; return FALSE;
} }
Item *get_copy(THD *thd) Item *get_copy(THD *thd)
@@ -1033,10 +1038,11 @@ class Item_func_srid: public Item_long_func_args_geometry
public: public:
Item_func_srid(THD *thd, Item *a) Item_func_srid(THD *thd, Item *a)
:Item_long_func_args_geometry(thd, a) {} :Item_long_func_args_geometry(thd, a) {}
longlong val_int(); longlong val_int() override;
const char *func_name() const { return "srid"; } const char *func_name() const { return "srid"; }
bool fix_length_and_dec() { max_length= 10; flags|= ITEM_FLAG_MAYBE_NULL; return FALSE; } bool fix_length_and_dec() override
Item *get_copy(THD *thd) { max_length= 10; set_maybe_null(); return FALSE; }
Item *get_copy(THD *thd) override
{ return get_item_copy<Item_func_srid>(thd, this); } { return get_item_copy<Item_func_srid>(thd, this); }
}; };

View File

@@ -397,7 +397,7 @@ bool Item_func_json_exists::fix_length_and_dec()
{ {
if (Item_bool_func::fix_length_and_dec()) if (Item_bool_func::fix_length_and_dec())
return TRUE; return TRUE;
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
path.set_constant_flag(args[1]->const_item()); path.set_constant_flag(args[1]->const_item());
return FALSE; return FALSE;
} }
@@ -451,7 +451,7 @@ bool Item_func_json_value::fix_length_and_dec()
collation.set(args[0]->collation); collation.set(args[0]->collation);
max_length= args[0]->max_length; max_length= args[0]->max_length;
set_constant_flag(args[1]->const_item()); set_constant_flag(args[1]->const_item());
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
return FALSE; return FALSE;
} }
@@ -461,7 +461,7 @@ bool Item_func_json_query::fix_length_and_dec()
collation.set(args[0]->collation); collation.set(args[0]->collation);
max_length= args[0]->max_length; max_length= args[0]->max_length;
set_constant_flag(args[1]->const_item()); set_constant_flag(args[1]->const_item());
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
return FALSE; return FALSE;
} }
@@ -609,7 +609,7 @@ bool Item_func_json_unquote::fix_length_and_dec()
collation.set(&my_charset_utf8mb3_general_ci, collation.set(&my_charset_utf8mb3_general_ci,
DERIVATION_COERCIBLE, MY_REPERTOIRE_ASCII); DERIVATION_COERCIBLE, MY_REPERTOIRE_ASCII);
max_length= args[0]->max_length; max_length= args[0]->max_length;
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
return FALSE; return FALSE;
} }
@@ -730,7 +730,7 @@ bool Item_func_json_extract::fix_length_and_dec()
max_length= args[0]->max_length * (arg_count - 1); max_length= args[0]->max_length * (arg_count - 1);
mark_constant_paths(paths, args+1, arg_count-1); mark_constant_paths(paths, args+1, arg_count-1);
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
return FALSE; return FALSE;
} }
@@ -1000,7 +1000,7 @@ bool Item_func_json_contains::fix_length_and_dec()
{ {
a2_constant= args[1]->const_item(); a2_constant= args[1]->const_item();
a2_parsed= FALSE; a2_parsed= FALSE;
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
if (arg_count > 2) if (arg_count > 2)
path.set_constant_flag(args[2]->const_item()); path.set_constant_flag(args[2]->const_item());
return Item_bool_func::fix_length_and_dec(); return Item_bool_func::fix_length_and_dec();
@@ -1251,7 +1251,7 @@ bool Item_func_json_contains_path::fix_length_and_dec()
{ {
ooa_constant= args[1]->const_item(); ooa_constant= args[1]->const_item();
ooa_parsed= FALSE; ooa_parsed= FALSE;
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
mark_constant_paths(paths, args+2, arg_count-2); mark_constant_paths(paths, args+2, arg_count-2);
return Item_bool_func::fix_length_and_dec(); return Item_bool_func::fix_length_and_dec();
} }
@@ -1642,7 +1642,7 @@ bool Item_func_json_array_append::fix_length_and_dec()
} }
fix_char_length_ulonglong(char_length); fix_char_length_ulonglong(char_length);
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
return FALSE; return FALSE;
} }
@@ -2561,7 +2561,7 @@ bool Item_func_json_length::fix_length_and_dec()
{ {
if (arg_count > 1) if (arg_count > 1)
path.set_constant_flag(args[1]->const_item()); path.set_constant_flag(args[1]->const_item());
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
max_length= 10; max_length= 10;
return FALSE; return FALSE;
} }
@@ -2707,7 +2707,7 @@ bool Item_func_json_type::fix_length_and_dec()
{ {
collation.set(&my_charset_utf8mb3_general_ci); collation.set(&my_charset_utf8mb3_general_ci);
max_length= 12; max_length= 12;
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
return FALSE; return FALSE;
} }
@@ -2776,7 +2776,7 @@ bool Item_func_json_insert::fix_length_and_dec()
} }
fix_char_length_ulonglong(char_length); fix_char_length_ulonglong(char_length);
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
return FALSE; return FALSE;
} }
@@ -3028,7 +3028,7 @@ bool Item_func_json_remove::fix_length_and_dec()
max_length= args[0]->max_length; max_length= args[0]->max_length;
mark_constant_paths(paths, args+1, arg_count-1); mark_constant_paths(paths, args+1, arg_count-1);
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
return FALSE; return FALSE;
} }
@@ -3213,7 +3213,7 @@ bool Item_func_json_keys::fix_length_and_dec()
{ {
collation.set(args[0]->collation); collation.set(args[0]->collation);
max_length= args[0]->max_length; max_length= args[0]->max_length;
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
if (arg_count > 1) if (arg_count > 1)
path.set_constant_flag(args[1]->const_item()); path.set_constant_flag(args[1]->const_item());
return FALSE; return FALSE;
@@ -3398,7 +3398,7 @@ bool Item_func_json_search::fix_length_and_dec()
if (arg_count > 4) if (arg_count > 4)
mark_constant_paths(paths, args+4, arg_count-4); mark_constant_paths(paths, args+4, arg_count-4);
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
return FALSE; return FALSE;
} }
@@ -3581,7 +3581,7 @@ bool Item_func_json_format::fix_length_and_dec()
{ {
decimals= 0; decimals= 0;
max_length= args[0]->max_length; max_length= args[0]->max_length;
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
return FALSE; return FALSE;
} }
@@ -3789,7 +3789,7 @@ Item_func_json_objectagg::fix_fields(THD *thd, Item **ref)
if (init_sum_func_check(thd)) if (init_sum_func_check(thd))
return TRUE; return TRUE;
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
/* /*
Fix fields for select list and ORDER clause Fix fields for select list and ORDER clause
@@ -3799,9 +3799,7 @@ Item_func_json_objectagg::fix_fields(THD *thd, Item **ref)
{ {
if (args[i]->fix_fields_if_needed_for_scalar(thd, &args[i])) if (args[i]->fix_fields_if_needed_for_scalar(thd, &args[i]))
return TRUE; return TRUE;
flags|= (args[i]->flags & (ITEM_FLAG_WITH_SUBQUERY | with_flags|= args[i]->with_flags;
ITEM_FLAG_WITH_PARAM |
ITEM_FLAG_WITH_WINDOW_FUNC));
} }
/* skip charset aggregation for order columns */ /* skip charset aggregation for order columns */
@@ -3818,7 +3816,7 @@ Item_func_json_objectagg::fix_fields(THD *thd, Item **ref)
if (check_sum_func(thd, ref)) if (check_sum_func(thd, ref))
return TRUE; return TRUE;
flags|= ITEM_FLAG_FIXED; base_flags|= item_base_t::FIXED;
return FALSE; return FALSE;
} }

View File

@@ -88,7 +88,7 @@ public:
{ {
if (Item_bool_func::fix_length_and_dec()) if (Item_bool_func::fix_length_and_dec())
return TRUE; return TRUE;
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
return FALSE; return FALSE;
} }
bool set_format_by_check_constraint(Send_field_extended_metadata *to) const bool set_format_by_check_constraint(Send_field_extended_metadata *to) const

View File

@@ -38,7 +38,7 @@ bool Item_row::fix_fields(THD *thd, Item **ref)
{ {
DBUG_ASSERT(fixed() == 0); DBUG_ASSERT(fixed() == 0);
null_value= 0; null_value= 0;
flags&= (item_flags_t) ~ITEM_FLAG_MAYBE_NULL; base_flags&= ~item_base_t::MAYBE_NULL;
Item **arg, **arg_end; Item **arg, **arg_end;
for (arg= args, arg_end= args + arg_count; arg != arg_end ; arg++) for (arg= args, arg_end= args + arg_count; arg != arg_end ; arg++)
@@ -61,14 +61,10 @@ bool Item_row::fix_fields(THD *thd, Item **ref)
with_null|= 1; with_null|= 1;
} }
} }
flags|= (item->flags & (ITEM_FLAG_MAYBE_NULL | base_flags|= (item->base_flags & item_base_t::MAYBE_NULL);
ITEM_FLAG_WITH_SUM_FUNC | with_flags|= item->with_flags;
ITEM_FLAG_WITH_WINDOW_FUNC |
ITEM_FLAG_WITH_FIELD |
ITEM_FLAG_WITH_SUBQUERY |
ITEM_FLAG_WITH_PARAM));
} }
flags|= ITEM_FLAG_FIXED; base_flags|= item_base_t::FIXED;
return FALSE; return FALSE;
} }

View File

@@ -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 In Item_str_func::check_well_formed_result() we may set null_value
flag on the same condition as in test() below. 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; return res;
} }
@@ -286,7 +287,7 @@ String *Item_func_sha2::val_str_ascii(String *str)
bool Item_func_sha2::fix_length_and_dec() bool Item_func_sha2::fix_length_and_dec()
{ {
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
max_length = 0; max_length = 0;
int sha_variant= (int)(args[1]->const_item() ? args[1]->val_int() : 512); 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() bool Item_func_aes_decrypt::fix_length_and_dec()
{ {
max_length=args[0]->max_length; max_length=args[0]->max_length;
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
what= ENCRYPTION_FLAG_DECRYPT; what= ENCRYPTION_FLAG_DECRYPT;
return FALSE; return FALSE;
} }
@@ -382,11 +383,11 @@ bool Item_func_aes_decrypt::fix_length_and_dec()
bool Item_func_to_base64::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); collation.set(default_charset(), DERIVATION_COERCIBLE, MY_REPERTOIRE_ASCII);
if (args[0]->max_length > (uint) my_base64_encode_max_arg_length()) 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()); fix_char_length_ulonglong((ulonglong) my_base64_encode_max_arg_length());
} }
else 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); int length= my_base64_needed_decoded_length((int) args[0]->max_length);
fix_char_length_ulonglong((ulonglong) 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; return FALSE;
} }
@@ -2311,7 +2313,8 @@ bool Item_func_encode::seed()
bool Item_func_encode::fix_length_and_dec() bool Item_func_encode::fix_length_and_dec()
{ {
max_length=args[0]->max_length; 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); collation.set(&my_charset_bin);
/* Precompute the seed state if the item is constant. */ /* Precompute the seed state if the item is constant. */
seeded= args[1]->const_item() && seeded= args[1]->const_item() &&
@@ -2475,11 +2478,11 @@ bool Item_func_current_role::fix_fields(THD *thd, Item **ref)
return 1; return 1;
str_value.mark_as_const(); str_value.mark_as_const();
null_value= 0; null_value= 0;
flags&= (item_flags_t) ~ITEM_FLAG_MAYBE_NULL; base_flags&= ~item_base_t::MAYBE_NULL;
return 0; return 0;
} }
null_value= 1; null_value= 1;
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
return 0; return 0;
} }
@@ -2814,7 +2817,7 @@ bool Item_func_elt::fix_length_and_dec()
set_if_bigger(decimals,args[i]->decimals); set_if_bigger(decimals,args[i]->decimals);
} }
fix_char_length(char_length); 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; return FALSE;
} }
@@ -3038,7 +3041,7 @@ bool Item_func_repeat::fix_length_and_dec()
return false; return false;
} }
max_length= MAX_BLOB_WIDTH; max_length= MAX_BLOB_WIDTH;
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
return false; return false;
} }
@@ -3110,7 +3113,7 @@ bool Item_func_space::fix_length_and_dec()
return false; return false;
} }
max_length= MAX_BLOB_WIDTH; max_length= MAX_BLOB_WIDTH;
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
return false; return false;
} }
@@ -3165,7 +3168,7 @@ bool Item_func_binlog_gtid_pos::fix_length_and_dec()
{ {
collation.set(system_charset_info); collation.set(system_charset_info);
max_length= MAX_BLOB_WIDTH; max_length= MAX_BLOB_WIDTH;
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
return FALSE; return FALSE;
} }
@@ -3207,8 +3210,9 @@ bool Item_func_pad::fix_length_and_dec()
if (arg_count == 3) if (arg_count == 3)
{ {
String *str; String *str;
if (!args[2]->basic_const_item() || !(str= args[2]->val_str(&pad_str)) || !str->length()) if (!args[2]->basic_const_item() || !(str= args[2]->val_str(&pad_str)) ||
flags|= ITEM_FLAG_MAYBE_NULL; !str->length())
set_maybe_null();
// Handle character set for args[0] and args[2]. // Handle character set for args[0] and args[2].
if (agg_arg_charsets_for_string_result(collation, &args[0], 2, 2)) if (agg_arg_charsets_for_string_result(collation, &args[0], 2, 2))
return TRUE; return TRUE;
@@ -3229,7 +3233,7 @@ bool Item_func_pad::fix_length_and_dec()
return false; return false;
} }
max_length= MAX_BLOB_WIDTH; max_length= MAX_BLOB_WIDTH;
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
return false; return false;
} }
@@ -3614,7 +3618,7 @@ bool Item_func_weight_string::fix_length_and_dec()
args[0]->max_char_length() : nweights * cs->levels_for_order; args[0]->max_char_length() : nweights * cs->levels_for_order;
max_length= (uint32) cs->strnxfrmlen(char_length * cs->mbmaxlen); max_length= (uint32) cs->strnxfrmlen(char_length * cs->mbmaxlen);
} }
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
return FALSE; 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() bool Item_func_dyncol_create::fix_length_and_dec()
{ {
max_length= MAX_BLOB_WIDTH; max_length= MAX_BLOB_WIDTH;
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
collation.set(&my_charset_bin); collation.set(&my_charset_bin);
decimals= 0; decimals= 0;
return FALSE; return FALSE;

View File

@@ -299,7 +299,7 @@ public:
{ {
collation.set(system_charset_info); collation.set(system_charset_info);
max_length= MAX_BLOB_WIDTH; max_length= MAX_BLOB_WIDTH;
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
return FALSE; return FALSE;
} }
const char *func_name() const { return "decode_histogram"; } const char *func_name() const { return "decode_histogram"; }
@@ -511,7 +511,7 @@ public:
bool fix_length_and_dec() bool fix_length_and_dec()
{ {
bool res= Item_func_substr::fix_length_and_dec(); bool res= Item_func_substr::fix_length_and_dec();
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
return res; return res;
} }
const char *func_name() const { return "substr_oracle"; } const char *func_name() const { return "substr_oracle"; }
@@ -586,7 +586,7 @@ public:
bool fix_length_and_dec() bool fix_length_and_dec()
{ {
bool res= Item_func_trim::fix_length_and_dec(); bool res= Item_func_trim::fix_length_and_dec();
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
return res; return res;
} }
Item *get_copy(THD *thd) Item *get_copy(THD *thd)
@@ -625,7 +625,7 @@ public:
bool fix_length_and_dec() bool fix_length_and_dec()
{ {
bool res= Item_func_ltrim::fix_length_and_dec(); bool res= Item_func_ltrim::fix_length_and_dec();
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
return res; return res;
} }
Item *get_copy(THD *thd) Item *get_copy(THD *thd)
@@ -660,7 +660,7 @@ public:
bool fix_length_and_dec() bool fix_length_and_dec()
{ {
bool res= Item_func_rtrim::fix_length_and_dec(); bool res= Item_func_rtrim::fix_length_and_dec();
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
return res; return res;
} }
Item *get_copy(THD *thd) Item *get_copy(THD *thd)
@@ -719,7 +719,7 @@ public:
String *val_str(String *); String *val_str(String *);
bool fix_length_and_dec() bool fix_length_and_dec()
{ {
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
/* 9 = MAX ((8- (arg_len % 8)) + 1) */ /* 9 = MAX ((8- (arg_len % 8)) + 1) */
max_length = args[0]->max_length + 9; max_length = args[0]->max_length + 9;
return FALSE; return FALSE;
@@ -740,7 +740,7 @@ public:
String *val_str(String *); String *val_str(String *);
bool fix_length_and_dec() bool fix_length_and_dec()
{ {
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
/* 9 = MAX ((8- (arg_len % 8)) + 1) */ /* 9 = MAX ((8- (arg_len % 8)) + 1) */
max_length= args[0]->max_length; max_length= args[0]->max_length;
if (max_length >= 9U) if (max_length >= 9U)
@@ -780,7 +780,7 @@ public:
String *val_str(String *); String *val_str(String *);
bool fix_length_and_dec() bool fix_length_and_dec()
{ {
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
max_length = 13; max_length = 13;
return FALSE; return FALSE;
} }
@@ -860,7 +860,7 @@ public:
bool fix_length_and_dec() bool fix_length_and_dec()
{ {
max_length= MAX_FIELD_NAME * system_charset_info->mbmaxlen; max_length= MAX_FIELD_NAME * system_charset_info->mbmaxlen;
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
return FALSE; return FALSE;
} }
const char *func_name() const { return "database"; } const char *func_name() const { return "database"; }
@@ -885,7 +885,7 @@ public:
{ {
max_length= 512 * system_charset_info->mbmaxlen; max_length= 512 * system_charset_info->mbmaxlen;
null_value= false; null_value= false;
flags&= (item_flags_t) ~ITEM_FLAG_MAYBE_NULL; base_flags&= ~item_base_t::MAYBE_NULL;
return FALSE; return FALSE;
} }
Item *get_copy(THD *thd) Item *get_copy(THD *thd)
@@ -1160,7 +1160,7 @@ public:
bool fix_length_and_dec() bool fix_length_and_dec()
{ {
bool res= Item_func_rpad::fix_length_and_dec(); bool res= Item_func_rpad::fix_length_and_dec();
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
return res; return res;
} }
const char *func_name() const { return "rpad_oracle"; } const char *func_name() const { return "rpad_oracle"; }
@@ -1195,7 +1195,7 @@ public:
bool fix_length_and_dec() bool fix_length_and_dec()
{ {
bool res= Item_func_lpad::fix_length_and_dec(); bool res= Item_func_lpad::fix_length_and_dec();
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
return res; return res;
} }
const char *func_name() const { return "lpad_oracle"; } const char *func_name() const { return "lpad_oracle"; }
@@ -1215,7 +1215,7 @@ public:
{ {
collation.set(default_charset()); collation.set(default_charset());
fix_char_length(64); fix_char_length(64);
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
return FALSE; return FALSE;
} }
Item *get_copy(THD *thd) Item *get_copy(THD *thd)
@@ -1265,7 +1265,7 @@ public:
Item_func_unhex(THD *thd, Item *a): Item_str_func(thd, a) Item_func_unhex(THD *thd, Item *a): Item_str_func(thd, a)
{ {
/* there can be bad hex strings */ /* there can be bad hex strings */
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
} }
const char *func_name() const { return "unhex"; } const char *func_name() const { return "unhex"; }
String *val_str(String *); String *val_str(String *);
@@ -1292,7 +1292,7 @@ public:
Item_func_like_range(THD *thd, Item *a, Item *b, bool is_min_arg): Item_func_like_range(THD *thd, Item *a, Item *b, bool is_min_arg):
Item_str_func(thd, a, b), is_min(is_min_arg) Item_str_func(thd, a, b), is_min(is_min_arg)
{ {
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
} }
String *val_str(String *); String *val_str(String *);
bool fix_length_and_dec() bool fix_length_and_dec()
@@ -1365,7 +1365,7 @@ public:
bool fix_length_and_dec() bool fix_length_and_dec()
{ {
collation.set(&my_charset_bin, DERIVATION_COERCIBLE); collation.set(&my_charset_bin, DERIVATION_COERCIBLE);
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
max_length=MAX_BLOB_WIDTH; max_length=MAX_BLOB_WIDTH;
return FALSE; return FALSE;
} }
@@ -1539,7 +1539,7 @@ public:
{ {
collation.set(system_charset_info); collation.set(system_charset_info);
max_length= 64 * collation.collation->mbmaxlen; // should be enough max_length= 64 * collation.collation->mbmaxlen; // should be enough
flags&= (item_flags_t) ~ITEM_FLAG_MAYBE_NULL; base_flags&= ~item_base_t::MAYBE_NULL;
return FALSE; return FALSE;
}; };
table_map not_null_tables() const { return 0; } table_map not_null_tables() const { return 0; }
@@ -1632,7 +1632,7 @@ public:
bool fix_length_and_dec() bool fix_length_and_dec()
{ {
max_length=10; max_length=10;
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
return FALSE; } return FALSE; }
longlong val_int(); longlong val_int();
Item *get_copy(THD *thd) Item *get_copy(THD *thd)
@@ -1670,7 +1670,7 @@ public:
:Item_str_binary_checksum_func(thd, a) {} :Item_str_binary_checksum_func(thd, a) {}
bool fix_length_and_dec() bool fix_length_and_dec()
{ {
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
max_length= MAX_BLOB_WIDTH; max_length= MAX_BLOB_WIDTH;
return FALSE; return FALSE;
} }
@@ -1750,7 +1750,7 @@ public:
bool fix_length_and_dec() bool fix_length_and_dec()
{ {
max_length= MAX_BLOB_WIDTH; max_length= MAX_BLOB_WIDTH;
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
decimals= 0; decimals= 0;
return FALSE; return FALSE;
} }
@@ -1769,7 +1769,7 @@ public:
{} {}
bool fix_length_and_dec() bool fix_length_and_dec()
{ {
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
max_length= MAX_BLOB_WIDTH; max_length= MAX_BLOB_WIDTH;
return FALSE; return FALSE;
} }
@@ -1812,7 +1812,7 @@ public:
{collation.set(DYNCOL_UTF);} {collation.set(DYNCOL_UTF);}
bool fix_length_and_dec() bool fix_length_and_dec()
{ {
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
max_length= MAX_BLOB_WIDTH; max_length= MAX_BLOB_WIDTH;
return FALSE; return FALSE;
} }
@@ -1856,7 +1856,7 @@ public:
bool fix_length_and_dec() bool fix_length_and_dec()
{ {
max_length= WSREP_GTID_STR_LEN; max_length= WSREP_GTID_STR_LEN;
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
return FALSE; return FALSE;
} }
Item *get_copy(THD *thd) Item *get_copy(THD *thd)
@@ -1873,7 +1873,7 @@ public:
bool fix_length_and_dec() bool fix_length_and_dec()
{ {
max_length= WSREP_GTID_STR_LEN; max_length= WSREP_GTID_STR_LEN;
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
return FALSE; return FALSE;
} }
Item *get_copy(THD *thd) Item *get_copy(THD *thd)

View File

@@ -67,7 +67,7 @@ Item_subselect::Item_subselect(THD *thd_arg):
#ifndef DBUG_OFF #ifndef DBUG_OFF
exec_counter= 0; exec_counter= 0;
#endif #endif
flags|= ITEM_FLAG_WITH_SUBQUERY; with_flags|= item_with_t::SUBQUERY;
reset(); reset();
/* /*
Item value is NULL if select_result_interceptor didn't change this value Item value is NULL if select_result_interceptor didn't change this value
@@ -346,7 +346,7 @@ bool Item_subselect::fix_fields(THD *thd_param, Item **ref)
if (uncacheable & UNCACHEABLE_RAND) if (uncacheable & UNCACHEABLE_RAND)
used_tables_cache|= RAND_TABLE_BIT; used_tables_cache|= RAND_TABLE_BIT;
} }
flags|= ITEM_FLAG_FIXED; base_flags|= item_base_t::FIXED;
end: end:
done_first_fix_fields= FALSE; done_first_fix_fields= FALSE;
@@ -1117,7 +1117,7 @@ Item_singlerow_subselect::Item_singlerow_subselect(THD *thd, st_select_lex *sele
{ {
DBUG_ENTER("Item_singlerow_subselect::Item_singlerow_subselect"); DBUG_ENTER("Item_singlerow_subselect::Item_singlerow_subselect");
init(select_lex, new (thd->mem_root) select_singlerow_subselect(thd, this)); init(select_lex, new (thd->mem_root) select_singlerow_subselect(thd, this));
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
max_columns= UINT_MAX; max_columns= UINT_MAX;
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
@@ -1154,7 +1154,7 @@ Item_maxmin_subselect::Item_maxmin_subselect(THD *thd,
new (thd->mem_root) select_max_min_finder_subselect(thd, new (thd->mem_root) select_max_min_finder_subselect(thd,
this, max_arg, parent->substype() == Item_subselect::ALL_SUBS)); this, max_arg, parent->substype() == Item_subselect::ALL_SUBS));
max_columns= 1; max_columns= 1;
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
max_columns= 1; max_columns= 1;
/* /*
@@ -1342,7 +1342,7 @@ bool Item_singlerow_subselect::fix_length_and_dec()
else else
{ {
for (uint i= 0; i < max_columns; i++) for (uint i= 0; i < max_columns; i++)
row[i]->flags|= ITEM_FLAG_MAYBE_NULL; row[i]->set_maybe_null();
} }
return FALSE; return FALSE;
} }
@@ -1589,7 +1589,7 @@ Item_exists_subselect::Item_exists_subselect(THD *thd,
init(select_lex, new (thd->mem_root) select_exists_subselect(thd, this)); init(select_lex, new (thd->mem_root) select_exists_subselect(thd, this));
max_columns= UINT_MAX; max_columns= UINT_MAX;
null_value= FALSE; //can't be NULL 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; value= 0;
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
@@ -1638,7 +1638,7 @@ Item_in_subselect::Item_in_subselect(THD *thd, Item * left_exp,
func= &eq_creator; func= &eq_creator;
init(select_lex, new (thd->mem_root) select_exists_subselect(thd, this)); init(select_lex, new (thd->mem_root) select_exists_subselect(thd, this));
max_columns= UINT_MAX; max_columns= UINT_MAX;
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
reset(); reset();
//if test_limit will fail then error will be reported to client //if test_limit will fail then error will be reported to client
test_limit(select_lex->master_unit()); test_limit(select_lex->master_unit());
@@ -3541,7 +3541,7 @@ bool Item_in_subselect::fix_fields(THD *thd_arg, Item **ref)
else else
if (Item_subselect::fix_fields(thd_arg, ref)) if (Item_subselect::fix_fields(thd_arg, ref))
goto err; goto err;
flags|= ITEM_FLAG_FIXED; base_flags|= item_base_t::FIXED;
thd->where= save_where; thd->where= save_where;
DBUG_RETURN(FALSE); DBUG_RETURN(FALSE);

View File

@@ -407,7 +407,7 @@ bool Item_sum::register_sum_func(THD *thd, Item **ref)
for (sl= thd->lex->current_select; for (sl= thd->lex->current_select;
sl && sl != aggr_sel && sl->master_unit()->item; sl && sl != aggr_sel && sl->master_unit()->item;
sl= sl->master_unit()->outer_select() ) 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); 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->n_sum_items++;
cur_select->with_sum_func= 1; cur_select->with_sum_func= 1;
const_item_cache= false; 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; window_func_sum_expr_flag= false;
} }
@@ -892,7 +892,7 @@ bool Aggregator_distinct::setup(THD *thd)
*/ */
item_sum->null_value= 1; item_sum->null_value= 1;
item_sum->flags|= ITEM_FLAG_MAYBE_NULL; item_sum->set_maybe_null();
item_sum->quick_group= 0; item_sum->quick_group= 0;
DBUG_ASSERT(item_sum->get_arg(0)->fixed()); 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])) if (args[i]->fix_fields_if_needed_for_scalar(thd, &args[i]))
return TRUE; return TRUE;
set_if_bigger(decimals, args[i]->decimals); set_if_bigger(decimals, args[i]->decimals);
flags|= (args[i]->flags & (ITEM_FLAG_WITH_SUBQUERY | /* We should ignore FIELD's in arguments to sum functions */
ITEM_FLAG_WITH_PARAM | with_flags|= (args[i]->with_flags & ~item_with_t::FIELD);
ITEM_FLAG_WITH_WINDOW_FUNC));
} }
result_field=0; result_field=0;
max_length=float_length(decimals); max_length=float_length(decimals);
@@ -1138,7 +1137,7 @@ Item_sum_num::fix_fields(THD *thd, Item **ref)
if (arg_count) if (arg_count)
memcpy (orig_args, args, sizeof (Item *) * arg_count); memcpy (orig_args, args, sizeof (Item *) * arg_count);
flags|= ITEM_FLAG_FIXED; base_flags|= item_base_t::FIXED;
return FALSE; 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])) if (args[0]->fix_fields_if_needed_for_scalar(thd, &args[0]))
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
flags|= (args[0]->flags & (ITEM_FLAG_WITH_SUBQUERY | /* We should ignore FIELD's in arguments to sum functions */
ITEM_FLAG_WITH_PARAM | with_flags|= (args[0]->with_flags & ~item_with_t::FIELD);
ITEM_FLAG_WITH_WINDOW_FUNC));
if (fix_length_and_dec()) if (fix_length_and_dec())
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
@@ -1171,7 +1168,7 @@ Item_sum_min_max::fix_fields(THD *thd, Item **ref)
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
orig_args[0]= args[0]; orig_args[0]= args[0];
flags|= ITEM_FLAG_FIXED; base_flags|= item_base_t::FIXED;
DBUG_RETURN(FALSE); 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]->field_type() == args[0]->real_item()->field_type());
DBUG_ASSERT(args[0]->result_type() == args[0]->real_item()->result_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 */ /* MIN/MAX can return NULL for empty set indepedent of the used column */
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
null_value= true; null_value= true;
return args[0]->type_handler()->Item_sum_hybrid_fix_length_and_dec(this); 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) sp_name *name_arg, sp_head *sp, List<Item> &list)
:Item_sum(thd, list), Item_sp(thd, context_arg, name_arg) :Item_sum(thd, list), Item_sp(thd, context_arg, name_arg)
{ {
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
quick_group= 0; quick_group= 0;
m_sp= sp; 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) sp_name *name_arg, sp_head *sp)
:Item_sum(thd), Item_sp(thd, context_arg, name_arg) :Item_sum(thd), Item_sp(thd, context_arg, name_arg)
{ {
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
quick_group= 0; quick_group= 0;
m_sp= sp; 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_sp::Item_sum_sp(THD *thd, Item_sum_sp *item):
Item_sum(thd, item), Item_sp(thd, 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; 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])) if (args[i]->fix_fields_if_needed_for_scalar(thd, &args[i]))
return TRUE; return TRUE;
set_if_bigger(decimals, args[i]->decimals); set_if_bigger(decimals, args[i]->decimals);
flags|= (args[i]->flags & (ITEM_FLAG_WITH_SUBQUERY | /* We should ignore FIELD's in arguments to sum functions */
ITEM_FLAG_WITH_WINDOW_FUNC)); with_flags|= (args[i]->with_flags & ~item_with_t::FIELD);
} }
result_field= NULL; result_field= NULL;
max_length= float_length(decimals); max_length= float_length(decimals);
@@ -1373,7 +1370,7 @@ Item_sum_sp::fix_fields(THD *thd, Item **ref)
if (arg_count) if (arg_count)
memcpy(orig_args, args, sizeof(Item *) * arg_count); memcpy(orig_args, args, sizeof(Item *) * arg_count);
flags|= ITEM_FLAG_FIXED; base_flags|= item_base_t::FIXED;
return FALSE; return FALSE;
} }
@@ -1557,7 +1554,7 @@ void Item_sum_sum::fix_length_and_dec_decimal()
bool Item_sum_sum::fix_length_and_dec() bool Item_sum_sum::fix_length_and_dec()
{ {
DBUG_ENTER("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; null_value=1;
if (args[0]->cast_to_int_type_handler()-> if (args[0]->cast_to_int_type_handler()->
Item_sum_sum_fix_length_and_dec(this)) 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"); DBUG_ENTER("Item_sum_avg::fix_length_and_dec");
prec_increment= current_thd->variables.div_precincrement; prec_increment= current_thd->variables.div_precincrement;
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
null_value=1; null_value=1;
if (args[0]->cast_to_int_type_handler()-> if (args[0]->cast_to_int_type_handler()->
Item_sum_avg_fix_length_and_dec(this)) 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() bool Item_sum_variance::fix_length_and_dec()
{ {
DBUG_ENTER("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; null_value= 1;
prec_increment= current_thd->variables.div_precincrement; 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)) if (init_sum_func_check(thd))
return TRUE; return TRUE;
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
/* /*
Fix fields for select list and ORDER clause 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])) if (args[i]->fix_fields_if_needed_for_scalar(thd, &args[i]))
return TRUE; return TRUE;
flags|= (args[i]->flags & (ITEM_FLAG_WITH_SUBQUERY | /* We should ignore FIELD's in arguments to sum functions */
ITEM_FLAG_WITH_PARAM | with_flags|= (args[i]->with_flags & ~item_with_t::FIELD);
ITEM_FLAG_WITH_WINDOW_FUNC));
} }
/* skip charset aggregation for order columns */ /* 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)) if (check_sum_func(thd, ref))
return TRUE; return TRUE;
flags|= ITEM_FLAG_FIXED; base_flags|= item_base_t::FIXED;
return FALSE; return FALSE;
} }

View File

@@ -463,7 +463,7 @@ public:
virtual void update_field()=0; virtual void update_field()=0;
virtual bool fix_length_and_dec() virtual bool fix_length_and_dec()
{ {
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
null_value=1; null_value=1;
return FALSE; return FALSE;
} }
@@ -786,7 +786,7 @@ public:
{ {
decimals=0; decimals=0;
max_length=21; max_length=21;
flags&= (item_flags_t) ~ITEM_FLAG_MAYBE_NULL; base_flags&= ~item_base_t::MAYBE_NULL;
null_value=0; null_value=0;
return FALSE; } return FALSE; }
}; };
@@ -1219,7 +1219,7 @@ public:
if (args[0]->check_type_can_return_int(func_name())) if (args[0]->check_type_can_return_int(func_name()))
return true; return true;
decimals= 0; max_length=21; unsigned_flag= 1; 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; null_value= 0;
return FALSE; return FALSE;
} }
@@ -1470,7 +1470,7 @@ public:
:Item(thd), field(item->result_field) :Item(thd), field(item->result_field)
{ {
name= item->name; name= item->name;
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
decimals= item->decimals; decimals= item->decimals;
max_length= item->max_length; max_length= item->max_length;
unsigned_flag= item->unsigned_flag; unsigned_flag= item->unsigned_flag;
@@ -1614,7 +1614,7 @@ public:
if (init_sum_func_check(thd)) if (init_sum_func_check(thd))
return TRUE; return TRUE;
flags|= ITEM_FLAG_FIXED; base_flags|= item_base_t::FIXED;
/* /*
We set const_item_cache to false in constructors. We set const_item_cache to false in constructors.
It can be later changed to "true", in a Item_sum::make_const() call. It can be later changed to "true", in a Item_sum::make_const() call.
@@ -1846,7 +1846,8 @@ public:
{ DBUG_ASSERT(fixed()); null_value=1; return 0; } { DBUG_ASSERT(fixed()); null_value=1; return 0; }
double val_real() { DBUG_ASSERT(fixed()); null_value=1; return 0.0; } double val_real() { DBUG_ASSERT(fixed()); null_value=1; return 0.0; }
longlong val_int() { DBUG_ASSERT(fixed()); null_value=1; return 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; } enum Sumfunctype sum_func () const { return UDF_SUM_FUNC; }
void clear() {} void clear() {}
bool add() { return 0; } bool add() { return 0; }

View File

@@ -980,7 +980,7 @@ bool Item_func_monthname::fix_length_and_dec()
collation.set(cs, DERIVATION_COERCIBLE, locale->repertoire()); collation.set(cs, DERIVATION_COERCIBLE, locale->repertoire());
decimals=0; decimals=0;
max_length= locale->max_month_name_length * collation.collation->mbmaxlen; max_length= locale->max_month_name_length * collation.collation->mbmaxlen;
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
return FALSE; return FALSE;
} }
@@ -1125,7 +1125,7 @@ bool Item_func_dayname::fix_length_and_dec()
collation.set(cs, DERIVATION_COERCIBLE, locale->repertoire()); collation.set(cs, DERIVATION_COERCIBLE, locale->repertoire());
decimals=0; decimals=0;
max_length= locale->max_day_name_length * collation.collation->mbmaxlen; max_length= locale->max_day_name_length * collation.collation->mbmaxlen;
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
return FALSE; return FALSE;
} }
@@ -1774,7 +1774,7 @@ bool Item_func_date_format::fix_length_and_dec()
collation.collation->mbmaxlen; collation.collation->mbmaxlen;
set_if_smaller(max_length,MAX_BLOB_WIDTH); set_if_smaller(max_length,MAX_BLOB_WIDTH);
} }
flags|= ITEM_FLAG_MAYBE_NULL; // If wrong date set_maybe_null(); // If wrong date
return FALSE; return FALSE;
} }
@@ -1937,7 +1937,7 @@ bool Item_func_from_unixtime::fix_length_and_dec()
Type_temporal_attributes_not_fixed_dec(MAX_DATETIME_WIDTH, Type_temporal_attributes_not_fixed_dec(MAX_DATETIME_WIDTH,
args[0]->decimals, false), args[0]->decimals, false),
DTCollation_numeric()); DTCollation_numeric());
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
return FALSE; return FALSE;
} }
@@ -2064,7 +2064,7 @@ bool Item_date_add_interval::fix_length_and_dec()
{ {
set_func_handler(&func_handler_date_add_interval_string); 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); return m_func_handler->fix_length_and_dec(this);
} }
@@ -2141,7 +2141,7 @@ bool Item_extract::check_arguments() const
bool Item_extract::fix_length_and_dec() 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 : uint32 daylen= args[0]->cmp_type() == TIME_RESULT ? 2 :
TIME_MAX_INTERVAL_DAY_CHAR_LENGTH; TIME_MAX_INTERVAL_DAY_CHAR_LENGTH;
switch (int_type) { switch (int_type) {
@@ -2504,7 +2504,8 @@ Item_char_typecast::fix_length_and_dec_native_to_binary(uint32 octet_length)
{ {
collation.set(&my_charset_bin, DERIVATION_IMPLICIT); collation.set(&my_charset_bin, DERIVATION_IMPLICIT);
max_length= has_explicit_length() ? (uint32) cast_length : octet_length; 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();
} }
@@ -2549,7 +2550,8 @@ void Item_char_typecast::fix_length_and_dec_internal(CHARSET_INFO *from_cs)
args[0]->collation.collation->mbmaxlen)); args[0]->collation.collation->mbmaxlen));
max_length= char_length * cast_cs->mbmaxlen; max_length= char_length * cast_cs->mbmaxlen;
// Add NULL-ability in strict mode. See Item_str_func::fix_fields() // 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();
} }
@@ -2673,7 +2675,7 @@ bool Item_func_add_time::fix_length_and_dec()
&func_handler_add_time_string_sub); &func_handler_add_time_string_sub);
} }
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
return m_func_handler->fix_length_and_dec(this); return m_func_handler->fix_length_and_dec(this);
} }
@@ -3059,7 +3061,7 @@ bool Item_func_str_to_date::fix_length_and_dec()
if (collation.collation->mbminlen > 1) if (collation.collation->mbminlen > 1)
internal_charset= &my_charset_utf8mb4_general_ci; 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); set_func_handler(&func_handler_str_to_date_datetime_usec);
if ((const_item= args[1]->const_item())) if ((const_item= args[1]->const_item()))

View File

@@ -97,7 +97,7 @@ public:
{ {
decimals=0; decimals=0;
max_length=6*MY_CHARSET_BIN_MB_MAXLEN; max_length=6*MY_CHARSET_BIN_MB_MAXLEN;
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
return FALSE; return FALSE;
} }
enum_monotonicity_info get_monotonicity_info() const; enum_monotonicity_info get_monotonicity_info() const;
@@ -125,7 +125,7 @@ public:
{ {
decimals=0; decimals=0;
fix_char_length(12); fix_char_length(12);
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
return FALSE; return FALSE;
} }
enum_monotonicity_info get_monotonicity_info() const; enum_monotonicity_info get_monotonicity_info() const;
@@ -152,7 +152,7 @@ public:
{ {
decimals=0; decimals=0;
max_length=2*MY_CHARSET_BIN_MB_MAXLEN; max_length=2*MY_CHARSET_BIN_MB_MAXLEN;
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
return FALSE; return FALSE;
} }
bool check_partition_func_processor(void *int_arg) {return FALSE;} bool check_partition_func_processor(void *int_arg) {return FALSE;}
@@ -177,7 +177,7 @@ public:
{ {
decimals= 0; decimals= 0;
fix_char_length(2); fix_char_length(2);
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
return FALSE; return FALSE;
} }
bool check_partition_func_processor(void *int_arg) {return FALSE;} bool check_partition_func_processor(void *int_arg) {return FALSE;}
@@ -223,7 +223,7 @@ public:
{ {
decimals= 0; decimals= 0;
fix_char_length(3); fix_char_length(3);
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
return FALSE; return FALSE;
} }
bool check_partition_func_processor(void *int_arg) {return FALSE;} bool check_partition_func_processor(void *int_arg) {return FALSE;}
@@ -247,7 +247,7 @@ public:
{ {
decimals=0; decimals=0;
max_length=2*MY_CHARSET_BIN_MB_MAXLEN; max_length=2*MY_CHARSET_BIN_MB_MAXLEN;
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
return FALSE; return FALSE;
} }
bool check_partition_func_processor(void *int_arg) {return FALSE;} bool check_partition_func_processor(void *int_arg) {return FALSE;}
@@ -271,7 +271,7 @@ public:
{ {
decimals=0; decimals=0;
max_length=2*MY_CHARSET_BIN_MB_MAXLEN; max_length=2*MY_CHARSET_BIN_MB_MAXLEN;
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
return FALSE; return FALSE;
} }
bool check_partition_func_processor(void *int_arg) {return FALSE;} bool check_partition_func_processor(void *int_arg) {return FALSE;}
@@ -295,7 +295,7 @@ public:
{ {
decimals=0; decimals=0;
max_length=1*MY_CHARSET_BIN_MB_MAXLEN; max_length=1*MY_CHARSET_BIN_MB_MAXLEN;
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
return FALSE; return FALSE;
} }
bool check_partition_func_processor(void *int_arg) {return FALSE;} bool check_partition_func_processor(void *int_arg) {return FALSE;}
@@ -319,7 +319,7 @@ public:
{ {
decimals=0; decimals=0;
max_length=2*MY_CHARSET_BIN_MB_MAXLEN; max_length=2*MY_CHARSET_BIN_MB_MAXLEN;
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
return FALSE; return FALSE;
} }
bool check_partition_func_processor(void *int_arg) {return FALSE;} bool check_partition_func_processor(void *int_arg) {return FALSE;}
@@ -349,7 +349,7 @@ public:
{ {
decimals=0; decimals=0;
max_length=2*MY_CHARSET_BIN_MB_MAXLEN; max_length=2*MY_CHARSET_BIN_MB_MAXLEN;
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
return FALSE; return FALSE;
} }
bool check_vcol_func_processor(void *arg) bool check_vcol_func_processor(void *arg)
@@ -382,7 +382,7 @@ public:
{ {
decimals=0; decimals=0;
max_length=6*MY_CHARSET_BIN_MB_MAXLEN; max_length=6*MY_CHARSET_BIN_MB_MAXLEN;
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
return FALSE; return FALSE;
} }
bool check_partition_func_processor(void *int_arg) {return FALSE;} bool check_partition_func_processor(void *int_arg) {return FALSE;}
@@ -408,7 +408,7 @@ public:
{ {
decimals=0; decimals=0;
max_length=4*MY_CHARSET_BIN_MB_MAXLEN; max_length=4*MY_CHARSET_BIN_MB_MAXLEN;
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
return FALSE; return FALSE;
} }
bool check_partition_func_processor(void *int_arg) {return FALSE;} bool check_partition_func_processor(void *int_arg) {return FALSE;}
@@ -441,7 +441,7 @@ public:
{ {
decimals= 0; decimals= 0;
fix_char_length(1); fix_char_length(1);
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
return FALSE; return FALSE;
} }
bool check_partition_func_processor(void *int_arg) {return FALSE;} bool check_partition_func_processor(void *int_arg) {return FALSE;}
@@ -487,7 +487,7 @@ public:
DBUG_ASSERT(dec <= TIME_SECOND_PART_DIGITS); DBUG_ASSERT(dec <= TIME_SECOND_PART_DIGITS);
decimals= dec; decimals= dec;
max_length=17 + (decimals ? decimals + 1 : 0); max_length=17 + (decimals ? decimals + 1 : 0);
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
if (decimals) if (decimals)
set_handler(&type_handler_newdecimal); set_handler(&type_handler_newdecimal);
else else
@@ -906,7 +906,7 @@ class Item_func_convert_tz :public Item_datetimefunc
bool fix_length_and_dec() bool fix_length_and_dec()
{ {
fix_attributes_datetime(args[0]->datetime_precision(current_thd)); fix_attributes_datetime(args[0]->datetime_precision(current_thd));
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
return FALSE; return FALSE;
} }
bool get_date(THD *thd, MYSQL_TIME *res, date_mode_t fuzzydate); bool get_date(THD *thd, MYSQL_TIME *res, date_mode_t fuzzydate);
@@ -926,7 +926,7 @@ public:
bool fix_length_and_dec() bool fix_length_and_dec()
{ {
fix_attributes_time(args[0]->decimals); fix_attributes_time(args[0]->decimals);
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
return FALSE; return FALSE;
} }
const char *func_name() const { return "sec_to_time"; } const char *func_name() const { return "sec_to_time"; }
@@ -1214,7 +1214,7 @@ public:
uint dec0= args[0]->datetime_precision(thd); uint dec0= args[0]->datetime_precision(thd);
uint dec1= Interval_DDhhmmssff::fsp(thd, args[1]); uint dec1= Interval_DDhhmmssff::fsp(thd, args[1]);
fix_attributes_datetime(MY_MAX(dec0, dec1)); fix_attributes_datetime(MY_MAX(dec0, dec1));
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
return false; return false;
} }
bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate) bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate)
@@ -1274,7 +1274,7 @@ public:
uint dec= MY_MAX(args[0]->time_precision(thd), uint dec= MY_MAX(args[0]->time_precision(thd),
args[1]->time_precision(thd)); args[1]->time_precision(thd));
fix_attributes_time(dec); fix_attributes_time(dec);
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
return FALSE; return FALSE;
} }
bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate); bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate);
@@ -1296,7 +1296,7 @@ public:
bool fix_length_and_dec() bool fix_length_and_dec()
{ {
fix_attributes_time(args[2]->decimals); fix_attributes_time(args[2]->decimals);
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
return FALSE; return FALSE;
} }
const char *func_name() const { return "maketime"; } const char *func_name() const { return "maketime"; }
@@ -1315,7 +1315,7 @@ public:
bool fix_length_and_dec() bool fix_length_and_dec()
{ {
decimals=0; decimals=0;
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
fix_char_length(6); fix_char_length(6);
return FALSE; return FALSE;
} }
@@ -1346,7 +1346,7 @@ public:
bool fix_length_and_dec() bool fix_length_and_dec()
{ {
decimals=0; decimals=0;
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
return FALSE; return FALSE;
} }
virtual void print(String *str, enum_query_type query_type); virtual void print(String *str, enum_query_type query_type);
@@ -1371,7 +1371,7 @@ public:
const char *func_name() const { return "get_format"; } const char *func_name() const { return "get_format"; }
bool fix_length_and_dec() bool fix_length_and_dec()
{ {
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
decimals=0; decimals=0;
fix_length_and_charset(17, default_charset()); fix_length_and_charset(17, default_charset());
return FALSE; return FALSE;

View File

@@ -40,7 +40,7 @@ public:
} }
bool fix_length_and_dec() bool fix_length_and_dec()
{ {
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
null_value= 0; null_value= 0;
decimals= 0; decimals= 0;
max_length= 1; max_length= 1;

View File

@@ -120,7 +120,7 @@ Item_window_func::fix_fields(THD *thd, Item **ref)
const_item_cache= false; 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()) if (fix_length_and_dec())
return TRUE; return TRUE;
@@ -128,7 +128,7 @@ Item_window_func::fix_fields(THD *thd, Item **ref)
max_length= window_func()->max_length; max_length= window_func()->max_length;
set_maybe_null(window_func()->maybe_null()); set_maybe_null(window_func()->maybe_null());
flags|= ITEM_FLAG_FIXED; base_flags|= item_base_t::FIXED;
set_phase_to_initial(); set_phase_to_initial();
return false; 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])) if (args[i]->fix_fields_if_needed_for_scalar(thd, &args[i]))
return TRUE; return TRUE;
flags|= (args[i]->flags & (ITEM_FLAG_WITH_WINDOW_FUNC | with_flags|= args[i]->with_flags;
ITEM_FLAG_WITH_SUBQUERY));
} }
if (fix_length_and_dec()) 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++) for (uint i= 0; i < arg_count; i++)
orig_args[i]= args[i]; orig_args[i]= args[i];
flags|= ITEM_FLAG_FIXED; base_flags|= item_base_t::FIXED;
return FALSE; return FALSE;
} }
bool Item_sum_hybrid_simple::fix_length_and_dec() bool Item_sum_hybrid_simple::fix_length_and_dec()
{ {
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
null_value= true; null_value= true;
return args[0]->type_handler()->Item_sum_hybrid_fix_length_and_dec(this); return args[0]->type_handler()->Item_sum_hybrid_fix_length_and_dec(this);
} }

View File

@@ -110,12 +110,12 @@ protected:
public: public:
Item_xml_str_func(THD *thd, Item *a, Item *b): Item_str_func(thd, a, b) Item_xml_str_func(THD *thd, Item *a, Item *b): Item_str_func(thd, a, b)
{ {
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
} }
Item_xml_str_func(THD *thd, Item *a, Item *b, Item *c): Item_xml_str_func(THD *thd, Item *a, Item *b, Item *c):
Item_str_func(thd, a, b, c) Item_str_func(thd, a, b, c)
{ {
flags|= ITEM_FLAG_MAYBE_NULL; set_maybe_null();
} }
bool fix_fields(THD *thd, Item **ref); bool fix_fields(THD *thd, Item **ref);
bool fix_length_and_dec(); bool fix_length_and_dec();

View File

@@ -966,7 +966,7 @@ bool make_in_exists_conversion(THD *thd, JOIN *join, Item_in_subselect *item)
call. call.
*/ */
item->changed= 0; item->changed= 0;
item->flags|= ITEM_FLAG_FIXED; item->base_flags|= item_base_t::FIXED;
SELECT_LEX *save_select_lex= thd->lex->current_select; SELECT_LEX *save_select_lex= thd->lex->current_select;
thd->lex->current_select= item->unit->first_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; JOIN *child_join= in_subq->unit->first_select()->join;
in_subq->changed= 0; 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; SELECT_LEX *save_select_lex= thd->lex->current_select;
thd->lex->current_select= in_subq->unit->first_select(); thd->lex->current_select= in_subq->unit->first_select();

View File

@@ -2994,7 +2994,7 @@ sp_head::show_create_routine_get_fields(THD *thd, const Sp_handler *sph,
Item_empty_string *stmt_fld= Item_empty_string *stmt_fld=
new (mem_root) Item_empty_string(thd, col3_caption, 1024); 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); fields->push_back(stmt_fld, mem_root);
} }
@@ -3070,7 +3070,7 @@ sp_head::show_create_routine(THD *thd, const Sp_handler *sph)
new (mem_root) Item_empty_string(thd, col3_caption, new (mem_root) Item_empty_string(thd, col3_caption,
(uint)MY_MAX(m_defstr.length, 1024)); (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); fields.push_back(stmt_fld, thd->mem_root);
} }

View File

@@ -510,18 +510,18 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
field_list.push_back(item= new (thd->mem_root) field_list.push_back(item= new (thd->mem_root)
Item_empty_string(thd, "Table", Item_empty_string(thd, "Table",
NAME_CHAR_LEN * 2), thd->mem_root); 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) field_list.push_back(item= new (thd->mem_root)
Item_empty_string(thd, "Op", 10), 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) field_list.push_back(item= new (thd->mem_root)
Item_empty_string(thd, "Msg_type", 10), 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) field_list.push_back(item= new (thd->mem_root)
Item_empty_string(thd, "Msg_text", Item_empty_string(thd, "Msg_text",
SQL_ADMIN_MSG_TEXT_SIZE), SQL_ADMIN_MSG_TEXT_SIZE),
thd->mem_root); thd->mem_root);
item->flags|= ITEM_FLAG_MAYBE_NULL; item->set_maybe_null();
if (protocol->send_result_set_metadata(&field_list, if (protocol->send_result_set_metadata(&field_list,
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);

View File

@@ -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[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]= 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]= 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[3]= new (mem_root) Item_proc_int(thd, "Min_length");
func_items[4]= new (mem_root) Item_proc_int(thd, "Max_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[5]= new (mem_root) Item_proc_int(thd, "Empties_or_zeros");
func_items[6]= new (mem_root) Item_proc_int(thd, "Nulls"); 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[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]= 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", func_items[9]= new (mem_root) Item_proc_string(thd, "Optimal_fieldtype",
MY_MAX(64, MY_MAX(64,
output_str_length)); output_str_length));

View File

@@ -2711,45 +2711,45 @@ void THD::make_explain_field_list(List<Item> &field_list, uint8 explain_flags,
field_list.push_back(item= new (mem_root) field_list.push_back(item= new (mem_root)
Item_return_int(this, "id", 3, Item_return_int(this, "id", 3,
MYSQL_TYPE_LONGLONG), mem_root); MYSQL_TYPE_LONGLONG), mem_root);
item->flags|= ITEM_FLAG_MAYBE_NULL; item->set_maybe_null();
field_list.push_back(new (mem_root) field_list.push_back(new (mem_root)
Item_empty_string(this, "select_type", 19, cs), Item_empty_string(this, "select_type", 19, cs),
mem_root); mem_root);
field_list.push_back(item= new (mem_root) field_list.push_back(item= new (mem_root)
Item_empty_string(this, "table", NAME_CHAR_LEN, cs), Item_empty_string(this, "table", NAME_CHAR_LEN, cs),
mem_root); mem_root);
item->flags|= ITEM_FLAG_MAYBE_NULL; item->set_maybe_null();
if (explain_flags & DESCRIBE_PARTITIONS) if (explain_flags & DESCRIBE_PARTITIONS)
{ {
/* Maximum length of string that make_used_partitions_str() can produce */ /* Maximum length of string that make_used_partitions_str() can produce */
item= new (mem_root) Item_empty_string(this, "partitions", item= new (mem_root) Item_empty_string(this, "partitions",
MAX_PARTITIONS * (1 + FN_LEN), cs); MAX_PARTITIONS * (1 + FN_LEN), cs);
field_list.push_back(item, mem_root); 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) field_list.push_back(item= new (mem_root)
Item_empty_string(this, "type", 10, cs), Item_empty_string(this, "type", 10, cs),
mem_root); mem_root);
item->flags|= ITEM_FLAG_MAYBE_NULL; item->set_maybe_null();
field_list.push_back(item= new (mem_root) field_list.push_back(item= new (mem_root)
Item_empty_string(this, "possible_keys", Item_empty_string(this, "possible_keys",
NAME_CHAR_LEN*MAX_KEY, cs), NAME_CHAR_LEN*MAX_KEY, cs),
mem_root); mem_root);
item->flags|= ITEM_FLAG_MAYBE_NULL; item->set_maybe_null();
field_list.push_back(item=new (mem_root) field_list.push_back(item=new (mem_root)
Item_empty_string(this, "key", NAME_CHAR_LEN, cs), Item_empty_string(this, "key", NAME_CHAR_LEN, cs),
mem_root); mem_root);
item->flags|= ITEM_FLAG_MAYBE_NULL; item->set_maybe_null();
field_list.push_back(item=new (mem_root) field_list.push_back(item=new (mem_root)
Item_empty_string(this, "key_len", Item_empty_string(this, "key_len",
NAME_CHAR_LEN*MAX_KEY), NAME_CHAR_LEN*MAX_KEY),
mem_root); mem_root);
item->flags|= ITEM_FLAG_MAYBE_NULL; item->set_maybe_null();
field_list.push_back(item=new (mem_root) field_list.push_back(item=new (mem_root)
Item_empty_string(this, "ref", Item_empty_string(this, "ref",
NAME_CHAR_LEN*MAX_REF_PARTS, cs), NAME_CHAR_LEN*MAX_REF_PARTS, cs),
mem_root); mem_root);
item->flags|= ITEM_FLAG_MAYBE_NULL; item->set_maybe_null();
field_list.push_back(item=new (mem_root) field_list.push_back(item=new (mem_root)
Item_empty_string(this, "rows", NAME_CHAR_LEN, cs), Item_empty_string(this, "rows", NAME_CHAR_LEN, cs),
mem_root); mem_root);
@@ -2758,7 +2758,7 @@ void THD::make_explain_field_list(List<Item> &field_list, uint8 explain_flags,
field_list.push_back(item= new (mem_root) field_list.push_back(item= new (mem_root)
Item_empty_string(this, "r_rows", NAME_CHAR_LEN, cs), Item_empty_string(this, "r_rows", NAME_CHAR_LEN, cs),
mem_root); mem_root);
item->flags|= ITEM_FLAG_MAYBE_NULL; item->set_maybe_null();
} }
if (is_analyze || (explain_flags & DESCRIBE_EXTENDED)) if (is_analyze || (explain_flags & DESCRIBE_EXTENDED))
@@ -2766,7 +2766,7 @@ void THD::make_explain_field_list(List<Item> &field_list, uint8 explain_flags,
field_list.push_back(item= new (mem_root) field_list.push_back(item= new (mem_root)
Item_float(this, "filtered", 0.1234, 2, 4), Item_float(this, "filtered", 0.1234, 2, 4),
mem_root); mem_root);
item->flags|= ITEM_FLAG_MAYBE_NULL; item->set_maybe_null();
} }
if (is_analyze) if (is_analyze)
@@ -2774,10 +2774,10 @@ void THD::make_explain_field_list(List<Item> &field_list, uint8 explain_flags,
field_list.push_back(item= new (mem_root) field_list.push_back(item= new (mem_root)
Item_float(this, "r_filtered", 0.1234, 2, 4), Item_float(this, "r_filtered", 0.1234, 2, 4),
mem_root); 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) field_list.push_back(new (mem_root)
Item_empty_string(this, "Extra", 255, cs), Item_empty_string(this, "Extra", 255, cs),
mem_root); mem_root);

View File

@@ -993,7 +993,7 @@ With_element::process_columns_of_derived_unit(THD *thd,
while ((item= it++, name= nm++)) while ((item= it++, name= nm++))
{ {
item->set_name(thd, *name); item->set_name(thd, *name);
item->flags&= ~ITEM_FLAG_IS_AUTOGENERATED_NAME; item->base_flags&= ~item_base_t::IS_AUTOGENERATED_NAME;
} }
if (arena) if (arena)
@@ -1036,7 +1036,7 @@ With_element::process_columns_of_derived_unit(THD *thd,
my_error(ER_BAD_FIELD_ERROR, MYF(0), name->str, "CYCLE clause"); my_error(ER_BAD_FIELD_ERROR, MYF(0), name->str, "CYCLE clause");
return true; 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; unit->columns_are_renamed= true;

View File

@@ -18731,7 +18731,7 @@ bool Create_tmp_table::add_fields(THD *thd,
new_field->maybe_null() is still false, it will be new_field->maybe_null() is still false, it will be
changed below. But we have to setup Item_field correctly changed below. But we have to setup Item_field correctly
*/ */
arg->flags|= ITEM_FLAG_MAYBE_NULL; arg->set_maybe_null();
} }
if (current_counter == distinct) if (current_counter == distinct)
new_field->flags|= FIELD_PART_OF_TMP_UNIQUE; new_field->flags|= FIELD_PART_OF_TMP_UNIQUE;
@@ -19133,7 +19133,7 @@ bool Create_tmp_table::finalize(THD *thd,
that the key,field and item definition match. that the key,field and item definition match.
*/ */
maybe_null= 0; 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, if (!(cur_group->field= field->new_key_field(thd->mem_root,table,
@@ -25119,7 +25119,7 @@ count_field_types(SELECT_LEX *select_lex, TMP_TABLE_PARAM *param,
{ {
param->func_count++; param->func_count++;
if (reset_with_sum_func) if (reset_with_sum_func)
field->flags&= ~ITEM_FLAG_WITH_SUM_FUNC; field->with_flags&= ~item_with_t::SUM_FUNC;
} }
} }
} }
@@ -26192,7 +26192,7 @@ static bool change_group_ref(THD *thd, Item_func *expr, ORDER *group_list,
} }
if (arg_changed) 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; *changed= TRUE;
} }
} }
@@ -26263,7 +26263,7 @@ bool JOIN::rollup_init()
{ {
if (*group_tmp->item == item) 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; found_in_group= 1;
break; break;
} }
@@ -26279,7 +26279,7 @@ bool JOIN::rollup_init()
Marking the expression item as 'with_sum_func' will ensure this. Marking the expression item as 'with_sum_func' will ensure this.
*/ */
if (changed) if (changed)
item->flags|= ITEM_FLAG_WITH_SUM_FUNC; item->with_flags|= item_with_t::SUM_FUNC;
} }
} }
return 0; return 0;
@@ -26449,7 +26449,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); Item_null_result *null_item= new (thd->mem_root) Item_null_result(thd);
if (!null_item) if (!null_item)
return 1; 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(); null_item->result_field= item->get_tmp_table_field();
item= null_item; item= null_item;
break; break;

View File

@@ -2865,7 +2865,7 @@ void mysqld_list_processes(THD *thd,const char *user, bool verbose)
field_list.push_back(field=new (mem_root) field_list.push_back(field=new (mem_root)
Item_empty_string(thd, "db", NAME_CHAR_LEN), Item_empty_string(thd, "db", NAME_CHAR_LEN),
mem_root); 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), field_list.push_back(new (mem_root) Item_empty_string(thd, "Command", 16),
mem_root); mem_root);
field_list.push_back(field= new (mem_root) field_list.push_back(field= new (mem_root)
@@ -2875,18 +2875,18 @@ void mysqld_list_processes(THD *thd,const char *user, bool verbose)
field_list.push_back(field=new (mem_root) field_list.push_back(field=new (mem_root)
Item_empty_string(thd, "State", 30), Item_empty_string(thd, "State", 30),
mem_root); mem_root);
field->flags|= ITEM_FLAG_MAYBE_NULL;; field->set_maybe_null();;
field_list.push_back(field=new (mem_root) field_list.push_back(field=new (mem_root)
Item_empty_string(thd, "Info", arg.max_query_length), Item_empty_string(thd, "Info", arg.max_query_length),
mem_root); mem_root);
field->flags|= ITEM_FLAG_MAYBE_NULL;; field->set_maybe_null();;
if (!thd->variables.old_mode && if (!thd->variables.old_mode &&
!(thd->variables.old_behavior & OLD_MODE_NO_PROGRESS_INFO)) !(thd->variables.old_behavior & OLD_MODE_NO_PROGRESS_INFO))
{ {
field_list.push_back(field= new (mem_root) field_list.push_back(field= new (mem_root)
Item_float(thd, "Progress", 0.0, 3, 7), Item_float(thd, "Progress", 0.0, 3, 7),
mem_root); 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, if (protocol->send_result_set_metadata(&field_list,
Protocol::SEND_NUM_ROWS | Protocol::SEND_NUM_ROWS |
@@ -9767,7 +9767,7 @@ static bool show_create_trigger_impl(THD *thd, Trigger *trigger)
(uint)MY_MAX(trg_sql_original_stmt.length, (uint)MY_MAX(trg_sql_original_stmt.length,
1024)); 1024));
stmt_fld->flags|= ITEM_FLAG_MAYBE_NULL; stmt_fld->set_maybe_null();
fields.push_back(stmt_fld, mem_root); fields.push_back(stmt_fld, mem_root);
} }

View File

@@ -11816,12 +11816,12 @@ bool mysql_checksum_table(THD *thd, TABLE_LIST *tables,
field_list.push_back(item= new (thd->mem_root) field_list.push_back(item= new (thd->mem_root)
Item_empty_string(thd, "Table", NAME_LEN*2), Item_empty_string(thd, "Table", NAME_LEN*2),
thd->mem_root); thd->mem_root);
item->flags|= ITEM_FLAG_MAYBE_NULL; item->set_maybe_null();
field_list.push_back(item= new (thd->mem_root) field_list.push_back(item= new (thd->mem_root)
Item_int(thd, "Checksum", (longlong) 1, Item_int(thd, "Checksum", (longlong) 1,
MY_INT64_NUM_DECIMAL_DIGITS), MY_INT64_NUM_DECIMAL_DIGITS),
thd->mem_root); thd->mem_root);
item->flags|= ITEM_FLAG_MAYBE_NULL; item->set_maybe_null();
if (protocol->send_result_set_metadata(&field_list, if (protocol->send_result_set_metadata(&field_list,
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);

View File

@@ -4792,7 +4792,8 @@ bool Type_handler_temporal_result::
continue; // No conversion. continue; // No conversion.
if (ha->cmp_type() != TIME_RESULT) 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; break;
} }
timestamp_type tf= hf->mysql_timestamp_type(); timestamp_type tf= hf->mysql_timestamp_type();
@@ -4843,7 +4844,7 @@ bool Type_handler_temporal_result::
DBUG_ASSERT(hf->field_type() == MYSQL_TYPE_DATETIME); DBUG_ASSERT(hf->field_type() == MYSQL_TYPE_DATETIME);
if (!(thd->variables.old_behavior & OLD_MODE_ZERO_DATE_TIME_CAST)) if (!(thd->variables.old_behavior & OLD_MODE_ZERO_DATE_TIME_CAST))
continue; continue;
func->flags|= ITEM_FLAG_MAYBE_NULL; func->set_maybe_null();
break; break;
} }
return rc; return rc;
@@ -4867,7 +4868,7 @@ bool Type_handler_date_common::
{ {
if (items[i]->type_handler()->cmp_type() != TIME_RESULT) if (items[i]->type_handler()->cmp_type() != TIME_RESULT)
{ {
func->flags|= ITEM_FLAG_MAYBE_NULL; func->set_maybe_null();
break; break;
} }
} }
@@ -6749,7 +6750,7 @@ bool Type_handler::
item->arguments()[0]->time_precision(current_thd) : item->arguments()[0]->time_precision(current_thd) :
item->decimals; item->decimals;
item->fix_attributes_temporal(MIN_TIME_WIDTH, dec); item->fix_attributes_temporal(MIN_TIME_WIDTH, dec);
item->flags|= ITEM_FLAG_MAYBE_NULL; item->set_maybe_null();
return false; return false;
} }
@@ -6758,7 +6759,7 @@ bool Type_handler::
Item_date_typecast_fix_length_and_dec(Item_date_typecast *item) const Item_date_typecast_fix_length_and_dec(Item_date_typecast *item) const
{ {
item->fix_attributes_temporal(MAX_DATE_WIDTH, 0); item->fix_attributes_temporal(MAX_DATE_WIDTH, 0);
item->flags|= ITEM_FLAG_MAYBE_NULL; item->set_maybe_null();
return false; return false;
} }
@@ -6771,7 +6772,7 @@ bool Type_handler::
item->arguments()[0]->datetime_precision(current_thd) : item->arguments()[0]->datetime_precision(current_thd) :
item->decimals; item->decimals;
item->fix_attributes_temporal(MAX_DATETIME_WIDTH, dec); item->fix_attributes_temporal(MAX_DATETIME_WIDTH, dec);
item->flags|= ITEM_FLAG_MAYBE_NULL; item->set_maybe_null();
return false; return false;
} }

View File

@@ -137,7 +137,7 @@ bool check_duplicate_names(THD *thd, List<Item> &item_list, bool gen_unique_view
Item *check; Item *check;
/* treat underlying fields like set by user names */ /* treat underlying fields like set by user names */
if (item->real_item()->type() == Item::FIELD_ITEM) 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(); itc.rewind();
while ((check= itc++) && check != item) while ((check= itc++) && check != item)
{ {
@@ -566,7 +566,7 @@ bool mysql_create_view(THD *thd, TABLE_LIST *views,
while ((item= it++, name= nm++)) while ((item= it++, name= nm++))
{ {
item->set_name(thd, *name); item->set_name(thd, *name);
item->flags&= ~ITEM_FLAG_IS_AUTOGENERATED_NAME; item->base_flags&= ~item_base_t::IS_AUTOGENERATED_NAME;
} }
} }

View File

@@ -9223,7 +9223,7 @@ select_item:
if (unlikely(Lex->sql_command == SQLCOM_CREATE_VIEW && if (unlikely(Lex->sql_command == SQLCOM_CREATE_VIEW &&
check_column_name($4.str))) check_column_name($4.str)))
my_yyabort_error((ER_WRONG_COLUMN_NAME, MYF(0), $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); $2->set_name(thd, $4);
} }
else if (!$2->name.str || $2->name.str == item_empty_name) else if (!$2->name.str || $2->name.str == item_empty_name)
@@ -10801,7 +10801,7 @@ udf_expr:
*/ */
if ($4.str) if ($4.str)
{ {
$2->flags&= ~ITEM_FLAG_IS_AUTOGENERATED_NAME; $2->base_flags&= ~item_base_t::IS_AUTOGENERATED_NAME;
$2->set_name(thd, $4); $2->set_name(thd, $4);
} }
/* /*

View File

@@ -6854,7 +6854,7 @@ Item *create_view_field(THD *thd, TABLE_LIST *view, Item **field_ref,
views/derived tables. views/derived tables.
*/ */
if (view->table && view->table->maybe_null) 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. */ /* Save item in case we will need to fall back to materialization. */
view->used_items.push_front(item, thd->mem_root); view->used_items.push_front(item, thd->mem_root);
/* /*