Item Class Reference

#include <item.h>

Inheritance diagram for Item:

Inheritance graph
[legend]
Collaboration diagram for Item:

Collaboration graph
[legend]
List of all members.

Public Types

enum  Type {
  FIELD_ITEM, FUNC_ITEM, SUM_FUNC_ITEM, STRING_ITEM, INT_ITEM, REAL_ITEM, NULL_ITEM, VARBIN_ITEM, COPY_STR_ITEM, FIELD_AVG_ITEM,
  DEFAULT_VALUE_ITEM, PROC_ITEM, COND_ITEM, REF_ITEM, FIELD_STD_ITEM, FIELD_VARIANCE_ITEM, INSERT_VALUE_ITEM, SUBSELECT_ITEM, ROW_ITEM, CACHE_ITEM,
  TYPE_HOLDER, PARAM_ITEM, TRIGGER_FIELD_ITEM
}
enum  cond_result { COND_UNDEF, COND_OK, COND_TRUE, COND_FALSE }

Public Member Functions

 Item ()
 Item (THD *thd, Item *item)
virtual ~Item ()
void set_name (const char *str, uint length, CHARSET_INFO *cs)
void rename (char *new_name)
void init_make_field (Send_field *tmp_field, enum enum_field_types type)
virtual void cleanup ()
virtual void make_field (Send_field *field)
virtual bool fix_fields (THD *, struct st_table_list *, Item **)
void quick_fix_field ()
int save_in_field_no_warnings (Field *field, bool no_conversions)
virtual int save_in_field (Field *field, bool no_conversions)
virtual void save_org_in_field (Field *field)
virtual int save_safe_in_field (Field *field)
virtual bool send (Protocol *protocol, String *str)
virtual bool eq (const Item *, bool binary_cmp) const
virtual Item_result result_type () const
virtual enum_field_types field_type () const
virtual enum Type type () const =0
virtual double val_real ()=0
virtual longlong val_int ()=0
virtual Stringval_str (String *)=0
virtual Fieldget_tmp_table_field ()
virtual Fieldtmp_table_field (TABLE *t_arg)
virtual const char * full_name () const
virtual double val_result ()
virtual longlong val_int_result ()
virtual Stringstr_result (String *tmp)
virtual table_map used_tables () const
virtual table_map not_null_tables () const
virtual bool basic_const_item () const
virtual Itemnew_item ()
virtual cond_result eq_cmp_result () const
uint float_length (uint decimals_par) const
virtual bool const_item () const
virtual bool const_during_execution () const
virtual void print (String *str_arg)
void print_item_w_name (String *)
virtual void update_used_tables ()
virtual void split_sum_func (THD *thd, Item **ref_pointer_array, List< Item > &fields)
virtual bool get_date (TIME *ltime, uint fuzzydate)
virtual bool get_time (TIME *ltime)
virtual bool get_date_result (TIME *ltime, uint fuzzydate)
virtual bool is_null ()
virtual void top_level_item ()
virtual void set_result_field (Field *field)
virtual bool is_result_field ()
virtual bool is_bool_func ()
virtual void save_in_result_field (bool no_conversions)
virtual void no_rows_in_result ()
virtual Itemcopy_or_same (THD *thd)
virtual Itemcopy_andor_structure (THD *thd)
virtual Itemreal_item ()
virtual Itemget_tmp_table_item (THD *thd)
virtual CHARSET_INFOcompare_collation ()
virtual bool walk (Item_processor processor, byte *arg)
virtual Itemtransform (Item_transformer transformer, byte *arg)
virtual bool remove_dependence_processor (byte *arg)
virtual bool remove_fixed (byte *arg)
virtual bool cleanup_processor (byte *arg)
virtual bool collect_item_field_processor (byte *arg)
virtual Itemequal_fields_propagator (byte *arg)
virtual Itemset_no_const_sub (byte *arg)
virtual bool replace_equal_field_processor (byte *arg)
virtual Itemthis_item ()
virtual Itemthis_const_item () const
virtual uint cols ()
virtual Itemel (uint i)
virtual Item ** addr (uint i)
virtual bool check_cols (uint c)
virtual bool null_inside ()
virtual void bring_value ()
Fieldtmp_table_field_from_field_type (TABLE *table)
virtual Item_fieldfiled_for_view_update ()
virtual Itemneg_transformer (THD *thd)
virtual Itemsafe_charset_converter (CHARSET_INFO *tocs)
void delete_self ()

Static Public Member Functions

void * operator new (size_t size)
void * operator new (size_t size, MEM_ROOT *mem_root)
void operator delete (void *ptr, size_t size)
void operator delete (void *ptr, size_t size, MEM_ROOT *mem_root)
CHARSET_INFOdefault_charset ()

Public Attributes

String str_value
my_string name
my_string orig_name
Itemnext
uint32 max_length
uint name_length
uint8 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

Private Member Functions

 Item (const Item &)
void operator= (Item &)

Member Enumeration Documentation

enum Item::cond_result
 

Enumeration values:
COND_UNDEF 
COND_OK 
COND_TRUE 
COND_FALSE 
00135 { COND_UNDEF,COND_OK,COND_TRUE,COND_FALSE };

enum Item::Type
 

Enumeration values:
FIELD_ITEM 
FUNC_ITEM 
SUM_FUNC_ITEM 
STRING_ITEM 
INT_ITEM 
REAL_ITEM 
NULL_ITEM 
VARBIN_ITEM 
COPY_STR_ITEM 
FIELD_AVG_ITEM 
DEFAULT_VALUE_ITEM 
PROC_ITEM 
COND_ITEM 
REF_ITEM 
FIELD_STD_ITEM 
FIELD_VARIANCE_ITEM 
INSERT_VALUE_ITEM 
SUBSELECT_ITEM 
ROW_ITEM 
CACHE_ITEM 
TYPE_HOLDER 
PARAM_ITEM 
TRIGGER_FIELD_ITEM 
00127             {FIELD_ITEM, FUNC_ITEM, SUM_FUNC_ITEM, STRING_ITEM,
00128              INT_ITEM, REAL_ITEM, NULL_ITEM, VARBIN_ITEM,
00129              COPY_STR_ITEM, FIELD_AVG_ITEM, DEFAULT_VALUE_ITEM,
00130              PROC_ITEM,COND_ITEM, REF_ITEM, FIELD_STD_ITEM,
00131              FIELD_VARIANCE_ITEM, INSERT_VALUE_ITEM,
00132              SUBSELECT_ITEM, ROW_ITEM, CACHE_ITEM, TYPE_HOLDER,
00133              PARAM_ITEM, TRIGGER_FIELD_ITEM};


Constructor & Destructor Documentation

Item::Item const Item  )  [private]
 

Item::Item  ) 
 

00048           :
00049   name(0), orig_name(0), name_length(0), fixed(0),
00050   collation(default_charset(), DERIVATION_COERCIBLE)
00051 {
00052   marker= 0;
00053   maybe_null=null_value=with_sum_func=unsigned_flag=0;
00054   decimals= 0; max_length= 0;
00055 
00056   /* Put item in free list so that we can free all items at end */
00057   THD *thd= current_thd;
00058   next= thd->free_list;
00059   thd->free_list= this;
00060   /*
00061     Item constructor can be called during execution other then SQL_COM
00062     command => we should check thd->lex->current_select on zero (thd->lex
00063     can be uninitialised)
00064   */
00065   if (thd->lex->current_select)
00066   {
00067     enum_parsing_place place= 
00068       thd->lex->current_select->parsing_place;
00069     if (place == SELECT_LIST ||
00070         place == IN_HAVING)
00071       thd->lex->current_select->select_n_having_items++;
00072   }
00073 }

Item::Item THD thd,
Item item
 

00080                               :
00081   str_value(item->str_value),
00082   name(item->name),
00083   orig_name(item->orig_name),
00084   max_length(item->max_length),
00085   marker(item->marker),
00086   decimals(item->decimals),
00087   maybe_null(item->maybe_null),
00088   null_value(item->null_value),
00089   unsigned_flag(item->unsigned_flag),
00090   with_sum_func(item->with_sum_func),
00091   fixed(item->fixed),
00092   collation(item->collation)
00093 {
00094   next= thd->free_list;                         // Put in free list
00095   thd->free_list= this;
00096 }

virtual Item::~Item  )  [inline, virtual]
 

00168   {
00169     name=0;
00170   }             /*lint -e1509 */


Member Function Documentation

virtual Item** Item::addr uint  i  )  [inline, virtual]
 

Reimplemented in Item_cache_row, Item_row, and Item_singlerow_subselect.

00331 { return 0; }

virtual bool Item::basic_const_item  )  const [inline, virtual]
 

Reimplemented in Item_null, Item_int, Item_real, Item_string, and Item_varbinary.

00247 { return 0; }

virtual void Item::bring_value  )  [inline, virtual]
 

Reimplemented in Item_cache_row, Item_row, and Item_singlerow_subselect.

00336 {}

bool Item::check_cols uint  c  )  [virtual]
 

Reimplemented in Item_cache_row, Item_row, and Item_singlerow_subselect.

00253 {
00254   if (c != 1)
00255   {
00256     my_error(ER_OPERAND_COLUMNS, MYF(0), c);
00257     return 1;
00258   }
00259   return 0;
00260 }

void Item::cleanup  )  [virtual]
 

Reimplemented in Item_ident, Item_field, Item_null, Item_int, Item_real, Item_string, Item_varbinary, Item_result_field, Item_ref, Item_trigger_field, Item_cache, Item_cache_row, Item_type_holder, Item_in_optimizer, Item_func_in, Item_func_match, Item_subselect, Item_singlerow_subselect, Item_sum_count, Item_sum_count_distinct, Item_sum_hybrid, and Item_func_group_concat.

00112 {
00113   DBUG_ENTER("Item::cleanup");
00114   DBUG_PRINT("info", ("Item: 0x%lx, Type: %d, name %s, original name %s",
00115                       this, (int)type(), name ? name : "(null)",
00116                       orig_name ? orig_name : "null"));
00117   fixed=0;
00118   marker= 0;
00119   if (orig_name)
00120     name= orig_name;
00121   DBUG_VOID_RETURN;
00122 }

bool Item::cleanup_processor byte arg  )  [virtual]
 

00134 {
00135   if (fixed)
00136     cleanup();
00137   return FALSE;
00138 }

virtual bool Item::collect_item_field_processor byte arg  )  [inline, virtual]
 

Reimplemented in Item_field.

00320 { return 0; }

virtual uint Item::cols  )  [inline, virtual]
 

Reimplemented in Item_cache_row, Item_row, and Item_singlerow_subselect.

00329 { return 1; }

virtual CHARSET_INFO* Item::compare_collation  )  [inline, virtual]
 

Reimplemented in Item_bool_func2, Item_func_between, Item_func_case, Item_func_in, Item_func_isnull, Item_func_isnotnull, and Item_equal.

00305 { return NULL; }

virtual bool Item::const_during_execution  )  const [inline, virtual]
 

00263   { return (used_tables() & ~PARAM_TABLE_BIT) == 0; }

virtual bool Item::const_item  )  const [inline, virtual]
 

Reimplemented in Item_splocal, Item_copy_string, Item_func, Item_func_rand, Item_func_get_user_var, Item_row, Item_subselect, Item_sum, Item_sum_count, and Item_sum_hybrid.

00257 { return used_tables() == 0; }

virtual Item* Item::copy_andor_structure THD thd  )  [inline, virtual]
 

Reimplemented in Item_cond_and, and Item_cond_or.

00300 { return this; }

virtual Item* Item::copy_or_same THD thd  )  [inline, virtual]
 

Reimplemented in Item_sum_sum, Item_sum_sum_distinct, Item_sum_count, Item_sum_count_distinct, Item_sum_avg, Item_sum_variance, Item_sum_std, Item_sum_min, Item_sum_max, Item_sum_or, Item_sum_and, Item_sum_xor, Item_func_group_concat, and Item_sum_unique_users.

00299 { return this; }

CHARSET_INFO * Item::default_charset  )  [static]
 

00394 {
00395   return current_thd->variables.collation_connection;
00396 }

void Item::delete_self  )  [inline]
 

00344   {
00345     cleanup();
00346     delete this;
00347   }

virtual Item* Item::el uint  i  )  [inline, virtual]
 

Reimplemented in Item_cache_row, Item_row, and Item_singlerow_subselect.

00330 { return this; }

bool Item::eq const Item ,
bool  binary_cmp
const [virtual]
 

Reimplemented in Item_field, Item_null, Item_param, Item_string, Item_ref, Item_default_value, Item_insert_value, Item_trigger_field, Item_func, Item_func_get_user_var, Item_func_match, Item_func_set_collation, Item_extract, and Item_char_typecast.

00303 {
00304   return type() == item->type() && name && item->name &&
00305     !my_strcasecmp(system_charset_info,name,item->name);
00306 }

virtual cond_result Item::eq_cmp_result  )  const [inline, virtual]
 

Reimplemented in Item_func_eq, Item_func_equal, Item_func_ge, Item_func_gt, Item_func_le, Item_func_lt, Item_func_ne, and Item_func_like.

00250 { return COND_OK; }

virtual Item* Item::equal_fields_propagator byte arg  )  [inline, virtual]
 

Reimplemented in Item_field.

00321 { return this; }

enum_field_types Item::field_type  )  const [virtual]
 

Reimplemented in Item_field, Item_null, Item_param, Item_int, Item_real, Item_string, Item_datetime, Item_return_int, Item_varbinary, Item_ref, Item_copy_string, Item_func_ifnull, Item_func_get_user_var, Item_func_sp, Item_avg_field, Item_variance_field, Item_sum_hybrid, Item_date, Item_date_func, Item_func_curtime, Item_func_sec_to_time, Item_date_add_interval, Item_date_typecast, Item_time_typecast, Item_datetime_typecast, Item_func_makedate, Item_func_add_time, Item_func_timediff, Item_func_maketime, Item_func_str_to_date, Item_proc, Item_proc_real, Item_proc_int, and Item_proc_string.

02243 {
02244   return ((result_type() == STRING_RESULT) ? FIELD_TYPE_VAR_STRING :
02245           (result_type() == INT_RESULT) ? FIELD_TYPE_LONGLONG :
02246           FIELD_TYPE_DOUBLE);
02247 }

virtual Item_field* Item::filed_for_view_update  )  [inline, virtual]
 

Reimplemented in Item_field, and Item_func_set_collation.

00339 { return 0; }

bool Item::fix_fields THD ,
struct st_table_list ,
Item ** 
[virtual]
 

Reimplemented in Item_field, Item_ref, Item_default_value, Item_insert_value, Item_trigger_field, Item_in_optimizer, Item_func_if, Item_func_like, Item_cond, Item_func, Item_func_rand, Item_func_set_user_var, Item_func_match, and Item_func_convert_tz.

01519 {
01520 
01521   // We do not check fields which are fixed during construction
01522   DBUG_ASSERT(fixed == 0 || basic_const_item());
01523   fixed= 1;
01524   return FALSE;
01525 }

uint Item::float_length uint  decimals_par  )  const [inline]
 

00252   { return decimals != NOT_FIXED_DEC ? (DBL_DIG+2+decimals_par) : DBL_DIG+8;}

virtual const char* Item::full_name  )  const [inline, virtual]
 

Reimplemented in Item_ident.

00225 { return name ? name : "???"; }

bool Item::get_date TIME ltime,
uint  fuzzydate
[virtual]
 

Reimplemented in Item_field, Item_param, Item_ref, Item_ref_null_helper, Item_func_curdate, Item_func_now, Item_func_from_days, Item_func_from_unixtime, Item_func_convert_tz, Item_date_add_interval, Item_date_typecast, Item_func_str_to_date, and Item_func_last_day.

00362 {
00363   char buff[40];
00364   String tmp(buff,sizeof(buff), &my_charset_bin),*res;
00365   if (!(res=val_str(&tmp)) ||
00366       str_to_datetime_with_warn(res->ptr(), res->length(),
00367                                 ltime, fuzzydate) <= MYSQL_TIMESTAMP_ERROR)
00368   {
00369     bzero((char*) ltime,sizeof(*ltime));
00370     return 1;
00371   }
00372   return 0;
00373 }

virtual bool Item::get_date_result TIME ltime,
uint  fuzzydate
[inline, virtual]
 

Reimplemented in Item_field.

00272   { return get_date(ltime,fuzzydate); }

bool Item::get_time TIME ltime  )  [virtual]
 

Reimplemented in Item_field, Item_param, and Item_time_typecast.

00381 {
00382   char buff[40];
00383   String tmp(buff,sizeof(buff),&my_charset_bin),*res;
00384   if (!(res=val_str(&tmp)) ||
00385       str_to_time_with_warn(res->ptr(), res->length(), ltime))
00386   {
00387     bzero((char*) ltime,sizeof(*ltime));
00388     return 1;
00389   }
00390   return 0;
00391 }

virtual Field* Item::get_tmp_table_field  )  [inline, virtual]
 

Reimplemented in Item_field, Item_result_field, and Item_ref.

00223 { return 0; }

virtual Item* Item::get_tmp_table_item THD thd  )  [inline, virtual]
 

Reimplemented in Item_field, Item_func, Item_subselect, and Item_sum.

00302 { return copy_or_same(thd); }

void Item::init_make_field Send_field tmp_field,
enum enum_field_types  type
 

02212 {
02213   char *empty_name= (char*) "";
02214   tmp_field->db_name=           empty_name;
02215   tmp_field->org_table_name=    empty_name;
02216   tmp_field->org_col_name=      empty_name;
02217   tmp_field->table_name=        empty_name;
02218   tmp_field->col_name=          name;
02219   tmp_field->charsetnr=         collation.collation->number;
02220   tmp_field->flags=             (maybe_null ? 0 : NOT_NULL_FLAG) | 
02221                                 (my_binary_compare(collation.collation) ?
02222                                  BINARY_FLAG : 0);
02223   tmp_field->type=field_type;
02224   tmp_field->length=max_length;
02225   tmp_field->decimals=decimals;
02226   if (unsigned_flag)
02227     tmp_field->flags |= UNSIGNED_FLAG;
02228 }

virtual bool Item::is_bool_func  )  [inline, virtual]
 

Reimplemented in Item_bool_func, Item_bool_func2, and Item_func_in.

00293 { return 0; }

virtual bool Item::is_null  )  [inline, virtual]
 

Reimplemented in Item_splocal, Item_field, Item_null, Item_param, Item_ref, Item_copy_string, Item_in_optimizer, Item_bool_func2, Item_func_nullif, Item_func, Item_num_func, Item_num_op, Item_row, Item_subselect, Item_sum, Item_avg_field, and Item_variance_field.

00281 { return 0; }

virtual bool Item::is_result_field  )  [inline, virtual]
 

Reimplemented in Item_result_field, and Item_ref.

00292 { return 0; }

void Item::make_field Send_field field  )  [virtual]
 

Reimplemented in Item_splocal, Item_field, Item_empty_string, Item_ref, Item_copy_string, Item_cache_row, Item_row, Item_sum, and Item_proc.

02231 {
02232   init_make_field(tmp_field, field_type());
02233 }

virtual Item* Item::neg_transformer THD thd  )  [inline, virtual]
 

Reimplemented in Item_bool_rowready_func2, Item_func_not, Item_func_equal, Item_func_isnull, Item_func_isnotnull, Item_cond_and, and Item_cond_or.

00341 { return NULL; }

virtual Item* Item::new_item  )  [inline, virtual]
 

Reimplemented in Item_null, Item_param, Item_int, Item_uint, Item_real, and Item_string.

00249 { return 0; }

virtual void Item::no_rows_in_result  )  [inline, virtual]
 

Reimplemented in Item_sum, Item_sum_sum, Item_sum_sum_distinct, Item_sum_count, Item_sum_count_distinct, Item_sum_avg, Item_sum_variance, and Item_func_group_concat.

00298 {}

virtual table_map Item::not_null_tables  )  const [inline, virtual]
 

Reimplemented in Item_func_ifnull, Item_func_if, Item_func_nullif, Item_func_coalesce, Item_func_case, Item_func_isnull, Item_func_isnotnull, Item_cond_or, Item_func, Item_func_min_max, and Item_func_match.

00242 { return used_tables(); }

virtual bool Item::null_inside  )  [inline, virtual]
 

Reimplemented in Item_cache_row, Item_row, and Item_singlerow_subselect.

00334 { return 0; }

void Item::operator delete void *  ptr,
size_t  size,
MEM_ROOT mem_root
[inline, static]
 

00125   { TRASH(ptr, size); }

void Item::operator delete void *  ptr,
size_t  size
[inline, static]
 

00123 { TRASH(ptr, size); }

void* Item::operator new size_t  size,
MEM_ROOT mem_root
[inline, static]
 

00122   { return (void*) alloc_root(mem_root, (uint) size); }

void* Item::operator new size_t  size  )  [inline, static]
 

00120 {return (void*) sql_alloc((uint) size); }

void Item::operator= Item  )  [private]
 

virtual void Item::print String str_arg  )  [inline, virtual]
 

Reimplemented in Item_splocal, Item_ident, Item_null, Item_param, Item_int, Item_static_int_func, Item_uint, Item_real, Item_static_real_func, Item_string, Item_static_string_func, Item_ref, Item_ref_null_helper, Item_null_helper, Item_default_value, Item_insert_value, Item_trigger_field, Item_cache, Item_bool_func2, Item_func_not_all, Item_func_between, Item_func_nullif, Item_func_case, Item_func_in, Item_func_isnotnull, Item_func_regex, Item_cond, Item_equal, Item_func, Item_num_op, Item_func_signed, Item_func_unsigned, Item_func_locate, Item_func_bit, Item_func_bit_neg, Item_func_benchmark, Item_func_set_user_var, Item_func_get_user_var, Item_func_match, Item_row, Item_func_make_set, Item_func_format, Item_func_binary, Item_func_conv_charset, Item_func_set_collation, Item_subselect, Item_maxmin_subselect, Item_exists_subselect, Item_in_subselect, Item_allany_subselect, Item_sum, Item_sum_count_distinct,