summaryrefslogtreecommitdiff
path: root/sql/item_func.cc
diff options
context:
space:
mode:
authorMonty <monty@mariadb.org>2020-09-02 03:13:32 +0300
committerSergei Golubchik <serg@mariadb.org>2021-05-19 22:27:28 +0200
commit6079b46d8d371262882d1bbe7ebeec23b2f83075 (patch)
treead649946b27e58e5b451b6bbd470d14d1c161189 /sql/item_func.cc
parent7ca4e381f7af59dad07aebc5dc4f467b235ab962 (diff)
downloadmariadb-git-6079b46d8d371262882d1bbe7ebeec23b2f83075.tar.gz
Split item->flags into base_flags and with_flags
This was done to simplify copying of with_* flags Other things: - Changed Flags to C++ enums, which enables gdb to print out bit values for the flags. This also enables compiler errors if one tries to manipulate a non existing bit in a variable. - Added set_maybe_null() as a shortcut as setting the MAYBE_NULL flags was used in a LOT of places. - Renamed PARAM flag to SP_VAR to ensure it's not confused with persistent statement parameters.
Diffstat (limited to 'sql/item_func.cc')
-rw-r--r--sql/item_func.cc52
1 files changed, 23 insertions, 29 deletions
diff --git a/sql/item_func.cc b/sql/item_func.cc
index 67251b73faf..21aaebdd52e 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -133,12 +133,7 @@ void Item_func::sync_with_sum_func_and_with_field(List<Item> &list)
List_iterator_fast<Item> li(list);
Item *item;
while ((item= li++))
- {
- flags|= (item->flags & (ITEM_FLAG_WITH_SUM_FUNC |
- ITEM_FLAG_WITH_WINDOW_FUNC |
- ITEM_FLAG_WITH_FIELD |
- ITEM_FLAG_WITH_PARAM));
- }
+ with_flags|= item->with_flags;
}
@@ -353,8 +348,8 @@ Item_func::fix_fields(THD *thd, Item **ref)
return TRUE; /* purecov: inspected */
item= *arg;
- flags|= item->flags & ~(ITEM_FLAG_IS_AUTOGENERATED_NAME |
- ITEM_FLAG_IS_IN_WITH_CYCLE);
+ base_flags|= item->base_flags & item_base_t::MAYBE_NULL;
+ with_flags|= item->with_flags;
used_tables_and_const_cache_join(item);
not_null_tables_cache|= item->not_null_tables();
}
@@ -363,7 +358,7 @@ Item_func::fix_fields(THD *thd, Item **ref)
return true;
if (fix_length_and_dec())
return TRUE;
- flags|= ITEM_FLAG_FIXED;
+ base_flags|= item_base_t::FIXED;
return FALSE;
}
@@ -379,7 +374,7 @@ Item_func::quick_fix_field()
(*arg)->quick_fix_field();
}
}
- flags|= ITEM_FLAG_FIXED;
+ base_flags|= item_base_t::FIXED;
}
@@ -593,9 +588,12 @@ void Item_func::split_sum_func(THD *thd, Ref_ptr_array ref_pointer_array,
List<Item> &fields, uint flags)
{
Item **arg, **arg_end;
+ DBUG_ENTER("Item_func::split_sum_func");
+
for (arg= args, arg_end= args+arg_count; arg != arg_end ; arg++)
(*arg)->split_sum_func2(thd, ref_pointer_array, fields, arg,
flags | SPLIT_SUM_SKIP_REGISTERED);
+ DBUG_VOID_RETURN;
}
@@ -1586,7 +1584,7 @@ bool Item_func_div::fix_length_and_dec()
DBUG_ENTER("Item_func_div::fix_length_and_dec");
DBUG_PRINT("info", ("name %s", func_name()));
prec_increment= current_thd->variables.div_precincrement;
- flags|= ITEM_FLAG_MAYBE_NULL; // division by zero
+ set_maybe_null(); // division by zero
const Type_aggregator *aggregator= &type_handler_data->m_type_aggregator_for_div;
DBUG_EXECUTE_IF("num_op", aggregator= &type_handler_data->m_type_aggregator_non_commutative_test;);
@@ -1664,7 +1662,7 @@ bool Item_func_int_div::fix_length_and_dec()
uint32 prec= args[0]->decimal_int_part();
set_if_smaller(prec, MY_INT64_NUM_DECIMAL_DIGITS);
fix_char_length(prec);
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
unsigned_flag=args[0]->unsigned_flag | args[1]->unsigned_flag;
return false;
}
@@ -1744,7 +1742,7 @@ bool Item_func_mod::fix_length_and_dec()
{
DBUG_ENTER("Item_func_mod::fix_length_and_dec");
DBUG_PRINT("info", ("name %s", func_name()));
- flags|= ITEM_FLAG_MAYBE_NULL; // division by zero
+ set_maybe_null(); // division by zero
const Type_aggregator *aggregator= &type_handler_data->m_type_aggregator_for_mod;
DBUG_EXECUTE_IF("num_op", aggregator= &type_handler_data->m_type_aggregator_non_commutative_test;);
DBUG_ASSERT(!aggregator->is_commutative());
@@ -2553,7 +2551,7 @@ void Item_func_round::fix_arg_datetime()
return NULL.
*/
if (!truncate)
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
fix_arg_temporal(&type_handler_datetime2, MAX_DATETIME_WIDTH);
}
@@ -3235,7 +3233,7 @@ longlong Item_func_field::val_int()
bool Item_func_field::fix_length_and_dec()
{
- flags&= (item_flags_t) ~ITEM_FLAG_MAYBE_NULL;
+ base_flags&= ~item_base_t::MAYBE_NULL;
max_length=3;
cmp_type= args[0]->result_type();
for (uint i=1; i < arg_count ; i++)
@@ -3479,7 +3477,7 @@ udf_handler::fix_fields(THD *thd, Item_func_or_sum *func,
args=arguments;
/* Fix all arguments */
- func->flags&= (Item::item_flags_t) ~ITEM_FLAG_MAYBE_NULL;
+ func->base_flags&= ~item_base_t::MAYBE_NULL;
func->used_tables_and_const_cache_init();
if ((f_args.arg_count=arg_count))
@@ -3514,12 +3512,8 @@ udf_handler::fix_fields(THD *thd, Item_func_or_sum *func,
*/
if (item->collation.collation->state & MY_CS_BINSORT)
func->collation.set(&my_charset_bin);
- func->flags|= (item->flags & (ITEM_FLAG_MAYBE_NULL |
- ITEM_FLAG_WITH_SUM_FUNC |
- ITEM_FLAG_WITH_WINDOW_FUNC |
- ITEM_FLAG_WITH_FIELD |
- ITEM_FLAG_WITH_PARAM |
- ITEM_FLAG_WITH_SUBQUERY));
+ func->base_flags|= item->base_flags & item_base_t::MAYBE_NULL;
+ func->with_flags|= item->with_flags;
func->used_tables_and_const_cache_join(item);
f_args.arg_type[i]=item->result_type();
}
@@ -4789,7 +4783,7 @@ bool Item_func_set_user_var::fix_fields(THD *thd, Item **ref)
bool
Item_func_set_user_var::fix_length_and_dec()
{
- flags|= (args[0]->flags & ITEM_FLAG_MAYBE_NULL);
+ base_flags|= (args[0]->base_flags & item_base_t::MAYBE_NULL);
decimals=args[0]->decimals;
if (args[0]->collation.derivation == DERIVATION_NUMERIC)
{
@@ -5646,7 +5640,7 @@ bool Item_func_get_user_var::fix_length_and_dec()
{
THD *thd=current_thd;
int error;
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
decimals=NOT_FIXED_DEC;
max_length=MAX_BLOB_WIDTH;
@@ -5856,7 +5850,7 @@ void Item_func_get_system_var::update_null_value()
bool Item_func_get_system_var::fix_length_and_dec()
{
char *cptr;
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
max_length= 0;
if (var->check_type(var_type))
@@ -6219,7 +6213,7 @@ bool Item_func_match::fix_fields(THD *thd, Item **ref)
status_var_increment(thd->status_var.feature_fulltext);
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
join_key=0;
/*
@@ -6555,7 +6549,7 @@ Item_func_sp::Item_func_sp(THD *thd, Name_resolution_context *context_arg,
sp_name *name, const Sp_handler *sph):
Item_func(thd), Item_sp(thd, context_arg, name), m_handler(sph)
{
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
}
@@ -6564,7 +6558,7 @@ Item_func_sp::Item_func_sp(THD *thd, Name_resolution_context *context_arg,
List<Item> &list):
Item_func(thd, list), Item_sp(thd, context_arg, name_arg), m_handler(sph)
{
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
}
@@ -6620,7 +6614,7 @@ bool Item_func_sp::fix_length_and_dec()
Type_std_attributes::set(sp_result_field->type_std_attributes());
// There is a bug in the line below. See MDEV-11292 for details.
collation.derivation= DERIVATION_COERCIBLE;
- flags|= ITEM_FLAG_MAYBE_NULL;
+ set_maybe_null();
DBUG_RETURN(FALSE);
}