MySQL 8.3.0
Source Code Documentation
Item_field Class Reference

#include <item.h>

Inheritance diagram for Item_field:
[legend]

Public Member Functions

void set_item_equal (Item_equal *item_equal_arg)
 
void set_item_equal_all_join_nests (Item_equal *item_equal)
 
 Item_field (Name_resolution_context *context_arg, const char *db_arg, const char *table_name_arg, const char *field_name_arg)
 Constructor used for internal information queries. More...
 
 Item_field (const POS &pos, const char *db_arg, const char *table_name_arg, const char *field_name_arg)
 Used from parser to construct column references. More...
 
 Item_field (THD *thd, Item_field *item)
 Used to create a copy (clone) of another Item_field. More...
 
 Item_field (THD *thd, Name_resolution_context *context_arg, Table_ref *tr, Field *field)
 Constructor used inside setup_wild(). More...
 
 Item_field (Field *field)
 Create column reference based on a table field. More...
 
bool do_itemize (Parse_context *pc, Item **res) override
 The core function that does the actual itemization. More...
 
enum Type type () const override
 
bool eq (const Item *item, bool binary_cmp) const override
 
double val_real () override
 
longlong val_int () override
 
longlong val_time_temporal () override
 Return time value of item in packed longlong format. More...
 
longlong val_date_temporal () override
 Return date value of item in packed longlong format. More...
 
longlong val_time_temporal_at_utc () override
 
longlong val_date_temporal_at_utc () override
 
my_decimalval_decimal (my_decimal *) override
 
Stringval_str (String *) override
 
bool val_json (Json_wrapper *result) override
 Get a JSON value from an Item. More...
 
bool send (Protocol *protocol, String *str_arg) override
 This is only called from items that is not of type item_field. More...
 
void reset_field (Field *f)
 Reset this item to point to a field from the new temporary table. More...
 
bool fix_fields (THD *, Item **) override
 Resolve the name of a column reference. More...
 
void make_field (Send_field *tmp_field) override
 
void save_org_in_field (Field *field) override
 Set a field's value from a item. More...
 
table_map used_tables () const override
 
Item_result result_type () const override
 
Item_result numeric_context_result_type () const override
 Result type when an item appear in a numeric context. More...
 
TYPELIBget_typelib () const override
 Get the typelib information for an item of type set or enum. More...
 
Item_result cast_to_int_type () const override
 
enum_monotonicity_info get_monotonicity_info () const override
 
longlong val_int_endpoint (bool left_endp, bool *incl_endp) override
 
void set_result_field (Field *field_arg) override
 
Fieldget_tmp_table_field () override
 If this Item is being materialized into a temporary table, returns the field that is being materialized into. More...
 
Fieldtmp_table_field (TABLE *) override
 
void set_base_item_field (const Item_field *item)
 
const Item_fieldbase_item_field () const
 
bool get_date (MYSQL_TIME *ltime, my_time_flags_t fuzzydate) override
 
bool get_time (MYSQL_TIME *ltime) override
 
bool get_timeval (my_timeval *tm, int *warnings) override
 Get timestamp in "struct timeval" format. More...
 
bool is_null () override
 The method allows to determine nullness of a complex expression without fully evaluating it, instead of calling val*() then checking null_value. More...
 
Itemget_tmp_table_item (THD *thd) override
 If an Item is materialized in a temporary table, a different Item may have to be used in the part of the query that runs after the materialization. More...
 
bool collect_item_field_processor (uchar *arg) override
 Store the pointer to this item field into a list if not already there. More...
 
bool collect_item_field_or_ref_processor (uchar *arg) override
 When collecting information about columns when transforming correlated scalar subqueries using derived tables, we need to decide which duplicates, if any, to retain: More...
 
bool collect_item_field_or_view_ref_processor (uchar *arg) override
 Collects fields and view references that have the qualifying table in the specified query block. More...
 
bool add_field_to_set_processor (uchar *arg) override
 Item::walk function. More...
 
bool add_field_to_cond_set_processor (uchar *) override
 Item::walk function. More...
 
bool remove_column_from_bitmap (uchar *arg) override
 Visitor interface for removing all column expressions (Item_field) in this expression tree from a bitmap. More...
 
bool find_item_in_field_list_processor (uchar *arg) override
 Check if an Item_field references some field from a list of fields. More...
 
bool find_field_processor (uchar *arg) override
 Is this an Item_field which references the given Field argument? More...
 
bool check_function_as_value_generator (uchar *args) override
 Check if this item is allowed for a virtual column or inside a default expression. More...
 
bool mark_field_in_map (uchar *arg) override
 Mark underlying field in read or write map of a table. More...
 
bool used_tables_for_level (uchar *arg) override
 Return used table information for the specified query block (level). More...
 
bool check_column_privileges (uchar *arg) override
 Check privileges of base table column. More...
 
bool check_partition_func_processor (uchar *) override
 Check if a partition function is allowed. More...
 
void bind_fields () override
 Bind objects from the current execution context to field objects in item trees. More...
 
bool is_valid_for_pushdown (uchar *arg) override
 Check if all the columns present in this expression are from the derived table. More...
 
bool check_column_in_window_functions (uchar *arg) override
 Check if this column is found in PARTITION clause of all the window functions. More...
 
bool check_column_in_group_by (uchar *arg) override
 Check if this column is found in GROUP BY. More...
 
Itemreplace_with_derived_expr (uchar *arg) override
 Assuming this expression is part of a condition that would be pushed to the WHERE clause of a materialized derived table, replace, in this expression, each derived table's column with a clone of the expression lying under it in the derived table's definition. More...
 
Itemreplace_with_derived_expr_ref (uchar *arg) override
 Assuming this expression is part of a condition that would be pushed to the HAVING clause of a materialized derived table, replace, in this expression, each derived table's column with a reference to the expression lying under it in the derived table's definition. More...
 
void cleanup () override
 Called for every Item after use (preparation and execution). More...
 
void reset_field ()
 Reset all aspect of a field object, so that it can be re-resolved. More...
 
Item_equalfind_item_equal (COND_EQUAL *cond_equal) const
 Find a field among specified multiple equalities. More...
 
bool subst_argument_checker (uchar **arg) override
 Check whether a field can be substituted by an equal item. More...
 
Itemequal_fields_propagator (uchar *arg) override
 If field matches a multiple equality, set a pointer to that object in the field. More...
 
Itemreplace_item_field (uchar *) override
 If this field is the target is the target of replacement, replace it with the info object's item or, if the item is found inside a subquery, the target is an outer reference, so we create a new Item_field, mark it accordingly and replace with that instead. More...
 
bool disable_constant_propagation (uchar *) override
 
Itemreplace_equal_field (uchar *) override
 Replace an Item_field for an equal Item_field that evaluated earlier (if any). More...
 
uint32 max_disp_length ()
 
Item_fieldfield_for_view_update () override
 
Itemsafe_charset_converter (THD *thd, const CHARSET_INFO *tocs) override
 
int fix_outer_field (THD *thd, Field **field, Item **reference)
 Resolve the name of an outer select column reference. More...
 
Itemupdate_value_transformer (uchar *select_arg) override
 Add the field to the select list and substitute it for the reference to the field. More...
 
void print (const THD *thd, String *str, enum_query_type query_type) const override
 This method is used for to: More...
 
bool is_outer_field () const override
 
Field::geometry_type get_geometry_type () const override
 
const CHARSET_INFOcharset_for_protocol (void) override
 
void dbug_print () const
 
float get_filtering_effect (THD *thd, table_map filter_for_table, table_map read_tables, const MY_BITMAP *fields_to_ignore, double rows_in_table) override
 Calculate condition filtering effect for "WHERE field", which implicitly means "WHERE field <> 0". More...
 
float get_cond_filter_default_probability (double max_distinct_values, float default_filter) const
 Returns the probability for the predicate "col OP <val>" to be true for a row in the case where no index statistics or range estimates are available for 'col'. More...
 
bool alias_name_used () const override
 
bool repoint_const_outer_ref (uchar *arg) override
 If this object is the real_item of an Item_ref, repoint the result_field to field. More...
 
bool returns_array () const override
 Whether the item returns array of its data type. More...
 
void set_can_use_prefix_key () override
 
bool replace_field_processor (uchar *arg) override
 A processor that replaces any Fields with a Create_field_wrapper. More...
 
bool strip_db_table_name_processor (uchar *) override
 Generated fields don't need db/table names. More...
 
virtual bool is_asterisk () const
 Checks if the current object represents an asterisk select list item. More...
 
bool protected_by_any_value () const
 See m_protected_by_any_value. More...
 
void compute_cost (CostOfItem *root_cost) const override
 Compute the cost of evaluating this Item. More...
 
- Public Member Functions inherited from Item_ident
 Item_ident (Name_resolution_context *context_arg, const char *db_name_arg, const char *table_name_arg, const char *field_name_arg)
 
 Item_ident (const POS &pos, const char *db_name_arg, const char *table_name_arg, const char *field_name_arg)
 
 Item_ident (THD *thd, Item_ident *item)
 Constructor used by Item_field & Item_*_ref (see Item comment) More...
 
const char * full_name () const override
 
void set_orignal_db_name (const char *name_arg)
 
void set_original_table_name (const char *name_arg)
 
void set_original_field_name (const char *name_arg)
 
const char * original_db_name () const
 
const char * original_table_name () const
 
const char * original_field_name () const
 
bool aggregate_check_distinct (uchar *arg) override
 
bool aggregate_check_group (uchar *arg) override
 
Bool3 local_column (const Query_block *sl) const override
 Tells if this is a column of a table whose qualifying query block is 'sl'. More...
 
bool change_context_processor (uchar *arg) override
 
bool is_alias_of_expr () const
 
void set_alias_of_expr ()
 Marks that this Item's name is alias of SELECT expression. More...
 
bool walk (Item_processor processor, enum_walk walk, uchar *arg) override
 Traverses a tree of Items in prefix and/or postfix order. More...
 
bool update_depended_from (uchar *) override
 
bool is_strong_side_column_not_in_fd (uchar *arg) override
 
bool is_column_not_in_fd (uchar *arg) override
 
- Public Member Functions inherited from Item
 Item (const Item &)=delete
 
void operator= (Item &)=delete
 
 Item ()
 Item constructor for general use. More...
 
 Item (THD *thd, const Item *item)
 Constructor used by Item_field, Item_ref & aggregate functions. More...
 
 Item (const POS &)
 Parse-time context-independent constructor. More...
 
 ~Item () override=default
 
virtual bool itemize (Parse_context *pc, Item **res) final
 The same as contextualize() but with additional parameter. More...
 
void rename (char *new_name)
 rename item (used for views, cleanup() return original name). More...
 
void init_make_field (Send_field *tmp_field, enum enum_field_types type)
 
virtual void notify_removal ()
 Called when an item has been removed, can be used to notify external objects about the removal, e.g subquery predicates that are part of the sj_candidates container. More...
 
virtual Fieldmake_string_field (TABLE *table) const
 Create a field to hold a string value from an item. More...
 
void quick_fix_field ()
 
virtual bool propagate_type (THD *thd, const Type_properties &type)
 Propagate data type specifications into parameters and user variables. More...
 
bool propagate_type (THD *thd, enum_field_types def=MYSQL_TYPE_VARCHAR, bool pin=false, bool inherit=false)
 Wrapper for easier calling of propagate_type(const Type_properties &). More...
 
virtual void mark_json_as_scalar ()
 For Items with data type JSON, mark that a string argument is treated as a scalar JSON value. More...
 
virtual std::optional< ContainedSubqueryget_contained_subquery (const Query_block *outer_query_block)
 If this item represents a IN/ALL/ANY/comparison_operator subquery, return that (along with data on how it will be executed). More...
 
type_conversion_status save_in_field_no_warnings (Field *field, bool no_conversions)
 Save the item into a field but do not emit any warnings. More...
 
type_conversion_status save_in_field (Field *field, bool no_conversions)
 Save a temporal value in packed longlong format into a Field. More...
 
void save_in_field_no_error_check (Field *field, bool no_conversions)
 A slightly faster value of save_in_field() that returns no error value (you will need to check thd->is_error() yourself), and does not support saving into hidden fields for functional indexes. More...
 
bool evaluate (THD *thd, String *str)
 Evaluate scalar item, possibly using the supplied buffer. More...
 
Item_result temporal_with_date_as_number_result_type () const
 Similar to result_type() but makes DATE, DATETIME, TIMESTAMP pretend to be numbers rather than strings. More...
 
virtual void set_data_type_inherited ()
 Set data type for item as inherited. More...
 
virtual void pin_data_type ()
 Pin the data type for the item. More...
 
enum_field_types data_type () const
 Retrieve the derived data type of the Item. More...
 
virtual enum_field_types actual_data_type () const
 Retrieve actual data type for an item. More...
 
virtual enum_field_types default_data_type () const
 Get the default data (output) type for the specific item. More...
 
void set_data_type (enum_field_types data_type)
 Set the data type of the current Item. More...
 
void set_data_type_null ()
 
void set_data_type_bool ()
 
void set_data_type_int (enum_field_types type, bool unsigned_prop, uint32 max_width)
 Set the data type of the Item to be a specific integer type. More...
 
void set_data_type_longlong ()
 Set the data type of the Item to be longlong. More...
 
void set_data_type_decimal (uint8 precision, uint8 scale)
 Set the data type of the Item to be decimal. More...
 
void set_data_type_double ()
 Set the data type of the Item to be double precision floating point. More...
 
void set_data_type_float ()
 Set the data type of the Item to be single precision floating point. More...
 
void set_data_type_string (uint32 max_l)
 Set the Item to be variable length string. More...
 
void set_data_type_string (ulonglong max_char_length_arg)
 Set the Item to be variable length string. More...
 
void set_data_type_string (uint32 max_l, const CHARSET_INFO *cs)
 Set the Item to be variable length string. More...
 
void set_data_type_string (uint32 max_l, const DTCollation &coll)
 Set the Item to be variable length string. More...
 
void set_data_type_char (uint32 max_l)
 Set the Item to be fixed length string. More...
 
void set_data_type_char (uint32 max_l, const CHARSET_INFO *cs)
 Set the Item to be fixed length string. More...
 
void set_data_type_blob (enum_field_types type, uint32 max_l)
 Set the Item to be of BLOB type. More...
 
void set_data_type_date ()
 Set all type properties for Item of DATE type. More...
 
void set_data_type_time (uint8 fsp)
 Set all type properties for Item of TIME type. More...
 
void set_data_type_datetime (uint8 fsp)
 Set all properties for Item of DATETIME type. More...
 
void set_data_type_timestamp (uint8 fsp)
 Set all properties for Item of TIMESTAMP type. More...
 
void set_data_type_geometry ()
 Set the data type of the Item to be GEOMETRY. More...
 
void set_data_type_json ()
 Set the data type of the Item to be JSON. More...
 
void set_data_type_year ()
 Set the data type of the Item to be YEAR. More...
 
void set_data_type_bit (uint32 max_bits)
 Set the data type of the Item to be bit. More...
 
void set_data_type_from_item (const Item *item)
 Set data type properties of the item from the properties of another item. More...
 
bool aggregate_type (const char *name, Item **items, uint count)
 Aggregates data types from array of items into current item. More...
 
longlong val_temporal_by_field_type ()
 Return date or time value of item in packed longlong format, depending on item field type. More...
 
longlong int_sort_key ()
 Produces a key suitable for filesort. More...
 
longlong val_temporal_with_round (enum_field_types type, uint8 dec)
 Get date or time value in packed longlong format. More...
 
ulonglong val_uint ()
 
virtual Stringval_str_ascii (String *str)
 
virtual bool val_bool ()
 
bool error_json ()
 Get the value to return from val_json() in case of errors. More...
 
bool get_date_from_non_temporal (MYSQL_TIME *ltime, my_time_flags_t fuzzydate)
 Convert a non-temporal type to date. More...
 
bool get_time_from_non_temporal (MYSQL_TIME *ltime)
 Convert a non-temporal type to time. More...
 
my_decimalerror_decimal (my_decimal *decimal_value)
 Get the value to return from val_decimal() in case of errors. More...
 
Stringerror_str ()
 Get the value to return from val_str() in case of errors. More...
 
type_conversion_status save_time_in_field (Field *field)
 
type_conversion_status save_date_in_field (Field *field)
 
type_conversion_status save_str_value_in_field (Field *field, String *result)
 
virtual table_map not_null_tables () const
 Return table map of tables that can't be NULL tables (tables that are used in a context where if they would contain a NULL row generated by a LEFT or RIGHT join, the item would not be true). More...
 
virtual bool basic_const_item () const
 Returns true if this is a simple constant item like an integer, not a constant expression. More...
 
bool may_eval_const_item (const THD *thd) const
 
virtual Itemclone_item () const
 
virtual cond_result eq_cmp_result () const
 
uint float_length (uint decimals_par) const
 
virtual uint decimal_precision () const
 
int decimal_int_part () const
 
virtual uint time_precision ()
 TIME precision of the item: 0..6. More...
 
virtual uint datetime_precision ()
 DATETIME precision of the item: 0..6. More...
 
bool const_item () const
 Returns true if item is constant, regardless of query evaluation state. More...
 
bool const_for_execution () const
 Returns true if item is constant during one query execution. More...
 
bool may_evaluate_const (const THD *thd) const
 Return true if this is a const item that may be evaluated in the current phase of statement processing. More...
 
bool is_non_deterministic () const
 
bool is_outer_reference () const
 
void print_item_w_name (const THD *thd, String *, enum_query_type query_type) const
 
void print_for_order (const THD *thd, String *str, enum_query_type query_type, const char *used_alias) const
 Prints the item when it's part of ORDER BY and GROUP BY. More...
 
virtual void update_used_tables ()
 Updates used tables, not null tables information and accumulates properties up the item tree, cf. More...
 
virtual bool split_sum_func (THD *, Ref_item_array, mem_root_deque< Item * > *)
 
bool split_sum_func2 (THD *thd, Ref_item_array ref_item_array, mem_root_deque< Item * > *fields, Item **ref, bool skip_registered)
 
bool update_null_value ()
 Make sure the null_value member has a correct value. More...
 
virtual void apply_is_true ()
 Apply the IS TRUE truth property, meaning that an UNKNOWN result and a FALSE result are treated the same. More...
 
virtual bool is_result_field () const
 
virtual Fieldget_result_field () const
 
virtual bool is_bool_func () const
 
virtual void no_rows_in_result ()
 
virtual Itemcopy_or_same (THD *)
 
virtual Itemcopy_andor_structure (THD *)
 
virtual Itemreal_item ()
 
virtual const Itemreal_item () const
 
virtual const CHARSET_INFOcompare_collation () const
 
template<class T >
auto walk_helper_thunk (uchar *arg)
 
template<class T >
auto analyze_helper_thunk (uchar **arg)
 See CompileItem. More...
 
virtual Itemtransform (Item_transformer transformer, uchar *arg)
 Perform a generic transformation of the Item tree, by adding zero or more additional Item objects to it. More...
 
virtual Itemcompile (Item_analyzer analyzer, uchar **arg_p, Item_transformer transformer, uchar *arg_t)
 Perform a generic "compilation" of the Item tree, ie transform the Item tree by adding zero or more Item objects to it. More...
 
virtual void traverse_cond (Cond_traverser traverser, void *arg, traverse_order)
 
virtual bool intro_version (uchar *)
 
bool cleanup_processor (uchar *)
 cleanup() item if it is resolved ('fixed'). More...
 
virtual bool visitor_processor (uchar *arg)
 A processor to handle the select lex visitor framework. More...
 
virtual bool find_item_processor (uchar *arg)
 
virtual bool is_non_const_over_literals (uchar *)
 
virtual bool cast_incompatible_args (uchar *)
 Wrap incompatible arguments in CAST nodes to the expected data types. More...
 
virtual bool reset_wf_state (uchar *arg)
 Reset execution state for such window function types as determined by arg. More...
 
virtual bool inform_item_in_cond_of_tab (uchar *)
 
virtual bool clean_up_after_removal (uchar *arg)
 Clean up after removing the item from the item tree. More...
 
virtual bool collect_scalar_subqueries (uchar *)
 
virtual bool collect_grouped_aggregates (uchar *)
 
virtual bool collect_subqueries (uchar *)
 
virtual bool has_aggregate_ref_in_group_by (uchar *)
 Check if an aggregate is referenced from within the GROUP BY clause of the query block in which it is aggregated. More...
 
bool visit_all_analyzer (uchar **)
 
virtual bool cache_const_expr_analyzer (uchar **cache_item)
 Check if an item is a constant one and can be cached. More...
 
Itemcache_const_expr_transformer (uchar *item)
 Cache item if needed. More...
 
virtual bool equality_substitution_analyzer (uchar **)
 
virtual Itemequality_substitution_transformer (uchar *)
 
virtual bool explain_subquery_checker (uchar **)
 
virtual Itemexplain_subquery_propagator (uchar *)
 
virtual bool replace_equal_field_checker (uchar **)
 
virtual bool check_valid_arguments_processor (uchar *)
 
virtual bool check_gcol_depend_default_processor (uchar *args)
 Check if a generated expression depends on DEFAULT function with specific column name as argument. More...
 
virtual Itemreplace_view_refs_with_clone (uchar *arg)
 Assuming this expression is part of a condition that would be pushed to a materialized derived table, replace, in this expression, each view reference with a clone of the expression in merged derived table's definition. More...
 
virtual Itemthis_item ()
 
virtual const Itemthis_item () const
 
virtual Item ** this_item_addr (THD *, Item **addr_arg)
 
virtual uint cols () const
 
virtual Itemelement_index (uint)
 
virtual Item ** addr (uint)
 
virtual bool check_cols (uint c)
 
virtual bool null_inside ()
 
virtual void bring_value ()
 
Fieldtmp_table_field_from_field_type (TABLE *table, bool fixed_length) const
 Create a field based on field_type of argument. More...
 
virtual Itemtruth_transformer (THD *thd, Bool_test test)
 Informs an item that it is wrapped in a truth test, in case it wants to transforms itself to implement this test by itself. More...
 
virtual Itemreplace_scalar_subquery (uchar *)
 When walking the item tree seeing an Item_singlerow_subselect matching a target, replace it with a substitute field used when transforming scalar subqueries into derived tables. More...
 
virtual Itemreplace_item_view_ref (uchar *)
 
virtual Itemreplace_aggregate (uchar *)
 
virtual Itemreplace_outer_ref (uchar *)
 
virtual bool update_aggr_refs (uchar *)
 A walker processor overridden by Item_aggregate_ref, q.v. More...
 
void delete_self ()
 Delete this item. More...
 
virtual bool is_splocal () const
 
virtual Settable_routine_parameterget_settable_routine_parameter ()
 
bool is_temporal_with_date () const
 
bool is_temporal_with_date_and_time () const
 
bool is_temporal_with_time () const
 
bool is_temporal () const
 
bool has_compatible_context (Item *item) const
 Check whether this and the given item has compatible comparison context. More...
 
Stringcheck_well_formed_result (String *str, bool send_error, bool truncate)
 Verifies that the input string is well-formed according to its character set. More...
 
bool eq_by_collation (Item *item, bool binary_cmp, const CHARSET_INFO *cs)
 
CostOfItem cost () const
 
uint32 max_char_length () const
 
uint32 max_char_length (const CHARSET_INFO *cs) const
 
void fix_char_length (uint32 max_char_length_arg)
 
bool is_blob_field () const
 Check if an item either is a blob field, or will be represented as a BLOB field if a field is created based on this item. More...
 
uint reference_count () const
 
void increment_ref_count ()
 Increment reference count. More...
 
uint decrement_ref_count ()
 Decrement reference count. More...
 
bool has_subquery () const
 
bool has_stored_program () const
 
bool has_aggregation () const
 
void set_aggregation ()
 Set the "has aggregation" property. More...
 
void reset_aggregation ()
 Reset the "has aggregation" property. More...
 
bool has_wf () const
 
void set_wf ()
 Set the "has window function" property. More...
 
bool has_grouping_set_dep () const
 
void set_group_by_modifier ()
 Set the property: this item (tree) contains a reference to a GROUP BY modifier (such as ROLLUP) More...
 
bool has_grouping_func () const
 
void set_grouping_func ()
 Set the property: this item is a call to GROUPING. More...
 
virtual bool created_by_in2exists () const
 Whether this Item was created by the IN->EXISTS subquery transformation. More...
 
void mark_subqueries_optimized_away ()
 
virtual bool gc_subst_analyzer (uchar **)
 Analyzer function for GC substitution. More...
 
virtual Itemgc_subst_transformer (uchar *)
 Transformer function for GC substitution. More...
 
bool can_be_substituted_for_gc (bool array=false) const
 Check if this item is of a type that is eligible for GC substitution. More...
 
void aggregate_float_properties (enum_field_types type, Item **items, uint nitems)
 Set max_length and decimals of function if function is floating point and result length/precision depends on argument ones. More...
 
void aggregate_decimal_properties (Item **items, uint nitems)
 Set data type, precision and scale of item of type decimal from list of items. More...
 
uint32 aggregate_char_width (Item **items, uint nitems)
 Calculate the maximum number of characters required by any of the items. More...
 
void aggregate_temporal_properties (enum_field_types type, Item **items, uint nitems)
 Set data type and fractional seconds precision for temporal functions. More...
 
bool aggregate_string_properties (enum_field_types type, const char *name, Item **items, uint nitems)
 Aggregate string properties (character set, collation and maximum length) for string function. More...
 
void aggregate_bit_properties (Item **items, uint nitems)
 Set data type and properties of a BIT column. More...
 
bool is_abandoned () const
 
bool is_nullable () const
 
void set_nullable (bool nullable)
 
virtual bool supports_partial_update (const Field_json *field) const
 Check if this expression can be used for partial update of a given JSON column. More...
 
virtual void allow_array_cast ()
 A helper function to ensure proper usage of CAST(. More...
 
- Public Member Functions inherited from Parse_tree_node_tmpl< Context >
virtual ~Parse_tree_node_tmpl ()=default
 
bool is_contextualized () const
 
virtual bool contextualize (Context *pc) final
 
void error (Context *pc, const POS &pos) const
 syntax_error() function replacement for deferred reporting of syntax errors More...
 
void error (Context *pc, const POS &pos, const char *msg) const
 syntax_error() function replacement for deferred reporting of syntax errors More...
 
void errorf (Context *pc, const POS &pos, const char *format,...) const
 syntax_error() function replacement for deferred reporting of syntax errors More...
 

Public Attributes

Table_reftable_ref
 Table containing this resolved field. More...
 
Fieldfield
 Source field. More...
 
Item_equalitem_equal {nullptr}
 Used during optimization to perform multiple equality analysis, this analysis should be performed during preparation instead, so that Item_field can be const after preparation. More...
 
uint16 field_index
 Index for this field in table->field array. More...
 
Item_equalitem_equal_all_join_nests {nullptr}
 
bool no_constant_propagation {false}
 If true, the optimizer's constant propagation will not replace this item with an equal constant. More...
 
uint have_privileges
 
bool any_privileges
 
bool can_use_prefix_key {false}
 
- Public Attributes inherited from Item_ident
Name_resolution_contextcontext
 For regularly resolved column references, 'context' points to a name resolution context object belonging to the query block which simply contains the reference. More...
 
const char * db_name
 Schema name of the base table or view the column is part of. More...
 
const char * table_name
 If column is from a non-aliased base table or view, name of base table or view. More...
 
const char * field_name
 If column is aliased, the column alias name. More...
 
Table_refcached_table
 
Query_blockdepended_from
 
- Public Attributes inherited from Item
Itemnext_free
 Intrusive list pointer for free list. More...
 
DTCollation collation
 Character set and collation properties assigned for this Item. More...
 
Item_name_string item_name
 Name from query. More...
 
Item_name_string orig_name
 Original item name (if it was renamed) More...
 
uint32 max_length
 Maximum length of result of evaluating this item, in number of bytes. More...
 
item_marker marker
 This member has several successive meanings, depending on the phase we're in (. More...
 
Item_result cmp_context
 Comparison context. More...
 
bool fixed
 True if item has been resolved. More...
 
uint8 decimals
 Number of decimals in result when evaluating this item. More...
 
bool null_value
 True if item is null. More...
 
bool unsigned_flag
 
bool m_is_window_function
 True if item represents window func. More...
 
bool hidden {false}
 If the item is in a SELECT list (Query_block::fields) and hidden is true, the item wasn't actually in the list as given by the user (it was added by the optimizer, to e.g. More...
 
bool m_in_check_constraint_exec_ctx {false}
 True if item is a top most element in the expression being evaluated for a check constraint. More...
 
- Public Attributes inherited from Parse_tree_node_tmpl< Context >
POS m_pos
 

Protected Member Functions

void set_field (Field *field)
 
void fix_after_pullout (Query_block *parent_query_block, Query_block *removed_query_block) override
 Fix after tables have been moved from one query_block level to the parent level, e.g by semijoin conversion. More...
 
type_conversion_status save_in_field_inner (Field *field, bool no_conversions) override
 Helper function which does all of the work for save_in_field(Field*, bool), except some error checking common to all subclasses, which is performed by save_in_field() itself. More...
 
- Protected Member Functions inherited from Item_ident
void print (const THD *thd, String *str, enum_query_type query_type, const char *db_name_arg, const char *table_name_arg) const
 Function to print column name for a table. More...
 
- Protected Member Functions inherited from Item
Stringmake_empty_result ()
 Sets the result value of the function an empty string, using the current character set. More...
 
bool skip_itemize (Item **res)
 Helper function to skip itemize() for grammar-allocated items. More...
 
Stringval_string_from_real (String *str)
 
Stringval_string_from_int (String *str)
 
Stringval_string_from_decimal (String *str)
 
Stringval_string_from_date (String *str)
 
Stringval_string_from_datetime (String *str)
 
Stringval_string_from_time (String *str)
 
my_decimalval_decimal_from_real (my_decimal *decimal_value)
 
my_decimalval_decimal_from_int (my_decimal *decimal_value)
 
my_decimalval_decimal_from_string (my_decimal *decimal_value)
 
my_decimalval_decimal_from_date (my_decimal *decimal_value)
 
my_decimalval_decimal_from_time (my_decimal *decimal_value)
 
longlong val_int_from_decimal ()
 
longlong val_int_from_date ()
 
longlong val_int_from_time ()
 
longlong val_int_from_datetime ()
 
longlong val_int_from_string ()
 
double val_real_from_decimal ()
 
double val_real_from_string ()
 
bool error_bool ()
 Get the value to return from val_bool() in case of errors. More...
 
int error_int ()
 Get the value to return from val_int() in case of errors. More...
 
double error_real ()
 Get the value to return from val_real() in case of errors. More...
 
bool error_date ()
 Get the value to return from get_date() in case of errors. More...
 
bool error_time ()
 Get the value to return from get_time() in case of errors. More...
 
Stringnull_return_str ()
 Gets the value to return from val_str() when returning a NULL value. More...
 
bool get_date_from_string (MYSQL_TIME *ltime, my_time_flags_t flags)
 Convert val_str() to date in MYSQL_TIME. More...
 
bool get_date_from_real (MYSQL_TIME *ltime, my_time_flags_t flags)
 Convert val_real() to date in MYSQL_TIME. More...
 
bool get_date_from_decimal (MYSQL_TIME *ltime, my_time_flags_t flags)
 Convert val_decimal() to date in MYSQL_TIME. More...
 
bool get_date_from_int (MYSQL_TIME *ltime, my_time_flags_t flags)
 Convert val_int() to date in MYSQL_TIME. More...
 
bool get_date_from_time (MYSQL_TIME *ltime)
 Convert get_time() from time to date in MYSQL_TIME. More...
 
bool get_date_from_numeric (MYSQL_TIME *ltime, my_time_flags_t fuzzydate)
 Convert a numeric type to date. More...
 
bool get_time_from_string (MYSQL_TIME *ltime)
 Convert val_str() to time in MYSQL_TIME. More...
 
bool get_time_from_real (MYSQL_TIME *ltime)
 Convert val_real() to time in MYSQL_TIME. More...
 
bool get_time_from_decimal (MYSQL_TIME *ltime)
 Convert val_decimal() to time in MYSQL_TIME. More...
 
bool get_time_from_int (MYSQL_TIME *ltime)
 Convert val_int() to time in MYSQL_TIME. More...
 
bool get_time_from_date (MYSQL_TIME *ltime)
 Convert date to time. More...
 
bool get_time_from_datetime (MYSQL_TIME *ltime)
 Convert datetime to time. More...
 
bool get_time_from_numeric (MYSQL_TIME *ltime)
 Convert a numeric type to time. More...
 
void set_accum_properties (const Item *item)
 Set accumulated properties for an Item. More...
 
void add_accum_properties (const Item *item)
 Add more accumulated properties to an Item. More...
 
void set_subquery ()
 Set the "has subquery" property. More...
 
void set_stored_program ()
 Set the "has stored program" property. More...
 
- Protected Member Functions inherited from Parse_tree_node_tmpl< Context >
 Parse_tree_node_tmpl ()=delete
 
 Parse_tree_node_tmpl (const POS &pos)
 
 Parse_tree_node_tmpl (const POS &start_pos, const POS &end_pos)
 
bool begin_parse_tree (Show_parse_tree *tree)
 
bool end_parse_tree (Show_parse_tree *tree)
 
virtual bool do_contextualize (Context *pc)
 Do all context-sensitive things and mark the node as contextualized. More...
 
virtual void add_json_info (Json_object *json_obj)
 Add all the node-specific json fields. More...
 

Private Types

typedef Item_ident super
 

Private Attributes

Fieldresult_field {nullptr}
 Result field. More...
 
Fieldlast_org_destination_field {nullptr}
 
Fieldlast_destination_field {nullptr}
 
uint32_t last_org_destination_field_memcpyable = ~0U
 
uint32_t last_destination_field_memcpyable = ~0U
 
const Item_fieldm_base_item_field {nullptr}
 If this field is derived from another field, e.g. More...
 
bool m_protected_by_any_value {false}
 State used for transforming scalar subqueries to JOINs with derived tables, cf. More...
 

Additional Inherited Members

- Public Types inherited from Item
enum  Type {
  INVALID_ITEM = 0 , FIELD_ITEM , FUNC_ITEM , SUM_FUNC_ITEM ,
  STRING_ITEM , INT_ITEM , REAL_ITEM , NULL_ITEM ,
  VARBIN_ITEM , METADATA_COPY_ITEM , FIELD_AVG_ITEM , DEFAULT_VALUE_ITEM ,
  PROC_ITEM , COND_ITEM , REF_ITEM , FIELD_STD_ITEM ,
  FIELD_VARIANCE_ITEM , INSERT_VALUE_ITEM , SUBSELECT_ITEM , ROW_ITEM ,
  CACHE_ITEM , TYPE_HOLDER , PARAM_ITEM , TRIGGER_FIELD_ITEM ,
  DECIMAL_ITEM , XPATH_NODESET , XPATH_NODESET_CMP , VIEW_FIXER_ITEM ,
  FIELD_BIT_ITEM , VALUES_COLUMN_ITEM
}
 
enum  cond_result { COND_UNDEF , COND_OK , COND_TRUE , COND_FALSE }
 
enum  traverse_order { POSTFIX , PREFIX }
 
enum  enum_const_item_cache { CACHE_NONE = 0 , CACHE_JSON_VALUE , CACHE_JSON_ATOM }
 How to cache constant JSON data. More...
 
enum  Bool_test {
  BOOL_IS_TRUE = 0x00 , BOOL_IS_FALSE = 0x01 , BOOL_IS_UNKNOWN = 0x02 , BOOL_NOT_TRUE = 0x03 ,
  BOOL_NOT_FALSE = 0x04 , BOOL_NOT_UNKNOWN = 0x05 , BOOL_IDENTITY = 0x06 , BOOL_NEGATED = 0x07 ,
  BOOL_ALWAYS_TRUE = 0x08 , BOOL_ALWAYS_FALSE = 0x09
}
 < Modifier for result transformation More...
 
enum  item_marker {
  MARKER_NONE = 0 , MARKER_IMPLICIT_NE_ZERO = 1 , MARKER_CONST_PROPAG = 2 , MARKER_BIT = 4 ,
  MARKER_FUNC_DEP_NOT_NULL = 5 , MARKER_DISTINCT_GROUP = 6 , MARKER_COND_DERIVED_TABLE = 7 , MARKER_TRAVERSAL = 8 ,
  MARKER_ICP_COND_USES_INDEX_ONLY = 10
}
 < Values for member 'marker' More...
 
- Public Types inherited from Parse_tree_node_tmpl< Context >
typedef Context context_t
 
- Static Public Member Functions inherited from Item
static void * operator new (size_t size) noexcept
 
static void * operator new (size_t size, MEM_ROOT *mem_root, const std::nothrow_t &arg=std::nothrow) noexcept
 
static void operator delete (void *ptr, size_t size)
 
static void operator delete (void *, MEM_ROOT *, const std::nothrow_t &) noexcept
 
static enum_field_types result_to_type (Item_result result)
 
static Item_result type_to_result (enum_field_types type)
 
static enum_field_types type_for_variable (enum_field_types src_type)
 Provide data type for a user or system variable, based on the type of the item that is assigned to the variable. More...
 
static enum_field_types string_field_type (uint32 max_bytes)
 Determine correct string field type, based on string length. More...
 
static const CHARSET_INFOdefault_charset ()
 
- Static Public Member Functions inherited from Parse_tree_node_tmpl< Context >
static void * operator new (size_t size, MEM_ROOT *mem_root, const std::nothrow_t &arg=std::nothrow) noexcept
 
static void operator delete (void *ptr, size_t size)
 
static void operator delete (void *, MEM_ROOT *, const std::nothrow_t &) noexcept
 
- Static Protected Member Functions inherited from Item
static bool bit_func_returns_binary (const Item *a, const Item *b)
 
static bool mark_field_in_map (Mark_field *mark_field, Field *field)
 Helper function for mark_field_in_map(uchar *arg). More...
 
- Protected Attributes inherited from Item_ident
const char * m_orig_db_name
 The fields m_orig_db_name, m_orig_table_name and m_orig_field_name are maintained so that we can provide information about the origin of a column that may have been renamed within the query, e.g. More...
 
const char * m_orig_table_name
 Names the original table that is the source of the field. More...
 
const char * m_orig_field_name
 Names the field in the source base table. More...
 
bool m_alias_of_expr
 if this Item's name is alias of SELECT expression More...
 
- Protected Attributes inherited from Item
String str_value
 str_values's main purpose is to cache the value in save_in_field More...
 
uint8 m_accum_properties
 
- Static Protected Attributes inherited from Item
static constexpr uint8 PROP_SUBQUERY = 0x01
 Set of properties that are calculated by accumulation from underlying items. More...
 
static constexpr uint8 PROP_STORED_PROGRAM = 0x02
 
static constexpr uint8 PROP_AGGREGATION = 0x04
 
static constexpr uint8 PROP_WINDOW_FUNCTION = 0x08
 
static constexpr uint8 PROP_HAS_GROUPING_SET_DEP = 0x10
 Set if the item or one or more of the underlying items contains a GROUP BY modifier (such as ROLLUP). More...
 
static constexpr uint8 PROP_GROUPING_FUNC = 0x20
 Set if the item or one or more of the underlying items is a GROUPING function. More...
 

Member Typedef Documentation

◆ super

typedef Item_ident Item_field::super
private

Constructor & Destructor Documentation

◆ Item_field() [1/5]

Item_field::Item_field ( Name_resolution_context context_arg,
const char *  db_arg,
const char *  table_name_arg,
const char *  field_name_arg 
)

Constructor used for internal information queries.

Parameters
context_argName resolution context
db_argSchema name, may be NULL
table_name_argTable name, may be NULL if schema name is NULL
field_name_argField name

◆ Item_field() [2/5]

Item_field::Item_field ( const POS pos,
const char *  db_arg,
const char *  table_name_arg,
const char *  field_name_arg 
)

Used from parser to construct column references.

Parameters
posParse context
db_argSchema name for column, may be NULL
table_name_argTable name for column, may be NULL if db_arg is NULL
field_name_argColumn name, always given.

◆ Item_field() [3/5]

Item_field::Item_field ( THD thd,
Item_field item 
)

Used to create a copy (clone) of another Item_field.

Item has same lifetime as the copied item.

Parameters
thdthread handler
itemColumn reference to make a copy from.

◆ Item_field() [4/5]

Item_field::Item_field ( THD thd,
Name_resolution_context context_arg,
Table_ref tr,
Field f 
)

Constructor used inside setup_wild().

Item is resolved after construction. Item is supposed to have lifetime same as statement it is created within.

Parameters
thdthread context
context_argName resolution context for this field
trTable reference, provides table and schema name
fField reference, provides field name and original table name

◆ Item_field() [5/5]

Item_field::Item_field ( Field f)

Create column reference based on a table field.

Parameters
fPointer to field in a TABLE object

Item is resolved after construction. Notice that lifetime of object is limited to the lifetime of the supplied field.

Member Function Documentation

◆ add_field_to_cond_set_processor()

bool Item_field::add_field_to_cond_set_processor ( uchar )
overridevirtual

Item::walk function.

Set bit in table->cond_set for all fields of all tables that are referred to by the Item.

Reimplemented from Item.

◆ add_field_to_set_processor()

bool Item_field::add_field_to_set_processor ( uchar )
overridevirtual

Item::walk function.

Set bit in table->tmp_set for all fields in table 'arg' that are referred to by the Item.

Reimplemented from Item.

◆ alias_name_used()

bool Item_field::alias_name_used ( ) const
inlineoverridevirtual
Note
that field->table->alias_name_used is reliable only if thd->lex->need_correct_ident() is true.

Reimplemented from Item_ident.

◆ base_item_field()

const Item_field * Item_field::base_item_field ( ) const
inline

◆ bind_fields()

void Item_field::bind_fields ( )
overridevirtual

Bind objects from the current execution context to field objects in item trees.

Typically used to bind Field objects from TABLEs to Item_field objects.

Reimplemented from Item.

Reimplemented in Item_default_value, Item_insert_value, and Item_trigger_field.

◆ cast_to_int_type()

Item_result Item_field::cast_to_int_type ( ) const
inlineoverridevirtual

Reimplemented from Item.

◆ charset_for_protocol()

const CHARSET_INFO * Item_field::charset_for_protocol ( void  )
inlineoverridevirtual

Reimplemented from Item.

◆ check_column_in_group_by()

bool Item_field::check_column_in_group_by ( uchar arg)
overridevirtual

Check if this column is found in GROUP BY.

Called when checking to see if a condition can be pushed past GROUP BY while pushing conditions down to materialized derived tables.

Parameters
argderived table
Return values
falseif this field is not part of GROUP BY.
trueotherwise.

Reimplemented from Item.

◆ check_column_in_window_functions()

bool Item_field::check_column_in_window_functions ( uchar arg)
overridevirtual

Check if this column is found in PARTITION clause of all the window functions.

Called when checking to see if a condition can be pushed past window functions while pushing conditions down to materialized derived tables.

Parameters
argderived table
Return values
falseif this field is part of PARTITION clause of all window functions present in the derived table.
trueotherwise

Reimplemented from Item.

◆ check_column_privileges()

bool Item_field::check_column_privileges ( uchar arg)
overridevirtual

Check privileges of base table column.

Reimplemented from Item.

Reimplemented in Item_default_value, and Item_trigger_field.

◆ check_function_as_value_generator()

bool Item_field::check_function_as_value_generator ( uchar args)
overridevirtual

Check if this item is allowed for a virtual column or inside a default expression.

Should be overridden in child classes.

Parameters
[in,out]argsDue to the limitation of Item::walk() it is declared as a pointer to uchar, underneath there's a actually a structure of type Check_function_as_value_generator_parameters. It is used mainly in Item_field.
Returns
true if function is not accepted

Reimplemented from Item.

Reimplemented in Item_insert_value, and Item_trigger_field.

◆ check_partition_func_processor()

bool Item_field::check_partition_func_processor ( uchar )
inlineoverridevirtual

Check if a partition function is allowed.

Returns
whether a partition function is not accepted

check_partition_func_processor is used to check if a partition function uses an allowed function. An allowed function will always ensure that X=Y guarantees that also part_function(X)=part_function(Y) where X is a set of partition fields and so is Y. The problems comes mainly from character sets where two equal strings can be quite unequal. E.g. the german character for double s is equal to 2 s.

The default is that an item is not allowed in a partition function. Allowed functions can never depend on server version, they cannot depend on anything related to the environment. They can also only depend on a set of fields in the table itself. They cannot depend on other tables and cannot contain any queries and cannot contain udf's or similar. If a new Item class is defined and it inherits from a class that is allowed in a partition function then it is very important to consider whether this should be inherited to the new class. If not the function below should be defined in the new Item class.

The general behaviour is that most integer functions are allowed. If the partition function contains any multi-byte collations then the function check_part_func_fields will report an error on the partition function independent of what functions are used. So the only character sets allowed are single character collation and even for those only a limited set of functions are allowed. The problem with multi-byte collations is that almost every string function has the ability to change things such that two strings that are equal will not be equal after manipulated by a string function. E.g. two strings one contains a double s, there is a special german character that is equal to two s. Now assume a string function removes one character at this place, then in one the double s will be removed and in the other there will still be one s remaining and the strings are no longer equal and thus the partition function will not sort equal strings into the same partitions.

So the check if a partition function is valid is two steps. First check that the field types are valid, next check that the partition function is valid. The current set of partition functions valid assumes that there are no multi-byte collations amongst the partition fields.

Reimplemented from Item.

◆ cleanup()

void Item_field::cleanup ( )
overridevirtual

Called for every Item after use (preparation and execution).

Release all allocated resources, such as dynamic memory. Prepare for new execution by clearing cached values. Do not remove values allocated during preparation, destructor handles this.

Reimplemented from Item.

Reimplemented in Item_default_value, Item_insert_value, and Item_trigger_field.

◆ collect_item_field_or_ref_processor()

bool Item_field::collect_item_field_or_ref_processor ( uchar arg)
overridevirtual

When collecting information about columns when transforming correlated scalar subqueries using derived tables, we need to decide which duplicates, if any, to retain:

  • Local columns are collected once, duplicates are ignored.
  • All columns that are outer references are included, regardless of being duplicates. This is so we can properly reset outer status for all occurences, cf. Query_block::decorrelate_derived_scalar_subquery_post where we reset Item::depended_from.
Parameters
argA pointer to an object of type Collect_item_fields_or_refs, a subclass of Item_tree_walker, which holds the already collected columns.
Returns
true on error

Reimplemented from Item.

◆ collect_item_field_or_view_ref_processor()

bool Item_field::collect_item_field_or_view_ref_processor ( uchar )
overridevirtual

Collects fields and view references that have the qualifying table in the specified query block.

Reimplemented from Item.

Reimplemented in Item_default_value.

◆ collect_item_field_processor()

bool Item_field::collect_item_field_processor ( uchar arg)
overridevirtual

Store the pointer to this item field into a list if not already there.

The method is used by Item::walk to collect all unique Item_field objects from a tree of Items into a set of items represented as a list.

Item_cond::walk() and Item_func::walk() stop the evaluation of the processor function for its arguments once the processor returns true.Therefore in order to force this method being called for all item arguments in a condition the method must return false.

Parameters
argpointer to a mem_root_deque<Item_field *>
Returns
false to force the evaluation of collect_item_field_processor for the subsequent items.

Reimplemented from Item.

◆ compute_cost()

void Item_field::compute_cost ( CostOfItem root_cost) const
inlineoverridevirtual

Compute the cost of evaluating this Item.

Parameters
root_costThe cost object to which the cost should be added.

Reimplemented from Item.

◆ dbug_print()

void Item_field::dbug_print ( ) const
inline

◆ disable_constant_propagation()

bool Item_field::disable_constant_propagation ( uchar )
inlineoverridevirtual

Reimplemented from Item.

◆ do_itemize()

bool Item_field::do_itemize ( Parse_context pc,
Item **  res 
)
overridevirtual

The core function that does the actual itemization.

itemize() is just a wrapper over this.

Reimplemented from Item_ident.

Reimplemented in Item_asterisk, Item_default_value, and Item_insert_value.

◆ eq()

bool Item_field::eq ( const Item item,
bool  binary_cmp 
) const
overridevirtual

This function is called when:

  • Comparing items in the WHERE clause (when doing where optimization)
  • When trying to find an ORDER BY/GROUP BY item in the SELECT part
  • When matching fields in multiple equality objects (Item_equal)

Reimplemented from Item.

Reimplemented in Item_default_value, Item_insert_value, and Item_trigger_field.

◆ equal_fields_propagator()

Item * Item_field::equal_fields_propagator ( uchar arg)
overridevirtual

If field matches a multiple equality, set a pointer to that object in the field.

Also return a pointer to a constant value that can be substituted for a field (if any).

A constant value is returned only if certain conditions are met (see implementation).

In addition, a numeric field with a zerofill attribute can be substituted with a zerofilled value if it is to be used in a character string context.

Parameters
argreference to list of multiple equalities where the field (this object) is to be looked for
Note
This function is supposed to be called as a callback parameter in calls of the compile method.
Returns
  • pointer to the replacing constant item, if the field item was substituted
  • pointer to the field item, otherwise.

Reimplemented from Item.

◆ field_for_view_update()

Item_field * Item_field::field_for_view_update ( )
inlineoverridevirtual

Reimplemented from Item.

◆ find_field_processor()

bool Item_field::find_field_processor ( uchar )
inlineoverridevirtual

Is this an Item_field which references the given Field argument?

Reimplemented from Item.

◆ find_item_equal()

Item_equal * Item_field::find_item_equal ( COND_EQUAL cond_equal) const

Find a field among specified multiple equalities.

The function first searches the field among multiple equalities of the current level (in the cond_equal->current_level list). If it fails, it continues searching in upper levels accessed through a pointer cond_equal->upper_levels. The search terminates as soon as a multiple equality containing the field is found.

Parameters
cond_equalreference to list of multiple equalities where the field (this object) is to be looked for
Returns
  • First Item_equal containing the field, if success
  • nullptr, otherwise

◆ find_item_in_field_list_processor()

bool Item_field::find_item_in_field_list_processor ( uchar arg)
overridevirtual

Check if an Item_field references some field from a list of fields.

Check whether the Item_field represented by 'this' references any of the fields in the keyparts passed via 'arg'. Used with the method Item::walk() to test whether any keypart in a sequence of keyparts is referenced in an expression.

Parameters
argField being compared, arg must be of type Field
Return values
trueif 'this' references the field 'arg'
falseotherwise

Reimplemented from Item.

◆ fix_after_pullout()

void Item_field::fix_after_pullout ( Query_block parent_query_block,
Query_block removed_query_block 
)
inlineoverrideprotectedvirtual

Fix after tables have been moved from one query_block level to the parent level, e.g by semijoin conversion.

Basically re-calculate all attributes dependent on the tables.

Parameters
parent_query_blockquery_block that tables are moved to.
removed_query_blockquery_block that tables are moved away from, child of parent_query_block.

Reimplemented from Item_ident.

◆ fix_fields()

bool Item_field::fix_fields ( THD thd,
Item **  reference 
)
overridevirtual

Resolve the name of a column reference.

The method resolves the column reference represented by 'this' as a column present in one of: FROM clause, SELECT clause, GROUP BY clause of a query Q, or in outer queries that contain Q.

The name resolution algorithm used is (where [T_j] is an optional table name that qualifies the column name):

resolve_column_reference([T_j].col_ref_i)
{
search for a column or derived column named col_ref_i
[in table T_j] in the FROM clause of Q;
if such a column is NOT found AND // Lookup in outer queries.
there are outer queries
{
for each outer query Q_k beginning from the inner-most one
{
search for a column or derived column named col_ref_i
[in table T_j] in the FROM clause of Q_k;
if such a column is not found
Search for a column or derived column named col_ref_i
[in table T_j] in the SELECT and GROUP clauses of Q_k.
}
}
}
static char * query
Definition: myisam_ftdump.cc:46
static PFS_engine_table_share_proxy table
Definition: pfs.cc:60
const std::string SELECT("SELECT")
Name of the static privileges.
@ FROM
Definition: sql_yacc.h:250

Notice that compared to Item_ref::fix_fields, here we first search the FROM clause, and then we search the SELECT and GROUP BY clauses.

For the case where a table reference is already set for the field, we just need to make a call to set_field(). This is true for a cloned field used during condition pushdown to derived tables. A cloned field inherits table reference, depended_from, cached_table, context and field from the original field. set_field() ensures all other members are set correctly.

Parameters
[in]thdcurrent thread
[in,out]referenceview column if this item was resolved to a view column
Returns
false on success, true on error

Reimplemented from Item.

Reimplemented in Item_asterisk, Item_default_value, Item_insert_value, and Item_trigger_field.

◆ fix_outer_field()

int Item_field::fix_outer_field ( THD thd,
Field **  from_field,
Item **  reference 
)

Resolve the name of an outer select column reference.

The method resolves the column reference represented by 'this' as a column present in outer selects that contain current select.

In prepared statements, because of cache, find_field_in_tables() can resolve fields even if they don't belong to current context. In this case this method only finds appropriate context and marks current select as dependent. The found reference of field should be provided in 'from_field'.

Parameters
[in]thdcurrent thread
[in,out]from_fieldfound field reference or (Field*)not_found_field
[in,out]referenceview column if this item was resolved to a view column
Note
This is the inner loop of Item_field::fix_fields:
for each outer query Q_k beginning from the inner-most one
{
search for a column or derived column named col_ref_i
[in table T_j] in the FROM clause of Q_k;
if such a column is not found
Search for a column or derived column named col_ref_i
[in table T_j] in the SELECT and GROUP clauses of Q_k.
}
Return values
1column succefully resolved and fix_fields() should continue.
0column fully fixed and fix_fields() should return false
-1error occurred

◆ get_cond_filter_default_probability()

float Item_field::get_cond_filter_default_probability ( double  max_distinct_values,
float  default_filter 
) const

Returns the probability for the predicate "col OP <val>" to be true for a row in the case where no index statistics or range estimates are available for 'col'.

The probability depends on the number of rows in the table: it is by default 'default_filter', but never lower than 1/max_distinct_values (e.g. number of rows in the table, or the number of distinct values possible for the datatype if the field provides that kind of information).

Parameters
max_distinct_valuesThe maximum number of distinct values, typically the number of rows in the table
default_filterThe default filter for the predicate
Returns
the estimated filtering effect for this predicate

◆ get_date()

bool Item_field::get_date ( MYSQL_TIME ltime,
my_time_flags_t  fuzzydate 
)
overridevirtual

Implements Item.

◆ get_filtering_effect()

float Item_field::get_filtering_effect ( THD thd,
table_map  filter_for_table,
table_map  read_tables,
const MY_BITMAP fields_to_ignore,
double  rows_in_table 
)
overridevirtual

Calculate condition filtering effect for "WHERE field", which implicitly means "WHERE field <> 0".

The filtering effect is therefore identical to that of Item_func_ne.

Reimplemented from Item.

◆ get_geometry_type()

Field::geometry_type Item_field::get_geometry_type ( ) const
inlineoverridevirtual

Reimplemented from Item.

◆ get_monotonicity_info()

enum_monotonicity_info Item_field::get_monotonicity_info ( ) const
inlineoverridevirtual

Reimplemented from Item.

◆ get_time()

bool Item_field::get_time ( MYSQL_TIME ltime)
overridevirtual

Implements Item.

◆ get_timeval()

bool Item_field::get_timeval ( my_timeval tm,
int *  warnings 
)
overridevirtual

Get timestamp in "struct timeval" format.

If argument is NULL, sets null_value.

Return values
falseon success
trueon error

Otherwise: if invalid DATETIME value, or a valid DATETIME value but which is out of the supported Unix timestamp range, sets 'tm' to 0.

Reimplemented from Item.

◆ get_tmp_table_field()

Field * Item_field::get_tmp_table_field ( )
inlineoverridevirtual

If this Item is being materialized into a temporary table, returns the field that is being materialized into.

(Typically, this is the “result_field” members for items that have one.)

Reimplemented from Item.

Reimplemented in Item_trigger_field.

◆ get_tmp_table_item()

Item * Item_field::get_tmp_table_item ( THD thd)
overridevirtual

If an Item is materialized in a temporary table, a different Item may have to be used in the part of the query that runs after the materialization.

For instance, if the Item was an Item_field, the new Item_field needs to point into the temporary table instead of the original one, but if, on the other hand, the Item was a literal constant, it can be reused as-is. This function encapsulates these policies for the different kinds of Items. See also get_tmp_table_field().

TODO: Document how aggregate functions (Item_sum) are handled.

Reimplemented from Item.

Reimplemented in Item_default_value, and Item_trigger_field.

◆ get_typelib()

TYPELIB * Item_field::get_typelib ( ) const
overridevirtual

Get the typelib information for an item of type set or enum.

Reimplemented from Item.

◆ is_asterisk()

virtual bool Item_field::is_asterisk ( ) const
inlinevirtual

Checks if the current object represents an asterisk select list item.

Returns
false if a regular column reference, true if an asterisk select list item.

Reimplemented in Item_asterisk.

◆ is_null()

bool Item_field::is_null ( )
inlineoverridevirtual

The method allows to determine nullness of a complex expression without fully evaluating it, instead of calling val*() then checking null_value.

Used in Item_func_isnull/Item_func_isnotnull and Item_sum_count/Item_sum_count_distinct. Any item which can be NULL must implement this method.

Return values
falseif the expression is not NULL.
trueif the expression is NULL, or evaluation caused an error. The null_value member is set according to the return value.

Reimplemented from Item.

◆ is_outer_field()

bool Item_field::is_outer_field ( ) const
inlineoverridevirtual

Reimplemented from Item.

◆ is_valid_for_pushdown()

bool Item_field::is_valid_for_pushdown ( uchar arg)
overridevirtual

Check if all the columns present in this expression are from the derived table.

Used in determining if a condition can be pushed down to derived table.

Reimplemented from Item.

Reimplemented in Item_trigger_field.

◆ make_field()

void Item_field::make_field ( Send_field tmp_field)
overridevirtual

Reimplemented from Item.

◆ mark_field_in_map()

bool Item_field::mark_field_in_map ( uchar arg)
inlineoverridevirtual

Mark underlying field in read or write map of a table.

Parameters
argMark_field object

Reimplemented from Item.

◆ max_disp_length()

uint32 Item_field::max_disp_length ( )
inline

◆ numeric_context_result_type()

Item_result Item_field::numeric_context_result_type ( ) const
inlineoverridevirtual

Result type when an item appear in a numeric context.

See Field::numeric_context_result_type() for more comments.

Reimplemented from Item.

◆ print()

void Item_field::print ( const THD ,
String str,
enum_query_type   
) const
overridevirtual

This method is used for to:

  • to generate a view definition query (SELECT-statement);
  • to generate a SQL-query for EXPLAIN EXTENDED;
  • to generate a SQL-query to be shown in INFORMATION_SCHEMA;
  • to generate a SQL-query that looks like a prepared statement for query_rewrite
  • debug.

For more information about view definition query, INFORMATION_SCHEMA query and why they should be generated from the Item-tree,

See also
mysql_register_view().

Reimplemented from Item_ident.

Reimplemented in Item_default_value, Item_insert_value, and Item_trigger_field.

◆ protected_by_any_value()

bool Item_field::protected_by_any_value ( ) const
inline

See m_protected_by_any_value.

◆ remove_column_from_bitmap()

bool Item_field::remove_column_from_bitmap ( uchar arg)
overridevirtual

Visitor interface for removing all column expressions (Item_field) in this expression tree from a bitmap.

See also
walk()
Parameters
argA MY_BITMAP* cast to unsigned char*, where the bits represent Field::field_index values.

Reimplemented from Item.

◆ replace_equal_field()

Item * Item_field::replace_equal_field ( uchar arg)
overridevirtual

Replace an Item_field for an equal Item_field that evaluated earlier (if any).

The function returns a pointer to an item that is taken from the very beginning of the item_equal list which the Item_field object refers to (belongs to) unless item_equal contains a constant item. In this case the function returns this constant item, (if the substitution does not require conversion). If the Item_field object does not refer any Item_equal object 'this' is returned .

Note
This function is supposed to be called as a callback parameter in calls of the thransformer method.
Returns
  • pointer to a replacement Item_field if there is a better equal item or a pointer to a constant equal item;
  • this - otherwise.

Reimplemented from Item.

◆ replace_field_processor()

bool Item_field::replace_field_processor ( uchar )
overridevirtual

A processor that replaces any Fields with a Create_field_wrapper.

This will allow us to resolve functions during CREATE TABLE, where we only have Create_field available and not Field. Used for functional index implementation.

Reimplemented from Item.

◆ replace_item_field()

Item * Item_field::replace_item_field ( uchar arg)
overridevirtual

If this field is the target is the target of replacement, replace it with the info object's item or, if the item is found inside a subquery, the target is an outer reference, so we create a new Item_field, mark it accordingly and replace with that instead.

Parameters
argAn info object of type Item::Item_field_replacement.
Returns
the resulting item, replaced or not, or nullptr if error

Reimplemented from Item.

Reimplemented in Item_default_value.

◆ replace_with_derived_expr()

Item * Item_field::replace_with_derived_expr ( uchar arg)
overridevirtual

Assuming this expression is part of a condition that would be pushed to the WHERE clause of a materialized derived table, replace, in this expression, each derived table's column with a clone of the expression lying under it in the derived table's definition.

We replace with a clone, because the condition can be pushed further down in case of nested derived tables.

Reimplemented from Item.

◆ replace_with_derived_expr_ref()

Item * Item_field::replace_with_derived_expr_ref ( uchar arg)
overridevirtual

Assuming this expression is part of a condition that would be pushed to the HAVING clause of a materialized derived table, replace, in this expression, each derived table's column with a reference to the expression lying under it in the derived table's definition.

Unlike replace_with_derived_expr, a clone is not used because HAVING condition will not be pushed further down in case of nested derived tables.

Reimplemented from Item.

◆ repoint_const_outer_ref()

bool Item_field::repoint_const_outer_ref ( uchar arg)
overridevirtual

If this object is the real_item of an Item_ref, repoint the result_field to field.

Reimplemented from Item.

◆ reset_field() [1/2]

void Item_field::reset_field ( )

Reset all aspect of a field object, so that it can be re-resolved.

This is only for use in prepared CREATE TABLE statements.

◆ reset_field() [2/2]

void Item_field::reset_field ( Field f)

Reset this item to point to a field from the new temporary table.

This is used when we create a new temporary table for each execution of prepared statement.

◆ result_type()

Item_result Item_field::result_type ( ) const
inlineoverridevirtual

Reimplemented from Item.

◆ returns_array()

bool Item_field::returns_array ( ) const
inlineoverridevirtual

Whether the item returns array of its data type.

Reimplemented from Item.

◆ safe_charset_converter()

Item * Item_field::safe_charset_converter ( THD thd,
const CHARSET_INFO tocs 
)
overridevirtual

Reimplemented from Item.

◆ save_in_field_inner()

type_conversion_status Item_field::save_in_field_inner ( Field field,
bool  no_conversions 
)
overrideprotectedvirtual

Helper function which does all of the work for save_in_field(Field*, bool), except some error checking common to all subclasses, which is performed by save_in_field() itself.

Subclasses that need to specialize the behaviour of save_in_field(), should override this function instead of save_in_field().

Parameters
[in,out]fieldthe field to save the item into
no_conversionswhether or not to allow conversions of the value
Returns
the status from saving into the field
Return values
TYPE_OKitem saved without any errors or warnings
!=TYPE_OK there were errors or warnings when saving the item

Reimplemented from Item.

Reimplemented in Item_default_value, and Item_insert_value.

◆ save_org_in_field()

void Item_field::save_org_in_field ( Field field)
overridevirtual

Set a field's value from a item.

Reimplemented from Item.

◆ send()

bool Item_field::send ( Protocol protocol,
String str 
)
overridevirtual

This is only called from items that is not of type item_field.

Reimplemented from Item.

◆ set_base_item_field()

void Item_field::set_base_item_field ( const Item_field item)
inline

◆ set_can_use_prefix_key()

void Item_field::set_can_use_prefix_key ( )
inlineoverridevirtual

Reimplemented from Item.

◆ set_field()

void Item_field::set_field ( Field field)
protected

◆ set_item_equal()

void Item_field::set_item_equal ( Item_equal item_equal_arg)
inline

◆ set_item_equal_all_join_nests()

void Item_field::set_item_equal_all_join_nests ( Item_equal item_equal)
inline

◆ set_result_field()

void Item_field::set_result_field ( Field field_arg)
inlineoverridevirtual

Reimplemented from Item.

◆ strip_db_table_name_processor()

bool Item_field::strip_db_table_name_processor ( uchar )
overridevirtual

Generated fields don't need db/table names.

Strip them off as inplace ALTER can reallocate them, making pointers invalid.

Reimplemented from Item.

◆ subst_argument_checker()

bool Item_field::subst_argument_checker ( uchar **  arg)
overridevirtual

Check whether a field can be substituted by an equal item.

The function checks whether a substitution of the field occurrence for an equal item is valid.

Parameters
arg*arg != NULL <-> the field is in the context where substitution for an equal item is valid
Note
The following statement is not always true:
x=y => F(x)=F(x/y).
This means substitution of an item for an equal item not always yields an equavalent condition. Here's an example:
'a'='a '
(LENGTH('a')=1) != (LENGTH('a ')=2)
Such a substitution is surely valid if either the substituted field is not of a STRING type or if it is an argument of a comparison predicate.
Return values
truesubstitution is valid
falseotherwise

Reimplemented from Item.

◆ tmp_table_field()

Field * Item_field::tmp_table_field ( TABLE )
inlineoverridevirtual

Reimplemented from Item.

◆ type()

enum Type Item_field::type ( ) const
inlineoverridevirtual

Implements Item.

Reimplemented in Item_default_value, Item_insert_value, and Item_trigger_field.

◆ update_value_transformer()

Item * Item_field::update_value_transformer ( uchar select_arg)
overridevirtual

Add the field to the select list and substitute it for the reference to the field.

If the field doesn't belong to the table being inserted into then it is added to the select list, pointer to it is stored in the ref_item_array of the select and the field itself is substituted for the Item_ref object. This is done in order to get correct values from update fields that belongs to the SELECT part in the INSERT .. SELECT .. ON DUPLICATE KEY UPDATE statement.

Return values
nullptrif an error occurred
refif all conditions are met
thisfield otherwise

Reimplemented from Item.

◆ used_tables()

table_map Item_field::used_tables ( ) const
overridevirtual

Reimplemented from Item.

Reimplemented in Item_default_value, Item_insert_value, and Item_trigger_field.

◆ used_tables_for_level()

bool Item_field::used_tables_for_level ( uchar arg)
overridevirtual

Return used table information for the specified query block (level).

For a field that is resolved from this query block, return the table number. For a field that is resolved from a query block outer to the specified one, return OUTER_REF_TABLE_BIT

Parameters
[in,out]argpointer to an instance of class Used_tables, which is constructed with the query block as argument. The used tables information is accumulated in the field used_tables in this class.
Note
This function is used to update used tables information after merging a query block (a subquery) with its parent.

Reimplemented from Item.

◆ val_date_temporal()

longlong Item_field::val_date_temporal ( )
overridevirtual

Return date value of item in packed longlong format.

Reimplemented from Item.

◆ val_date_temporal_at_utc()

longlong Item_field::val_date_temporal_at_utc ( )
overridevirtual

Reimplemented from Item.

◆ val_decimal()

my_decimal * Item_field::val_decimal ( my_decimal decimal_value)
overridevirtual

Implements Item.

◆ val_int()

longlong Item_field::val_int ( void  )
overridevirtual

Implements Item.

◆ val_int_endpoint()

longlong Item_field::val_int_endpoint ( bool  left_endp,
bool *  incl_endp 
)
overridevirtual

Reimplemented from Item.

◆ val_json()

bool Item_field::val_json ( Json_wrapper result)
overridevirtual

Get a JSON value from an Item.

All subclasses that can return a JSON value, should override this function. The function in the base class is not expected to be called. If it is called, it most likely means that some subclass is missing an override of val_json().

Parameters
[in,out]resultThe resulting Json_wrapper.
Returns
false if successful, true on failure

Reimplemented from Item.

◆ val_real()

double Item_field::val_real ( void  )
overridevirtual

Implements Item.

◆ val_str()

String * Item_field::val_str ( String str)
overridevirtual

Implements Item.

◆ val_time_temporal()

longlong Item_field::val_time_temporal ( )
overridevirtual

Return time value of item in packed longlong format.

Reimplemented from Item.

◆ val_time_temporal_at_utc()

longlong Item_field::val_time_temporal_at_utc ( )
overridevirtual

Reimplemented from Item.

Member Data Documentation

◆ any_privileges

bool Item_field::any_privileges

◆ can_use_prefix_key

bool Item_field::can_use_prefix_key {false}

◆ field

Field* Item_field::field

Source field.

◆ field_index

uint16 Item_field::field_index

Index for this field in table->field array.

Holds NO_FIELD_INDEX if index value is not known.

◆ have_privileges

uint Item_field::have_privileges

◆ item_equal

Item_equal* Item_field::item_equal {nullptr}

Used during optimization to perform multiple equality analysis, this analysis should be performed during preparation instead, so that Item_field can be const after preparation.

◆ item_equal_all_join_nests

Item_equal* Item_field::item_equal_all_join_nests {nullptr}

◆ last_destination_field

Field* Item_field::last_destination_field {nullptr}
private

◆ last_destination_field_memcpyable

uint32_t Item_field::last_destination_field_memcpyable = ~0U
private

◆ last_org_destination_field

Field* Item_field::last_org_destination_field {nullptr}
private

◆ last_org_destination_field_memcpyable

uint32_t Item_field::last_org_destination_field_memcpyable = ~0U
private

◆ m_base_item_field

const Item_field* Item_field::m_base_item_field {nullptr}
private

If this field is derived from another field, e.g.

it is reading a column from a temporary table which is populated from a base table, this member points to the field used to populate the temporary table column.

◆ m_protected_by_any_value

bool Item_field::m_protected_by_any_value {false}
private

State used for transforming scalar subqueries to JOINs with derived tables, cf.

transform_grouped_to_derived. Has accessor.

◆ no_constant_propagation

bool Item_field::no_constant_propagation {false}

If true, the optimizer's constant propagation will not replace this item with an equal constant.

◆ result_field

Field* Item_field::result_field {nullptr}
private

Result field.

◆ table_ref

Table_ref* Item_field::table_ref

Table containing this resolved field.

This is required e.g for calculation of table map. Notice that for the following types of "tables", no Table_ref object is assigned and hence table_ref is NULL:

  • Temporary tables assigned by join optimizer for sorting and aggregation.
  • Stored procedure dummy tables. For fields referencing such tables, table number is always 0, and other uses of table_ref is not needed.

The documentation for this class was generated from the following files: