MySQL 9.0.0
Source Code Documentation
item_cmpfunc.h File Reference
#include <assert.h>
#include <sys/types.h>
#include <cstring>
#include <memory>
#include "field_types.h"
#include "my_alloc.h"
#include "my_compiler.h"
#include "my_inttypes.h"
#include "my_table_map.h"
#include "my_time.h"
#include "mysql/udf_registration_types.h"
#include "mysql_time.h"
#include "sql-common/my_decimal.h"
#include "sql/enum_query_type.h"
#include "sql/item.h"
#include "sql/item_func.h"
#include "sql/item_row.h"
#include "sql/mem_root_array.h"
#include "sql/parse_location.h"
#include "sql/sql_const.h"
#include "sql/sql_list.h"
#include "sql/table.h"
#include "sql_string.h"
#include "template_utils.h"

Go to the source code of this file.

Classes

class  HashJoinCondition
 A class that represents a join condition in a hash join. More...
 
class  Arg_comparator
 
class  Item_bool_func
 
class  Item_func_bool_const
 A predicate that is "always true" or "always false". More...
 
class  Item_func_true
 A predicate that is "always true". More...
 
class  Item_func_false
 A predicate that is "always false". More...
 
class  Item_func_truth
 Item class, to represent X IS [NOT] (TRUE | FALSE) boolean predicates. More...
 
class  Item_in_optimizer
 
class  Comp_creator
 Abstract factory interface for creating comparison predicates. More...
 
class  Linear_comp_creator
 Abstract base class for the comparison operators =, <> and <=>. More...
 
class  Eq_creator
 
class  Equal_creator
 
class  Ne_creator
 
class  Gt_creator
 
class  Lt_creator
 
class  Ge_creator
 
class  Le_creator
 
class  Item_bool_func2
 Base class for functions that usually take two arguments, which are possibly strings, and perform some kind of comparison on the two arguments and return a boolean. More...
 
class  Item_func_comparison
 Item_func_comparison is a class for comparison functions that take two arguments and return a boolean result. More...
 
class  Item_func_xor
 XOR inherits from Item_bool_func2 because it is not optimized yet. More...
 
class  Item_func_not
 
class  Item_func_match_predicate
 Wrapper class when MATCH function is used in WHERE clause. More...
 
class  Item_func_trig_cond
 
class  Item_func_not_all
 
class  Item_func_nop_all
 
class  Item_eq_base
 Base class for the equality comparison operators = and <=>. More...
 
class  Item_func_eq
 Implements the comparison operator equals (=) More...
 
class  Item_func_equal
 The <=> operator evaluates the same as. More...
 
class  Item_func_ge
 Implements the comparison operator greater than or equals (>=) More...
 
class  Item_func_gt
 Implements the comparison operator greater than (>) More...
 
class  Item_func_le
 Implements the comparison operator less than or equals (<=) More...
 
class  Item_func_reject_if
 Internal function used by subquery to derived transformation to check if a subquery is scalar. More...
 
class  Item_func_lt
 Implements the comparison operator less than (<) More...
 
class  Item_func_ne
 Implements the comparison operator not equals (<>) More...
 
class  Item_func_opt_neg
 
class  Item_func_between
 
class  Item_func_strcmp
 
struct  interval_range
 
class  Item_func_interval
 
class  Item_func_coalesce
 
class  Item_func_ifnull
 
class  Item_func_any_value
 ANY_VALUE(expr) is like expr except that it is not checked by aggregate_check logic. More...
 
class  Item_func_if
 
class  Item_func_nullif
 
class  in_vector
 
class  in_string
 
class  in_longlong
 
struct  in_longlong::packed_longlong
 
class  in_datetime_as_longlong
 
class  in_time_as_longlong
 
class  in_datetime
 
class  in_double
 
class  in_decimal
 
class  cmp_item
 
class  cmp_item_scalar
 cmp_item which stores a scalar (i.e. non-ROW). More...
 
class  cmp_item_string
 
class  cmp_item_json
 
class  cmp_item_int
 
class  cmp_item_datetime
 
class  cmp_item_real
 
class  cmp_item_decimal
 
class  Item_func_case
 CASE ... WHEN ... THEN ... END function implementation. More...
 
class  Item_func_in
 in_expr [NOT] IN (in_value_list). More...
 
class  cmp_item_row
 
class  in_row
 
class  Item_func_isnull
 
class  Item_is_not_null_test
 
class  Item_func_isnotnull
 
class  Item_func_like
 
class  Item_cond
 
class  Item_multi_eq
 The class Item_multi_eq is used to represent conjunctions of equality predicates of the form field1 = field2, and field = const in where conditions and on join conditions. More...
 
class  Item_multi_eq::FieldProxy
 
class  Item_multi_eq::ConstFieldProxy
 
struct  COND_EQUAL
 
class  Item_cond_and
 
class  Item_cond_or
 

Typedefs

typedef int(Arg_comparator::* arg_cmp_func) ()
 

Functions

Itemmake_condition (Parse_context *pc, Item *item)
 Ensure that all expressions involved in conditions are boolean functions. More...
 
Itemand_conds (Item *a, Item *b)
 Builds condition: (a AND b) IS TRUE. More...
 
longlong get_datetime_value (THD *thd, Item ***item_arg, Item **, const Item *warn_item, bool *is_null)
 Retrieve correct DATETIME value from given item. More...
 
bool get_mysql_time_from_str_no_warn (THD *thd, String *str, MYSQL_TIME *l_time, MYSQL_TIME_STATUS *status)
 A minion of get_mysql_time_from_str, see its description. More...
 
bool get_mysql_time_from_str (THD *thd, String *str, enum_mysql_timestamp_type warn_type, const char *warn_name, MYSQL_TIME *l_time)
 Parse date provided in a string to a MYSQL_TIME. More...
 
void find_and_adjust_equal_fields (Item *item, table_map available_tables, bool replace, bool *found)
 
bool IsAnd (const Item *item)
 Returns true if the item is a conjunction. More...
 
template<class Func >
bool WalkConjunction (Item *condition, Func func)
 Calls "func" on each term in "condition" if it's a conjunction (and recursively on any conjunction directly contained in it, thereby flattening nested AND structures). More...
 

Variables

static const int UNKNOWN = -1
 
Eq_creator eq_creator
 
Equal_creator equal_creator
 
Ne_creator ne_creator
 
Gt_creator gt_creator
 
Lt_creator lt_creator
 
Ge_creator ge_creator
 
Le_creator le_creator
 

Typedef Documentation

◆ arg_cmp_func

typedef int(Arg_comparator::* arg_cmp_func) ()

Function Documentation

◆ and_conds()

Item * and_conds ( Item a,
Item b 
)
inline

Builds condition: (a AND b) IS TRUE.

◆ find_and_adjust_equal_fields()

void find_and_adjust_equal_fields ( Item item,
table_map  available_tables,
bool  replace,
bool *  found 
)

◆ get_datetime_value()

longlong get_datetime_value ( THD thd,
Item ***  item_arg,
Item **  ,
const Item warn_item,
bool *  is_null 
)

Retrieve correct DATETIME value from given item.

Parameters
thdthread handle
item_argitem to retrieve DATETIME value from
warn_itemitem for issuing the conversion warning
[out]is_nulltrue <=> the item_arg is null

Retrieves the correct DATETIME value from given item for comparison by the compare_datetime() function. If item's result can be compared as longlong then its int value is used and its string value is used otherwise. Strings are always parsed and converted to int values by the get_date_from_str() function. This allows us to compare correctly string dates with missed insignificant zeros. In order to compare correctly DATE and DATETIME items the result of the former are treated as a DATETIME with zero time (00:00:00).

Returns
the DATETIME value, all ones if Item is NULL

◆ get_mysql_time_from_str()

bool get_mysql_time_from_str ( THD thd,
String str,
enum_mysql_timestamp_type  warn_type,
const char *  warn_name,
MYSQL_TIME l_time 
)

Parse date provided in a string to a MYSQL_TIME.

Parameters
[in]thdThread handle
[in]strA string to convert
[in]warn_typeType of the timestamp for issuing the warning
[in]warn_nameField name for issuing the warning
[out]l_timeThe MYSQL_TIME objects is initialized.

Parses a date provided in the string str into a MYSQL_TIME object. If the string contains an incorrect date or doesn't correspond to a date at all then a warning is issued. The warn_type and the warn_name arguments are used as the name and the type of the field when issuing the warning. If any input was discarded (trailing or non-timestamp-y characters), return value will be true.

Returns
Status flag
Return values
falseSuccess.
TrueIndicates failure.

◆ get_mysql_time_from_str_no_warn()

bool get_mysql_time_from_str_no_warn ( THD thd,
String str,
MYSQL_TIME l_time,
MYSQL_TIME_STATUS status 
)

A minion of get_mysql_time_from_str, see its description.

This version doesn't issue any warnings, leaving that to its parent. This method has one extra argument which return warnings.

Parameters
[in]thdThread handle
[in]strA string to convert
[out]l_timeThe MYSQL_TIME objects is initialized.
[in,out]statusAny warnings given are returned here
Returns
true if error

◆ IsAnd()

bool IsAnd ( const Item item)
inline

Returns true if the item is a conjunction.

◆ make_condition()

Item * make_condition ( Parse_context pc,
Item item 
)

Ensure that all expressions involved in conditions are boolean functions.

Specifically, change <non-bool-expr> to (0 <> <non-bool-expr>)

Parameters
pcParse context, including memroot for Item construction
itemAny expression, if not a boolean expression, convert it
Returns
= NULL Error <> NULL A boolean expression, possibly constructed as described above
Note
Due to the special conditions of a MATCH expression (it is both a function returning a floating point value and it may be used standalone in the WHERE clause), it is wrapped inside a special Item_func_match_predicate, instead of forming a non-equality.

◆ WalkConjunction()

template<class Func >
bool WalkConjunction ( Item condition,
Func  func 
)

Calls "func" on each term in "condition" if it's a conjunction (and recursively on any conjunction directly contained in it, thereby flattening nested AND structures).

Otherwise, calls "func" on "condition". It aborts and returns true as soon as a call to "func" returns true.

Variable Documentation

◆ eq_creator

Eq_creator eq_creator
extern

◆ equal_creator

Equal_creator equal_creator
extern

◆ ge_creator

Ge_creator ge_creator
extern

◆ gt_creator

Gt_creator gt_creator
extern

◆ le_creator

Le_creator le_creator
extern

◆ lt_creator

Lt_creator lt_creator
extern

◆ ne_creator

Ne_creator ne_creator
extern

◆ UNKNOWN

const int UNKNOWN = -1
static