Item_func Class Reference

#include <item_func.h>

Inheritance diagram for Item_func:

Inheritance graph
[legend]
Collaboration diagram for Item_func:

Collaboration graph
[legend]
List of all members.

Public Types

enum  Functype {
  UNKNOWN_FUNC, EQ_FUNC, EQUAL_FUNC, NE_FUNC, LT_FUNC, LE_FUNC, GE_FUNC, GT_FUNC, FT_FUNC, LIKE_FUNC,
  NOTLIKE_FUNC, ISNULL_FUNC, ISNOTNULL_FUNC, COND_AND_FUNC, COND_OR_FUNC, COND_XOR_FUNC, BETWEEN, IN_FUNC, MULT_EQUAL_FUNC, INTERVAL_FUNC,
  ISNOTNULLTEST_FUNC, SP_EQUALS_FUNC, SP_DISJOINT_FUNC, SP_INTERSECTS_FUNC, SP_TOUCHES_FUNC, SP_CROSSES_FUNC, SP_WITHIN_FUNC, SP_CONTAINS_FUNC, SP_OVERLAPS_FUNC, SP_STARTPOINT,
  SP_ENDPOINT, SP_EXTERIORRING, SP_POINTN, SP_GEOMETRYN, SP_INTERIORRINGN, NOT_FUNC, NOT_ALL_FUNC, NOW_FUNC, TRIG_COND_FUNC, GUSERVAR_FUNC
}
enum  optimize_type { OPTIMIZE_NONE, OPTIMIZE_KEY, OPTIMIZE_OP, OPTIMIZE_NULL, OPTIMIZE_EQUAL }

Public Member Functions

enum Type type () const
virtual enum Functype functype () const
 Item_func (void)
 Item_func (Item *a)
 Item_func (Item *a, Item *b)
 Item_func (Item *a, Item *b, Item *c)
 Item_func (Item *a, Item *b, Item *c, Item *d)
 Item_func (Item *a, Item *b, Item *c, Item *d, Item *e)
 Item_func (List< Item > &list)
 Item_func (THD *thd, Item_func *item)
bool fix_fields (THD *, struct st_table_list *, Item **ref)
table_map used_tables () const
table_map not_null_tables () const
void update_used_tables ()
bool eq (const Item *item, bool binary_cmp) const
virtual optimize_type select_optimize () const
virtual bool have_rev_func () const
virtual Itemkey_item () const
virtual const char * func_name () const
virtual bool const_item () const
Item ** arguments () const
void set_arguments (List< Item > &list)
uint argument_count () const
void remove_arguments ()
void split_sum_func (THD *thd, Item **ref_pointer_array, List< Item > &fields)
void print (String *str)
void print_op (String *str)
void print_args (String *str, uint from)
void fix_num_length_and_dec ()
bool get_arg0_date (TIME *ltime, uint fuzzy_date)
bool get_arg0_time (TIME *ltime)
bool is_null ()
void signal_divide_by_null ()
Fieldtmp_table_field ()
Fieldtmp_table_field (TABLE *t_arg)
Itemget_tmp_table_item (THD *thd)
bool agg_arg_collations (DTCollation &c, Item **items, uint nitems, uint flags=0)
bool agg_arg_collations_for_comparison (DTCollation &c, Item **items, uint nitems, uint flags=0)
bool agg_arg_charsets (DTCollation &c, Item **items, uint nitems, uint flags=0)
bool walk (Item_processor processor, byte *arg)
Itemtransform (Item_transformer transformer, byte *arg)

Public Attributes

uint arg_count
table_map used_tables_cache
table_map not_null_tables_cache
bool const_item_cache

Protected Attributes

Item ** args
Itemtmp_arg [2]
uint allowed_arg_cols

Friends

class udf_handler

Member Enumeration Documentation

enum Item_func::Functype
 

Enumeration values:
UNKNOWN_FUNC 
EQ_FUNC 
EQUAL_FUNC 
NE_FUNC 
LT_FUNC 
LE_FUNC 
GE_FUNC 
GT_FUNC 
FT_FUNC 
LIKE_FUNC 
NOTLIKE_FUNC 
ISNULL_FUNC 
ISNOTNULL_FUNC 
COND_AND_FUNC 
COND_OR_FUNC 
COND_XOR_FUNC 
BETWEEN 
IN_FUNC 
MULT_EQUAL_FUNC 
INTERVAL_FUNC 
ISNOTNULLTEST_FUNC 
SP_EQUALS_FUNC 
SP_DISJOINT_FUNC 
SP_INTERSECTS_FUNC 
SP_TOUCHES_FUNC 
SP_CROSSES_FUNC 
SP_WITHIN_FUNC 
SP_CONTAINS_FUNC 
SP_OVERLAPS_FUNC 
SP_STARTPOINT 
SP_ENDPOINT 
SP_EXTERIORRING 
SP_POINTN 
SP_GEOMETRYN 
SP_INTERIORRINGN 
NOT_FUNC 
NOT_ALL_FUNC 
NOW_FUNC 
TRIG_COND_FUNC 
GUSERVAR_FUNC 
00040                 { UNKNOWN_FUNC,EQ_FUNC,EQUAL_FUNC,NE_FUNC,LT_FUNC,LE_FUNC,
00041                   GE_FUNC,GT_FUNC,FT_FUNC,
00042                   LIKE_FUNC,NOTLIKE_FUNC,ISNULL_FUNC,ISNOTNULL_FUNC,
00043                   COND_AND_FUNC, COND_OR_FUNC, COND_XOR_FUNC,
00044                   BETWEEN, IN_FUNC, MULT_EQUAL_FUNC,
00045                   INTERVAL_FUNC, ISNOTNULLTEST_FUNC,
00046                   SP_EQUALS_FUNC, SP_DISJOINT_FUNC,SP_INTERSECTS_FUNC,
00047                   SP_TOUCHES_FUNC,SP_CROSSES_FUNC,SP_WITHIN_FUNC,
00048                   SP_CONTAINS_FUNC,SP_OVERLAPS_FUNC,
00049                   SP_STARTPOINT,SP_ENDPOINT,SP_EXTERIORRING,
00050                   SP_POINTN,SP_GEOMETRYN,SP_INTERIORRINGN,
00051                   NOT_FUNC, NOT_ALL_FUNC,
00052                   NOW_FUNC, TRIG_COND_FUNC,
00053                   GUSERVAR_FUNC};

enum Item_func::optimize_type
 

Enumeration values:
OPTIMIZE_NONE 
OPTIMIZE_KEY 
OPTIMIZE_OP 
OPTIMIZE_NULL 
OPTIMIZE_EQUAL 
00054                      { OPTIMIZE_NONE,OPTIMIZE_KEY,OPTIMIZE_OP, OPTIMIZE_NULL,
00055                        OPTIMIZE_EQUAL };


Constructor & Destructor Documentation

Item_func::Item_func void   )  [inline]
 

00058                  :
00059     allowed_arg_cols(1), arg_count(0)
00060   {
00061     with_sum_func= 0;
00062   }
  Item_func(Item *a):

Item_func::Item_func Item a  )  [inline]
 

00063                     :
00064     allowed_arg_cols(1), arg_count(1)
00065   {
00066     args= tmp_arg;
00067     args[0]= a;
00068     with_sum_func= a->with_sum_func;
00069   }
  Item_func(Item *a,Item *b):

Item_func::Item_func Item a,
Item b
[inline]
 

00070                             :
00071     allowed_arg_cols(1), arg_count(2)
00072   {
00073     args= tmp_arg;
00074     args[0]= a; args[1]= b;
00075     with_sum_func= a->with_sum_func || b->with_sum_func;
00076   }
  Item_func(Item *a,Item *b,Item *c):

Item_func::Item_func Item a,
Item b,
Item c
[inline]
 

00077                                     :
00078     allowed_arg_cols(1)
00079   {
00080     arg_count= 0;
00081     if ((args= (Item**) sql_alloc(sizeof(Item*)*3)))
00082     {
00083       arg_count= 3;
00084       args[0]= a; args[1]= b; args[2]= c;
00085       with_sum_func= a->with_sum_func || b->with_sum_func || c->with_sum_func;
00086     }
00087   }
  Item_func(Item *a,Item *b,Item *c,Item *d):

Item_func::Item_func Item a,
Item b,
Item c,
Item d
[inline]
 

00088                                             :
00089     allowed_arg_cols(1)
00090   {
00091     arg_count= 0;
00092     if ((args= (Item**) sql_alloc(sizeof(Item*)*4)))
00093     {
00094       arg_count= 4;
00095       args[0]= a; args[1]= b; args[2]= c; args[3]= d;
00096       with_sum_func= a->with_sum_func || b->with_sum_func ||
00097         c->with_sum_func || d->with_sum_func;
00098     }
00099   }
  Item_func(Item *a,Item *b,Item *c,Item *d,Item* e):

Item_func::Item_func Item a,
Item b,
Item c,
Item d,
Item e
[inline]
 

00100                                                     :
00101     allowed_arg_cols(1)
00102   {
00103     arg_count= 5;
00104     if ((args= (Item**) sql_alloc(sizeof(Item*)*5)))
00105     {
00106       args[0]= a; args[1]= b; args[2]= c; args[3]= d; args[4]= e;
00107       with_sum_func= a->with_sum_func || b->with_sum_func ||
00108         c->with_sum_func || d->with_sum_func || e->with_sum_func ;
00109     }
00110   }
  Item_func(List<Item> &list);

Item_func::Item_func List< Item > &  list  ) 
 

00227   :allowed_arg_cols(1)
00228 {
00229   set_arguments(list);
00230 }

Item_func::Item_func THD thd,
Item_func item
 

00233   :Item_result_field(thd, item),
00234    allowed_arg_cols(item->allowed_arg_cols),
00235    arg_count(item->arg_count),
00236    used_tables_cache(item->used_tables_cache),
00237    not_null_tables_cache(item->not_null_tables_cache),
00238    const_item_cache(item->const_item_cache)
00239 {
00240   if (arg_count)
00241   {
00242     if (arg_count <=2)
00243       args= tmp_arg;
00244     else
00245     {
00246       if (!(args=(Item**) thd->alloc(sizeof(Item*)*arg_count)))
00247         return;
00248     }
00249     memcpy((char*) args, (char*) item->args, sizeof(Item*)*arg_count);
00250   }
00251 }


Member Function Documentation

bool Item_func::agg_arg_charsets DTCollation c,
Item **  items,
uint  nitems,
uint  flags = 0
 

00147 {
00148   Item **arg, **last, *safe_args[2];
00149   if (agg_arg_collations(coll, args, nargs, flags))
00150     return TRUE;
00151 
00152   /*
00153     For better error reporting: save the first and the second argument.
00154     We need this only if the the number of args is 3 or 2:
00155     - for a longer argument list, "Illegal mix of collations"
00156       doesn't display each argument's characteristics.
00157     - if nargs is 1, then this error cannot happen.
00158   */
00159   if (nargs >=2 && nargs <= 3)
00160   {
00161     safe_args[0]= args[0];
00162     safe_args[1]= args[1];
00163   }
00164 
00165   THD *thd= current_thd;
00166   Item_arena *arena, backup;
00167   bool res= FALSE;
00168   /*
00169     In case we're in statement prepare, create conversion item
00170     in its memory: it will be reused on each execute.
00171   */
00172   arena= thd->change_arena_if_needed(&backup);
00173 
00174   for (arg= args, last= args + nargs; arg < last; arg++)
00175   {
00176     Item* conv;
00177     uint32 dummy_offset;
00178     if (!String::needs_conversion(0, coll.collation,
00179                                   (*arg)->collation.collation,
00180                                   &dummy_offset))
00181       continue;
00182 
00183     if (!(conv= (*arg)->safe_charset_converter(coll.collation)))
00184     {
00185       if (nargs >=2 && nargs <= 3)
00186       {
00187         /* restore the original arguments for better error message */
00188         args[0]= safe_args[0];
00189         args[1]= safe_args[1];
00190       }
00191       my_coll_agg_error(args, nargs, func_name());
00192       res= TRUE;
00193       break; // we cannot return here, we need to restore "arena".
00194     }
00195     if ((*arg)->type() == FIELD_ITEM)
00196       ((Item_field *)(*arg))->no_const_subst= 1;
00197     conv->fix_fields(thd, 0, &conv);
00198     *arg= conv;
00199   }
00200   if (arena)
00201     thd->restore_backup_item_arena(arena, &backup);
00202   return res;
00203 }

bool Item_func::agg_arg_collations DTCollation c,
Item **  items,
uint  nitems,
uint  flags = 0
 

00083 {
00084   uint i;
00085   c.nagg= 0;
00086   c.strong= 0;
00087   c.set(av[0]->collation);
00088   for (i= 1; i < count; i++)
00089   {
00090     if (c.aggregate(av[i]->collation, flags))
00091     {
00092       my_coll_agg_error(av, count, func_name());
00093       return TRUE;
00094     }
00095   }
00096   if ((flags & MY_COLL_DISALLOW_NONE) &&
00097       c.derivation == DERIVATION_NONE)
00098   {
00099     my_coll_agg_error(av, count, func_name());
00100     return TRUE;
00101   }
00102   return FALSE;
00103 }

bool Item_func::agg_arg_collations_for_comparison DTCollation c,
Item **  items,
uint  nitems,
uint  flags = 0
 

00109 {
00110   return (agg_arg_collations(c, av, count, flags | MY_COLL_DISALLOW_NONE));
00111 }

uint Item_func::argument_count  )  const [inline]
 

00126 { return arg_count; }

Item** Item_func::arguments  )  const [inline]
 

00124 { return args; }

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

Reimplemented from Item.

Reimplemented in Item_func_rand, and Item_func_get_user_var.

00123 { return const_item_cache; }

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

Reimplemented from Item.

Reimplemented in Item_func_get_user_var, Item_func_match, Item_func_set_collation, Item_extract, and Item_char_typecast.

00468 {
00469   /* Assume we don't have rtti */
00470   if (this == item)
00471     return 1;
00472   if (item->type() != FUNC_ITEM)
00473     return 0;
00474   Item_func *item_func=(Item_func*) item;
00475   if (arg_count != item_func->arg_count ||
00476       func_name() != item_func->func_name())
00477     return 0;
00478   for (uint i=0; i < arg_count ; i++)
00479     if (!args[i]->eq(item_func->args[i], binary_cmp))
00480       return 0;
00481   return 1;
00482 }

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

Reimplemented from Item.

Reimplemented in Item_in_optimizer, Item_func_if, Item_func_like, Item_cond, Item_func_rand, Item_func_set_user_var, Item_func_match, and Item_func_convert_tz.

void Item_func::fix_num_length_and_dec  ) 
 

00553 {
00554   decimals=0;
00555   for (uint i=0 ; i < arg_count ; i++)
00556     set_if_bigger(decimals,args[i]->decimals);
00557   max_length=float_length(decimals);
00558 }

virtual const char* Item_func::func_name  )  const [inline, virtual]
 

Reimplemented in 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_func_signed, Item_func_unsigned, 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_ceiling, Item_func_floor, Item_func_round, Item_func_rand, Item_func_sign, Item_func_units, Item_func_min, Item_func_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_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_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_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_crc32, Item_func_uncompressed_length, Item_func_compress, Item_func_uncompress, Item_func_uuid, Item_func_period_add, Item_func_period_diff, Item_func_to_days, Item_func_dayofmonth, Item_func_month, Item_func_monthname, 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_dayname, Item_func_unix_timestamp, Item_func_time_to_sec, Item_date, Item_func_curtime_local, Item_func_curtime_utc, Item_func_curdate_local, Item_func_curdate_utc, Item_func_now_local, Item_func_now_utc, Item_func_from_days, Item_func_date_format, Item_func_from_unixtime, Item_func_convert_tz, Item_func_sec_to_time, Item_date_add_interval, Item_extract, Item_char_typecast, Item_date_typecast, Item_time_typecast, Item_datetime_typecast, Item_func_makedate, Item_func_timediff, Item_func_maketime, Item_func_microsecond, Item_func_timestamp_diff, Item_func_get_format, Item_func_str_to_date, and Item_func_last_day.

00122 { return "?"; }

virtual enum Functype Item_func::functype  )  const [inline, virtual]
 

Reimplemented in 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_in, Item_func_isnull, Item_is_not_null_test, Item_func_isnotnull, Item_func_like, Item_equal, Item_cond_and, Item_cond_or, Item_cond_xor, Item_func_get_user_var, Item_func_match, and Item_func_now_local.

00057 { return UNKNOWN_FUNC; }

bool Item_func::get_arg0_date TIME ltime,
uint  fuzzy_date
[inline]
 

00134   {
00135     return (null_value=args[0]->get_date(ltime, fuzzy_date));
00136   }

bool Item_func::get_arg0_time TIME ltime  )  [inline]
 

00138   {
00139     return (null_value=args[0]->get_time(ltime));
00140   }

Item * Item_func::get_tmp_table_item THD thd  )  [virtual]
 

Reimplemented from Item.

00571 {
00572   if (!with_sum_func && !const_item())
00573     return new Item_field(result_field);
00574   return copy_or_same(thd);
00575 }

virtual bool Item_func::have_rev_func  )  const [inline, virtual]
 

Reimplemented in Item_bool_func2.

00120 { return 0; }

bool Item_func::is_null  )  [inline, virtual]
 

Reimplemented from Item.

Reimplemented in Item_in_optimizer, Item_bool_func2, Item_func_nullif, Item_num_func, and Item_num_op.

00141 { (void) val_int(); return null_value; }

virtual Item* Item_func::key_item  )  const [inline, virtual]
 

00121 { return args[0]; }

table_map Item_func::not_null_tables  )  const [virtual]
 

Reimplemented from Item.

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_min_max, and Item_func_match.

00427 {
00428   return not_null_tables_cache;
00429 }

void Item_func::print String str  )  [virtual]
 

Reimplemented from Item.

Reimplemented in 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_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_func_make_set, Item_func_format, Item_func_binary, Item_func_conv_charset, Item_func_set_collation, Item_date_add_interval, Item_extract, Item_typecast, Item_char_typecast, Item_func_add_time, Item_func_timestamp_diff, Item_func_get_format, and Item_func_unique_users.

00433 {
00434   str->append(func_name());
00435   str->append('(');
00436   print_args(str, 0);
00437   str->append(')');
00438 }

void Item_func::print_args String str,
uint  from
 

00442 {
00443   for (uint i=from ; i < arg_count ; i++)
00444   {
00445     if (i != from)
00446       str->append(',');
00447     args[i]->print(str);
00448   }
00449 }

void Item_func::print_op String str  ) 
 

00453 {
00454   str->append('(');
00455   for (uint i=0 ; i < arg_count-1 ; i++)
00456   {
00457     args[i]->print(str);
00458     str->append(' ');
00459     str->append(func_name());
00460     str->append(' ');
00461   }
00462   args[arg_count-1]->print(str);
00463   str->append(')');
00464 }

void Item_func::remove_arguments  )  [inline]
 

00127 { arg_count=0; }

virtual optimize_type Item_func::select_optimize  )  const [inline, virtual]
 

Reimplemented in Item_bool_func2, Item_func_ne, Item_func_between, Item_func_strcmp, Item_func_in, Item_func_isnull, Item_func_isnotnull, Item_func_like, and Item_equal.

00119 { return OPTIMIZE_NONE; }

void Item_func::set_arguments List< Item > &  list  ) 
 

00208 {
00209   allowed_arg_cols= 1;
00210   arg_count=list.elements;
00211   if ((args=(Item**) sql_alloc(sizeof(Item*)*arg_count)))
00212   {
00213     uint i=0;
00214     List_iterator_fast<Item> li(list);
00215     Item *item;
00216 
00217     while ((item=li++))
00218     {
00219       args[i++]= item;
00220       with_sum_func|=item->with_sum_func;
00221     }
00222   }
00223   list.empty();                                 // Fields are used
00224 }

void Item_func::signal_divide_by_null  ) 
 

00561 {
00562   THD *thd= current_thd;
00563   if (thd->variables.sql_mode & MODE_ERROR_FOR_DIVISION_BY_ZERO)
00564     push_warning(thd, MYSQL_ERROR::WARN_LEVEL_ERROR, ER_DIVISION_BY_ZERO,
00565                  ER(ER_DIVISION_BY_ZERO));
00566   null_value= 1;
00567 }

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

Reimplemented from Item.

Reimplemented in Item_cond, and Item_func_make_set.

00387 {
00388   Item **arg, **arg_end;
00389   for (arg= args, arg_end= args+arg_count; arg != arg_end ; arg++)
00390   {
00391     Item *item=* arg;
00392     if (item->with_sum_func && item->type() != SUM_FUNC_ITEM)
00393       item->split_sum_func(thd, ref_pointer_array, fields);
00394     else if (item->used_tables() || item->type() == SUM_FUNC_ITEM)
00395     {
00396       uint el= fields.elements;
00397       Item *new_item= new Item_ref(ref_pointer_array + el, 0, item->name);
00398       new_item->collation.set(item->collation);
00399       fields.push_front(item);
00400       ref_pointer_array[el]= item;
00401       thd->change_item_tree(arg, new_item);
00402     }
00403   }
00404 }

Field * Item_func::tmp_table_field TABLE t_arg  )  [virtual]
 

Reimplemented from Item_result_field.

Reimplemented in Item_func_ifnull, 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.

00485 {
00486   Field *res;
00487   LINT_INIT(res);
00488 
00489   switch (result_type()) {
00490   case INT_RESULT:
00491     if (max_length > 11)
00492       res= new Field_longlong(max_length, maybe_null, name, t_arg,
00493                               unsigned_flag);
00494     else
00495       res= new Field_long(max_length, maybe_null, name, t_arg,
00496                           unsigned_flag);
00497     break;
00498   case REAL_RESULT:
00499     res= new Field_double(max_length, maybe_null, name, t_arg, decimals);
00500     break;
00501   case STRING_RESULT:
00502     if (max_length > 255)
00503       res= new Field_blob(max_length, maybe_null, name, t_arg, collation.collation);
00504     else
00505       res= new Field_string(max_length, maybe_null, name, t_arg, collation.collation);
00506     break;
00507   case ROW_RESULT:
00508   default:
00509     // This case should never be choosen
00510     DBUG_ASSERT(0);
00511     break;
00512   }
00513   return res;
00514 }

Field* Item_func::tmp_table_field  )  [inline]
 

00144 { return result_field; }