My Project
Public Types | Public Member Functions | Public Attributes
Item_trigger_field Class Reference
Inheritance diagram for Item_trigger_field:
Item_field Settable_routine_parameter Item_ident Item

List of all members.

Public Types

enum  row_version_type { OLD_ROW, NEW_ROW }

Public Member Functions

 Item_trigger_field (Name_resolution_context *context_arg, row_version_type row_ver_arg, const char *field_name_arg, ulong priv, const bool ro)
void setup_field (THD *thd, TABLE *table, GRANT_INFO *table_grant_info)
enum Type type () const
bool eq (const Item *item, bool binary_cmp) const
bool fix_fields (THD *, Item **)
virtual void print (String *str, enum_query_type query_type)
table_map used_tables () const
Fieldget_tmp_table_field ()
Itemcopy_or_same (THD *thd)
Itemget_tmp_table_item (THD *thd)
void cleanup ()
Settable_routine_parameterget_settable_routine_parameter ()
bool set_value (THD *thd, Item **it)

Public Attributes

row_version_type row_version
Item_trigger_fieldnext_trg_field
SQL_I_List< Item_trigger_field > * next_trig_field_list
uint field_idx
Table_triggers_listtriggers

Member Function Documentation

bool Item_trigger_field::eq ( const Item item,
bool  binary_cmp 
) const [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_field.

bool Item_trigger_field::fix_fields ( THD *  thd,
Item **  reference 
) [virtual]

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

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.

Parameters:
[in]thdcurrent thread
[in,out]referenceview column if this item was resolved to a view column
Return values:
TRUEif error
FALSEon success

Reimplemented from Item_field.

void Item_trigger_field::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_field.

void Item_trigger_field::setup_field ( THD *  thd,
TABLE table,
GRANT_INFO table_grant_info 
)

Find index of Field object which will be appropriate for item representing field of row being changed in trigger.

Parameters:
thdcurrent thread context
tabletable of trigger (and where we looking for fields)
table_grant_infoGRANT_INFO of the subject table
Note:
This function does almost the same as fix_fields() for Item_field but is invoked right after trigger definition parsing. Since at this stage we can't say exactly what Field object (corresponding to TABLE::record[0] or TABLE::record[1]) should be bound to this Item, we only find out index of the Field and then select concrete Field object in fix_fields() (by that time Table_trigger_list::old_field/ new_field should point to proper array of Fields). It also binds Item_trigger_field to Table_triggers_list object for table of trigger which uses this item.

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