#include <item_func.h>
Inheritance diagram for Item_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};
|
|
|
00054 { OPTIMIZE_NONE,OPTIMIZE_KEY,OPTIMIZE_OP, OPTIMIZE_NULL,
00055 OPTIMIZE_EQUAL };
|
|
|
00058 : 00059 allowed_arg_cols(1), arg_count(0) 00060 { 00061 with_sum_func= 0; 00062 } Item_func(Item *a):
|
|
|
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):
|
|
||||||||||||
|
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):
|
|
||||||||||||||||
|
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):
|
|
||||||||||||||||||||
|
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):
|
|
||||||||||||||||||||||||
|
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);
|
|
|
00227 :allowed_arg_cols(1) 00228 { 00229 set_arguments(list); 00230 }
|
|
||||||||||||
|
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 }
|
|
||||||||||||||||||||
|
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 }
|
|
||||||||||||||||||||
|
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 }
|
|
||||||||||||||||||||
|
00109 {
00110 return (agg_arg_collations(c, av, count, flags | MY_COLL_DISALLOW_NONE));
00111 }
|
|
|
00126 { return arg_count; }
|
|
|
00124 { return args; }
|
|
|
Reimplemented from Item. Reimplemented in Item_func_rand, and Item_func_get_user_var. 00123 { return const_item_cache; }
|
|
||||||||||||
|
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 }
|
|
||||||||||||||||
|
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. |
|
|
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 }
|
|
|
|
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; }
|
|
||||||||||||
|
00134 {
00135 return (null_value=args[0]->get_date(ltime, fuzzy_date));
00136 }
|
|
|
00138 {
00139 return (null_value=args[0]->get_time(ltime));
00140 }
|
|
|
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 }
|
|
|
Reimplemented in Item_bool_func2. 00120 { return 0; }
|
|
|
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; }
|
|
|
00121 { return args[0]; }
|
|
|
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 }
|
|
|
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 }
|
|
||||||||||||
|
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 }
|
|
|
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 }
|
|
|
00127 { arg_count=0; }
|
|
|
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; }
|
|
|
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 }
|
|
|
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 }
|
|
||||||||||||||||
|
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 }
|
|
|
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 }
|
|
|
00144 { return result_field; }
|
|
|