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, Item_func_group_concat, Item_date_add_interval, Item_extract, Item_typecast, Item_char_typecast, Item_func_add_time, Item_func_timestamp_diff, Item_func_get_format, Item_func_unique_users, and Item_sum_unique_users.

00264 { str_arg->append(full_name()); }

void Item::print_item_w_name String  ) 
 

00100 {
00101   print(str);
00102   if (name)
00103   {
00104     THD *thd= current_thd;
00105     str->append(" AS ", 4);
00106     append_identifier(thd, str, name, strlen(name));
00107   }
00108 }

void Item::quick_fix_field  )  [inline]
 

00181 { fixed= 1; }

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

Reimplemented in Item_ref.

00301 { return this; }

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

Reimplemented in Item_ident.

00317 { return 0; }

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

00318 { fixed= 0; return 0; }

void Item::rename char *  new_name  ) 
 

00150 {
00151   /*
00152     we can compare pointers to names here, bacause if name was not changed,
00153     pointer will be same
00154   */
00155   if (!orig_name && new_name != name)
00156     orig_name= name;
00157   name= new_name;
00158 }

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

Reimplemented in Item_field.

00323 { return 0; }

virtual Item_result Item::result_type  )  const [inline, virtual]
 

Reimplemented in Item_splocal, Item_field, Item_null, Item_param, Item_int, Item_string, Item_varbinary, Item_ref, Item_copy_string, Item_cache_int, Item_cache_real, Item_cache_str, Item_cache_row, Item_type_holder, Item_func_ifnull, Item_func_if, Item_func_nullif, Item_func_coalesce, Item_func_case, Item_real_func, Item_num_func, Item_num_op, Item_int_func, Item_func_abs, Item_func_min_max, Item_func_udf_str, Item_func_set_user_var, Item_func_get_user_var, Item_func_sp, Item_row, Item_str_func, Item_singlerow_subselect, Item_exists_subselect, Item_sum_int, Item_sum_hybrid, Item_sum_udf_str, Item_func_group_concat, Item_func_month, Item_func_monthname, Item_func_weekday, Item_func_dayname, Item_date, Item_func_curtime, Item_func_now, Item_proc_real, Item_proc_int, and Item_proc_string.

00191 { return REAL_RESULT; }

Item * Item::safe_charset_converter CHARSET_INFO tocs  )  [virtual]
 

Reimplemented in Item_field, Item_null, and Item_string.

00310 {
00311   /*
00312     Don't allow automatic conversion to non-Unicode charsets,
00313     as it potentially loses data.
00314   */
00315   if (!(tocs->state & MY_CS_UNICODE))
00316     return NULL; // safe conversion is not possible
00317   return new Item_func_conv_charset(this, tocs);
00318 }

int Item::save_in_field Field field,
bool  no_conversions
[virtual]
 

Reimplemented in Item_splocal, Item_field, Item_null, Item_param, Item_int, Item_uint, Item_real, Item_string, Item_varbinary, Item_ref, Item_int_with_ref, Item_copy_string, Item_default_value, Item_insert_value, Item_date, and Item_func_now.

02415 {
02416   int error;
02417   if (result_type() == STRING_RESULT ||
02418       result_type() == REAL_RESULT &&
02419       field->result_type() == STRING_RESULT)
02420   {
02421     String *result;
02422     CHARSET_INFO *cs= collation.collation;
02423     char buff[MAX_FIELD_WIDTH];         // Alloc buffer for small columns
02424     str_value.set_quick(buff, sizeof(buff), cs);
02425     result=val_str(&str_value);
02426     if (null_value)
02427     {
02428       str_value.set_quick(0, 0, cs);
02429       return set_field_to_null_with_conversions(field, no_conversions);
02430     }
02431     field->set_notnull();
02432     error=field->store(result->ptr(),result->length(),cs);
02433     str_value.set_quick(0, 0, cs);
02434   }
02435   else if (result_type() == REAL_RESULT)
02436   {
02437     double nr= val_real();
02438     if (null_value)
02439       return set_field_to_null(field);
02440     field->set_notnull();
02441     error=field->store(nr);
02442   }
02443   else
02444   {
02445     longlong nr=val_int();
02446     if (null_value)
02447       return set_field_to_null_with_conversions(field, no_conversions);
02448     field->set_notnull();
02449     error=field->store(nr);
02450   }
02451   return error;
02452 }

int Item::save_in_field_no_warnings Field field,
bool  no_conversions
 

00400 {
00401   int res;
00402   THD *thd= field->table->in_use;
00403   enum_check_fields tmp= thd->count_cuted_fields;
00404   thd->count_cuted_fields= CHECK_FIELD_IGNORE;
00405   res= save_in_field(field, no_conversions);
00406   thd->count_cuted_fields= tmp;
00407   return res;
00408 }

virtual void Item::save_in_result_field bool  no_conversions  )  [inline, virtual]
 

Reimplemented in Item_result_field, and Item_ref.

00294 {}

virtual void Item::save_org_in_field Field field  )  [inline, virtual]
 

Reimplemented in Item_field, and Item_ref.

00186   { (void) save_in_field(field, 1); }

virtual int Item::save_safe_in_field Field field  )  [inline, virtual]
 

Reimplemented in Item_null.

00188   { return save_in_field(field, 1); }

bool Item::send Protocol protocol,
String str
[virtual]
 

Reimplemented in Item_splocal, Item_field, Item_null, and Item_ref.

02620 {
02621   bool result;
02622   enum_field_types type;
02623   LINT_INIT(result);                     // Will be set if null_value == 0
02624 
02625   switch ((type=field_type())) {
02626   default:
02627   case MYSQL_TYPE_NULL:
02628   case MYSQL_TYPE_DECIMAL:
02629   case MYSQL_TYPE_ENUM:
02630   case MYSQL_TYPE_SET:
02631   case MYSQL_TYPE_TINY_BLOB:
02632   case MYSQL_TYPE_MEDIUM_BLOB:
02633   case MYSQL_TYPE_LONG_BLOB:
02634   case MYSQL_TYPE_BLOB:
02635   case MYSQL_TYPE_GEOMETRY:
02636   case MYSQL_TYPE_STRING:
02637   case MYSQL_TYPE_VAR_STRING:
02638   {
02639     String *res;
02640     if ((res=val_str(buffer)))
02641       result= protocol->store(res->ptr(),res->length(),res->charset());
02642     break;
02643   }
02644   case MYSQL_TYPE_TINY:
02645   {
02646     longlong nr;
02647     nr= val_int();
02648     if (!null_value)
02649       result= protocol->store_tiny(nr);
02650     break;
02651   }
02652   case MYSQL_TYPE_SHORT:
02653   {
02654     longlong nr;
02655     nr= val_int();
02656     if (!null_value)
02657       result= protocol->store_short(nr);
02658     break;
02659   }
02660   case MYSQL_TYPE_INT24:
02661   case MYSQL_TYPE_LONG:
02662   {
02663     longlong nr;
02664     nr= val_int();
02665     if (!null_value)
02666       result= protocol->store_long(nr);
02667     break;
02668   }
02669   case MYSQL_TYPE_LONGLONG:
02670   {
02671     longlong nr;
02672     nr= val_int();
02673     if (!null_value)
02674       result= protocol->store_longlong(nr, unsigned_flag);
02675     break;
02676   }
02677   case MYSQL_TYPE_FLOAT:
02678   {
02679     float nr;
02680     nr= (float) val_real();
02681     if (!null_value)
02682       result= protocol->store(nr, decimals, buffer);
02683     break;
02684   }
02685   case MYSQL_TYPE_DOUBLE:
02686   {
02687     double nr= val_real();
02688     if (!null_value)
02689       result= protocol->store(nr, decimals, buffer);
02690     break;
02691   }
02692   case MYSQL_TYPE_DATETIME:
02693   case MYSQL_TYPE_DATE:
02694   case MYSQL_TYPE_TIMESTAMP:
02695   {
02696     TIME tm;
02697     get_date(&tm, TIME_FUZZY_DATE);
02698     if (!null_value)
02699     {
02700       if (type == MYSQL_TYPE_DATE)
02701         return protocol->store_date(&tm);
02702       else
02703         result= protocol->store(&tm);
02704     }
02705     break;
02706   }
02707   case MYSQL_TYPE_TIME:
02708   {
02709     TIME tm;
02710     get_time(&tm);
02711     if (!null_value)
02712       result= protocol->store_time(&tm);
02713     break;
02714   }
02715   }
02716   if (null_value)
02717     result= protocol->store_null();
02718   return result;
02719 }

void Item::set_name const char *  str,
uint  length,
CHARSET_INFO cs
 

00264 {
00265   if (!length)
00266   {
00267     /* Empty string, used by AS or internal function like last_insert_id() */
00268     name= (char*) str;
00269     name_length= 0;
00270     return;
00271   }
00272   if (cs->ctype)
00273   {
00274     /*
00275       This will probably need a better implementation in the future:
00276       a function in CHARSET_INFO structure.
00277     */
00278     while (length && !my_isgraph(cs,*str))
00279     {                                           // Fix problem with yacc
00280       length--;
00281       str++;
00282     }
00283   }
00284   if (!my_charset_same(cs, system_charset_info))
00285   {
00286     uint32 res_length;
00287     name= sql_strmake_with_convert(str, name_length= length, cs,
00288                                    MAX_ALIAS_NAME, system_charset_info,
00289                                    &res_length);
00290   }
00291   else
00292     name= sql_strmake(str, (name_length= min(length,MAX_ALIAS_NAME)));
00293 }

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

Reimplemented in Item_field.

00322 { return this; }

virtual void Item::set_result_field Field field  )  [inline, virtual]
 

Reimplemented in Item_result_field, and Item_ref.

00291 {}

virtual void Item::split_sum_func THD thd,
Item **  ref_pointer_array,
List< Item > &  fields
[inline, virtual]
 

Reimplemented in Item_cond, Item_func, Item_row, and Item_func_make_set.

00268                                                   {}

virtual String* Item::str_result String tmp  )  [inline, virtual]
 

Reimplemented in Item_field, and Item_ref.

00228 { return val_str(tmp); }

virtual Item* Item::this_const_item  )  const [inline, virtual]
 

Reimplemented in Item_splocal.

00326 { return const_cast<Item*>(this); } /* For SPs mostly. */

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

Reimplemented in Item_splocal.

00325 { return this; } /* For SPs mostly. */

virtual Field* Item::tmp_table_field TABLE t_arg  )  [inline, virtual]
 

Reimplemented in Item_field, Item_result_field, Item_func_ifnull, Item_func, Item_date, Item_date_func, Item_func_curtime, Item_func_sec_to_time, Item_date_typecast, Item_time_typecast, Item_datetime_typecast, Item_func_makedate, Item_func_add_time, Item_func_timediff, Item_func_maketime, and Item_func_str_to_date.

00224 { return 0; }

Field * Item::tmp_table_field_from_field_type TABLE table  ) 
 

02251 {
02252   /*
02253     The field functions defines a field to be not null if null_ptr is not 0
02254   */
02255   uchar *null_ptr= maybe_null ? (uchar*) "" : 0;
02256 
02257   switch (field_type()) {
02258   case MYSQL_TYPE_DECIMAL:
02259     return new Field_decimal((char*) 0, max_length, null_ptr, 0, Field::NONE,
02260                              name, table, decimals, 0, unsigned_flag);
02261   case MYSQL_TYPE_TINY:
02262     return new Field_tiny((char*) 0, max_length, null_ptr, 0, Field::NONE,
02263                           name, table, 0, unsigned_flag);
02264   case MYSQL_TYPE_SHORT:
02265     return new Field_short((char*) 0, max_length, null_ptr, 0, Field::NONE,
02266                            name, table, 0, unsigned_flag);
02267   case MYSQL_TYPE_LONG:
02268     return new Field_long((char*) 0, max_length, null_ptr, 0, Field::NONE,
02269                           name, table, 0, unsigned_flag);
02270 #ifdef HAVE_LONG_LONG
02271   case MYSQL_TYPE_LONGLONG:
02272     return new Field_longlong((char*) 0, max_length, null_ptr, 0, Field::NONE,
02273                               name, table, 0, unsigned_flag);
02274 #endif
02275   case MYSQL_TYPE_FLOAT:
02276     return new Field_float((char*) 0, max_length, null_ptr, 0, Field::NONE,
02277                            name, table, decimals, 0, unsigned_flag);
02278   case MYSQL_TYPE_DOUBLE:
02279     return new Field_double((char*) 0, max_length, null_ptr, 0, Field::NONE,
02280                             name, table, decimals, 0, unsigned_flag);
02281   case MYSQL_TYPE_NULL:
02282     return new Field_null((char*) 0, max_length, Field::NONE,
02283                           name, table, &my_charset_bin);
02284   case MYSQL_TYPE_NEWDATE:
02285   case MYSQL_TYPE_INT24:
02286     return new Field_medium((char*) 0, max_length, null_ptr, 0, Field::NONE,
02287                             name, table, 0, unsigned_flag);
02288   case MYSQL_TYPE_DATE:
02289     return new Field_date(maybe_null, name, table, &my_charset_bin);
02290   case MYSQL_TYPE_TIME:
02291     return new Field_time(maybe_null, name, table, &my_charset_bin);
02292   case MYSQL_TYPE_TIMESTAMP:
02293   case MYSQL_TYPE_DATETIME:
02294     return new Field_datetime(maybe_null, name, table, &my_charset_bin);
02295   case MYSQL_TYPE_YEAR:
02296     return new Field_year((char*) 0, max_length, null_ptr, 0, Field::NONE,
02297                           name, table);
02298   default:
02299     /* This case should never be choosen */
02300     DBUG_ASSERT(0);
02301     /* If something goes awfully wrong, it's better to get a string than die */
02302   case MYSQL_TYPE_ENUM:
02303   case MYSQL_TYPE_SET:
02304   case MYSQL_TYPE_VAR_STRING:
02305     if (max_length > 255)
02306       break;                                    // If blob
02307     return new Field_varstring(max_length, maybe_null, name, table,
02308                                collation.collation);
02309   case MYSQL_TYPE_STRING:
02310     if (max_length > 255)                       // If blob
02311       break;
02312     return new Field_string(max_length, maybe_null, name, table,
02313                             collation.collation);
02314   case MYSQL_TYPE_TINY_BLOB:
02315   case MYSQL_TYPE_MEDIUM_BLOB:
02316   case MYSQL_TYPE_LONG_BLOB:
02317   case MYSQL_TYPE_BLOB:
02318   case MYSQL_TYPE_GEOMETRY:
02319     break;                                      // Blob handled outside of case
02320   }
02321 
02322   /* blob is special as it's generated for both blobs and long strings */
02323   return new Field_blob(max_length, maybe_null, name, table,
02324                         collation.collation);
02325 }

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

Reimplemented in Item_func_not_all, Item_cond, and Item_in_subselect.

00286 {}

virtual Item* Item::transform Item_transformer  transformer,
byte arg
[inline, virtual]
 

Reimplemented in Item_default_value, Item_cond, Item_equal, Item_func, Item_row, and Item_func_make_set.

00313   {
00314     return (this->*transformer)(arg);
00315   }

virtual enum Type Item::type  )  const [pure virtual]
 

Implemented in Item_splocal, Item_field, Item_null, Item_param, Item_int, Item_real, Item_string, Item_varbinary, Item_ref, Item_copy_string, Item_default_value, Item_trigger_field, Item_cache, Item_type_holder, Item_cond, Item_cond_xor, Item_func, Item_row, Item_subselect, Item_sum, Item_avg_field, Item_variance_field, Item_std_field, and Item_proc.

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

Reimplemented in Item_func_isnull, Item_is_not_null_test, Item_cond, Item_equal, Item_func, Item_func_rand, Item_func_match, Item_row, Item_func_make_set, Item_subselect, and Item_sum.

00266 {}

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

Reimplemented in Item_field, Item_param, Item_result_field, Item_ref, Item_copy_string, Item_default_value, Item_insert_value, Item_trigger_field, Item_cache, Item_cond, Item_func, Item_func_get_user_var, Item_row, Item_subselect, Item_sum, Item_sum_count, Item_sum_count_distinct, and Item_sum_hybrid.

00230 { return (table_map) 0L; }

virtual longlong Item::val_int  )  [pure virtual]
 

Implemented in Item_splocal, Item_field, Item_null, Item_param, Item_int, Item_real, Item_string, Item_varbinary, Item_ref, Item_ref_null_helper, Item_copy_string, Item_cache_int, Item_cache_real, Item_cache_str, Item_cache_row, Item_type_holder, Item_in_optimizer, Item_func_not, Item_func_trig_cond, Item_func_not_all, Item_func_eq, Item_func_equal, Item_func_ge, Item_func_gt, Item_func_le, Item_func_lt, Item_func_ne, Item_func_between, Item_func_strcmp, Item_func_interval, Item_func_ifnull, Item_func_if, Item_func_nullif, Item_func_coalesce, Item_func_case, Item_func_in, Item_func_isnull, Item_is_not_null_test, Item_func_isnotnull, Item_func_like, Item_func_regex, Item_equal, Item_cond_and, Item_cond_or, Item_cond_xor, Item_real_func, Item_num_func, Item_func_signed, Item_func_plus, Item_func_minus, Item_func_mul, Item_func_div, Item_func_int_div, Item_func_mod, Item_func_neg, Item_func_abs, Item_func_ceiling, Item_func_floor, Item_func_sign, Item_func_min_max, Item_func_length, Item_func_bit_length, Item_func_char_length, Item_func_coercibility, Item_func_locate, Item_func_field, Item_func_ascii, Item_func_ord, Item_func_find_in_set, Item_func_bit_or, Item_func_bit_and, Item_func_bit_count, Item_func_shift_left, Item_func_shift_right, Item_func_bit_neg, Item_func_last_insert_id, Item_func_benchmark, Item_func_udf_int, Item_func_udf_str, Item_func_get_lock, Item_func_release_lock, Item_master_pos_wait, Item_func_set_user_var, Item_func_get_user_var, Item_func_inet_aton, Item_func_match, Item_func_bit_xor, Item_func_is_free_lock, Item_func_is_used_lock, Item_func_row_count, Item_func_sp, Item_func_found_rows, Item_row, Item_str_func, Item_func_elt, Item_func_crc32, Item_func_uncompressed_length, Item_singlerow_subselect, Item_exists_subselect, Item_in_subselect, Item_sum_num, Item_sum_count, Item_sum_count_distinct, Item_avg_field, Item_variance_field, Item_sum_hybrid, Item_sum_bit, Item_sum_udf_int, Item_sum_udf_str, Item_func_group_concat, Item_func_period_add, Item_func_period_diff, Item_func_to_days, Item_func_dayofmonth, Item_func_month, Item_func_dayofyear, Item_func_hour, Item_func_minute, Item_func_quarter, Item_func_second, Item_func_week, Item_func_yearweek, Item_func_year, Item_func_weekday, Item_func_unix_timestamp, Item_func_time_to_sec, Item_date, Item_func_curtime, Item_func_curdate, Item_func_now, Item_func_from_unixtime, Item_func_convert_tz, Item_func_sec_to_time, Item_date_add_interval, Item_extract, Item_func_microsecond, Item_func_timestamp_diff, Item_proc_real, Item_proc_int, and Item_proc_string.

virtual longlong Item::val_int_result  )  [inline, virtual]
 

Reimplemented in Item_field, and Item_ref.

00227 { return val_int(); }

virtual double Item::val_real  )  [pure virtual]
 

Implemented in Item_splocal, Item_field, Item_null, Item_param, Item_int, Item_uint, Item_real, Item_string, Item_varbinary, Item_ref, Item_ref_null_helper, Item_copy_string, Item_cache_int, Item_cache_real, Item_cache_str, Item_cache_row, Item_type_holder, Item_func_ifnull, Item_func_if, Item_func_nullif, Item_func_coalesce, Item_func_case, Item_int_func, Item_func_signed, Item_func_plus, Item_func_minus, Item_func_mul, Item_func_div, Item_func_int_div, Item_func_mod, Item_func_neg, Item_func_abs, Item_func_exp, Item_func_ln, Item_func_log, Item_func_log2, Item_func_log10, Item_func_sqrt, Item_func_pow, Item_func_acos, Item_func_asin, Item_func_atan, Item_func_cos, Item_func_sin, Item_func_tan, Item_func_round, Item_func_rand, Item_func_units, Item_func_min_max, Item_func_udf_float, Item_func_udf_str, Item_func_set_user_var, Item_func_get_user_var, Item_func_match, Item_func_sp, Item_row, Item_str_func, Item_func_elt, Item_singlerow_subselect, Item_exists_subselect, Item_in_subselect, Item_sum_int, Item_sum_sum, Item_sum_sum_distinct, Item_avg_field, Item_sum_avg, Item_variance_field, Item_sum_variance, Item_std_field, Item_sum_std, Item_sum_hybrid, Item_sum_udf_float, Item_sum_udf_int, Item_sum_udf_str, Item_func_group_concat, Item_func_month, Item_func_weekday, Item_date, Item_func_curtime, Item_func_now, Item_func_from_unixtime, Item_func_convert_tz, Item_func_sec_to_time, Item_date_add_interval, Item_func_unique_users, Item_sum_unique_users, Item_proc_real, Item_proc_int, and Item_proc_string.

virtual double Item::val_result  )  [inline, virtual]
 

Reimplemented in Item_field, and Item_ref.

00226 { return val_real(); }

virtual String* Item::val_str String  )  [pure virtual]
 

Implemented in Item_splocal, Item_field, Item_null, Item_param, Item_int, Item_uint, Item_real, Item_string, Item_varbinary, Item_ref, Item_ref_null_helper, Item_copy_string, Item_cache_int, Item_cache_real, Item_cache_str, Item_cache_row, Item_type_holder, Item_func_ifnull, Item_func_if, Item_func_nullif, Item_func_coalesce, Item_func_case, Item_real_func, Item_num_func, Item_num_op, Item_int_func, Item_func_min_max, Item_func_udf_str, Item_func_set_user_var, Item_func_get_user_var, Item_func_sp, Item_row, Item_func_md5, Item_func_sha, Item_func_aes_encrypt, Item_func_aes_decrypt, Item_func_concat, Item_func_concat_ws, Item_func_reverse, Item_func_replace, Item_func_insert, Item_func_lcase, Item_func_ucase, Item_func_left, Item_func_right, Item_func_substr, Item_func_substr_index, Item_func_trim, Item_func_ltrim, Item_func_rtrim, Item_func_password, Item_func_old_password, Item_func_des_encrypt, Item_func_des_decrypt, Item_func_encrypt, Item_func_encode, Item_func_decode, Item_func_database, Item_func_user, Item_func_soundex, Item_func_elt, Item_func_make_set, Item_func_format, Item_func_char, Item_func_repeat, Item_func_rpad, Item_func_lpad, Item_func_conv, Item_func_hex, Item_func_unhex, Item_func_binary, Item_load_file, Item_func_export_set, Item_func_inet_ntoa, Item_func_quote, Item_func_conv_charset, Item_func_set_collation, Item_func_charset, Item_func_collation, Item_func_compress, Item_func_uncompress, Item_func_uuid, Item_singlerow_subselect, Item_exists_subselect, Item_in_subselect, Item_sum_num, Item_sum_int, Item_avg_field, Item_variance_field, Item_sum_hybrid, Item_sum_udf_str, Item_func_group_concat, Item_func_month, Item_func_monthname, Item_func_weekday, Item_func_dayname, Item_date, Item_func_curtime, Item_func_curdate, Item_func_now, Item_func_date_format, Item_func_from_unixtime, Item_func_convert_tz, Item_func_sec_to_time, Item_date_add_interval, Item_typecast, Item_char_typecast, Item_date_typecast, Item_time_typecast, Item_datetime_typecast, Item_func_makedate, Item_func_add_time, Item_func_timediff, Item_func_maketime, Item_func_get_format, Item_func_str_to_date, Item_proc_real, Item_proc_int, and Item_proc_string.

virtual bool Item::walk Item_processor  processor,
byte arg
[inline, virtual]
 

Reimplemented in Item_ref, Item_default_value, Item_insert_value, Item_cond, Item_equal, Item_func, Item_row, Item_func_make_set, and Item_sum.

00308   {
00309     return (this->*processor)(arg);
00310   }


Member Data Documentation

DTCollation Item::collation
 

uint8 Item::decimals
 

my_bool Item::fixed
 

uint8 Item::marker
 

uint32 Item::max_length
 

my_bool Item::maybe_null
 

my_string Item::name
 

Reimplemented in Item_func_units, Item_func_set_user_var, and Item_func_get_user_var.

uint Item::name_length
 

Item* Item::next
 

my_bool Item::null_value
 

my_string Item::orig_name
 

String Item::str_value
 

my_bool Item::unsigned_flag
 

my_bool Item::with_sum_func
 


The documentation for this class was generated from the following files:
Generated on Thu Feb 24 11:21:30 2005 for MySQL by  doxygen 1.3.9.1