MySQL 9.1.0
Source Code Documentation
item_create.cc File Reference

Functions to create an item. More...

#include "sql/item_create.h"
#include <errno.h>
#include <limits.h>
#include <stdint.h>
#include <stdlib.h>
#include <sys/types.h>
#include <algorithm>
#include <cctype>
#include <iterator>
#include <limits>
#include <new>
#include <string>
#include <unordered_map>
#include <utility>
#include "decimal.h"
#include "field_types.h"
#include "m_string.h"
#include "my_dbug.h"
#include "my_inttypes.h"
#include "my_sys.h"
#include "my_time.h"
#include "mysql/strings/dtoa.h"
#include "mysql/strings/m_ctype.h"
#include "mysql/strings/my_strtoll10.h"
#include "mysql/udf_registration_types.h"
#include "mysql_time.h"
#include "mysqld_error.h"
#include "sql-common/my_decimal.h"
#include "sql/item.h"
#include "sql/item_cmpfunc.h"
#include "sql/item_func.h"
#include "sql/item_geofunc.h"
#include "sql/item_gtid_func.h"
#include "sql/item_inetfunc.h"
#include "sql/item_json_func.h"
#include "sql/item_pfs_func.h"
#include "sql/item_regexp_func.h"
#include "sql/item_strfunc.h"
#include "sql/item_sum.h"
#include "sql/item_timefunc.h"
#include "sql/item_xmlfunc.h"
#include "sql/parse_location.h"
#include "sql/parse_tree_helpers.h"
#include "sql/parser_yystype.h"
#include "sql/sql_class.h"
#include "sql/sql_const.h"
#include "sql/sql_error.h"
#include "sql/sql_exception_handler.h"
#include "sql/sql_lex.h"
#include "sql/sql_time.h"
#include "sql/sql_udf.h"
#include "sql/system_variables.h"
#include "sql_string.h"
#include "tztime.h"

Classes

class  anonymous_namespace{item_create.cc}::Instantiator< Function_class, Min_argc, Max_argc >
 Instantiates a function class with the list of arguments. More...
 
class  anonymous_namespace{item_create.cc}::Instantiator< Function_class, 0 >
 Instantiates a function class with no arguments. More...
 
class  anonymous_namespace{item_create.cc}::Instantiator_with_thd< Function_class, Min_argc, Max_argc >
 
class  anonymous_namespace{item_create.cc}::Instantiator_with_functype< Function_class, Functype, Min_argc, Max_argc >
 
class  anonymous_namespace{item_create.cc}::Instantiator_with_functype< Function_class, Function_type, 1, 1 >
 
class  anonymous_namespace{item_create.cc}::Instantiator_with_functype< Function_class, Function_type, 2, 2 >
 
class  anonymous_namespace{item_create.cc}::List_instantiator< Function_class, Min_argc, Max_argc >
 
class  anonymous_namespace{item_create.cc}::List_instantiator_with_thd< Function_class, Min_argc, Max_argc >
 
class  anonymous_namespace{item_create.cc}::Instantiator< Function_class, 1 >
 Instantiates a function class with one argument. More...
 
class  anonymous_namespace{item_create.cc}::Instantiator< Function_class, 2 >
 Instantiates a function class with two arguments. More...
 
class  anonymous_namespace{item_create.cc}::Instantiator< Function_class, 3 >
 Instantiates a function class with three arguments. More...
 
class  anonymous_namespace{item_create.cc}::Instantiator< Function_class, 4 >
 Instantiates a function class with four arguments. More...
 
class  anonymous_namespace{item_create.cc}::Instantiator< Function_class, 5 >
 Instantiates a function class with five arguments. More...
 
class  anonymous_namespace{item_create.cc}::Instantiator< Function_class, 0, 1 >
 Instantiates a function class with zero or one arguments. More...
 
class  anonymous_namespace{item_create.cc}::Instantiator< Function_class, 1, 2 >
 Instantiates a function class with one or two arguments. More...
 
class  anonymous_namespace{item_create.cc}::Instantiator< Function_class, 1, 3 >
 Instantiates a function class with between one and three arguments. More...
 
class  anonymous_namespace{item_create.cc}::Instantiator_with_thd< Function_class, 1, 3 >
 Instantiates a function class taking between one and three arguments. More...
 
class  anonymous_namespace{item_create.cc}::Instantiator_with_thd< Function_class, 1, 2 >
 Instantiates a function class taking a thd and one or two arguments. More...
 
class  anonymous_namespace{item_create.cc}::Instantiator< Function_class, 2, 3 >
 Instantiates a function class with two or three arguments. More...
 
class  anonymous_namespace{item_create.cc}::Instantiator< Function_class, 2, 4 >
 Instantiates a function class with between two and four arguments. More...
 
class  anonymous_namespace{item_create.cc}::Instantiator< Function_class, 2, 6 >
 Instantiates a function class with between two and six arguments. More...
 
class  anonymous_namespace{item_create.cc}::Instantiator< Function_class, 3, 5 >
 Instantiates a function class with two or three arguments. More...
 
class  anonymous_namespace{item_create.cc}::Geometry_instantiator< Geometry_class, Functype >
 
class  anonymous_namespace{item_create.cc}::Bin_instantiator
 
class  anonymous_namespace{item_create.cc}::Oct_instantiator
 
class  anonymous_namespace{item_create.cc}::Weekday_instantiator
 
class  anonymous_namespace{item_create.cc}::Weekofyear_instantiator
 
class  anonymous_namespace{item_create.cc}::Datediff_instantiator
 
class  anonymous_namespace{item_create.cc}::Subtime_instantiator
 
class  anonymous_namespace{item_create.cc}::Time_format_instantiator
 
class  anonymous_namespace{item_create.cc}::Dayofweek_instantiator
 
class  anonymous_namespace{item_create.cc}::From_unixtime_instantiator
 
class  anonymous_namespace{item_create.cc}::Round_instantiator
 
class  anonymous_namespace{item_create.cc}::Locate_instantiator
 
class  anonymous_namespace{item_create.cc}::Srid_instantiator
 
class  anonymous_namespace{item_create.cc}::Latitude_instantiator
 
class  anonymous_namespace{item_create.cc}::Longitude_instantiator
 
class  anonymous_namespace{item_create.cc}::X_instantiator
 
class  anonymous_namespace{item_create.cc}::Y_instantiator
 
class  anonymous_namespace{item_create.cc}::Yearweek_instantiator
 
class  anonymous_namespace{item_create.cc}::Make_set_instantiator
 
class  anonymous_namespace{item_create.cc}::Json_length_instantiator
 Instantiates a call to JSON_LENGTH, which may take either one or two arguments. More...
 
class  anonymous_namespace{item_create.cc}::Function_factory< Instantiator_fn >
 Factory for creating function objects. More...
 
class  anonymous_namespace{item_create.cc}::Odd_argcount_function_factory< Instantiator_fn >
 
class  anonymous_namespace{item_create.cc}::Even_argcount_function_factory< Instantiator_fn >
 
class  anonymous_namespace{item_create.cc}::Internal_function_factory< Instantiator_fn >
 Factory for internal functions that should be invoked from the system views only. More...
 
class  Create_sp_func
 Function builder for stored functions. More...
 

Namespaces

namespace  anonymous_namespace{item_create.cc}
 

Macros

#define SQL_FN(F, N)   &Function_factory<Instantiator<F, N>>::s_singleton
 Shorthand macro to reference the singleton instance. More...
 
#define SQL_FACTORY(INSTANTIATOR)   &Function_factory<INSTANTIATOR>::s_singleton
 Shorthand macro to reference the singleton instance when there is a specialized instantiator. More...
 
#define SQL_FN_V(F, MIN, MAX)    &Function_factory<Instantiator<F, MIN, MAX>>::s_singleton
 Use this macro if you want to instantiate the Item_func object like Item_func_xxx::Item_func_xxx(pos, args[0], ..., args[MAX]) More...
 
#define SQL_FN_V_THD(F, MIN, MAX)    &Function_factory<Instantiator_with_thd<F, MIN, MAX>>::s_singleton
 Use this macro if you want to instantiate the Item_func object like Item_func_xxx::Item_func_xxx(thd, pos, args[0], ..., args[MAX]) More...
 
#define SQL_FN_V_LIST(F, MIN, MAX)    &Function_factory<List_instantiator<F, MIN, MAX>>::s_singleton
 Use this macro if you want to instantiate the Item_func object like Item_func_xxx::Item_func_xxx(pos, item_list) More...
 
#define SQL_FN_LIST(F, N)    &Function_factory<List_instantiator<F, N>>::s_singleton
 Use this macro if you want to instantiate the Item_func object like Item_func_xxx::Item_func_xxx(pos, item_list) More...
 
#define SQL_FN_V_LIST_THD(F, MIN, MAX)    &Function_factory<List_instantiator_with_thd<F, MIN, MAX>>::s_singleton
 Use this macro if you want to instantiate the Item_func object like Item_func_xxx::Item_func_xxx(thd, pos, item_list) More...
 
#define SQL_FN_ODD(F, MIN, MAX)
 Just like SQL_FN_V_THD, but enforces a check that the argument count is odd. More...
 
#define SQL_FN_EVEN(F, MIN, MAX)
 Just like SQL_FN_V_THD, but enforces a check that the argument count is even. More...
 
#define SQL_FN_INTERNAL(F, N)    &Internal_function_factory<Instantiator<F, N>>::s_singleton
 Like SQL_FN, but for functions that may only be referenced from system views. More...
 
#define SQL_FN_INTERNAL_V(F, MIN, MAX)    &Internal_function_factory<Instantiator<F, MIN, MAX>>::s_singleton
 Just like SQL_FN_INTERNAL, but enforces a check that the argument count is even. More...
 
#define SQL_FN_LIST_INTERNAL(F, N)    &Internal_function_factory<List_instantiator<F, N>>::s_singleton
 Like SQL_FN_LIST, but for functions that may only be referenced from system views. More...
 
#define SQL_FN_LIST_INTERNAL_V(F, MIN, MAX)    &Internal_function_factory<List_instantiator<F, MIN, MAX>>::s_singleton
 Like SQL_FN_LIST, but enforces a check that the argument count is within the range specified. More...
 

Typedefs

template<Item_func::Functype Functype>
using anonymous_namespace{item_create.cc}::Spatial_decomp_instantiator = Instantiator_with_functype< Item_func_spatial_decomp, Functype, 1 >
 
using anonymous_namespace{item_create.cc}::Startpoint_instantiator = Spatial_decomp_instantiator< Item_func::SP_STARTPOINT >
 
using anonymous_namespace{item_create.cc}::Endpoint_instantiator = Spatial_decomp_instantiator< Item_func::SP_ENDPOINT >
 
using anonymous_namespace{item_create.cc}::Exteriorring_instantiator = Spatial_decomp_instantiator< Item_func::SP_EXTERIORRING >
 
template<Item_func::Functype Functype>
using anonymous_namespace{item_create.cc}::Spatial_decomp_n_instantiator = Instantiator_with_functype< Item_func_spatial_decomp_n, Functype, 2 >
 
using anonymous_namespace{item_create.cc}::Sp_geometryn_instantiator = Spatial_decomp_n_instantiator< Item_func::SP_GEOMETRYN >
 
using anonymous_namespace{item_create.cc}::Sp_interiorringn_instantiator = Spatial_decomp_n_instantiator< Item_func::SP_INTERIORRINGN >
 
using anonymous_namespace{item_create.cc}::Sp_pointn_instantiator = Spatial_decomp_n_instantiator< Item_func::SP_POINTN >
 
using anonymous_namespace{item_create.cc}::txt_ft = Item_func_geometry_from_text::Functype
 
using anonymous_namespace{item_create.cc}::I_txt = Item_func_geometry_from_text
 
template<typename Geometry_class , enum Geometry_class::Functype Functype>
using anonymous_namespace{item_create.cc}::G_i = Geometry_instantiator< Geometry_class, Functype >
 
using anonymous_namespace{item_create.cc}::Geomcollfromtext_instantiator = G_i< I_txt, txt_ft::GEOMCOLLFROMTEXT >
 
using anonymous_namespace{item_create.cc}::Geomcollfromtxt_instantiator = G_i< I_txt, txt_ft::GEOMCOLLFROMTXT >
 
using anonymous_namespace{item_create.cc}::Geometrycollectionfromtext_instantiator = G_i< I_txt, txt_ft::GEOMETRYCOLLECTIONFROMTEXT >
 
using anonymous_namespace{item_create.cc}::Geometryfromtext_instantiator = G_i< I_txt, txt_ft::GEOMETRYFROMTEXT >
 
using anonymous_namespace{item_create.cc}::Geomfromtext_instantiator = G_i< I_txt, txt_ft::GEOMFROMTEXT >
 
using anonymous_namespace{item_create.cc}::Linefromtext_instantiator = G_i< I_txt, txt_ft::LINEFROMTEXT >
 
using anonymous_namespace{item_create.cc}::Linestringfromtext_instantiator = G_i< I_txt, txt_ft::LINESTRINGFROMTEXT >
 
using anonymous_namespace{item_create.cc}::Mlinefromtext_instantiator = G_i< I_txt, txt_ft::MLINEFROMTEXT >
 
using anonymous_namespace{item_create.cc}::Mpointfromtext_instantiator = G_i< I_txt, txt_ft::MPOINTFROMTEXT >
 
using anonymous_namespace{item_create.cc}::Mpolyfromtext_instantiator = G_i< I_txt, txt_ft::MPOLYFROMTEXT >
 
using anonymous_namespace{item_create.cc}::Multilinestringfromtext_instantiator = G_i< I_txt, txt_ft::MULTILINESTRINGFROMTEXT >
 
using anonymous_namespace{item_create.cc}::Multipointfromtext_instantiator = G_i< I_txt, txt_ft::MULTIPOINTFROMTEXT >
 
using anonymous_namespace{item_create.cc}::Multipolygonfromtext_instantiator = G_i< I_txt, txt_ft::MULTIPOLYGONFROMTEXT >
 
using anonymous_namespace{item_create.cc}::Pointfromtext_instantiator = G_i< I_txt, txt_ft::POINTFROMTEXT >
 
using anonymous_namespace{item_create.cc}::Polyfromtext_instantiator = G_i< I_txt, txt_ft::POLYFROMTEXT >
 
using anonymous_namespace{item_create.cc}::Polygonfromtext_instantiator = G_i< I_txt, txt_ft::POLYGONFROMTEXT >
 
using anonymous_namespace{item_create.cc}::wkb_ft = Item_func_geometry_from_wkb::Functype
 
using anonymous_namespace{item_create.cc}::I_wkb = Item_func_geometry_from_wkb
 
using anonymous_namespace{item_create.cc}::Geomcollfromwkb_instantiator = G_i< I_wkb, wkb_ft::GEOMCOLLFROMWKB >
 
using anonymous_namespace{item_create.cc}::Geometrycollectionfromwkb_instantiator = G_i< I_wkb, wkb_ft::GEOMETRYCOLLECTIONFROMWKB >
 
using anonymous_namespace{item_create.cc}::Geometryfromwkb_instantiator = G_i< I_wkb, wkb_ft::GEOMETRYFROMWKB >
 
using anonymous_namespace{item_create.cc}::Geomfromwkb_instantiator = G_i< I_wkb, wkb_ft::GEOMFROMWKB >
 
using anonymous_namespace{item_create.cc}::Linefromwkb_instantiator = G_i< I_wkb, wkb_ft::LINEFROMWKB >
 
using anonymous_namespace{item_create.cc}::Linestringfromwkb_instantiator = G_i< I_wkb, wkb_ft::LINESTRINGFROMWKB >
 
using anonymous_namespace{item_create.cc}::Mlinefromwkb_instantiator = G_i< I_wkb, wkb_ft::MLINEFROMWKB >
 
using anonymous_namespace{item_create.cc}::Mpointfromwkb_instantiator = G_i< I_wkb, wkb_ft::MPOINTFROMWKB >
 
using anonymous_namespace{item_create.cc}::Mpolyfromwkb_instantiator = G_i< I_wkb, wkb_ft::MPOLYFROMWKB >
 
using anonymous_namespace{item_create.cc}::Multilinestringfromwkb_instantiator = G_i< I_wkb, wkb_ft::MULTILINESTRINGFROMWKB >
 
using anonymous_namespace{item_create.cc}::Multipointfromwkb_instantiator = G_i< I_wkb, wkb_ft::MULTIPOINTFROMWKB >
 
using anonymous_namespace{item_create.cc}::Multipolygonfromwkb_instantiator = G_i< I_wkb, wkb_ft::MULTIPOLYGONFROMWKB >
 
using anonymous_namespace{item_create.cc}::Pointfromwkb_instantiator = G_i< I_wkb, wkb_ft::POINTFROMWKB >
 
using anonymous_namespace{item_create.cc}::Polyfromwkb_instantiator = G_i< I_wkb, wkb_ft::POLYFROMWKB >
 
using anonymous_namespace{item_create.cc}::Polygonfromwkb_instantiator = G_i< I_wkb, wkb_ft::POLYGONFROMWKB >
 
using Native_functions_hash = std::unordered_map< std::string, Create_func * >
 

Functions

uint anonymous_namespace{item_create.cc}::arglist_length (const PT_item_list *args)
 
bool anonymous_namespace{item_create.cc}::check_argcount_bounds (THD *, LEX_STRING function_name, PT_item_list *item_list, uint min_argcount, uint max_argcount)
 
bool item_create_init ()
 Load the hash table for native functions. More...
 
void item_create_cleanup ()
 Empty the hash table for native functions. More...
 
Create_funcfind_native_function_builder (const LEX_STRING &name)
 Find the native function builder associated with a given function name. More...
 
Create_qfuncfind_qualified_function_builder (THD *thd)
 Find the function builder for qualified functions. More...
 
Itemcreate_func_cast (THD *thd, const POS &pos, Item *a, Cast_target cast_target, const CHARSET_INFO *cs)
 
static bool validate_cast_type_and_extract_length (const THD *thd, Item *arg, const Cast_type &cast_type, bool as_array, int64_t *length, uint *precision)
 Validates a cast target type and extracts the specified length and precision of the target type. More...
 
Itemcreate_func_cast (THD *thd, const POS &pos, Item *arg, const Cast_type &type, bool as_array)
 This function does not store the reference to type. More...
 
Itemcreate_func_json_value (THD *thd, const POS &pos, Item *arg, Item *path, const Cast_type &type, Json_on_response_type on_empty_type, Item *on_empty_default, Json_on_response_type on_error_type, Item *on_error_default)
 Creates an Item that represents a JSON_VALUE expression. More...
 
Itemcreate_temporal_literal (THD *thd, const char *str, size_t length, const CHARSET_INFO *cs, enum_field_types type, bool send_error)
 Builder for datetime literals: TIME'00:00:00', DATE'2001-01-01', TIMESTAMP'2001-01-01 00:00:00'. More...
 

Variables

constexpr auto anonymous_namespace{item_create.cc}::MAX_ARGLIST_SIZE
 We use this to declare that a function takes an infinite number of arguments. More...
 
static const std::pair< const char *, Create_func * > func_array []
 MySQL native functions. More...
 
static const Native_functions_hashnative_functions_hash
 

Detailed Description

Functions to create an item.

Used by sql_yacc.yy