My Project
Public Member Functions | Public Attributes | Protected Member Functions | Friends
Item_field Class Reference
Inheritance diagram for Item_field:
Item_ident Item Item_default_value Item_insert_value Item_trigger_field

List of all members.

Public Member Functions

 Item_field (Name_resolution_context *context_arg, const char *db_arg, const char *table_name_arg, const char *field_name_arg)
 Item_field (THD *thd, Item_field *item)
 Item_field (THD *thd, Name_resolution_context *context_arg, Field *field)
 Item_field (Field *field)
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 *)
Stringval_str (String *)
double val_result ()
longlong val_int_result ()
longlong val_time_temporal_result ()
longlong val_date_temporal_result ()
Stringstr_result (String *tmp)
my_decimalval_decimal_result (my_decimal *)
bool val_bool_result ()
bool is_null_result ()
bool send (Protocol *protocol, String *str_arg)
void reset_field (Field *f)
bool fix_fields (THD *, Item **)
void make_field (Send_field *tmp_field)
type_conversion_status save_in_field (Field *field, bool no_conversions)
void save_org_in_field (Field *field)
table_map used_tables () const
virtual table_map resolved_used_tables () const
enum Item_result result_type () const
enum Item_result numeric_context_result_type () const
Item_result cast_to_int_type () const
enum_field_types field_type () const
enum_monotonicity_info get_monotonicity_info () const
longlong val_int_endpoint (bool left_endp, bool *incl_endp)
Fieldget_tmp_table_field ()
Fieldtmp_table_field (TABLE *t_arg)
bool get_date (MYSQL_TIME *ltime, uint fuzzydate)
bool get_date_result (MYSQL_TIME *ltime, uint fuzzydate)
bool get_time (MYSQL_TIME *ltime)
bool get_timeval (struct timeval *tm, int *warnings)
bool is_null ()
void update_null_value ()
Itemget_tmp_table_item (THD *thd)
bool collect_item_field_processor (uchar *arg)
bool add_field_to_set_processor (uchar *arg)
bool remove_column_from_bitmap (uchar *arg)
bool find_item_in_field_list_processor (uchar *arg)
bool register_field_in_read_map (uchar *arg)
bool check_partition_func_processor (uchar *int_arg)
void cleanup ()
Item_equalfind_item_equal (COND_EQUAL *cond_equal)
bool subst_argument_checker (uchar **arg)
Itemequal_fields_propagator (uchar *arg)
bool set_no_const_sub (uchar *arg)
Itemreplace_equal_field (uchar *arg)
uint32 max_disp_length ()
Item_fieldfield_for_view_update ()
Itemsafe_charset_converter (const CHARSET_INFO *tocs)
int fix_outer_field (THD *thd, Field **field, Item **reference)
virtual Itemupdate_value_transformer (uchar *select_arg)
virtual bool item_field_by_name_analyzer (uchar **arg)
virtual Itemitem_field_by_name_transformer (uchar *arg)
virtual void print (String *str, enum_query_type query_type)
bool is_outer_field () const
Field::geometry_type get_geometry_type () const
const CHARSET_INFO * charset_for_protocol (void) const
void dbug_print ()
bool push_to_non_agg_fields (st_select_lex *select_lex)
 Pushes the item to select_lex.non_agg_fields() and updates its marker.

Public Attributes

Fieldfield
Fieldresult_field
Item_equalitem_equal
bool no_const_subst
uint have_privileges
bool any_privileges

Protected Member Functions

void set_field (Field *field)

Friends

class Item_default_value
class Item_insert_value
class st_select_lex_unit

Constructor & Destructor Documentation

Item_field::Item_field ( THD *  thd,
Item_field item 
)

Constructor need to process subselect with temporary tables (see Item)

Item_field::Item_field ( THD *  thd,
Name_resolution_context context_arg,
Field f 
)

Constructor used inside setup_wild().

Ensures that field, table, and database names will live as long as Item_field (this is important in prepared statements).


Member Function Documentation

bool Item_field::collect_item_field_processor ( uchar *  arg) [virtual]

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 List<Item_field>
Returns:
FALSE to force the evaluation of collect_item_field_processor for the subsequent items.

Reimplemented from Item.

bool Item_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.

Reimplemented in Item_trigger_field, Item_insert_value, and Item_default_value.

Item * Item_field::equal_fields_propagator ( uchar *  arg) [virtual]

Set a pointer to the multiple equality the field reference belongs to (if any).

The function looks for a multiple equality containing the field item among those referenced by arg. In the case such equality exists the function does the following. If the found multiple equality contains a constant, then the field reference is substituted for this constant, otherwise it sets a pointer to the multiple equality in the field item.

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.

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
  • 0, otherwise
bool Item_field::find_item_in_field_list_processor ( uchar *  arg) [virtual]

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.

bool Item_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.

Reimplemented in Item_trigger_field, Item_insert_value, and Item_default_value.

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 occured
bool Item_field::get_timeval ( struct timeval *  tm,
int *  warnings 
) [virtual]

Get timestamp in "struct timeval" format.

Return values:
falseon success
trueon error

If argument is NULL, sets null_value. 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.

bool Item_field::item_field_by_name_analyzer ( uchar **  arg) [virtual]

Analyzer for finding Item_field by name

Parameters:
argField name to search for
Returns:
TRUE Go deeper in item tree. (Found Item or not an Item_field)
FALSE Don't go deeper in item tree. (Item_field with other name)

Reimplemented from Item.

Item * Item_field::item_field_by_name_transformer ( uchar *  arg) [virtual]

Simple transformer that returns the argument if this is an Item_field. The new item will inherit it's name to maintain aliases.

Parameters:
argItem to replace Item_field
Returns:
argument if this is an Item_field
this otherwise.

Reimplemented from Item.

enum Item_result Item_field::numeric_context_result_type ( ) const [inline, virtual]

Result type when an item appear in a numeric context. See Field::numeric_context_result_type() for more comments.

Reimplemented from Item.

void Item_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_ident.

Reimplemented in Item_trigger_field, Item_insert_value, and Item_default_value.

bool Item_field::remove_column_from_bitmap ( uchar *  arg) [virtual]

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

Parameters:
argA MY_BITMAP* cast to unsigned char*, where the bits represent Field::field_index values.

Reimplemented from Item.

Item * Item_field::replace_equal_field ( uchar *  arg) [virtual]

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 .

Parameters:
arga dummy parameter, is not used here
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.

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.

table_map Item_field::resolved_used_tables ( ) const [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_field::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.

Reimplemented in Item_insert_value, and Item_default_value.

void Item_field::save_org_in_field ( Field to) [virtual]

Set a field's value from a item.

Reimplemented from Item.

bool Item_field::send ( Protocol protocol,
String buffer 
) [virtual]

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

Reimplemented from Item.

bool Item_field::set_no_const_sub ( uchar *  arg) [virtual]

Mark the item to not be part of substitution if it's not a binary item.

See comments in Arg_comparator::set_compare_func() for details.

Reimplemented from Item.

bool Item_field::subst_argument_checker ( uchar **  arg) [virtual]

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.

longlong Item_field::val_date_temporal ( ) [virtual]

Return date value of item in packed longlong format.

Reimplemented from Item.

longlong Item_field::val_date_temporal_result ( ) [virtual]

Get date value in packed longlong format. NULL is converted to 0.

Reimplemented from Item.

longlong Item_field::val_time_temporal ( ) [virtual]

Return time value of item in packed longlong format.

Reimplemented from Item.

longlong Item_field::val_time_temporal_result ( ) [virtual]

Get time value in packed longlong format. NULL is converted to 0.

Reimplemented from Item.


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