My Project
Public Types | Public Member Functions | Public Attributes | Protected Member Functions
Item_ref Class Reference
Inheritance diagram for Item_ref:
Item_ident Item Item_aggregate_ref Item_direct_ref Item_ref_null_helper Item_direct_view_ref Item_outer_ref

List of all members.

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 Attributes

Fieldresult_field
Item ** ref

Protected Member Functions

void set_properties ()

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.

bool Item_ref::eq ( const Item item,
bool  binary_cmp 
) const [inline, virtual]

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.

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.

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.

virtual bool Item_ref::has_stored_program ( ) const [inline, virtual]

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

Reimplemented from Item.

virtual bool Item_ref::has_subquery ( ) const [inline, virtual]

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

Reimplemented from Item.

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.

virtual table_map Item_ref::resolved_used_tables ( ) const [inline, virtual]

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.

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.

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.

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.

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.

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.

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.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines