mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
Remove calls to current_thd() in Item functions
- Added THD argument to functions that calls current_thd() or new without a mem_root argument: make_same(), set_comparator_func(), set_cmp_func(), set_cmp_func*(), set_aggregator() and prepare_sum_aggregators() - Changed "new Class" to "new (thd->mem_root) Class" Almost all changes mechanical, no logic changes.
This commit is contained in:
committed by
Sergei Golubchik
parent
3105c9e7a5
commit
9448548481
@@ -601,9 +601,9 @@ public:
|
|||||||
DBUG_ASSERT(!tmp->m_null_value);
|
DBUG_ASSERT(!tmp->m_null_value);
|
||||||
return m_native.cmp(tmp->m_native);
|
return m_native.cmp(tmp->m_native);
|
||||||
}
|
}
|
||||||
cmp_item *make_same() override
|
cmp_item *make_same(THD *thd) override
|
||||||
{
|
{
|
||||||
return new cmp_item_inet6();
|
return new (thd->mem_root) cmp_item_inet6();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -697,9 +697,9 @@ public:
|
|||||||
DBUG_ASSERT(b.length() == Inet6::binary_length());
|
DBUG_ASSERT(b.length() == Inet6::binary_length());
|
||||||
return memcmp(a.ptr(), b.ptr(), Inet6::binary_length());
|
return memcmp(a.ptr(), b.ptr(), Inet6::binary_length());
|
||||||
}
|
}
|
||||||
bool set_comparator_func(Arg_comparator *cmp) const override
|
bool set_comparator_func(THD *thd, Arg_comparator *cmp) const override
|
||||||
{
|
{
|
||||||
return cmp->set_cmp_func_native();
|
return cmp->set_cmp_func_native(thd);
|
||||||
}
|
}
|
||||||
bool Item_const_eq(const Item_const *a, const Item_const *b,
|
bool Item_const_eq(const Item_const *a, const Item_const *b,
|
||||||
bool binary_cmp) const override
|
bool binary_cmp) const override
|
||||||
|
@@ -355,8 +355,9 @@ static bool convert_const_to_int(THD *thd, Item_field *field_item,
|
|||||||
|
|
||||||
if (0 == field_cmp)
|
if (0 == field_cmp)
|
||||||
{
|
{
|
||||||
Item *tmp= new (thd->mem_root) Item_int_with_ref(thd, field->val_int(), *item,
|
Item *tmp= (new (thd->mem_root)
|
||||||
MY_TEST(field->flags & UNSIGNED_FLAG));
|
Item_int_with_ref(thd, field->val_int(), *item,
|
||||||
|
MY_TEST(field->flags & UNSIGNED_FLAG)));
|
||||||
if (tmp)
|
if (tmp)
|
||||||
thd->change_item_tree(item, tmp);
|
thd->change_item_tree(item, tmp);
|
||||||
result= 1; // Item was replaced
|
result= 1; // Item was replaced
|
||||||
@@ -418,7 +419,7 @@ bool Item_func::setup_args_and_comparator(THD *thd, Arg_comparator *cmp)
|
|||||||
DBUG_ASSERT(functype() != LIKE_FUNC);
|
DBUG_ASSERT(functype() != LIKE_FUNC);
|
||||||
convert_const_compared_to_int_field(thd);
|
convert_const_compared_to_int_field(thd);
|
||||||
|
|
||||||
return cmp->set_cmp_func(this, &args[0], &args[1], true);
|
return cmp->set_cmp_func(thd, this, &args[0], &args[1], true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -466,7 +467,7 @@ bool Item_bool_rowready_func2::fix_length_and_dec()
|
|||||||
items, holding the cached converted value of the original (constant) item.
|
items, holding the cached converted value of the original (constant) item.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int Arg_comparator::set_cmp_func(Item_func_or_sum *owner_arg,
|
int Arg_comparator::set_cmp_func(THD *thd, Item_func_or_sum *owner_arg,
|
||||||
Item **a1, Item **a2)
|
Item **a1, Item **a2)
|
||||||
{
|
{
|
||||||
owner= owner_arg;
|
owner= owner_arg;
|
||||||
@@ -477,15 +478,15 @@ int Arg_comparator::set_cmp_func(Item_func_or_sum *owner_arg,
|
|||||||
Type_handler_hybrid_field_type tmp;
|
Type_handler_hybrid_field_type tmp;
|
||||||
if (tmp.aggregate_for_comparison(owner_arg->func_name(), tmp_args, 2, false))
|
if (tmp.aggregate_for_comparison(owner_arg->func_name(), tmp_args, 2, false))
|
||||||
{
|
{
|
||||||
DBUG_ASSERT(current_thd->is_error());
|
DBUG_ASSERT(thd->is_error());
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
m_compare_handler= tmp.type_handler();
|
m_compare_handler= tmp.type_handler();
|
||||||
return m_compare_handler->set_comparator_func(this);
|
return m_compare_handler->set_comparator_func(thd, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Arg_comparator::set_cmp_func_for_row_arguments()
|
bool Arg_comparator::set_cmp_func_for_row_arguments(THD *thd)
|
||||||
{
|
{
|
||||||
uint n= (*a)->cols();
|
uint n= (*a)->cols();
|
||||||
if (n != (*b)->cols())
|
if (n != (*b)->cols())
|
||||||
@@ -494,7 +495,7 @@ bool Arg_comparator::set_cmp_func_for_row_arguments()
|
|||||||
comparators= 0;
|
comparators= 0;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!(comparators= new Arg_comparator[n]))
|
if (!(comparators= new (thd->mem_root) Arg_comparator[n]))
|
||||||
return true;
|
return true;
|
||||||
for (uint i=0; i < n; i++)
|
for (uint i=0; i < n; i++)
|
||||||
{
|
{
|
||||||
@@ -503,7 +504,7 @@ bool Arg_comparator::set_cmp_func_for_row_arguments()
|
|||||||
my_error(ER_OPERAND_COLUMNS, MYF(0), (*a)->element_index(i)->cols());
|
my_error(ER_OPERAND_COLUMNS, MYF(0), (*a)->element_index(i)->cols());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (comparators[i].set_cmp_func(owner, (*a)->addr(i),
|
if (comparators[i].set_cmp_func(thd, owner, (*a)->addr(i),
|
||||||
(*b)->addr(i), set_null))
|
(*b)->addr(i), set_null))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -511,17 +512,16 @@ bool Arg_comparator::set_cmp_func_for_row_arguments()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Arg_comparator::set_cmp_func_row()
|
bool Arg_comparator::set_cmp_func_row(THD *thd)
|
||||||
{
|
{
|
||||||
func= is_owner_equal_func() ? &Arg_comparator::compare_e_row :
|
func= is_owner_equal_func() ? &Arg_comparator::compare_e_row :
|
||||||
&Arg_comparator::compare_row;
|
&Arg_comparator::compare_row;
|
||||||
return set_cmp_func_for_row_arguments();
|
return set_cmp_func_for_row_arguments(thd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Arg_comparator::set_cmp_func_string()
|
bool Arg_comparator::set_cmp_func_string(THD *thd)
|
||||||
{
|
{
|
||||||
THD *thd= current_thd;
|
|
||||||
func= is_owner_equal_func() ? &Arg_comparator::compare_e_string :
|
func= is_owner_equal_func() ? &Arg_comparator::compare_e_string :
|
||||||
&Arg_comparator::compare_string;
|
&Arg_comparator::compare_string;
|
||||||
if (compare_type() == STRING_RESULT &&
|
if (compare_type() == STRING_RESULT &&
|
||||||
@@ -557,9 +557,8 @@ bool Arg_comparator::set_cmp_func_string()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Arg_comparator::set_cmp_func_time()
|
bool Arg_comparator::set_cmp_func_time(THD *thd)
|
||||||
{
|
{
|
||||||
THD *thd= current_thd;
|
|
||||||
m_compare_collation= &my_charset_numeric;
|
m_compare_collation= &my_charset_numeric;
|
||||||
func= is_owner_equal_func() ? &Arg_comparator::compare_e_time :
|
func= is_owner_equal_func() ? &Arg_comparator::compare_e_time :
|
||||||
&Arg_comparator::compare_time;
|
&Arg_comparator::compare_time;
|
||||||
@@ -569,9 +568,8 @@ bool Arg_comparator::set_cmp_func_time()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Arg_comparator::set_cmp_func_datetime()
|
bool Arg_comparator::set_cmp_func_datetime(THD *thd)
|
||||||
{
|
{
|
||||||
THD *thd= current_thd;
|
|
||||||
m_compare_collation= &my_charset_numeric;
|
m_compare_collation= &my_charset_numeric;
|
||||||
func= is_owner_equal_func() ? &Arg_comparator::compare_e_datetime :
|
func= is_owner_equal_func() ? &Arg_comparator::compare_e_datetime :
|
||||||
&Arg_comparator::compare_datetime;
|
&Arg_comparator::compare_datetime;
|
||||||
@@ -581,9 +579,8 @@ bool Arg_comparator::set_cmp_func_datetime()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Arg_comparator::set_cmp_func_native()
|
bool Arg_comparator::set_cmp_func_native(THD *thd)
|
||||||
{
|
{
|
||||||
THD *thd= current_thd;
|
|
||||||
m_compare_collation= &my_charset_numeric;
|
m_compare_collation= &my_charset_numeric;
|
||||||
func= is_owner_equal_func() ? &Arg_comparator::compare_e_native :
|
func= is_owner_equal_func() ? &Arg_comparator::compare_e_native :
|
||||||
&Arg_comparator::compare_native;
|
&Arg_comparator::compare_native;
|
||||||
@@ -593,9 +590,8 @@ bool Arg_comparator::set_cmp_func_native()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Arg_comparator::set_cmp_func_int()
|
bool Arg_comparator::set_cmp_func_int(THD *thd)
|
||||||
{
|
{
|
||||||
THD *thd= current_thd;
|
|
||||||
func= is_owner_equal_func() ? &Arg_comparator::compare_e_int :
|
func= is_owner_equal_func() ? &Arg_comparator::compare_e_int :
|
||||||
&Arg_comparator::compare_int_signed;
|
&Arg_comparator::compare_int_signed;
|
||||||
if ((*a)->field_type() == MYSQL_TYPE_YEAR &&
|
if ((*a)->field_type() == MYSQL_TYPE_YEAR &&
|
||||||
@@ -624,7 +620,7 @@ bool Arg_comparator::set_cmp_func_int()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Arg_comparator::set_cmp_func_real()
|
bool Arg_comparator::set_cmp_func_real(THD *thd)
|
||||||
{
|
{
|
||||||
if ((((*a)->result_type() == DECIMAL_RESULT && !(*a)->const_item() &&
|
if ((((*a)->result_type() == DECIMAL_RESULT && !(*a)->const_item() &&
|
||||||
(*b)->result_type() == STRING_RESULT && (*b)->const_item()) ||
|
(*b)->result_type() == STRING_RESULT && (*b)->const_item()) ||
|
||||||
@@ -639,10 +635,9 @@ bool Arg_comparator::set_cmp_func_real()
|
|||||||
Do comparison as decimal rather than float, in order not to lose precision.
|
Do comparison as decimal rather than float, in order not to lose precision.
|
||||||
*/
|
*/
|
||||||
m_compare_handler= &type_handler_newdecimal;
|
m_compare_handler= &type_handler_newdecimal;
|
||||||
return set_cmp_func_decimal();
|
return set_cmp_func_decimal(thd);
|
||||||
}
|
}
|
||||||
|
|
||||||
THD *thd= current_thd;
|
|
||||||
func= is_owner_equal_func() ? &Arg_comparator::compare_e_real :
|
func= is_owner_equal_func() ? &Arg_comparator::compare_e_real :
|
||||||
&Arg_comparator::compare_real;
|
&Arg_comparator::compare_real;
|
||||||
if ((*a)->decimals < NOT_FIXED_DEC && (*b)->decimals < NOT_FIXED_DEC)
|
if ((*a)->decimals < NOT_FIXED_DEC && (*b)->decimals < NOT_FIXED_DEC)
|
||||||
@@ -658,9 +653,8 @@ bool Arg_comparator::set_cmp_func_real()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Arg_comparator::set_cmp_func_decimal()
|
bool Arg_comparator::set_cmp_func_decimal(THD *thd)
|
||||||
{
|
{
|
||||||
THD *thd= current_thd;
|
|
||||||
func= is_owner_equal_func() ? &Arg_comparator::compare_e_decimal :
|
func= is_owner_equal_func() ? &Arg_comparator::compare_e_decimal :
|
||||||
&Arg_comparator::compare_decimal;
|
&Arg_comparator::compare_decimal;
|
||||||
a= cache_converted_constant(thd, a, &a_cache, compare_type_handler());
|
a= cache_converted_constant(thd, a, &a_cache, compare_type_handler());
|
||||||
@@ -4019,24 +4013,24 @@ bool Predicant_to_list_comparator::make_unique_cmp_items(THD *thd,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
cmp_item* cmp_item_sort_string::make_same()
|
cmp_item* cmp_item_sort_string::make_same(THD *thd)
|
||||||
{
|
{
|
||||||
return new cmp_item_sort_string_in_static(cmp_charset);
|
return new (thd->mem_root) cmp_item_sort_string_in_static(cmp_charset);
|
||||||
}
|
}
|
||||||
|
|
||||||
cmp_item* cmp_item_int::make_same()
|
cmp_item* cmp_item_int::make_same(THD *thd)
|
||||||
{
|
{
|
||||||
return new cmp_item_int();
|
return new (thd->mem_root) cmp_item_int();
|
||||||
}
|
}
|
||||||
|
|
||||||
cmp_item* cmp_item_real::make_same()
|
cmp_item* cmp_item_real::make_same(THD *thd)
|
||||||
{
|
{
|
||||||
return new cmp_item_real();
|
return new (thd->mem_root) cmp_item_real();
|
||||||
}
|
}
|
||||||
|
|
||||||
cmp_item* cmp_item_row::make_same()
|
cmp_item* cmp_item_row::make_same(THD *thd)
|
||||||
{
|
{
|
||||||
return new cmp_item_row();
|
return new (thd->mem_root) cmp_item_row();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -4100,7 +4094,7 @@ void cmp_item_row::store_value_by_template(THD *thd, cmp_item *t, Item *item)
|
|||||||
item->null_value= 0;
|
item->null_value= 0;
|
||||||
for (uint i=0; i < n; i++)
|
for (uint i=0; i < n; i++)
|
||||||
{
|
{
|
||||||
if (!(comparators[i]= tmpl->comparators[i]->make_same()))
|
if (!(comparators[i]= tmpl->comparators[i]->make_same(thd)))
|
||||||
break; // new failed
|
break; // new failed
|
||||||
comparators[i]->store_value_by_template(thd, tmpl->comparators[i],
|
comparators[i]->store_value_by_template(thd, tmpl->comparators[i],
|
||||||
item->element_index(i));
|
item->element_index(i));
|
||||||
@@ -4184,9 +4178,9 @@ int cmp_item_decimal::compare(cmp_item *arg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
cmp_item* cmp_item_decimal::make_same()
|
cmp_item* cmp_item_decimal::make_same(THD *thd)
|
||||||
{
|
{
|
||||||
return new cmp_item_decimal();
|
return new (thd->mem_root) cmp_item_decimal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -4227,15 +4221,15 @@ int cmp_item_temporal::compare(cmp_item *ci)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
cmp_item *cmp_item_datetime::make_same()
|
cmp_item *cmp_item_datetime::make_same(THD *thd)
|
||||||
{
|
{
|
||||||
return new cmp_item_datetime();
|
return new (thd->mem_root) cmp_item_datetime();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
cmp_item *cmp_item_time::make_same()
|
cmp_item *cmp_item_time::make_same(THD *thd)
|
||||||
{
|
{
|
||||||
return new cmp_item_time();
|
return new (thd->mem_root) cmp_item_time();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -4275,9 +4269,9 @@ int cmp_item_timestamp::compare(cmp_item *arg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
cmp_item* cmp_item_timestamp::make_same()
|
cmp_item* cmp_item_timestamp::make_same(THD *thd)
|
||||||
{
|
{
|
||||||
return new cmp_item_timestamp();
|
return new (thd->mem_root) cmp_item_timestamp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -56,7 +56,8 @@ class Arg_comparator: public Sql_alloc
|
|||||||
Item *a_cache, *b_cache; // Cached values of a and b items
|
Item *a_cache, *b_cache; // Cached values of a and b items
|
||||||
// when one of arguments is NULL.
|
// when one of arguments is NULL.
|
||||||
|
|
||||||
int set_cmp_func(Item_func_or_sum *owner_arg, Item **a1, Item **a2);
|
int set_cmp_func(THD *thd, Item_func_or_sum *owner_arg,
|
||||||
|
Item **a1, Item **a2);
|
||||||
|
|
||||||
int compare_not_null_values(longlong val1, longlong val2)
|
int compare_not_null_values(longlong val1, longlong val2)
|
||||||
{
|
{
|
||||||
@@ -83,21 +84,21 @@ public:
|
|||||||
a_cache(0), b_cache(0) {};
|
a_cache(0), b_cache(0) {};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool set_cmp_func_for_row_arguments();
|
bool set_cmp_func_for_row_arguments(THD *thd);
|
||||||
bool set_cmp_func_row();
|
bool set_cmp_func_row(THD *thd);
|
||||||
bool set_cmp_func_string();
|
bool set_cmp_func_string(THD *thd);
|
||||||
bool set_cmp_func_time();
|
bool set_cmp_func_time(THD *thd);
|
||||||
bool set_cmp_func_datetime();
|
bool set_cmp_func_datetime(THD *thd);
|
||||||
bool set_cmp_func_native();
|
bool set_cmp_func_native(THD *thd);
|
||||||
bool set_cmp_func_int();
|
bool set_cmp_func_int(THD *thd);
|
||||||
bool set_cmp_func_real();
|
bool set_cmp_func_real(THD *thd);
|
||||||
bool set_cmp_func_decimal();
|
bool set_cmp_func_decimal(THD *thd);
|
||||||
|
|
||||||
inline int set_cmp_func(Item_func_or_sum *owner_arg,
|
inline int set_cmp_func(THD *thd, Item_func_or_sum *owner_arg,
|
||||||
Item **a1, Item **a2, bool set_null_arg)
|
Item **a1, Item **a2, bool set_null_arg)
|
||||||
{
|
{
|
||||||
set_null= set_null_arg;
|
set_null= set_null_arg;
|
||||||
return set_cmp_func(owner_arg, a1, a2);
|
return set_cmp_func(thd, owner_arg, a1, a2);
|
||||||
}
|
}
|
||||||
inline int compare() { return (this->*func)(); }
|
inline int compare() { return (this->*func)(); }
|
||||||
|
|
||||||
@@ -538,9 +539,9 @@ public:
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
bool fix_length_and_dec();
|
bool fix_length_and_dec();
|
||||||
int set_cmp_func()
|
int set_cmp_func(THD *thd)
|
||||||
{
|
{
|
||||||
return cmp.set_cmp_func(this, tmp_arg, tmp_arg + 1, true);
|
return cmp.set_cmp_func(thd, this, tmp_arg, tmp_arg + 1, true);
|
||||||
}
|
}
|
||||||
CHARSET_INFO *compare_collation() const { return cmp.compare_collation(); }
|
CHARSET_INFO *compare_collation() const { return cmp.compare_collation(); }
|
||||||
const Type_handler *compare_type_handler() const
|
const Type_handler *compare_type_handler() const
|
||||||
@@ -1560,7 +1561,7 @@ public:
|
|||||||
virtual int cmp_not_null(const Value *value)= 0;
|
virtual int cmp_not_null(const Value *value)= 0;
|
||||||
// for optimized IN with row
|
// for optimized IN with row
|
||||||
virtual int compare(cmp_item *item)= 0;
|
virtual int compare(cmp_item *item)= 0;
|
||||||
virtual cmp_item *make_same()= 0;
|
virtual cmp_item *make_same(THD *thd)= 0;
|
||||||
virtual void store_value_by_template(THD *thd, cmp_item *tmpl, Item *item)
|
virtual void store_value_by_template(THD *thd, cmp_item *tmpl, Item *item)
|
||||||
{
|
{
|
||||||
store_value(item);
|
store_value(item);
|
||||||
@@ -1633,7 +1634,7 @@ public:
|
|||||||
cmp_item_string *l_cmp= (cmp_item_string *) ci;
|
cmp_item_string *l_cmp= (cmp_item_string *) ci;
|
||||||
return sortcmp(value_res, l_cmp->value_res, cmp_charset);
|
return sortcmp(value_res, l_cmp->value_res, cmp_charset);
|
||||||
}
|
}
|
||||||
cmp_item *make_same();
|
cmp_item *make_same(THD *thd);
|
||||||
void set_charset(CHARSET_INFO *cs)
|
void set_charset(CHARSET_INFO *cs)
|
||||||
{
|
{
|
||||||
cmp_charset= cs;
|
cmp_charset= cs;
|
||||||
@@ -1667,7 +1668,7 @@ public:
|
|||||||
cmp_item_int *l_cmp= (cmp_item_int *)ci;
|
cmp_item_int *l_cmp= (cmp_item_int *)ci;
|
||||||
return (value < l_cmp->value) ? -1 : ((value == l_cmp->value) ? 0 : 1);
|
return (value < l_cmp->value) ? -1 : ((value == l_cmp->value) ? 0 : 1);
|
||||||
}
|
}
|
||||||
cmp_item *make_same();
|
cmp_item *make_same(THD *thd);
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1696,7 +1697,7 @@ public:
|
|||||||
}
|
}
|
||||||
int cmp_not_null(const Value *val);
|
int cmp_not_null(const Value *val);
|
||||||
int cmp(Item *arg);
|
int cmp(Item *arg);
|
||||||
cmp_item *make_same();
|
cmp_item *make_same(THD *thd);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -1713,7 +1714,7 @@ public:
|
|||||||
}
|
}
|
||||||
int cmp_not_null(const Value *val);
|
int cmp_not_null(const Value *val);
|
||||||
int cmp(Item *arg);
|
int cmp(Item *arg);
|
||||||
cmp_item *make_same();
|
cmp_item *make_same(THD *thd);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -1726,7 +1727,7 @@ public:
|
|||||||
int cmp_not_null(const Value *val);
|
int cmp_not_null(const Value *val);
|
||||||
int cmp(Item *arg);
|
int cmp(Item *arg);
|
||||||
int compare(cmp_item *ci);
|
int compare(cmp_item *ci);
|
||||||
cmp_item *make_same();
|
cmp_item *make_same(THD *thd);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -1756,7 +1757,7 @@ public:
|
|||||||
cmp_item_real *l_cmp= (cmp_item_real *) ci;
|
cmp_item_real *l_cmp= (cmp_item_real *) ci;
|
||||||
return (value < l_cmp->value)? -1 : ((value == l_cmp->value) ? 0 : 1);
|
return (value < l_cmp->value)? -1 : ((value == l_cmp->value) ? 0 : 1);
|
||||||
}
|
}
|
||||||
cmp_item *make_same();
|
cmp_item *make_same(THD *thd);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -1769,7 +1770,7 @@ public:
|
|||||||
int cmp(Item *arg);
|
int cmp(Item *arg);
|
||||||
int cmp_not_null(const Value *val);
|
int cmp_not_null(const Value *val);
|
||||||
int compare(cmp_item *c);
|
int compare(cmp_item *c);
|
||||||
cmp_item *make_same();
|
cmp_item *make_same(THD *thd);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -1806,7 +1807,7 @@ public:
|
|||||||
cmp_item_string *l_cmp= (cmp_item_string *) ci;
|
cmp_item_string *l_cmp= (cmp_item_string *) ci;
|
||||||
return sortcmp(value_res, l_cmp->value_res, cmp_charset);
|
return sortcmp(value_res, l_cmp->value_res, cmp_charset);
|
||||||
}
|
}
|
||||||
cmp_item *make_same()
|
cmp_item *make_same(THD *thd)
|
||||||
{
|
{
|
||||||
return new cmp_item_sort_string_in_static(cmp_charset);
|
return new cmp_item_sort_string_in_static(cmp_charset);
|
||||||
}
|
}
|
||||||
@@ -2515,7 +2516,7 @@ public:
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
int compare(cmp_item *arg);
|
int compare(cmp_item *arg);
|
||||||
cmp_item *make_same();
|
cmp_item *make_same(THD *thd);
|
||||||
void store_value_by_template(THD *thd, cmp_item *tmpl, Item *);
|
void store_value_by_template(THD *thd, cmp_item *tmpl, Item *);
|
||||||
friend class Item_func_in;
|
friend class Item_func_in;
|
||||||
cmp_item *get_comparator(uint i) { return comparators[i]; }
|
cmp_item *get_comparator(uint i) { return comparators[i]; }
|
||||||
|
@@ -118,6 +118,7 @@ void Item_subselect::init(st_select_lex *select_lex,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
SELECT_LEX *outer_select= unit->outer_select();
|
SELECT_LEX *outer_select= unit->outer_select();
|
||||||
|
THD *thd= unit->thd;
|
||||||
/*
|
/*
|
||||||
do not take into account expression inside aggregate functions because
|
do not take into account expression inside aggregate functions because
|
||||||
they can access original table fields
|
they can access original table fields
|
||||||
@@ -127,9 +128,11 @@ void Item_subselect::init(st_select_lex *select_lex,
|
|||||||
outer_select->parsing_place);
|
outer_select->parsing_place);
|
||||||
if (unit->is_unit_op() &&
|
if (unit->is_unit_op() &&
|
||||||
(unit->first_select()->next_select() || unit->fake_select_lex))
|
(unit->first_select()->next_select() || unit->fake_select_lex))
|
||||||
engine= new subselect_union_engine(unit, result, this);
|
engine= new (thd->mem_root)
|
||||||
|
subselect_union_engine(unit, result, this);
|
||||||
else
|
else
|
||||||
engine= new subselect_single_select_engine(select_lex, result, this);
|
engine= new (thd->mem_root)
|
||||||
|
subselect_single_select_engine(select_lex, result, this);
|
||||||
}
|
}
|
||||||
DBUG_PRINT("info", ("engine: %p", engine));
|
DBUG_PRINT("info", ("engine: %p", engine));
|
||||||
DBUG_VOID_RETURN;
|
DBUG_VOID_RETURN;
|
||||||
@@ -3318,7 +3321,7 @@ bool Item_exists_subselect::exists2in_processor(void *opt_arg)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
List<Item> *and_list= new List<Item>;
|
List<Item> *and_list= new (thd->mem_root) List<Item>;
|
||||||
if (!and_list)
|
if (!and_list)
|
||||||
{
|
{
|
||||||
res= TRUE;
|
res= TRUE;
|
||||||
@@ -3598,7 +3601,8 @@ bool Item_in_subselect::setup_mat_engine()
|
|||||||
select_engine= (subselect_single_select_engine*) engine;
|
select_engine= (subselect_single_select_engine*) engine;
|
||||||
|
|
||||||
/* Create/initialize execution objects. */
|
/* Create/initialize execution objects. */
|
||||||
if (!(mat_engine= new subselect_hash_sj_engine(thd, this, select_engine)))
|
if (!(mat_engine= new (thd->mem_root)
|
||||||
|
subselect_hash_sj_engine(thd, this, select_engine)))
|
||||||
DBUG_RETURN(TRUE);
|
DBUG_RETURN(TRUE);
|
||||||
|
|
||||||
if (mat_engine->prepare(thd) ||
|
if (mat_engine->prepare(thd) ||
|
||||||
@@ -3636,7 +3640,7 @@ bool Item_in_subselect::init_left_expr_cache()
|
|||||||
if (!outer_join || !outer_join->table_count || !outer_join->tables_list)
|
if (!outer_join || !outer_join->table_count || !outer_join->tables_list)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
if (!(left_expr_cache= new List<Cached_item>))
|
if (!(left_expr_cache= new (thd->mem_root) List<Cached_item>))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
for (uint i= 0; i < left_expr->cols(); i++)
|
for (uint i= 0; i < left_expr->cols(); i++)
|
||||||
@@ -3867,8 +3871,9 @@ int subselect_single_select_engine::prepare(THD *thd)
|
|||||||
{
|
{
|
||||||
select_lex->cleanup();
|
select_lex->cleanup();
|
||||||
}
|
}
|
||||||
join= new JOIN(thd, select_lex->item_list,
|
join= (new (thd->mem_root)
|
||||||
select_lex->options | SELECT_NO_UNLOCK, result);
|
JOIN(thd, select_lex->item_list,
|
||||||
|
select_lex->options | SELECT_NO_UNLOCK, result));
|
||||||
if (!join || !result)
|
if (!join || !result)
|
||||||
return 1; /* Fatal error is set already. */
|
return 1; /* Fatal error is set already. */
|
||||||
prepared= 1;
|
prepared= 1;
|
||||||
@@ -5280,7 +5285,7 @@ bool subselect_hash_sj_engine::make_semi_join_conds()
|
|||||||
tmp_table_ref->init_one_table(&empty_clex_str, &table_name, NULL, TL_READ);
|
tmp_table_ref->init_one_table(&empty_clex_str, &table_name, NULL, TL_READ);
|
||||||
tmp_table_ref->table= tmp_table;
|
tmp_table_ref->table= tmp_table;
|
||||||
|
|
||||||
context= new Name_resolution_context;
|
context= new (thd->mem_root) Name_resolution_context;
|
||||||
context->init();
|
context->init();
|
||||||
context->first_name_resolution_table=
|
context->first_name_resolution_table=
|
||||||
context->last_name_resolution_table= tmp_table_ref;
|
context->last_name_resolution_table= tmp_table_ref;
|
||||||
@@ -5348,7 +5353,8 @@ subselect_hash_sj_engine::make_unique_engine()
|
|||||||
tab->preread_init_done= FALSE;
|
tab->preread_init_done= FALSE;
|
||||||
tab->ref.tmp_table_index_lookup_init(thd, tmp_key, it, FALSE);
|
tab->ref.tmp_table_index_lookup_init(thd, tmp_key, it, FALSE);
|
||||||
|
|
||||||
DBUG_RETURN(new subselect_uniquesubquery_engine(thd, tab, item_in,
|
DBUG_RETURN(new (thd->mem_root)
|
||||||
|
subselect_uniquesubquery_engine(thd, tab, item_in,
|
||||||
semi_join_conds));
|
semi_join_conds));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5745,14 +5751,15 @@ int subselect_hash_sj_engine::exec()
|
|||||||
if (strategy == PARTIAL_MATCH_MERGE)
|
if (strategy == PARTIAL_MATCH_MERGE)
|
||||||
{
|
{
|
||||||
pm_engine=
|
pm_engine=
|
||||||
new subselect_rowid_merge_engine((subselect_uniquesubquery_engine*)
|
(new (thd->mem_root)
|
||||||
|
subselect_rowid_merge_engine((subselect_uniquesubquery_engine*)
|
||||||
lookup_engine, tmp_table,
|
lookup_engine, tmp_table,
|
||||||
count_pm_keys,
|
count_pm_keys,
|
||||||
has_covering_null_row,
|
has_covering_null_row,
|
||||||
has_covering_null_columns,
|
has_covering_null_columns,
|
||||||
count_columns_with_nulls,
|
count_columns_with_nulls,
|
||||||
item, result,
|
item, result,
|
||||||
semi_join_conds->argument_list());
|
semi_join_conds->argument_list()));
|
||||||
if (!pm_engine ||
|
if (!pm_engine ||
|
||||||
pm_engine->prepare(thd) ||
|
pm_engine->prepare(thd) ||
|
||||||
((subselect_rowid_merge_engine*) pm_engine)->
|
((subselect_rowid_merge_engine*) pm_engine)->
|
||||||
@@ -5772,13 +5779,14 @@ int subselect_hash_sj_engine::exec()
|
|||||||
if (strategy == PARTIAL_MATCH_SCAN)
|
if (strategy == PARTIAL_MATCH_SCAN)
|
||||||
{
|
{
|
||||||
if (!(pm_engine=
|
if (!(pm_engine=
|
||||||
new subselect_table_scan_engine((subselect_uniquesubquery_engine*)
|
(new (thd->mem_root)
|
||||||
|
subselect_table_scan_engine((subselect_uniquesubquery_engine*)
|
||||||
lookup_engine, tmp_table,
|
lookup_engine, tmp_table,
|
||||||
item, result,
|
item, result,
|
||||||
semi_join_conds->argument_list(),
|
semi_join_conds->argument_list(),
|
||||||
has_covering_null_row,
|
has_covering_null_row,
|
||||||
has_covering_null_columns,
|
has_covering_null_columns,
|
||||||
count_columns_with_nulls)) ||
|
count_columns_with_nulls))) ||
|
||||||
pm_engine->prepare(thd))
|
pm_engine->prepare(thd))
|
||||||
{
|
{
|
||||||
/* This is an irrecoverable error. */
|
/* This is an irrecoverable error. */
|
||||||
@@ -6409,8 +6417,9 @@ subselect_rowid_merge_engine::init(MY_BITMAP *non_null_key_parts,
|
|||||||
/* Create the only non-NULL key if there is any. */
|
/* Create the only non-NULL key if there is any. */
|
||||||
if (non_null_key_parts)
|
if (non_null_key_parts)
|
||||||
{
|
{
|
||||||
non_null_key= new Ordered_key(cur_keyid, tmp_table, left,
|
non_null_key= (new (thd->mem_root)
|
||||||
0, 0, 0, row_num_to_rowid);
|
Ordered_key(cur_keyid, tmp_table, left,
|
||||||
|
0, 0, 0, row_num_to_rowid));
|
||||||
if (non_null_key->init(non_null_key_parts))
|
if (non_null_key->init(non_null_key_parts))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
merge_keys[cur_keyid]= non_null_key;
|
merge_keys[cur_keyid]= non_null_key;
|
||||||
@@ -6439,8 +6448,8 @@ subselect_rowid_merge_engine::init(MY_BITMAP *non_null_key_parts,
|
|||||||
result_sink->get_null_count_of_col(i) == row_count)
|
result_sink->get_null_count_of_col(i) == row_count)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
merge_keys[cur_keyid]= new Ordered_key(
|
merge_keys[cur_keyid]= new (thd->mem_root)
|
||||||
cur_keyid, tmp_table,
|
Ordered_key(cur_keyid, tmp_table,
|
||||||
left->element_index(i),
|
left->element_index(i),
|
||||||
result_sink->get_null_count_of_col(i),
|
result_sink->get_null_count_of_col(i),
|
||||||
result_sink->get_min_null_of_col(i),
|
result_sink->get_min_null_of_col(i),
|
||||||
|
@@ -478,7 +478,7 @@ Item_sum::Item_sum(THD *thd, Item_sum *item):
|
|||||||
init_aggregator();
|
init_aggregator();
|
||||||
with_distinct= item->with_distinct;
|
with_distinct= item->with_distinct;
|
||||||
if (item->aggr)
|
if (item->aggr)
|
||||||
set_aggregator(item->aggr->Aggrtype());
|
set_aggregator(thd, item->aggr->Aggrtype());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -579,7 +579,7 @@ Item *Item_sum::set_arg(uint i, THD *thd, Item *new_val)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int Item_sum::set_aggregator(Aggregator::Aggregator_type aggregator)
|
int Item_sum::set_aggregator(THD *thd, Aggregator::Aggregator_type aggregator)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
Dependent subselects may be executed multiple times, making
|
Dependent subselects may be executed multiple times, making
|
||||||
@@ -600,10 +600,10 @@ int Item_sum::set_aggregator(Aggregator::Aggregator_type aggregator)
|
|||||||
switch (aggregator)
|
switch (aggregator)
|
||||||
{
|
{
|
||||||
case Aggregator::DISTINCT_AGGREGATOR:
|
case Aggregator::DISTINCT_AGGREGATOR:
|
||||||
aggr= new Aggregator_distinct(this);
|
aggr= new (thd->mem_root) Aggregator_distinct(this);
|
||||||
break;
|
break;
|
||||||
case Aggregator::SIMPLE_AGGREGATOR:
|
case Aggregator::SIMPLE_AGGREGATOR:
|
||||||
aggr= new Aggregator_simple(this);
|
aggr= new (thd->mem_root) Aggregator_simple(this);
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
return aggr ? FALSE : TRUE;
|
return aggr ? FALSE : TRUE;
|
||||||
@@ -763,7 +763,7 @@ bool Aggregator_distinct::setup(THD *thd)
|
|||||||
List<Item> list;
|
List<Item> list;
|
||||||
SELECT_LEX *select_lex= thd->lex->current_select;
|
SELECT_LEX *select_lex= thd->lex->current_select;
|
||||||
|
|
||||||
if (!(tmp_table_param= new TMP_TABLE_PARAM))
|
if (!(tmp_table_param= new (thd->mem_root) TMP_TABLE_PARAM))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
/* Create a table with an unique key over all parameters */
|
/* Create a table with an unique key over all parameters */
|
||||||
@@ -863,8 +863,9 @@ bool Aggregator_distinct::setup(THD *thd)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
DBUG_ASSERT(tree == 0);
|
DBUG_ASSERT(tree == 0);
|
||||||
tree= new Unique(compare_key, cmp_arg, tree_key_length,
|
tree= (new (thd->mem_root)
|
||||||
item_sum->ram_limitation(thd));
|
Unique(compare_key, cmp_arg, tree_key_length,
|
||||||
|
item_sum->ram_limitation(thd)));
|
||||||
/*
|
/*
|
||||||
The only time tree_key_length could be 0 is if someone does
|
The only time tree_key_length could be 0 is if someone does
|
||||||
count(distinct) on a char(0) field - stupid thing to do,
|
count(distinct) on a char(0) field - stupid thing to do,
|
||||||
@@ -921,8 +922,9 @@ bool Aggregator_distinct::setup(THD *thd)
|
|||||||
simple_raw_key_cmp because the table contains numbers only; decimals
|
simple_raw_key_cmp because the table contains numbers only; decimals
|
||||||
are converted to binary representation as well.
|
are converted to binary representation as well.
|
||||||
*/
|
*/
|
||||||
tree= new Unique(simple_raw_key_cmp, &tree_key_length, tree_key_length,
|
tree= (new (thd->mem_root)
|
||||||
item_sum->ram_limitation(thd));
|
Unique(simple_raw_key_cmp, &tree_key_length, tree_key_length,
|
||||||
|
item_sum->ram_limitation(thd)));
|
||||||
|
|
||||||
DBUG_RETURN(tree == 0);
|
DBUG_RETURN(tree == 0);
|
||||||
}
|
}
|
||||||
@@ -1278,9 +1280,9 @@ void Item_sum_min_max::setup_hybrid(THD *thd, Item *item, Item *value_arg)
|
|||||||
/* Don't cache value, as it will change */
|
/* Don't cache value, as it will change */
|
||||||
if (!item->const_item())
|
if (!item->const_item())
|
||||||
arg_cache->set_used_tables(RAND_TABLE_BIT);
|
arg_cache->set_used_tables(RAND_TABLE_BIT);
|
||||||
cmp= new Arg_comparator();
|
cmp= new (thd->mem_root) Arg_comparator();
|
||||||
if (cmp)
|
if (cmp)
|
||||||
cmp->set_cmp_func(this, (Item**)&arg_cache, (Item**)&value, FALSE);
|
cmp->set_cmp_func(thd, this, (Item**)&arg_cache, (Item**)&value, FALSE);
|
||||||
DBUG_VOID_RETURN;
|
DBUG_VOID_RETURN;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4292,7 +4294,7 @@ bool Item_func_group_concat::setup(THD *thd)
|
|||||||
if (table || tree)
|
if (table || tree)
|
||||||
DBUG_RETURN(FALSE);
|
DBUG_RETURN(FALSE);
|
||||||
|
|
||||||
if (!(tmp_table_param= new TMP_TABLE_PARAM))
|
if (!(tmp_table_param= new (thd->mem_root) TMP_TABLE_PARAM))
|
||||||
DBUG_RETURN(TRUE);
|
DBUG_RETURN(TRUE);
|
||||||
|
|
||||||
/* Push all not constant fields to the list and create a temp table */
|
/* Push all not constant fields to the list and create a temp table */
|
||||||
@@ -4381,7 +4383,7 @@ bool Item_func_group_concat::setup(THD *thd)
|
|||||||
with ORDER BY | DISTINCT and BLOB field count > 0.
|
with ORDER BY | DISTINCT and BLOB field count > 0.
|
||||||
*/
|
*/
|
||||||
if (order_or_distinct && table->s->blob_fields)
|
if (order_or_distinct && table->s->blob_fields)
|
||||||
table->blob_storage= new Blob_mem_storage();
|
table->blob_storage= new (thd->mem_root) Blob_mem_storage();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Need sorting or uniqueness: init tree and choose a function to sort.
|
Need sorting or uniqueness: init tree and choose a function to sort.
|
||||||
@@ -4407,10 +4409,11 @@ bool Item_func_group_concat::setup(THD *thd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (distinct)
|
if (distinct)
|
||||||
unique_filter= new Unique(get_comparator_function_for_distinct(),
|
unique_filter= (new (thd->mem_root)
|
||||||
|
Unique(get_comparator_function_for_distinct(),
|
||||||
(void*)this,
|
(void*)this,
|
||||||
tree_key_length + get_null_bytes(),
|
tree_key_length + get_null_bytes(),
|
||||||
ram_limitation(thd));
|
ram_limitation(thd)));
|
||||||
if ((row_limit && row_limit->cmp_type() != INT_RESULT) ||
|
if ((row_limit && row_limit->cmp_type() != INT_RESULT) ||
|
||||||
(offset_limit && offset_limit->cmp_type() != INT_RESULT))
|
(offset_limit && offset_limit->cmp_type() != INT_RESULT))
|
||||||
{
|
{
|
||||||
|
@@ -512,7 +512,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual void no_rows_in_result()
|
virtual void no_rows_in_result()
|
||||||
{
|
{
|
||||||
set_aggregator(with_distinct ?
|
set_aggregator(current_thd, with_distinct ?
|
||||||
Aggregator::DISTINCT_AGGREGATOR :
|
Aggregator::DISTINCT_AGGREGATOR :
|
||||||
Aggregator::SIMPLE_AGGREGATOR);
|
Aggregator::SIMPLE_AGGREGATOR);
|
||||||
aggregator_clear();
|
aggregator_clear();
|
||||||
@@ -576,7 +576,7 @@ public:
|
|||||||
May be called multiple times.
|
May be called multiple times.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int set_aggregator(Aggregator::Aggregator_type aggregator);
|
int set_aggregator(THD *thd, Aggregator::Aggregator_type aggregator);
|
||||||
|
|
||||||
virtual void clear()= 0;
|
virtual void clear()= 0;
|
||||||
virtual bool add()= 0;
|
virtual bool add()= 0;
|
||||||
|
@@ -448,7 +448,8 @@ int opt_sum_query(THD *thd,
|
|||||||
const_result= 0;
|
const_result= 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
item_sum->set_aggregator(item_sum->has_with_distinct() ?
|
item_sum->set_aggregator(thd,
|
||||||
|
item_sum->has_with_distinct() ?
|
||||||
Aggregator::DISTINCT_AGGREGATOR :
|
Aggregator::DISTINCT_AGGREGATOR :
|
||||||
Aggregator::SIMPLE_AGGREGATOR);
|
Aggregator::SIMPLE_AGGREGATOR);
|
||||||
/*
|
/*
|
||||||
|
@@ -277,7 +277,8 @@ static void update_tmptable_sum_func(Item_sum **func,TABLE *tmp_table);
|
|||||||
static void copy_sum_funcs(Item_sum **func_ptr, Item_sum **end);
|
static void copy_sum_funcs(Item_sum **func_ptr, Item_sum **end);
|
||||||
static bool add_ref_to_table_cond(THD *thd, JOIN_TAB *join_tab);
|
static bool add_ref_to_table_cond(THD *thd, JOIN_TAB *join_tab);
|
||||||
static bool setup_sum_funcs(THD *thd, Item_sum **func_ptr);
|
static bool setup_sum_funcs(THD *thd, Item_sum **func_ptr);
|
||||||
static bool prepare_sum_aggregators(Item_sum **func_ptr, bool need_distinct);
|
static bool prepare_sum_aggregators(THD *thd, Item_sum **func_ptr,
|
||||||
|
bool need_distinct);
|
||||||
static bool init_sum_functions(Item_sum **func, Item_sum **end);
|
static bool init_sum_functions(Item_sum **func, Item_sum **end);
|
||||||
static bool update_sum_func(Item_sum **func);
|
static bool update_sum_func(Item_sum **func);
|
||||||
static void select_describe(JOIN *join, bool need_tmp_table,bool need_order,
|
static void select_describe(JOIN *join, bool need_tmp_table,bool need_order,
|
||||||
@@ -3605,7 +3606,7 @@ bool JOIN::make_aggr_tables_info()
|
|||||||
{
|
{
|
||||||
if (make_sum_func_list(*curr_all_fields, *curr_fields_list, true, true))
|
if (make_sum_func_list(*curr_all_fields, *curr_fields_list, true, true))
|
||||||
DBUG_RETURN(true);
|
DBUG_RETURN(true);
|
||||||
if (prepare_sum_aggregators(sum_funcs,
|
if (prepare_sum_aggregators(thd, sum_funcs,
|
||||||
!join_tab->is_using_agg_loose_index_scan()))
|
!join_tab->is_using_agg_loose_index_scan()))
|
||||||
DBUG_RETURN(true);
|
DBUG_RETURN(true);
|
||||||
group_list= NULL;
|
group_list= NULL;
|
||||||
@@ -3715,7 +3716,7 @@ bool JOIN::make_aggr_tables_info()
|
|||||||
}
|
}
|
||||||
if (make_sum_func_list(*curr_all_fields, *curr_fields_list, true, true))
|
if (make_sum_func_list(*curr_all_fields, *curr_fields_list, true, true))
|
||||||
DBUG_RETURN(true);
|
DBUG_RETURN(true);
|
||||||
if (prepare_sum_aggregators(sum_funcs,
|
if (prepare_sum_aggregators(thd, sum_funcs,
|
||||||
!join_tab ||
|
!join_tab ||
|
||||||
!join_tab-> is_using_agg_loose_index_scan()))
|
!join_tab-> is_using_agg_loose_index_scan()))
|
||||||
DBUG_RETURN(true);
|
DBUG_RETURN(true);
|
||||||
@@ -3920,7 +3921,7 @@ JOIN::create_postjoin_aggr_table(JOIN_TAB *tab, List<Item> *table_fields,
|
|||||||
goto err;
|
goto err;
|
||||||
if (make_sum_func_list(all_fields, fields_list, true))
|
if (make_sum_func_list(all_fields, fields_list, true))
|
||||||
goto err;
|
goto err;
|
||||||
if (prepare_sum_aggregators(sum_funcs,
|
if (prepare_sum_aggregators(thd, sum_funcs,
|
||||||
!(tables_list &&
|
!(tables_list &&
|
||||||
join_tab->is_using_agg_loose_index_scan())))
|
join_tab->is_using_agg_loose_index_scan())))
|
||||||
goto err;
|
goto err;
|
||||||
@@ -3932,7 +3933,7 @@ JOIN::create_postjoin_aggr_table(JOIN_TAB *tab, List<Item> *table_fields,
|
|||||||
{
|
{
|
||||||
if (make_sum_func_list(all_fields, fields_list, false))
|
if (make_sum_func_list(all_fields, fields_list, false))
|
||||||
goto err;
|
goto err;
|
||||||
if (prepare_sum_aggregators(sum_funcs,
|
if (prepare_sum_aggregators(thd, sum_funcs,
|
||||||
!join_tab->is_using_agg_loose_index_scan()))
|
!join_tab->is_using_agg_loose_index_scan()))
|
||||||
goto err;
|
goto err;
|
||||||
if (setup_sum_funcs(thd, sum_funcs))
|
if (setup_sum_funcs(thd, sum_funcs))
|
||||||
@@ -15134,7 +15135,7 @@ static bool check_row_equality(THD *thd, const Arg_comparator *comparators,
|
|||||||
{
|
{
|
||||||
Item_func_eq *eq_item;
|
Item_func_eq *eq_item;
|
||||||
if (!(eq_item= new (thd->mem_root) Item_func_eq(thd, left_item, right_item)) ||
|
if (!(eq_item= new (thd->mem_root) Item_func_eq(thd, left_item, right_item)) ||
|
||||||
eq_item->set_cmp_func())
|
eq_item->set_cmp_func(thd))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
eq_item->quick_fix_field();
|
eq_item->quick_fix_field();
|
||||||
eq_list->push_back(eq_item, thd->mem_root);
|
eq_list->push_back(eq_item, thd->mem_root);
|
||||||
@@ -15894,7 +15895,7 @@ Item *eliminate_item_equal(THD *thd, COND *cond, COND_EQUAL *upper_levels,
|
|||||||
Don't produce equality if const is equal to item_const.
|
Don't produce equality if const is equal to item_const.
|
||||||
*/
|
*/
|
||||||
Item_func_eq *func= new (thd->mem_root) Item_func_eq(thd, item_const, upper_const);
|
Item_func_eq *func= new (thd->mem_root) Item_func_eq(thd, item_const, upper_const);
|
||||||
func->set_cmp_func();
|
func->set_cmp_func(thd);
|
||||||
func->quick_fix_field();
|
func->quick_fix_field();
|
||||||
if (func->val_int())
|
if (func->val_int())
|
||||||
item= 0;
|
item= 0;
|
||||||
@@ -15942,7 +15943,7 @@ Item *eliminate_item_equal(THD *thd, COND *cond, COND_EQUAL *upper_levels,
|
|||||||
field_item->remove_item_direct_ref(),
|
field_item->remove_item_direct_ref(),
|
||||||
head_item->remove_item_direct_ref());
|
head_item->remove_item_direct_ref());
|
||||||
|
|
||||||
if (!eq_item || eq_item->set_cmp_func())
|
if (!eq_item || eq_item->set_cmp_func(thd))
|
||||||
return 0;
|
return 0;
|
||||||
eq_item->quick_fix_field();
|
eq_item->quick_fix_field();
|
||||||
}
|
}
|
||||||
@@ -16360,7 +16361,7 @@ change_cond_ref_to_const(THD *thd, I_List<COND_CMP> *save_list,
|
|||||||
So make sure to use set_cmp_func() only for non-LIKE operators.
|
So make sure to use set_cmp_func() only for non-LIKE operators.
|
||||||
*/
|
*/
|
||||||
if (functype != Item_func::LIKE_FUNC)
|
if (functype != Item_func::LIKE_FUNC)
|
||||||
((Item_bool_rowready_func2*) func)->set_cmp_func();
|
((Item_bool_rowready_func2*) func)->set_cmp_func(thd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (can_change_cond_ref_to_const(func, left_item, right_item,
|
else if (can_change_cond_ref_to_const(func, left_item, right_item,
|
||||||
@@ -16385,7 +16386,7 @@ change_cond_ref_to_const(THD *thd, I_List<COND_CMP> *save_list,
|
|||||||
save_list->push_back(tmp2);
|
save_list->push_back(tmp2);
|
||||||
}
|
}
|
||||||
if (functype != Item_func::LIKE_FUNC)
|
if (functype != Item_func::LIKE_FUNC)
|
||||||
((Item_bool_rowready_func2*) func)->set_cmp_func();
|
((Item_bool_rowready_func2*) func)->set_cmp_func(thd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -25915,13 +25916,15 @@ static bool setup_sum_funcs(THD *thd, Item_sum **func_ptr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static bool prepare_sum_aggregators(Item_sum **func_ptr, bool need_distinct)
|
static bool prepare_sum_aggregators(THD *thd,Item_sum **func_ptr,
|
||||||
|
bool need_distinct)
|
||||||
{
|
{
|
||||||
Item_sum *func;
|
Item_sum *func;
|
||||||
DBUG_ENTER("prepare_sum_aggregators");
|
DBUG_ENTER("prepare_sum_aggregators");
|
||||||
while ((func= *(func_ptr++)))
|
while ((func= *(func_ptr++)))
|
||||||
{
|
{
|
||||||
if (func->set_aggregator(need_distinct && func->has_with_distinct() ?
|
if (func->set_aggregator(thd,
|
||||||
|
need_distinct && func->has_with_distinct() ?
|
||||||
Aggregator::DISTINCT_AGGREGATOR :
|
Aggregator::DISTINCT_AGGREGATOR :
|
||||||
Aggregator::SIMPLE_AGGREGATOR))
|
Aggregator::SIMPLE_AGGREGATOR))
|
||||||
DBUG_RETURN(TRUE);
|
DBUG_RETURN(TRUE);
|
||||||
|
@@ -4347,46 +4347,54 @@ int Type_handler_int_result::Item_save_in_field(Item *item, Field *field,
|
|||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
|
|
||||||
bool Type_handler_row::set_comparator_func(Arg_comparator *cmp) const
|
bool Type_handler_row::
|
||||||
|
set_comparator_func(THD *thd, Arg_comparator *cmp) const
|
||||||
{
|
{
|
||||||
return cmp->set_cmp_func_row();
|
return cmp->set_cmp_func_row(thd);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Type_handler_int_result::set_comparator_func(Arg_comparator *cmp) const
|
bool Type_handler_int_result::
|
||||||
|
set_comparator_func(THD *thd, Arg_comparator *cmp) const
|
||||||
{
|
{
|
||||||
return cmp->set_cmp_func_int();
|
return cmp->set_cmp_func_int(thd);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Type_handler_real_result::set_comparator_func(Arg_comparator *cmp) const
|
bool Type_handler_real_result::
|
||||||
|
set_comparator_func(THD *thd, Arg_comparator *cmp) const
|
||||||
{
|
{
|
||||||
return cmp->set_cmp_func_real();
|
return cmp->set_cmp_func_real(thd);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Type_handler_decimal_result::set_comparator_func(Arg_comparator *cmp) const
|
bool Type_handler_decimal_result::
|
||||||
|
set_comparator_func(THD *thd, Arg_comparator *cmp) const
|
||||||
{
|
{
|
||||||
return cmp->set_cmp_func_decimal();
|
return cmp->set_cmp_func_decimal(thd);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Type_handler_string_result::set_comparator_func(Arg_comparator *cmp) const
|
bool Type_handler_string_result::
|
||||||
|
set_comparator_func(THD *thd, Arg_comparator *cmp) const
|
||||||
{
|
{
|
||||||
return cmp->set_cmp_func_string();
|
return cmp->set_cmp_func_string(thd);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Type_handler_time_common::set_comparator_func(Arg_comparator *cmp) const
|
bool Type_handler_time_common::
|
||||||
|
set_comparator_func(THD *thd, Arg_comparator *cmp) const
|
||||||
{
|
{
|
||||||
return cmp->set_cmp_func_time();
|
return cmp->set_cmp_func_time(thd);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
Type_handler_temporal_with_date::set_comparator_func(Arg_comparator *cmp) const
|
Type_handler_temporal_with_date::
|
||||||
|
set_comparator_func(THD *thd, Arg_comparator *cmp) const
|
||||||
{
|
{
|
||||||
return cmp->set_cmp_func_datetime();
|
return cmp->set_cmp_func_datetime(thd);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
Type_handler_timestamp_common::set_comparator_func(Arg_comparator *cmp) const
|
Type_handler_timestamp_common::
|
||||||
|
set_comparator_func(THD *thd, Arg_comparator *cmp) const
|
||||||
{
|
{
|
||||||
return cmp->set_cmp_func_native();
|
return cmp->set_cmp_func_native(thd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -4181,7 +4181,7 @@ public:
|
|||||||
DBUG_ASSERT(0);
|
DBUG_ASSERT(0);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
virtual bool set_comparator_func(Arg_comparator *cmp) const= 0;
|
virtual bool set_comparator_func(THD *thd, Arg_comparator *cmp) const= 0;
|
||||||
virtual bool Item_const_eq(const Item_const *a, const Item_const *b,
|
virtual bool Item_const_eq(const Item_const *a, const Item_const *b,
|
||||||
bool binary_cmp) const
|
bool binary_cmp) const
|
||||||
{
|
{
|
||||||
@@ -4521,7 +4521,7 @@ public:
|
|||||||
DBUG_ASSERT(0);
|
DBUG_ASSERT(0);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
bool set_comparator_func(Arg_comparator *cmp) const override;
|
bool set_comparator_func(THD *thd, Arg_comparator *cmp) const override;
|
||||||
bool Item_hybrid_func_fix_attributes(THD *thd,
|
bool Item_hybrid_func_fix_attributes(THD *thd,
|
||||||
const char *name,
|
const char *name,
|
||||||
Type_handler_hybrid_field_type *,
|
Type_handler_hybrid_field_type *,
|
||||||
@@ -4818,7 +4818,7 @@ public:
|
|||||||
const override;
|
const override;
|
||||||
Item *make_const_item_for_comparison(THD *, Item *src, const Item *cmp)
|
Item *make_const_item_for_comparison(THD *, Item *src, const Item *cmp)
|
||||||
const override;
|
const override;
|
||||||
bool set_comparator_func(Arg_comparator *cmp) const override;
|
bool set_comparator_func(THD *thd, Arg_comparator *cmp) const override;
|
||||||
bool Item_hybrid_func_fix_attributes(THD *thd,
|
bool Item_hybrid_func_fix_attributes(THD *thd,
|
||||||
const char *name,
|
const char *name,
|
||||||
Type_handler_hybrid_field_type *,
|
Type_handler_hybrid_field_type *,
|
||||||
@@ -4954,7 +4954,7 @@ public:
|
|||||||
Item *make_const_item_for_comparison(THD *, Item *src, const Item *cmp) const
|
Item *make_const_item_for_comparison(THD *, Item *src, const Item *cmp) const
|
||||||
override;
|
override;
|
||||||
Item_cache *Item_get_cache(THD *thd, const Item *item) const override;
|
Item_cache *Item_get_cache(THD *thd, const Item *item) const override;
|
||||||
bool set_comparator_func(Arg_comparator *cmp) const override;
|
bool set_comparator_func(THD *thd, Arg_comparator *cmp) const override;
|
||||||
bool Item_hybrid_func_fix_attributes(THD *thd,
|
bool Item_hybrid_func_fix_attributes(THD *thd,
|
||||||
const char *name,
|
const char *name,
|
||||||
Type_handler_hybrid_field_type *,
|
Type_handler_hybrid_field_type *,
|
||||||
@@ -5188,7 +5188,7 @@ public:
|
|||||||
int Item_save_in_field(Item *item, Field *field, bool no_conversions) const override;
|
int Item_save_in_field(Item *item, Field *field, bool no_conversions) const override;
|
||||||
Item *make_const_item_for_comparison(THD *, Item *src, const Item *cmp) const override;
|
Item *make_const_item_for_comparison(THD *, Item *src, const Item *cmp) const override;
|
||||||
Item_cache *Item_get_cache(THD *thd, const Item *item) const override;
|
Item_cache *Item_get_cache(THD *thd, const Item *item) const override;
|
||||||
bool set_comparator_func(Arg_comparator *cmp) const override;
|
bool set_comparator_func(THD *thd, Arg_comparator *cmp) const override;
|
||||||
bool Item_hybrid_func_fix_attributes(THD *thd,
|
bool Item_hybrid_func_fix_attributes(THD *thd,
|
||||||
const char *name,
|
const char *name,
|
||||||
Type_handler_hybrid_field_type *,
|
Type_handler_hybrid_field_type *,
|
||||||
@@ -5452,7 +5452,7 @@ public:
|
|||||||
Item *make_const_item_for_comparison(THD *, Item *src, const Item *cmp) const
|
Item *make_const_item_for_comparison(THD *, Item *src, const Item *cmp) const
|
||||||
override;
|
override;
|
||||||
Item_cache *Item_get_cache(THD *thd, const Item *item) const override;
|
Item_cache *Item_get_cache(THD *thd, const Item *item) const override;
|
||||||
bool set_comparator_func(Arg_comparator *cmp) const override;
|
bool set_comparator_func(THD *thd, Arg_comparator *cmp) const override;
|
||||||
bool Item_hybrid_func_fix_attributes(THD *thd,
|
bool Item_hybrid_func_fix_attributes(THD *thd,
|
||||||
const char *name,
|
const char *name,
|
||||||
Type_handler_hybrid_field_type *,
|
Type_handler_hybrid_field_type *,
|
||||||
@@ -6168,7 +6168,7 @@ public:
|
|||||||
bool Item_func_int_val_fix_length_and_dec(Item_func_int_val*) const override;
|
bool Item_func_int_val_fix_length_and_dec(Item_func_int_val*) const override;
|
||||||
Item *make_const_item_for_comparison(THD *, Item *src, const Item *cmp)
|
Item *make_const_item_for_comparison(THD *, Item *src, const Item *cmp)
|
||||||
const override;
|
const override;
|
||||||
bool set_comparator_func(Arg_comparator *cmp) const override;
|
bool set_comparator_func(THD *thd, Arg_comparator *cmp) const override;
|
||||||
cmp_item *make_cmp_item(THD *thd, CHARSET_INFO *cs) const override;
|
cmp_item *make_cmp_item(THD *thd, CHARSET_INFO *cs) const override;
|
||||||
in_vector *make_in_vector(THD *, const Item_func_in *, uint nargs)
|
in_vector *make_in_vector(THD *, const Item_func_in *, uint nargs)
|
||||||
const override;
|
const override;
|
||||||
@@ -6262,7 +6262,7 @@ public:
|
|||||||
const override;
|
const override;
|
||||||
Item *make_const_item_for_comparison(THD *, Item *src, const Item *cmp)
|
Item *make_const_item_for_comparison(THD *, Item *src, const Item *cmp)
|
||||||
const override;
|
const override;
|
||||||
bool set_comparator_func(Arg_comparator *cmp) const override;
|
bool set_comparator_func(THD *thd, Arg_comparator *cmp) const override;
|
||||||
cmp_item *make_cmp_item(THD *thd, CHARSET_INFO *cs) const override;
|
cmp_item *make_cmp_item(THD *thd, CHARSET_INFO *cs) const override;
|
||||||
in_vector *make_in_vector(THD *, const Item_func_in *, uint nargs)
|
in_vector *make_in_vector(THD *, const Item_func_in *, uint nargs)
|
||||||
const override;
|
const override;
|
||||||
@@ -6632,7 +6632,7 @@ public:
|
|||||||
longlong Item_func_min_max_val_int(Item_func_min_max *) const override;
|
longlong Item_func_min_max_val_int(Item_func_min_max *) const override;
|
||||||
my_decimal *Item_func_min_max_val_decimal(Item_func_min_max *,
|
my_decimal *Item_func_min_max_val_decimal(Item_func_min_max *,
|
||||||
my_decimal *) const override;
|
my_decimal *) const override;
|
||||||
bool set_comparator_func(Arg_comparator *cmp) const override;
|
bool set_comparator_func(THD *thd, Arg_comparator *cmp) const override;
|
||||||
bool Item_hybrid_func_fix_attributes(THD *thd,
|
bool Item_hybrid_func_fix_attributes(THD *thd,
|
||||||
const char *name,
|
const char *name,
|
||||||
Type_handler_hybrid_field_type *,
|
Type_handler_hybrid_field_type *,
|
||||||
|
@@ -2964,7 +2964,8 @@ bool Window_func_runner::exec(THD *thd, TABLE *tbl, SORT_INFO *filesort_result)
|
|||||||
win_func->set_phase_to_computation();
|
win_func->set_phase_to_computation();
|
||||||
// TODO(cvicentiu) Setting the aggregator should probably be done during
|
// TODO(cvicentiu) Setting the aggregator should probably be done during
|
||||||
// setup of Window_funcs_sort.
|
// setup of Window_funcs_sort.
|
||||||
win_func->window_func()->set_aggregator(Aggregator::SIMPLE_AGGREGATOR);
|
win_func->window_func()->set_aggregator(thd,
|
||||||
|
Aggregator::SIMPLE_AGGREGATOR);
|
||||||
}
|
}
|
||||||
it.rewind();
|
it.rewind();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user