MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Item_ref Class Reference
Inheritance diagram for Item_ref:
Collaboration diagram for Item_ref:

Public Types

enum  Ref_Type {
  REF, DIRECT_REF, VIEW_REF, OUTER_REF,
  AGGREGATE_REF
}

Public Member Functions

 Item_ref (Name_resolution_context *context_arg, const char *db_arg, const char *table_name_arg, const char *field_name_arg)
 Item_ref (Name_resolution_context *context_arg, Item **item, const char *table_name_arg, const char *field_name_arg, bool alias_name_used_arg=FALSE)
 Item_ref (THD *thd, Item_ref *item)
enum Type type () const
bool eq (const Item *item, bool binary_cmp) const
double val_real ()
longlong val_int ()
longlong val_time_temporal ()
longlong val_date_temporal ()
my_decimalval_decimal (my_decimal *)
bool val_bool ()
Stringval_str (String *tmp)
bool is_null ()
bool get_date (MYSQL_TIME *ltime, uint fuzzydate)
double val_result ()
longlong val_int_result ()
Stringstr_result (String *tmp)
my_decimalval_decimal_result (my_decimal *)
bool val_bool_result ()
bool is_null_result ()
bool send (Protocol *prot, String *tmp)
void make_field (Send_field *field)
bool fix_fields (THD *, Item **)
void fix_after_pullout (st_select_lex *parent_select, st_select_lex *removed_select)
type_conversion_status save_in_field (Field *field, bool no_conversions)
void save_org_in_field (Field *field)
enum Item_result result_type () const
enum_field_types field_type () const
Fieldget_tmp_table_field ()
Itemget_tmp_table_item (THD *thd)
bool const_item () const
table_map used_tables () const
void update_used_tables ()
virtual table_map resolved_used_tables () const
table_map not_null_tables () const
void set_result_field (Field *field)
bool is_result_field ()
void save_in_result_field (bool no_conversions)
Itemreal_item ()
bool walk (Item_processor processor, bool walk_subquery, uchar *arg)
virtual Itemtransform (Item_transformer, uchar *arg)
virtual Itemcompile (Item_analyzer analyzer, uchar **arg_p, Item_transformer transformer, uchar *arg_t)
virtual bool explain_subquery_checker (uchar **arg)
virtual void print (String *str, enum_query_type query_type)
void cleanup ()
Item_fieldfield_for_view_update ()
virtual Ref_Type ref_type ()
uint cols ()
Itemelement_index (uint i)
Item ** addr (uint i)
bool check_cols (uint c)
bool null_inside ()
void bring_value ()
bool get_time (MYSQL_TIME *ltime)
virtual bool basic_const_item () const
bool is_outer_field () const
virtual bool has_subquery () const
virtual bool has_stored_program () const
virtual bool created_by_in2exists () const
 Whether this Item was created by the IN->EXISTS subquery transformation.
- 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 (THD *thd, Item_ident *item)
const char * full_name () const
bool remove_dependence_processor (uchar *arg)
virtual bool change_context_processor (uchar *cntx)
- Public Member Functions inherited from Item
 Item (THD *thd, Item *item)
void rename (char *new_name)
void init_make_field (Send_field *tmp_field, enum enum_field_types type)
virtual Fieldmake_string_field (TABLE *table)
void quick_fix_field ()
type_conversion_status save_in_field_no_warnings (Field *field, bool no_conversions)
virtual type_conversion_status save_safe_in_field (Field *field)
virtual enum Item_result numeric_context_result_type () const
enum Item_result temporal_with_date_as_number_result_type () const
virtual Item_result cast_to_int_type () const
virtual enum_field_types string_field_type () const
virtual enum_monotonicity_info get_monotonicity_info () const
virtual longlong val_int_endpoint (bool left_endp, bool *incl_endp)
longlong val_temporal_by_field_type ()
longlong val_temporal_with_round (enum_field_types type, uint8 dec)
ulonglong val_uint ()
virtual Stringval_str_ascii (String *str)
virtual Stringval_nodeset (String *)
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 Fieldtmp_table_field (TABLE *t_arg)
virtual longlong val_time_temporal_result ()
virtual longlong val_date_temporal_result ()
virtual Itemclone_item ()
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 ()
virtual uint datetime_precision ()
virtual bool const_during_execution () const
void print_item_w_name (String *, enum_query_type query_type)
void print_for_order (String *str, enum_query_type query_type, bool used_alias)
virtual void split_sum_func (THD *thd, Ref_ptr_array ref_pointer_array, List< Item > &fields)
void split_sum_func2 (THD *thd, Ref_ptr_array ref_pointer_array, List< Item > &fields, Item **ref, bool skip_registered)
virtual bool get_timeval (struct timeval *tm, int *warnings)
virtual bool get_date_result (MYSQL_TIME *ltime, uint fuzzydate)
virtual void update_null_value ()
virtual void top_level_item ()
virtual bool is_bool_func ()
virtual void no_rows_in_result ()
virtual Itemcopy_or_same (THD *thd)
virtual Itemcopy_andor_structure (THD *thd, bool real_items=false)
virtual const CHARSET_INFOcompare_collation ()
virtual const CHARSET_INFOcharset_for_protocol (void) const
virtual void traverse_cond (Cond_traverser traverser, void *arg, traverse_order order)
virtual bool intro_version (uchar *int_arg)
virtual bool remove_fixed (uchar *arg)
virtual bool cleanup_processor (uchar *arg)
virtual bool collect_item_field_processor (uchar *arg)
virtual bool add_field_to_set_processor (uchar *arg)
virtual bool remove_column_from_bitmap (uchar *arg)
virtual bool find_item_in_field_list_processor (uchar *arg)
virtual bool reset_query_id_processor (uchar *query_id_arg)
virtual bool find_item_processor (uchar *arg)
virtual bool register_field_in_read_map (uchar *arg)
virtual bool inform_item_in_cond_of_tab (uchar *join_tab_index)
virtual bool clean_up_after_removal (uchar *arg)
virtual bool cache_const_expr_analyzer (uchar **arg)
virtual Itemcache_const_expr_transformer (uchar *arg)
virtual bool item_field_by_name_analyzer (uchar **arg)
virtual Itemitem_field_by_name_transformer (uchar *arg)
virtual bool equality_substitution_analyzer (uchar **arg)
virtual Itemequality_substitution_transformer (uchar *arg)
virtual bool check_partition_func_processor (uchar *bool_arg)
virtual bool subst_argument_checker (uchar **arg)
virtual Itemexplain_subquery_propagator (uchar *arg)
virtual Itemequal_fields_propagator (uchar *arg)
virtual bool set_no_const_sub (uchar *arg)
virtual Itemreplace_equal_field (uchar *arg)
virtual bool check_valid_arguments_processor (uchar *bool_arg)
virtual bool find_function_processor (uchar *arg)
virtual Itemthis_item ()
virtual const Itemthis_item () const
virtual Item ** this_item_addr (THD *thd, Item **addr_arg)
Fieldtmp_table_field_from_field_type (TABLE *table, bool fixed_length)
virtual Itemneg_transformer (THD *thd)
virtual Itemupdate_value_transformer (uchar *select_arg)
virtual Itemsafe_charset_converter (const CHARSET_INFO *tocs)
void delete_self ()
virtual bool is_splocal ()
virtual
Settable_routine_parameter
get_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
virtual Field::geometry_type get_geometry_type () const
Stringcheck_well_formed_result (String *str, bool send_error=0)
bool eq_by_collation (Item *item, bool binary_cmp, const CHARSET_INFO *cs)
virtual bool is_expensive ()
virtual bool can_be_evaluated_now () const
uint32 max_char_length () const
void fix_length_and_charset (uint32 max_char_length_arg, const CHARSET_INFO *cs)
void fix_char_length (uint32 max_char_length_arg)
void fix_char_length_ulonglong (ulonglong max_char_length_arg)
void fix_length_and_charset_datetime (uint32 max_char_length_arg)
void fix_length_and_dec_and_charset_datetime (uint32 max_char_length_arg, uint8 dec_arg)
bool is_blob_field () const

Public Attributes

Fieldresult_field
Item ** ref
- Public Attributes inherited from Item_ident
Name_resolution_contextcontext
const char * db_name
const char * table_name
const char * field_name
bool alias_name_used
uint cached_field_index
TABLE_LISTcached_table
st_select_lex * depended_from
- Public Attributes inherited from Item
uint rsize
String str_value
Item_name_string item_name
Item_name_string orig_name
Itemnext
uint32 max_length
int marker
uint8 decimals
my_bool maybe_null
my_bool null_value
my_bool unsigned_flag
my_bool with_sum_func
my_bool fixed
DTCollation collation
Item_result cmp_context

Protected Member Functions

void set_properties ()

Additional Inherited Members

- Static Public Member Functions inherited from Item
static void * operator new (size_t size) throw ()
static void * operator new (size_t size, MEM_ROOT *mem_root) throw ()
static void operator delete (void *ptr, size_t size)
static void operator delete (void *ptr, MEM_ROOT *mem_root)
static const CHARSET_INFOdefault_charset ()
- Protected Attributes inherited from Item_ident
const char * orig_db_name
const char * orig_table_name
const char * orig_field_name

Detailed Description

Definition at line 3128 of file item.h.

Member Function Documentation

Item * Item_ref::compile ( Item_analyzer  analyzer,
uchar **  arg_p,
Item_transformer  transformer,
uchar *  arg_t 
)
virtual

Compile an Item_ref object with a processor and a transformer callback function.

First the function applies the analyzer to the Item_ref object. Second it applies the compile function to the object the Item_ref object is referencing. If this replaces the item with a new one, this object is returned as the result of the compile. Otherwise we apply the transformer to the Item_ref object itself.

Parameters
analyzerthe analyzer callback function to be applied to the nodes of the tree of the object
[in,out]arg_pparameter to be passed to the processor
transformerthe transformer callback function to be applied to the nodes of the tree of the object
arg_tparameter to be passed to the transformer
Returns
Item returned as the result of transformation of the Item_ref object, or NULL if error.

Reimplemented from Item.

Definition at line 7476 of file item.cc.

bool Item_ref::eq ( const Item item,
bool  binary_cmp 
) const
inlinevirtual

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_direct_view_ref.

Definition at line 3163 of file item.h.

Here is the call graph for this function:

void Item_ref::fix_after_pullout ( st_select_lex *  parent_select,
st_select_lex *  removed_select 
)
virtual

Fix after tables have been moved from one select_lex level to the parent level, e.g by semijoin conversion. Basically re-calculate all attributes dependent on the tables.

Parameters
parent_selectselect_lex that tables are moved to.
removed_selectselect_lex that tables are moved away from, child of parent_select.

Reimplemented from Item_ident.

Reimplemented in Item_outer_ref.

Definition at line 7912 of file item.cc.

bool Item_ref::fix_fields ( THD *  thd,
Item **  reference 
)
virtual

Resolve the name of a reference to a column reference.

The method resolves the column reference represented by 'this' as a column present in one of: GROUP BY clause, SELECT clause, outer queries. It is used typically for columns in the HAVING clause which are not under aggregate functions.

POSTCONDITION
Item_ref::ref is 0 or points to a valid item.

Note
The name resolution algorithm used is (where [T_j] is an optional table name that qualifies the column name):
resolve_extended([T_j].col_ref_i)
{
Search for a column or derived column named col_ref_i [in table T_j]
in the SELECT and GROUP clauses 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 SELECT and GROUP clauses of Q_k.
if such a column is not found AND
- Q_k is not a group query AND
- Q_k is not inside an aggregate function
OR
- Q_(k-1) is not in a HAVING or SELECT clause of Q_k
{
search for a column or derived column named col_ref_i
[in table T_j] in the FROM clause of Q_k;
}
}
}
}


This procedure treats GROUP BY and SELECT clauses as one namespace for column references in HAVING. Notice that compared to Item_field::fix_fields, here we first search the SELECT and GROUP BY clauses, and then we search the FROM clause.

Parameters
[in]thdcurrent thread
[in,out]referenceview column if this item was resolved to a view column
Todo:
Here we could first find the field anyway, and then test this condition, so that we can give a better error message - ER_WRONG_FIELD_WITH_GROUP, instead of the less informative ER_BAD_FIELD_ERROR which we produce now.
Return values
TRUEif error
FALSEon success

Reimplemented from Item.

Reimplemented in Item_outer_ref, and Item_direct_view_ref.

Definition at line 7147 of file item.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

virtual bool Item_ref::has_stored_program ( ) const
inlinevirtual

Checks if the item tree that ref points to contains a stored program.

Reimplemented from Item.

Definition at line 3308 of file item.h.

virtual bool Item_ref::has_subquery ( ) const
inlinevirtual

Checks if the item tree that ref points to contains a subquery.

Reimplemented from Item.

Definition at line 3299 of file item.h.

void Item_ref::print ( String str,
enum_query_type  query_type 
)
virtual

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;
  • 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_ref_null_helper, and Item_aggregate_ref.

Definition at line 7498 of file item.cc.

Here is the call graph for this function:

virtual table_map Item_ref::resolved_used_tables ( ) const
inlinevirtual

Return used table information for the level this item is resolved on.

  • For fields, this returns the table the item is resolved from.
  • For all other items, this behaves like used_tables().
Note
: Use this function with caution. External calls to this function should only be made for class objects derived from Item_ident. Item::resolved_used_tables is for internal use only, in order to process fields underlying a view column reference.

Reimplemented from Item.

Definition at line 3209 of file item.h.

type_conversion_status Item_ref::save_in_field ( Field field,
bool  no_conversions 
)
virtual

Save a temporal value in packed longlong format into a Field. Used in optimizer.

Parameters
OUTfield The field to set the value to.
Return values
0On success.
>0In error.

Reimplemented from Item.

Definition at line 7690 of file item.cc.

Here is the call graph for this function:

bool Item_ref::send ( Protocol protocol,
String buffer 
)
virtual

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

Reimplemented from Item.

Definition at line 7516 of file item.cc.

Here is the call graph for this function:

Item * Item_ref::transform ( Item_transformer  transformer,
uchar *  arg 
)
virtual

Transform an Item_ref object with a transformer callback function.

The function first applies the transform function to the item referenced by this Item_ref object. If this replaces the item with a new one, this item object is returned as the result of the transform. Otherwise the transform function is applied to the Item_ref object itself.

Parameters
transformerthe transformer callback function to be applied to the nodes of the tree of the object
argumentparameter to be passed to the transformer
Returns
Item returned as the result of transformation of the Item_ref object
Return values
!NULLThe transformation was successful
NULLOut of memory error

Reimplemented from Item.

Definition at line 7431 of file item.cc.

Here is the call graph for this function:

bool Item_ref::val_bool ( )
virtual
Todo:
Make this functions class dependent

Reimplemented from Item.

Reimplemented in Item_ref_null_helper, and Item_direct_ref.

Definition at line 7649 of file item.cc.

longlong Item_ref::val_date_temporal ( )
virtual

Return date value of item in packed longlong format.

Reimplemented from Item.

Reimplemented in Item_ref_null_helper, and Item_direct_ref.

Definition at line 7639 of file item.cc.

longlong Item_ref::val_time_temporal ( )
virtual

Return time value of item in packed longlong format.

Reimplemented from Item.

Reimplemented in Item_ref_null_helper, and Item_direct_ref.

Definition at line 7629 of file item.cc.


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