My Project
Public Member Functions | Public Attributes
Item_outer_ref Class Reference
Inheritance diagram for Item_outer_ref:
Item_direct_ref Item_ref Item_ident Item

List of all members.

Public Member Functions

 Item_outer_ref (Name_resolution_context *context_arg, Item_field *outer_field_arg)
 Item_outer_ref (Name_resolution_context *context_arg, Item **item, const char *table_name_arg, const char *field_name_arg, bool alias_name_used_arg)
void save_in_result_field (bool no_conversions)
bool fix_fields (THD *, Item **)
void fix_after_pullout (st_select_lex *parent_select, st_select_lex *removed_select)
table_map used_tables () const
table_map not_null_tables () const
virtual Ref_Type ref_type ()

Public Attributes

Itemouter_ref
Item_sumin_sum_func
bool found_in_select_list

Member Function Documentation

void Item_outer_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_ref.

bool Item_outer_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_ref.


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