mirror of
https://github.com/MariaDB/server.git
synced 2025-04-16 20:25:33 +02:00
A helper patch for "MDEV-8228 Move Item_func_like out of Item_bool_func2"
- Changing Comp_creator::create() and create_swap() to return Item_bool_rowready_func2 instead of Item_bool_func2, as they can never return neither Item_func_like nor Item_func_xor - Changing the first argument of Comp_create::create() and create_swap() from THD to MEM_ROOT, so the method implementations can now reside in item_cmpfunc.h instead of item_cmpfunc.cc and thus make the code slightly easier to read.
This commit is contained in:
parent
b3aece9b99
commit
5bd25a9c53
4 changed files with 135 additions and 156 deletions
|
@ -264,66 +264,6 @@ static void my_coll_agg_error(DTCollation &c1, DTCollation &c2,
|
|||
}
|
||||
|
||||
|
||||
Item_bool_func2* Eq_creator::create(THD *thd, Item *a, Item *b) const
|
||||
{
|
||||
return new (thd->mem_root) Item_func_eq(a, b);
|
||||
}
|
||||
|
||||
Item_bool_func2* Eq_creator::create_swap(THD *thd, Item *a, Item *b) const
|
||||
{
|
||||
return new (thd->mem_root) Item_func_eq(b, a);
|
||||
}
|
||||
|
||||
Item_bool_func2* Ne_creator::create(THD *thd, Item *a, Item *b) const
|
||||
{
|
||||
return new (thd->mem_root) Item_func_ne(a, b);
|
||||
}
|
||||
|
||||
Item_bool_func2* Ne_creator::create_swap(THD *thd, Item *a, Item *b) const
|
||||
{
|
||||
return new (thd->mem_root) Item_func_ne(b, a);
|
||||
}
|
||||
|
||||
Item_bool_func2* Gt_creator::create(THD *thd, Item *a, Item *b) const
|
||||
{
|
||||
return new (thd->mem_root) Item_func_gt(a, b);
|
||||
}
|
||||
|
||||
Item_bool_func2* Gt_creator::create_swap(THD *thd, Item *a, Item *b) const
|
||||
{
|
||||
return new (thd->mem_root) Item_func_lt(b, a);
|
||||
}
|
||||
|
||||
Item_bool_func2* Lt_creator::create(THD *thd, Item *a, Item *b) const
|
||||
{
|
||||
return new (thd->mem_root) Item_func_lt(a, b);
|
||||
}
|
||||
|
||||
Item_bool_func2* Lt_creator::create_swap(THD *thd, Item *a, Item *b) const
|
||||
{
|
||||
return new (thd->mem_root) Item_func_gt(b, a);
|
||||
}
|
||||
|
||||
Item_bool_func2* Ge_creator::create(THD *thd, Item *a, Item *b) const
|
||||
{
|
||||
return new (thd->mem_root) Item_func_ge(a, b);
|
||||
}
|
||||
|
||||
Item_bool_func2* Ge_creator::create_swap(THD *thd, Item *a, Item *b) const
|
||||
{
|
||||
return new (thd->mem_root) Item_func_le(b, a);
|
||||
}
|
||||
|
||||
Item_bool_func2* Le_creator::create(THD *thd, Item *a, Item *b) const
|
||||
{
|
||||
return new (thd->mem_root) Item_func_le(a, b);
|
||||
}
|
||||
|
||||
Item_bool_func2* Le_creator::create_swap(THD *thd, Item *a, Item *b) const
|
||||
{
|
||||
return new (thd->mem_root) Item_func_ge(b, a);
|
||||
}
|
||||
|
||||
/*
|
||||
Test functions
|
||||
Most of these returns 0LL if false and 1LL if true and
|
||||
|
|
|
@ -289,96 +289,6 @@ public:
|
|||
void reset_cache() { cache= NULL; }
|
||||
};
|
||||
|
||||
class Comp_creator
|
||||
{
|
||||
public:
|
||||
Comp_creator() {} /* Remove gcc warning */
|
||||
virtual ~Comp_creator() {} /* Remove gcc warning */
|
||||
/**
|
||||
Create operation with given arguments.
|
||||
*/
|
||||
virtual Item_bool_func2* create(THD *thd, Item *a, Item *b) const = 0;
|
||||
/**
|
||||
Create operation with given arguments in swap order.
|
||||
*/
|
||||
virtual Item_bool_func2* create_swap(THD *thd, Item *a, Item *b) const = 0;
|
||||
virtual const char* symbol(bool invert) const = 0;
|
||||
virtual bool eqne_op() const = 0;
|
||||
virtual bool l_op() const = 0;
|
||||
};
|
||||
|
||||
class Eq_creator :public Comp_creator
|
||||
{
|
||||
public:
|
||||
Eq_creator() {} /* Remove gcc warning */
|
||||
virtual ~Eq_creator() {} /* Remove gcc warning */
|
||||
virtual Item_bool_func2* create(THD *thd, Item *a, Item *b) const;
|
||||
virtual Item_bool_func2* create_swap(THD *thd, Item *a, Item *b) const;
|
||||
virtual const char* symbol(bool invert) const { return invert? "<>" : "="; }
|
||||
virtual bool eqne_op() const { return 1; }
|
||||
virtual bool l_op() const { return 0; }
|
||||
};
|
||||
|
||||
class Ne_creator :public Comp_creator
|
||||
{
|
||||
public:
|
||||
Ne_creator() {} /* Remove gcc warning */
|
||||
virtual ~Ne_creator() {} /* Remove gcc warning */
|
||||
virtual Item_bool_func2* create(THD *thd, Item *a, Item *b) const;
|
||||
virtual Item_bool_func2* create_swap(THD *thd, Item *a, Item *b) const;
|
||||
virtual const char* symbol(bool invert) const { return invert? "=" : "<>"; }
|
||||
virtual bool eqne_op() const { return 1; }
|
||||
virtual bool l_op() const { return 0; }
|
||||
};
|
||||
|
||||
class Gt_creator :public Comp_creator
|
||||
{
|
||||
public:
|
||||
Gt_creator() {} /* Remove gcc warning */
|
||||
virtual ~Gt_creator() {} /* Remove gcc warning */
|
||||
virtual Item_bool_func2* create(THD *thd, Item *a, Item *b) const;
|
||||
virtual Item_bool_func2* create_swap(THD *thd, Item *a, Item *b) const;
|
||||
virtual const char* symbol(bool invert) const { return invert? "<=" : ">"; }
|
||||
virtual bool eqne_op() const { return 0; }
|
||||
virtual bool l_op() const { return 0; }
|
||||
};
|
||||
|
||||
class Lt_creator :public Comp_creator
|
||||
{
|
||||
public:
|
||||
Lt_creator() {} /* Remove gcc warning */
|
||||
virtual ~Lt_creator() {} /* Remove gcc warning */
|
||||
virtual Item_bool_func2* create(THD *thd, Item *a, Item *b) const;
|
||||
virtual Item_bool_func2* create_swap(THD *thd, Item *a, Item *b) const;
|
||||
virtual const char* symbol(bool invert) const { return invert? ">=" : "<"; }
|
||||
virtual bool eqne_op() const { return 0; }
|
||||
virtual bool l_op() const { return 1; }
|
||||
};
|
||||
|
||||
class Ge_creator :public Comp_creator
|
||||
{
|
||||
public:
|
||||
Ge_creator() {} /* Remove gcc warning */
|
||||
virtual ~Ge_creator() {} /* Remove gcc warning */
|
||||
virtual Item_bool_func2* create(THD *thd, Item *a, Item *b) const;
|
||||
virtual Item_bool_func2* create_swap(THD *thd, Item *a, Item *b) const;
|
||||
virtual const char* symbol(bool invert) const { return invert? "<" : ">="; }
|
||||
virtual bool eqne_op() const { return 0; }
|
||||
virtual bool l_op() const { return 0; }
|
||||
};
|
||||
|
||||
class Le_creator :public Comp_creator
|
||||
{
|
||||
public:
|
||||
Le_creator() {} /* Remove gcc warning */
|
||||
virtual ~Le_creator() {} /* Remove gcc warning */
|
||||
virtual Item_bool_func2* create(THD *thd, Item *a, Item *b) const;
|
||||
virtual Item_bool_func2* create_swap(THD *thd, Item *a, Item *b) const;
|
||||
virtual const char* symbol(bool invert) const { return invert? ">" : "<="; }
|
||||
virtual bool eqne_op() const { return 0; }
|
||||
virtual bool l_op() const { return 1; }
|
||||
};
|
||||
|
||||
class Item_bool_func2 :public Item_bool_func
|
||||
{ /* Bool with 2 string args */
|
||||
protected:
|
||||
|
@ -2248,6 +2158,135 @@ longlong get_datetime_value(THD *thd, Item ***item_arg, Item **cache_arg,
|
|||
bool get_mysql_time_from_str(THD *thd, String *str, timestamp_type warn_type,
|
||||
const char *warn_name, MYSQL_TIME *l_time);
|
||||
|
||||
|
||||
class Comp_creator
|
||||
{
|
||||
public:
|
||||
Comp_creator() {} /* Remove gcc warning */
|
||||
virtual ~Comp_creator() {} /* Remove gcc warning */
|
||||
/**
|
||||
Create operation with given arguments.
|
||||
*/
|
||||
virtual Item_bool_rowready_func2* create(MEM_ROOT *, Item *a, Item *b)
|
||||
const = 0;
|
||||
/**
|
||||
Create operation with given arguments in swap order.
|
||||
*/
|
||||
virtual Item_bool_rowready_func2* create_swap(MEM_ROOT *, Item *a, Item *b)
|
||||
const = 0;
|
||||
virtual const char* symbol(bool invert) const = 0;
|
||||
virtual bool eqne_op() const = 0;
|
||||
virtual bool l_op() const = 0;
|
||||
};
|
||||
|
||||
class Eq_creator :public Comp_creator
|
||||
{
|
||||
public:
|
||||
Eq_creator() {} /* Remove gcc warning */
|
||||
virtual ~Eq_creator() {} /* Remove gcc warning */
|
||||
Item_bool_rowready_func2* create(MEM_ROOT *root, Item *a, Item *b) const
|
||||
{
|
||||
return new(root) Item_func_eq(a, b);
|
||||
}
|
||||
Item_bool_rowready_func2* create_swap(MEM_ROOT *root, Item *a, Item *b) const
|
||||
{
|
||||
return new(root) Item_func_eq(b, a);
|
||||
}
|
||||
const char* symbol(bool invert) const { return invert? "<>" : "="; }
|
||||
bool eqne_op() const { return 1; }
|
||||
bool l_op() const { return 0; }
|
||||
};
|
||||
|
||||
class Ne_creator :public Comp_creator
|
||||
{
|
||||
public:
|
||||
Ne_creator() {} /* Remove gcc warning */
|
||||
virtual ~Ne_creator() {} /* Remove gcc warning */
|
||||
Item_bool_rowready_func2* create(MEM_ROOT *root, Item *a, Item *b) const
|
||||
{
|
||||
return new(root) Item_func_ne(a, b);
|
||||
}
|
||||
Item_bool_rowready_func2* create_swap(MEM_ROOT *root, Item *a, Item *b) const
|
||||
{
|
||||
return new(root) Item_func_ne(b, a);
|
||||
}
|
||||
const char* symbol(bool invert) const { return invert? "=" : "<>"; }
|
||||
bool eqne_op() const { return 1; }
|
||||
bool l_op() const { return 0; }
|
||||
};
|
||||
|
||||
class Gt_creator :public Comp_creator
|
||||
{
|
||||
public:
|
||||
Gt_creator() {} /* Remove gcc warning */
|
||||
virtual ~Gt_creator() {} /* Remove gcc warning */
|
||||
Item_bool_rowready_func2* create(MEM_ROOT *root, Item *a, Item *b) const
|
||||
{
|
||||
return new(root) Item_func_gt(a, b);
|
||||
}
|
||||
Item_bool_rowready_func2* create_swap(MEM_ROOT *root, Item *a, Item *b) const
|
||||
{
|
||||
return new(root) Item_func_lt(b, a);
|
||||
}
|
||||
const char* symbol(bool invert) const { return invert? "<=" : ">"; }
|
||||
bool eqne_op() const { return 0; }
|
||||
bool l_op() const { return 0; }
|
||||
};
|
||||
|
||||
class Lt_creator :public Comp_creator
|
||||
{
|
||||
public:
|
||||
Lt_creator() {} /* Remove gcc warning */
|
||||
virtual ~Lt_creator() {} /* Remove gcc warning */
|
||||
Item_bool_rowready_func2* create(MEM_ROOT *root, Item *a, Item *b) const
|
||||
{
|
||||
return new(root) Item_func_lt(a, b);
|
||||
}
|
||||
Item_bool_rowready_func2* create_swap(MEM_ROOT *root, Item *a, Item *b) const
|
||||
{
|
||||
return new(root) Item_func_gt(b, a);
|
||||
}
|
||||
const char* symbol(bool invert) const { return invert? ">=" : "<"; }
|
||||
bool eqne_op() const { return 0; }
|
||||
bool l_op() const { return 1; }
|
||||
};
|
||||
|
||||
class Ge_creator :public Comp_creator
|
||||
{
|
||||
public:
|
||||
Ge_creator() {} /* Remove gcc warning */
|
||||
virtual ~Ge_creator() {} /* Remove gcc warning */
|
||||
Item_bool_rowready_func2* create(MEM_ROOT *root, Item *a, Item *b) const
|
||||
{
|
||||
return new(root) Item_func_ge(a, b);
|
||||
}
|
||||
Item_bool_rowready_func2* create_swap(MEM_ROOT *root, Item *a, Item *b) const
|
||||
{
|
||||
return new(root) Item_func_le(b, a);
|
||||
}
|
||||
const char* symbol(bool invert) const { return invert? "<" : ">="; }
|
||||
bool eqne_op() const { return 0; }
|
||||
bool l_op() const { return 0; }
|
||||
};
|
||||
|
||||
class Le_creator :public Comp_creator
|
||||
{
|
||||
public:
|
||||
Le_creator() {} /* Remove gcc warning */
|
||||
virtual ~Le_creator() {} /* Remove gcc warning */
|
||||
Item_bool_rowready_func2* create(MEM_ROOT *root, Item *a, Item *b) const
|
||||
{
|
||||
return new(root) Item_func_le(a, b);
|
||||
}
|
||||
Item_bool_rowready_func2* create_swap(MEM_ROOT *root, Item *a, Item *b) const
|
||||
{
|
||||
return new(root) Item_func_ge(b, a);
|
||||
}
|
||||
const char* symbol(bool invert) const { return invert? ">" : "<="; }
|
||||
bool eqne_op() const { return 0; }
|
||||
bool l_op() const { return 1; }
|
||||
};
|
||||
|
||||
/*
|
||||
These need definitions from this file but the variables are defined
|
||||
in mysqld.h. The variables really belong in this component, but for
|
||||
|
|
|
@ -1779,7 +1779,7 @@ Item_in_subselect::single_value_transformer(JOIN *join)
|
|||
of the statement. Thus one of 'substitution' arguments
|
||||
can be broken in case of PS.
|
||||
*/
|
||||
substitution= func->create(thd, left_expr, where_item);
|
||||
substitution= func->create(thd->mem_root, left_expr, where_item);
|
||||
have_to_be_excluded= 1;
|
||||
if (thd->lex->describe)
|
||||
{
|
||||
|
@ -1948,7 +1948,7 @@ bool Item_allany_subselect::transform_into_max_min(JOIN *join)
|
|||
The swap is needed for expressions of type 'f1 < ALL ( SELECT ....)'
|
||||
where we want to evaluate the sub query even if f1 would be null.
|
||||
*/
|
||||
subs= func->create_swap(thd, *(optimizer->get_cache()), subs);
|
||||
subs= func->create_swap(thd->mem_root, *(optimizer->get_cache()), subs);
|
||||
thd->change_item_tree(place, subs);
|
||||
if (subs->fix_fields(thd, &subs))
|
||||
DBUG_RETURN(true);
|
||||
|
@ -2040,7 +2040,7 @@ Item_in_subselect::create_single_in_to_exists_cond(JOIN * join,
|
|||
if (join_having || select_lex->with_sum_func ||
|
||||
select_lex->group_list.elements)
|
||||
{
|
||||
Item *item= func->create(thd, expr,
|
||||
Item *item= func->create(thd->mem_root, expr,
|
||||
new (thd->mem_root) Item_ref_null_helper(
|
||||
&select_lex->context,
|
||||
this,
|
||||
|
@ -2072,7 +2072,7 @@ Item_in_subselect::create_single_in_to_exists_cond(JOIN * join,
|
|||
Item *having= item;
|
||||
Item *orig_item= item;
|
||||
|
||||
item= func->create(thd, expr, item);
|
||||
item= func->create(thd->mem_root, expr, item);
|
||||
if (!abort_on_null && orig_item->maybe_null)
|
||||
{
|
||||
having= new (thd->mem_root) Item_is_not_null_test(this, having);
|
||||
|
@ -2116,7 +2116,7 @@ Item_in_subselect::create_single_in_to_exists_cond(JOIN * join,
|
|||
if (select_lex->master_unit()->is_union())
|
||||
{
|
||||
Item *new_having=
|
||||
func->create(thd, expr,
|
||||
func->create(thd->mem_root, expr,
|
||||
new (thd->mem_root) Item_ref_null_helper(
|
||||
&select_lex->context,
|
||||
this,
|
||||
|
|
|
@ -8797,7 +8797,7 @@ bool_pri:
|
|||
}
|
||||
| bool_pri comp_op predicate %prec EQ
|
||||
{
|
||||
$$= (*$2)(0)->create(thd, $1, $3);
|
||||
$$= (*$2)(0)->create(thd->mem_root, $1, $3);
|
||||
if ($$ == NULL)
|
||||
MYSQL_YYABORT;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue