MySQL 8.4.3
Source Code Documentation
item_func.h File Reference
#include <sys/types.h>
#include <climits>
#include <cmath>
#include <cstddef>
#include <functional>
#include "decimal.h"
#include "field_types.h"
#include "ft_global.h"
#include "lex_string.h"
#include "my_alloc.h"
#include "my_base.h"
#include "my_compiler.h"
#include "my_dbug.h"
#include "my_inttypes.h"
#include "my_pointer_arithmetic.h"
#include "my_table_map.h"
#include "my_thread_local.h"
#include "my_time.h"
#include "mysql/service_mysql_alloc.h"
#include "mysql/strings/m_ctype.h"
#include "mysql/udf_registration_types.h"
#include "mysql_time.h"
#include "mysqld_error.h"
#include "sql-common/my_decimal.h"
#include "sql/enum_query_type.h"
#include "sql/field.h"
#include "sql/handler.h"
#include "sql/item.h"
#include "sql/parse_location.h"
#include "sql/set_var.h"
#include "sql/sql_const.h"
#include "sql/sql_udf.h"
#include "sql/table.h"
#include "sql/thr_malloc.h"
#include "sql_string.h"
#include "template_utils.h"

Go to the source code of this file.

Classes

class  Item_func
 
class  Item_real_func
 
class  Item_func_numhybrid
 
class  Item_func_num1
 
class  Item_num_op
 
class  Item_int_func
 
class  Item_func_connection_id
 
class  Item_typecast_signed
 
class  Item_typecast_unsigned
 
class  Item_typecast_decimal
 
class  Item_typecast_real
 Class used to implement CAST to floating-point data types. More...
 
class  Item_func_additive_op
 
class  Item_func_plus
 
class  Item_func_minus
 
class  Item_func_mul
 
class  Item_func_div_base
 
class  Item_func_div
 
class  Item_func_div_int
 
class  Item_func_mod
 
class  Item_func_neg
 
class  Item_func_abs
 
class  Item_dec_func
 
class  Item_func_exp
 
class  Item_func_ln
 
class  Item_func_log
 
class  Item_func_log2
 
class  Item_func_log10
 
class  Item_func_sqrt
 
class  Item_func_pow
 
class  Item_func_acos
 
class  Item_func_asin
 
class  Item_func_atan
 
class  Item_func_cos
 
class  Item_func_sin
 
class  Item_func_tan
 
class  Item_func_cot
 
class  Item_func_int_val
 
class  Item_func_ceiling
 
class  Item_func_floor
 
class  Item_func_round
 
class  Item_func_rand
 
class  Item_func_sign
 
class  Item_func_units
 
class  Item_func_degrees
 
class  Item_func_radians
 
class  Item_func_min_max
 
class  Item_func_min
 
class  Item_func_max
 
class  Item_rollup_group_item
 A wrapper Item that normally returns its parameter, but becomes NULL when processing rows for rollup. More...
 
class  Item_func_length
 
class  Item_func_bit_length
 
class  Item_func_char_length
 
class  Item_func_coercibility
 
class  Item_func_locate
 
class  Item_func_instr
 
class  Item_func_validate_password_strength
 
class  Item_func_field
 
class  Item_func_ascii
 
class  Item_func_ord
 
class  Item_func_find_in_set
 
class  Item_func_bit
 
class  Item_func_bit_two_param
 Base class for all the bit functions that work with two binary arguments: '&', '|', '^'. More...
 
class  Item_func_bit_or
 
class  Item_func_bit_and
 
class  Item_func_bit_xor
 
class  Item_func_bit_count
 
class  Item_func_shift
 
class  Item_func_shift_left
 
class  Item_func_shift_right
 
class  Item_func_bit_neg
 
class  Item_func_last_insert_id
 
class  Item_func_benchmark
 
class  Item_func_sleep
 
class  Item_udf_func
 
class  Item_func_udf_float
 
class  Item_func_udf_int
 
class  Item_func_udf_decimal
 
class  Item_func_udf_str
 
class  Item_func_get_lock
 
class  Item_func_release_lock
 
class  Item_func_release_all_locks
 
class  Item_source_pos_wait
 
class  Item_master_pos_wait
 
class  Item_func_can_access_database
 Internal functions used by INFORMATION_SCHEMA implementation to check if user have access to given database/table/column. More...
 
class  Item_func_can_access_table
 
class  Item_func_can_access_user
 
class  Item_func_can_access_trigger
 
class  Item_func_can_access_routine
 
class  Item_func_can_access_event
 
class  Item_func_can_access_resource_group
 
class  Item_func_can_access_view
 
class  Item_func_can_access_column
 
class  Item_func_is_visible_dd_object
 
class  Item_func_internal_table_rows
 
class  Item_func_internal_avg_row_length
 
class  Item_func_internal_data_length
 
class  Item_func_internal_max_data_length
 
class  Item_func_internal_index_length
 
class  Item_func_internal_data_free
 
class  Item_func_internal_auto_increment
 
class  Item_func_internal_checksum
 
class  Item_func_internal_keys_disabled
 
class  Item_func_internal_index_column_cardinality
 
class  Item_func_internal_dd_char_length
 
class  Item_func_internal_get_view_warning_or_error
 
class  Item_func_get_dd_index_sub_part_length
 
class  Item_func_internal_tablespace_id
 
class  Item_func_internal_tablespace_logfile_group_number
 
class  Item_func_internal_tablespace_free_extents
 
class  Item_func_internal_tablespace_total_extents
 
class  Item_func_internal_tablespace_extent_size
 
class  Item_func_internal_tablespace_initial_size
 
class  Item_func_internal_tablespace_maximum_size
 
class  Item_func_internal_tablespace_autoextend_size
 
class  Item_func_internal_tablespace_version
 
class  Item_func_internal_tablespace_data_free
 
class  Item_var_func
 Common class for: Item_func_get_system_var Item_func_get_user_var Item_func_set_user_var. More...
 
class  user_var_entry
 
class  Item_func_set_user_var
 This class is used to implement operations like SET @variable or @variable:= expression. More...
 
class  Item_func_get_user_var
 
class  Item_user_var_as_out_param
 
class  Audit_global_variable_get_event
 Class to log audit event EVENT_TRACKING_GLOBAL_VARIABLE_GET. More...
 
class  Item_func_get_system_var
 
class  Item_func_match
 
class  NonAggregatedFullTextSearchVisitor
 A visitor that calls the specified function on every non-aggregated full-text search function (Item_func_match) it encounters when it is used in a PREFIX+POSTFIX walk with WalkItem(). More...
 
class  Item_func_is_free_lock
 
class  Item_func_is_used_lock
 
class  Item_func_row_count
 
class  Item_func_sp
 
class  Item_func_found_rows
 
class  Item_func_uuid_short
 
class  Item_func_version
 
class  Item_func_internal_is_mandatory_role
 Internal function used by INFORMATION_SCHEMA implementation to check if a role is a mandatory role. More...
 
class  Item_func_internal_use_terminology_previous
 
class  Item_func_internal_is_enabled_role
 Internal function used by INFORMATION_SCHEMA implementation to check if a role is enabled. More...
 

Macros

#define GET_SYS_VAR_CACHE_LONG   1
 
#define GET_SYS_VAR_CACHE_DOUBLE   2
 
#define GET_SYS_VAR_CACHE_STRING   4
 

Functions

bool reject_geometry_args (uint arg_count, Item **args, Item_result_field *me)
 
void unsupported_json_comparison (size_t arg_count, Item **args, const char *msg)
 Go through the arguments of a function and check if any of them are JSON. More...
 
void report_conversion_error (const CHARSET_INFO *to_cs, const char *from, size_t from_length, const CHARSET_INFO *from_cs)
 
bool simplify_string_args (THD *thd, const DTCollation &c, Item **items, uint nitems)
 Simplify the string arguments to a function, if possible. More...
 
Stringeval_string_arg_noinline (const CHARSET_INFO *to_cs, Item *arg, String *buffer)
 Evaluate an argument string and return it in the desired character set. More...
 
Stringeval_string_arg (const CHARSET_INFO *to_cs, Item *arg, String *buffer)
 
void item_func_sleep_init ()
 
void item_func_sleep_free ()
 
void mysql_ull_cleanup (THD *thd)
 Release all user level locks for this THD. More...
 
void mysql_ull_set_explicit_lock_duration (THD *thd)
 Set explicit duration for metadata locks corresponding to user level locks to protect them from being released at the end of transaction. More...
 
void uuid_short_init ()
 
Itemget_system_variable (Parse_context *pc, enum_var_type scope, const LEX_CSTRING &prefix, const LEX_CSTRING &suffix, bool unsafe_for_replication)
 Create new Item_func_get_system_var object. More...
 
Itemget_system_variable (Parse_context *pc, enum_var_type scope, const LEX_CSTRING &trivial_name, bool unsafe_for_replication)
 
bool check_reserved_words (const char *name)
 
enum_field_types agg_field_type (Item **items, uint nitems)
 Aggregates field types from the array of items. More...
 
double my_double_round (double value, longlong dec, bool dec_unsigned, bool truncate)
 
bool eval_const_cond (THD *thd, Item *cond, bool *value)
 Evaluate a constant condition, represented by an Item tree. More...
 
Item_fieldget_gc_for_expr (const Item *func, Field *fld, Item_result type, Field **found=nullptr)
 Return new Item_field if given expression matches GC. More...
 
void retrieve_tablespace_statistics (THD *thd, Item **args, bool *null_value)
 Retrieve tablespace statistics from SE. More...
 
bool is_function_of_type (const Item *item, Item_func::Functype type)
 Checks if "item" is a function of the specified type. More...
 
bool contains_function_of_type (Item *item, Item_func::Functype type)
 Checks if "item" contains a function of the specified type. More...
 

Variables

bool volatile mqh_used
 

Macro Definition Documentation

◆ GET_SYS_VAR_CACHE_DOUBLE

#define GET_SYS_VAR_CACHE_DOUBLE   2

◆ GET_SYS_VAR_CACHE_LONG

#define GET_SYS_VAR_CACHE_LONG   1

◆ GET_SYS_VAR_CACHE_STRING

#define GET_SYS_VAR_CACHE_STRING   4

Function Documentation

◆ agg_field_type()

enum_field_types agg_field_type ( Item **  items,
uint  nitems 
)

Aggregates field types from the array of items.

Parameters
[in]itemsarray of items to aggregate the type from
[in]nitemsnumber of items in the array

This function aggregates field types from the array of items. Found type is supposed to be used later as the result field type of a multi-argument function. Aggregation itself is performed by the Field::field_type_merge() function.

Note
The term "aggregation" is used here in the sense of inferring the result type of a function from its argument types.
Returns
aggregated field type.

◆ check_reserved_words()

bool check_reserved_words ( const char *  name)

◆ contains_function_of_type()

bool contains_function_of_type ( Item item,
Item_func::Functype  type 
)

Checks if "item" contains a function of the specified type.

◆ eval_const_cond()

bool eval_const_cond ( THD thd,
Item cond,
bool *  value 
)

Evaluate a constant condition, represented by an Item tree.

Parameters
thdThread handler
condThe constant condition to evaluate
[out]valueReturned value, either true or false
Returns
false if evaluation is successful, true otherwise

◆ eval_string_arg()

String * eval_string_arg ( const CHARSET_INFO to_cs,
Item arg,
String buffer 
)
inline

◆ eval_string_arg_noinline()

String * eval_string_arg_noinline ( const CHARSET_INFO to_cs,
Item arg,
String buffer 
)

Evaluate an argument string and return it in the desired character set.

Perform character set conversion if needed. Perform character set validation (from a binary string) if needed.

Parameters
to_csThe desired character set
argArgument to evaluate as a string value
bufferString buffer where argument is evaluated, if necessary
Returns
string pointer if success, NULL if error or NULL value

◆ get_gc_for_expr()

Item_field * get_gc_for_expr ( const Item func,
Field fld,
Item_result  type,
Field **  found 
)

Return new Item_field if given expression matches GC.

See also
substitute_gc()
Parameters
funcExpression to be replaced
fldGCs field
typeResult type to match with Field
[out]foundIf given, just return found field, without Item_field
Returns
item new Item_field for matched GC NULL otherwise

◆ get_system_variable() [1/2]

Item * get_system_variable ( Parse_context pc,
enum_var_type  scope,
const LEX_CSTRING prefix,
const LEX_CSTRING suffix,
bool  unsafe_for_replication 
)

Create new Item_func_get_system_var object.

Parameters
pcParse context
scopeScope of the variable (GLOBAL, SESSION, PERSISTENT ...)
prefixEmpty LEX_CSTRING{} or the left hand side of the composite variable name, e.g.: component name of the component-registered variable name of MyISAM Multiple Key Cache.
suffixName of the variable (if prefix is empty) or the right hand side of the composite variable name, e.g.: name of the component-registered variable property name of MyISAM Multiple Key Cache variable.
unsafe_for_replicationforce writing this system variable to binlog (if not written yet)
Returns
new item on success, otherwise nullptr

Create new Item_func_get_system_var object.

Parameters
pcCurrent parse context
scopeGlobal / session
prefixOptional prefix part of the variable name
suffixTrivial name of suffix part of the variable name
unsafe_for_replicationIf true and if the variable is written to a binlog then mark the statement as unsafe.
Note
If component.str = 0 then the variable name is in 'name'
Returns
  • 0 : error
  • # : constant item

◆ get_system_variable() [2/2]

Item * get_system_variable ( Parse_context pc,
enum_var_type  scope,
const LEX_CSTRING trivial_name,
bool  unsafe_for_replication 
)
inline

◆ is_function_of_type()

bool is_function_of_type ( const Item item,
Item_func::Functype  type 
)

Checks if "item" is a function of the specified type.

◆ item_func_sleep_free()

void item_func_sleep_free ( )

◆ item_func_sleep_init()

void item_func_sleep_init ( )

◆ my_double_round()

double my_double_round ( double  value,
longlong  dec,
bool  dec_unsigned,
bool  truncate 
)

◆ mysql_ull_cleanup()

void mysql_ull_cleanup ( THD thd)

Release all user level locks for this THD.

◆ mysql_ull_set_explicit_lock_duration()

void mysql_ull_set_explicit_lock_duration ( THD thd)

Set explicit duration for metadata locks corresponding to user level locks to protect them from being released at the end of transaction.

◆ reject_geometry_args()

bool reject_geometry_args ( uint  arg_count,
Item **  args,
Item_result_field me 
)

◆ report_conversion_error()

void report_conversion_error ( const CHARSET_INFO to_cs,
const char *  from,
size_t  from_length,
const CHARSET_INFO from_cs 
)

◆ retrieve_tablespace_statistics()

void retrieve_tablespace_statistics ( THD thd,
Item **  args,
bool *  null_value 
)

Retrieve tablespace statistics from SE.

Parameters
thdThe current thread.
argsList of parameters in following order,
                   - Tablespace_name
                   - Engine_name
                   - Tablespace_se_private_data
[out]null_valueMarked true indicating NULL, if there is no value.

◆ simplify_string_args()

bool simplify_string_args ( THD thd,
const DTCollation c,
Item **  args,
uint  nargs 
)

Simplify the string arguments to a function, if possible.

Currently used to substitute const values with character strings in the desired character set. Only used during resolving.

Parameters
thdthread handler
cDesired character set and collation
argsPointer to argument array
nargsNumber of arguments to process
Returns
false if success, true if error

◆ unsupported_json_comparison()

void unsupported_json_comparison ( size_t  arg_count,
Item **  args,
const char *  msg 
)

Go through the arguments of a function and check if any of them are JSON.

If a JSON argument is found, raise a warning saying that this operation is not supported yet. This function is used to notify users that they are comparing JSON values using a mechanism that has not yet been updated to use the JSON comparator. JSON values are typically handled as strings in that case.

Parameters
arg_countthe number of arguments
argsthe arguments to go through looking for JSON values
msgthe message that explains what is not supported

◆ uuid_short_init()

void uuid_short_init ( )

Variable Documentation

◆ mqh_used

bool volatile mqh_used
extern