1 #ifndef ITEM_FUNC_INCLUDED
2 #define ITEM_FUNC_INCLUDED
32 Item **args, *tmp_arg[2];
39 uint allowed_arg_cols;
47 enum Functype { UNKNOWN_FUNC,EQ_FUNC,EQUAL_FUNC,NE_FUNC,LT_FUNC,LE_FUNC,
48 GE_FUNC,GT_FUNC,FT_FUNC,
49 LIKE_FUNC,ISNULL_FUNC,ISNOTNULL_FUNC,
50 COND_AND_FUNC, COND_OR_FUNC, XOR_FUNC,
51 BETWEEN, IN_FUNC, MULT_EQUAL_FUNC,
52 INTERVAL_FUNC, ISNOTNULLTEST_FUNC,
53 SP_EQUALS_FUNC, SP_DISJOINT_FUNC,SP_INTERSECTS_FUNC,
54 SP_TOUCHES_FUNC,SP_CROSSES_FUNC,SP_WITHIN_FUNC,
55 SP_CONTAINS_FUNC,SP_OVERLAPS_FUNC,
56 SP_STARTPOINT,SP_ENDPOINT,SP_EXTERIORRING,
57 SP_POINTN,SP_GEOMETRYN,SP_INTERIORRINGN,
58 NOT_FUNC, NOT_ALL_FUNC,
59 NOW_FUNC, TRIG_COND_FUNC,
60 SUSERVAR_FUNC, GUSERVAR_FUNC, COLLATE_FUNC,
61 EXTRACT_FUNC, CHAR_TYPECAST_FUNC, FUNC_SP, UDF_FUNC,
62 NEG_FUNC, GSYSVAR_FUNC };
63 enum optimize_type { OPTIMIZE_NONE,OPTIMIZE_KEY,OPTIMIZE_OP, OPTIMIZE_NULL,
65 enum Type type()
const {
return FUNC_ITEM; }
66 virtual enum Functype functype()
const {
return UNKNOWN_FUNC; }
68 allowed_arg_cols(1), arg_count(0)
73 allowed_arg_cols(1), arg_count(1)
77 with_sum_func= a->with_sum_func;
80 allowed_arg_cols(1), arg_count(2)
83 args[0]= a; args[1]= b;
84 with_sum_func= a->with_sum_func || b->with_sum_func;
90 if ((args= (
Item**) sql_alloc(
sizeof(
Item*)*3)))
93 args[0]= a; args[1]= b; args[2]= c;
94 with_sum_func= a->with_sum_func || b->with_sum_func || c->with_sum_func;
101 if ((args= (
Item**) sql_alloc(
sizeof(
Item*)*4)))
104 args[0]= a; args[1]= b; args[2]= c; args[3]= d;
105 with_sum_func= a->with_sum_func || b->with_sum_func ||
106 c->with_sum_func || d->with_sum_func;
113 if ((args= (
Item**) sql_alloc(
sizeof(
Item*)*5)))
115 args[0]= a; args[1]= b; args[2]= c; args[3]= d; args[4]= e;
116 with_sum_func= a->with_sum_func || b->with_sum_func ||
117 c->with_sum_func || d->with_sum_func || e->with_sum_func ;
123 bool fix_fields(THD *,
Item **ref);
125 st_select_lex *removed_select);
126 table_map used_tables()
const;
133 table_map not_null_tables()
const;
134 void update_used_tables();
137 bool eq(
const Item *item,
bool binary_cmp)
const;
138 virtual optimize_type select_optimize()
const {
return OPTIMIZE_NONE; }
139 virtual bool have_rev_func()
const {
return 0; }
140 virtual Item *key_item()
const {
return args[0]; }
142 inline Item **arguments()
const
143 { DBUG_ASSERT(argument_count() > 0);
return args; }
145 inline uint argument_count()
const {
return arg_count; }
146 inline void remove_arguments() { arg_count=0; }
149 virtual void print(
String *str, enum_query_type query_type);
150 void print_op(
String *str, enum_query_type query_type);
151 void print_args(
String *str, uint from, enum_query_type query_type);
152 virtual void fix_num_length_and_dec();
158 Item **item, uint nitems);
159 inline bool get_arg0_date(
MYSQL_TIME *ltime, uint fuzzy_date)
161 return (null_value=args[0]->get_date(ltime, fuzzy_date));
165 return (null_value= args[0]->get_time(ltime));
171 void signal_divide_by_null();
173 Field *tmp_table_field() {
return result_field; }
175 Item *get_tmp_table_item(THD *thd);
180 uint
flags,
int item_sep)
182 return agg_item_charsets(c, func_name(), items, nitems, flags, item_sep);
189 bool agg_arg_charsets_for_string_result(
DTCollation &c,
190 Item **items, uint nitems,
193 return agg_item_charsets_for_string_result(c, func_name(),
194 items, nitems, item_sep);
201 bool agg_arg_charsets_for_comparison(
DTCollation &c,
202 Item **items, uint nitems,
205 return agg_item_charsets_for_comparison(c, func_name(),
206 items, nitems, item_sep);
214 bool agg_arg_charsets_for_string_result_with_comparison(
DTCollation &c,
219 return agg_item_charsets_for_string_result_with_comparison(c, func_name(),
223 bool walk(Item_processor processor,
bool walk_subquery, uchar *arg);
225 Item*
compile(Item_analyzer analyzer, uchar **arg_p,
226 Item_transformer transformer, uchar *arg_t);
227 void traverse_cond(Cond_traverser traverser,
228 void * arg, traverse_order order);
229 inline double fix_result(
double value)
236 inline void raise_numeric_overflow(
const char *type_name)
239 String str(buf,
sizeof(buf), system_charset_info);
241 print(&str, QT_ORDINARY);
242 my_error(ER_DATA_OUT_OF_RANGE, MYF(0), type_name, str.c_ptr_safe());
244 inline double raise_float_overflow()
246 raise_numeric_overflow(
"DOUBLE");
249 inline longlong raise_integer_overflow()
251 raise_numeric_overflow(unsigned_flag ?
"BIGINT UNSIGNED":
"BIGINT");
254 inline int raise_decimal_overflow()
256 raise_numeric_overflow(
"DECIMAL");
257 return E_DEC_OVERFLOW;
265 return isfinite(value) ? value : raise_float_overflow();
274 if ((unsigned_flag && !val_unsigned && value < 0) ||
275 (!unsigned_flag && val_unsigned &&
276 (ulonglong) value > (ulonglong) LONGLONG_MAX))
277 return raise_integer_overflow();
285 return (error == E_DEC_OVERFLOW) ? raise_decimal_overflow() : error;
288 bool has_timestamp_args()
290 DBUG_ASSERT(fixed == TRUE);
291 for (uint
i= 0;
i < arg_count;
i++)
293 if (args[
i]->
type() == Item::FIELD_ITEM &&
294 args[
i]->field_type() == MYSQL_TYPE_TIMESTAMP)
302 DBUG_ASSERT(fixed == TRUE);
303 for (uint
i= 0;
i < arg_count;
i++)
305 if (args[
i]->
type() == Item::FIELD_ITEM &&
306 (args[
i]->field_type() == MYSQL_TYPE_DATE ||
307 args[
i]->field_type() == MYSQL_TYPE_DATETIME))
315 DBUG_ASSERT(fixed == TRUE);
316 for (uint
i= 0;
i < arg_count;
i++)
318 if (args[
i]->
type() == Item::FIELD_ITEM &&
319 (args[
i]->field_type() == MYSQL_TYPE_TIME ||
320 args[
i]->field_type() == MYSQL_TYPE_DATETIME))
326 bool has_datetime_args()
328 DBUG_ASSERT(fixed == TRUE);
329 for (uint
i= 0;
i < arg_count;
i++)
331 if (args[
i]->
type() == Item::FIELD_ITEM &&
332 args[
i]->field_type() == MYSQL_TYPE_DATETIME)
346 virtual bool check_valid_arguments_processor(uchar *bool_arg)
348 return has_timestamp_args();
353 return functype() == *(Functype *) arg;
368 { DBUG_ASSERT(fixed == 1);
return (longlong) rint(val_real()); }
369 bool get_date(
MYSQL_TIME *ltime, uint fuzzydate)
377 enum Item_result result_type ()
const {
return REAL_RESULT; }
378 void fix_length_and_dec()
379 { decimals= NOT_FIXED_DEC; max_length= float_length(decimals); }
386 Item_result hybrid_type;
389 { collation.set_numeric(); }
391 :
Item_func(a,b), hybrid_type(REAL_RESULT)
392 { collation.set_numeric(); }
394 :
Item_func(list), hybrid_type(REAL_RESULT)
395 { collation.set_numeric(); }
397 enum Item_result result_type ()
const {
return hybrid_type; }
398 void fix_length_and_dec();
399 void fix_num_length_and_dec();
400 virtual void find_num_type()= 0;
406 bool get_date(
MYSQL_TIME *ltime, uint fuzzydate);
414 virtual longlong
int_op()= 0;
451 bool is_null() { update_null_value();
return null_value; }
461 void fix_num_length_and_dec();
465 { DBUG_ASSERT(0);
return 0; }
467 { DBUG_ASSERT(0);
return 0; }
476 virtual void result_precision()= 0;
478 virtual inline void print(
String *str, enum_query_type query_type)
480 print_op(str, query_type);
486 { DBUG_ASSERT(0);
return 0; }
488 { DBUG_ASSERT(0);
return 0; }
496 { collation.set_numeric(); fix_char_length(21); }
498 { collation.set_numeric(); fix_char_length(21); }
500 { collation.set_numeric(); fix_char_length(21); }
502 { collation.set_numeric(); fix_char_length(21); }
504 { collation.set_numeric(); fix_char_length(21); }
506 { collation.set_numeric(); }
509 bool get_date(
MYSQL_TIME *ltime, uint fuzzydate)
517 enum Item_result result_type ()
const {
return INT_RESULT; }
518 void fix_length_and_dec() {}
528 const char *func_name()
const {
return "connection_id"; }
529 void fix_length_and_dec();
530 bool fix_fields(THD *thd,
Item **ref);
531 longlong val_int() { DBUG_ASSERT(fixed == 1);
return value; }
542 const char *func_name()
const {
return "cast_as_signed"; }
544 longlong val_int_from_str(
int *error);
545 void fix_length_and_dec()
547 fix_char_length(std::min<uint32>(args[0]->max_char_length(),
548 MY_INT64_NUM_DECIMAL_DIGITS));
550 virtual void print(
String *str, enum_query_type query_type);
551 uint decimal_precision()
const {
return args[0]->decimal_precision(); }
562 const char *func_name()
const {
return "cast_as_unsigned"; }
564 virtual void print(
String *str, enum_query_type query_type);
575 collation.set_numeric();
576 fix_char_length(my_decimal_precision_to_length_no_truncation(len, dec,
582 bool get_date(
MYSQL_TIME *ltime, uint fuzzydate)
591 enum Item_result result_type ()
const {
return DECIMAL_RESULT; }
592 enum_field_types field_type()
const {
return MYSQL_TYPE_NEWDECIMAL; }
593 void fix_length_and_dec() {};
594 const char *func_name()
const {
return "decimal_typecast"; }
595 virtual void print(
String *str, enum_query_type query_type);
604 bool check_partition_func_processor(uchar *int_arg) {
return FALSE;}
612 const char *func_name()
const {
return "+"; }
622 const char *func_name()
const {
return "-"; }
634 const char *func_name()
const {
return "*"; }
638 void result_precision();
639 bool check_partition_func_processor(uchar *int_arg) {
return FALSE;}
648 longlong
int_op() { DBUG_ASSERT(0);
return 0; }
651 const char *func_name()
const {
return "/"; }
652 void fix_length_and_dec();
653 void result_precision();
663 const char *func_name()
const {
return "DIV"; }
664 void fix_length_and_dec();
666 virtual inline void print(
String *str, enum_query_type query_type)
668 print_op(str, query_type);
671 bool check_partition_func_processor(uchar *int_arg) {
return FALSE;}
682 const char *func_name()
const {
return "%"; }
683 void result_precision();
684 void fix_length_and_dec();
685 bool check_partition_func_processor(uchar *int_arg) {
return FALSE;}
696 const char *func_name()
const {
return "-"; }
697 enum Functype functype()
const {
return NEG_FUNC; }
698 void fix_length_and_dec();
699 void fix_num_length_and_dec();
700 uint decimal_precision()
const {
return args[0]->decimal_precision(); }
701 bool check_partition_func_processor(uchar *int_arg) {
return FALSE;}
712 const char *func_name()
const {
return "abs"; }
713 void fix_length_and_dec();
714 bool check_partition_func_processor(uchar *int_arg) {
return FALSE;}
724 void fix_length_and_dec()
726 decimals=NOT_FIXED_DEC; max_length=float_length(decimals);
736 const char *func_name()
const {
return "exp"; }
745 const char *func_name()
const {
return "ln"; }
755 const char *func_name()
const {
return "log"; }
764 const char *func_name()
const {
return "log2"; }
773 const char *func_name()
const {
return "log10"; }
782 const char *func_name()
const {
return "sqrt"; }
791 const char *func_name()
const {
return "pow"; }
800 const char *func_name()
const {
return "acos"; }
808 const char *func_name()
const {
return "asin"; }
817 const char *func_name()
const {
return "atan"; }
825 const char *func_name()
const {
return "cos"; }
833 const char *func_name()
const {
return "sin"; }
841 const char *func_name()
const {
return "tan"; }
849 const char *func_name()
const {
return "cot"; }
856 void fix_length_and_dec();
864 void fix_num_length_and_dec();
873 const char *func_name()
const {
return "ceiling"; }
877 bool check_partition_func_processor(uchar *int_arg) {
return FALSE;}
885 const char *func_name()
const {
return "floor"; }
889 bool check_partition_func_processor(uchar *int_arg) {
return FALSE;}
900 const char *func_name()
const {
return truncate ?
"truncate" :
"round"; }
904 void fix_length_and_dec();
916 const char *func_name()
const {
return "rand"; }
917 bool const_item()
const {
return 0; }
925 bool fix_fields(THD *thd,
Item **ref);
926 void cleanup() { first_eval= TRUE; Item_real_func::cleanup(); }
928 void seed_random (
Item * val);
936 const char *func_name()
const {
return "sign"; }
949 const char *func_name()
const {
return name; }
950 void fix_length_and_dec()
951 { decimals= NOT_FIXED_DEC; max_length= float_length(decimals); }
957 Item_result cmp_type;
961 bool compare_as_dates;
966 enum_field_types cached_field_type;
967 uint cmp_datetimes(longlong *value);
968 uint cmp_times(longlong *value);
971 cmp_type(INT_RESULT), cmp_sign(cmp_sign_arg), compare_as_dates(FALSE),
977 bool get_date(
MYSQL_TIME *ltime, uint fuzzydate);
979 void fix_length_and_dec();
980 enum Item_result result_type ()
const
990 return compare_as_dates ? STRING_RESULT : cmp_type;
992 enum Item_result cast_to_int_type ()
const
998 return compare_as_dates ? INT_RESULT : result_type();
1000 enum_field_types field_type()
const {
return cached_field_type; }
1007 const char *func_name()
const {
return "least"; }
1014 const char *func_name()
const {
return "greatest"; }
1028 item_name= a->item_name;
1030 double val_real() {
return args[0]->val_real(); }
1031 longlong val_int() {
return args[0]->val_int(); }
1032 String *val_str(
String *str) {
return args[0]->val_str(str); }
1034 bool get_date(
MYSQL_TIME *ltime, uint fuzzydate)
1036 return args[0]->get_date(ltime, fuzzydate);
1040 return args[0]->get_time(ltime);
1042 const char *func_name()
const {
return "rollup_const"; }
1043 bool const_item()
const {
return 0; }
1044 Item_result result_type()
const {
return args[0]->result_type(); }
1045 void fix_length_and_dec()
1047 collation= args[0]->collation;
1048 max_length= args[0]->max_length;
1049 decimals=args[0]->decimals;
1051 null_value= args[0]->is_null();
1053 enum_field_types field_type()
const {
return args[0]->field_type(); }
1063 const char *func_name()
const {
return "length"; }
1064 void fix_length_and_dec() { max_length=10; }
1072 { DBUG_ASSERT(fixed == 1);
return Item_func_length::val_int()*8; }
1073 const char *func_name()
const {
return "bit_length"; }
1082 const char *func_name()
const {
return "char_length"; }
1083 void fix_length_and_dec() { max_length=10; }
1091 const char *func_name()
const {
return "coercibility"; }
1092 void fix_length_and_dec() { max_length=10; maybe_null= 0; }
1093 table_map not_null_tables()
const {
return 0; }
1103 const char *func_name()
const {
return "locate"; }
1105 void fix_length_and_dec();
1106 virtual void print(
String *str, enum_query_type query_type);
1116 const char *func_name()
const {
return "validate_password_strength"; }
1117 void fix_length_and_dec() { max_length= 10; maybe_null= 1; }
1124 Item_result cmp_type;
1129 const char *func_name()
const {
return "field"; }
1130 void fix_length_and_dec();
1140 const char *func_name()
const {
return "ascii"; }
1141 void fix_length_and_dec() { max_length=3; }
1150 const char *func_name()
const {
return "ord"; }
1162 const char *func_name()
const {
return "find_in_set"; }
1163 void fix_length_and_dec();
1173 void fix_length_and_dec() { unsigned_flag= 1; }
1177 print_op(str, query_type);
1186 const char *func_name()
const {
return "|"; }
1194 const char *func_name()
const {
return "&"; }
1202 const char *func_name()
const {
return "bit_count"; }
1203 void fix_length_and_dec() { max_length=2; }
1211 const char *func_name()
const {
return "<<"; }
1219 const char *func_name()
const {
return ">>"; }
1227 const char *func_name()
const {
return "~"; }
1242 const char *func_name()
const {
return "last_insert_id"; }
1243 void fix_length_and_dec()
1245 unsigned_flag= TRUE;
1247 max_length= args[0]->max_length;
1249 bool fix_fields(THD *thd,
Item **ref);
1260 const char *func_name()
const {
return "benchmark"; }
1261 void fix_length_and_dec() { max_length=1; maybe_null=0; }
1262 virtual void print(
String *str, enum_query_type query_type);
1270 bool const_item()
const {
return 0; }
1271 const char *func_name()
const {
return "sleep"; }
1290 bool is_expensive_processor(uchar *arg) {
return TRUE; }
1297 const char *func_name()
const {
return udf.name(); }
1298 enum Functype functype()
const {
return UDF_FUNC; }
1299 bool fix_fields(THD *thd,
Item **ref)
1301 DBUG_ASSERT(fixed == 0);
1302 bool res= udf.fix_fields(thd,
this, arg_count, args);
1303 used_tables_cache= udf.used_tables_cache;
1304 const_item_cache= udf.const_item_cache;
1308 void update_used_tables()
1350 if ((used_tables_cache & ~PSEUDO_TABLE_BITS) &&
1351 !(used_tables_cache & RAND_TABLE_BIT))
1353 Item_func::update_used_tables();
1354 if (!const_item_cache && !used_tables_cache)
1355 used_tables_cache= RAND_TABLE_BIT;
1359 Item_result result_type ()
const {
return udf.result_type(); }
1360 table_map not_null_tables()
const {
return 0; }
1361 bool is_expensive() {
return 1; }
1362 virtual void print(
String *str, enum_query_type query_type);
1370 :Item_udf_func(udf_arg) {}
1373 :Item_udf_func(udf_arg, list) {}
1376 DBUG_ASSERT(fixed == 1);
1377 return (longlong) rint(Item_func_udf_float::val_real());
1381 double res=val_real();
1384 double2my_decimal(E_DEC_FATAL_ERROR, res, dec_buf);
1389 bool get_date(
MYSQL_TIME *ltime, uint fuzzydate)
1397 void fix_length_and_dec() { fix_num_length_and_dec(); }
1405 :Item_udf_func(udf_arg) {}
1408 :Item_udf_func(udf_arg, list) {}
1410 double val_real() {
return (
double) Item_func_udf_int::val_int(); }
1412 bool get_date(
MYSQL_TIME *ltime, uint fuzzydate)
1420 enum Item_result result_type ()
const {
return INT_RESULT; }
1421 void fix_length_and_dec() { decimals= 0; max_length= 21; }
1429 :Item_udf_func(udf_arg) {}
1431 :Item_udf_func(udf_arg, list) {}
1436 bool get_date(
MYSQL_TIME *ltime, uint fuzzydate)
1444 enum Item_result result_type ()
const {
return DECIMAL_RESULT; }
1445 void fix_length_and_dec();
1453 :Item_udf_func(udf_arg) {}
1455 :Item_udf_func(udf_arg, list) {}
1462 res= val_str(&str_value);
1463 return res ? my_strntod(res->charset(),(
char*) res->ptr(),
1464 res->length(), &end_not_used, &err_not_used) : 0.0;
1469 String *res; res=val_str(&str_value);
1470 return res ? my_strntoll(res->charset(),res->ptr(),res->length(),10,
1471 (
char**) 0, &err_not_used) : (longlong) 0;
1475 String *res=val_str(&str_value);
1478 string2my_decimal(E_DEC_FATAL_ERROR, res, dec_buf);
1481 bool get_date(
MYSQL_TIME *ltime, uint fuzzydate)
1489 enum Item_result result_type ()
const {
return STRING_RESULT; }
1490 void fix_length_and_dec();
1503 double val_real() { DBUG_ASSERT(fixed == 1);
return 0.0; }
1514 longlong val_int() { DBUG_ASSERT(fixed == 1);
return 0; }
1537 { DBUG_ASSERT(fixed == 1); null_value=1;
return 0; }
1538 double val_real() { DBUG_ASSERT(fixed == 1); null_value= 1;
return 0.0; }
1539 longlong val_int() { DBUG_ASSERT(fixed == 1); null_value=1;
return 0; }
1540 enum Item_result result_type ()
const {
return STRING_RESULT; }
1541 void fix_length_and_dec() { maybe_null=1; max_length=0; }
1551 void item_user_lock_init(
void);
1553 void item_user_lock_free(
void);
1561 const char *func_name()
const {
return "get_lock"; }
1562 void fix_length_and_dec() { max_length=1; maybe_null=1;}
1571 const char *func_name()
const {
return "release_lock"; }
1572 void fix_length_and_dec() { max_length=1; maybe_null=1;}
1584 const char *func_name()
const {
return "master_pos_wait"; }
1585 void fix_length_and_dec() { max_length=21; maybe_null=1;}
1595 const char *func_name()
const {
return "wait_until_sql_thread_after_gtids"; }
1596 void fix_length_and_dec() { max_length= 21; maybe_null= 1; }
1606 const char *func_name()
const {
return "gtid_subset"; }
1607 void fix_length_and_dec() { max_length= 21; maybe_null= 0; }
1623 bool get_date(
MYSQL_TIME *ltime, uint fuzzydate)
1636 class user_var_entry;
1640 enum Item_result cached_result_type;
1641 user_var_entry *
entry;
1652 my_thread_id entry_thread_id;
1666 bool delayed_non_constness;
1667 char buffer[MAX_FIELD_WIDTH];
1683 entry(NULL), entry_thread_id(0), delayed_non_constness(delayed), name(a)
1686 :
Item_var_func(thd, item), cached_result_type(item->cached_result_type),
1687 entry(item->entry), entry_thread_id(item->entry_thread_id),
1688 delayed_non_constness(item->delayed_non_constness), value(item->value),
1689 decimal_buff(item->decimal_buff), null_item(item->null_item),
1690 save_result(item->save_result), name(item->name)
1692 enum Functype functype()
const {
return SUSERVAR_FUNC; }
1697 double val_result();
1698 longlong val_int_result();
1699 bool val_bool_result();
1702 bool is_null_result();
1703 bool update_hash(
void *ptr, uint length,
enum Item_result type,
1704 const CHARSET_INFO *cs, Derivation dv,
bool unsigned_arg);
1707 bool check(
bool use_result_field);
1710 enum Item_result result_type ()
const {
return cached_result_type; }
1711 bool fix_fields(THD *thd,
Item **ref);
1712 void fix_length_and_dec();
1713 virtual void print(
String *str, enum_query_type query_type);
1714 void print_assignment(
String *str, enum_query_type query_type);
1715 const char *func_name()
const {
return "set_user_var"; }
1716 type_conversion_status save_in_field(
Field *field,
bool no_conversions,
1717 bool can_use_result_field);
1718 type_conversion_status save_in_field(
Field *field,
bool no_conversions)
1720 return save_in_field(field, no_conversions, 1);
1722 void save_org_in_field(
Field *field) { (void)save_in_field(field, 1, 0); }
1723 bool register_field_in_read_map(uchar *arg);
1724 bool set_entry(THD *thd,
bool create_if_not_exists);
1732 user_var_entry *var_entry;
1733 Item_result m_cached_result_type;
1738 Item_var_func(), m_cached_result_type(STRING_RESULT), name(a) {}
1739 enum Functype functype()
const {
return GUSERVAR_FUNC; }
1744 void fix_length_and_dec();
1745 virtual void print(
String *str, enum_query_type query_type);
1746 enum Item_result result_type()
const;
1751 const char *func_name()
const {
return "get_user_var"; }
1752 bool const_item()
const;
1753 table_map used_tables()
const
1754 {
return const_item() ? 0 : RAND_TABLE_BIT; }
1755 bool eq(
const Item *item,
bool binary_cmp)
const;
1779 user_var_entry *
entry;
1782 { item_name.
copy(a); }
1784 enum Type type()
const {
return STRING_ITEM;}
1789 bool get_date(
MYSQL_TIME *ltime, uint fuzzydate)
1801 bool fix_fields(THD *thd,
Item **ref);
1802 virtual void print(
String *str, enum_query_type query_type);
1804 void set_value(
const char *str, uint length,
const CHARSET_INFO* cs);
1810 #define GET_SYS_VAR_CACHE_LONG 1
1811 #define GET_SYS_VAR_CACHE_DOUBLE 2
1812 #define GET_SYS_VAR_CACHE_STRING 4
1817 enum_var_type var_type, orig_var_type;
1819 longlong cached_llval;
1822 my_bool cached_null_value;
1823 query_id_t used_query_id;
1824 uchar cache_present;
1828 LEX_STRING *component_arg,
const char *name_arg,
1829 size_t name_len_arg);
1830 enum Functype functype()
const {
return GSYSVAR_FUNC; }
1831 void update_null_value();
1832 void fix_length_and_dec();
1833 void print(
String *str, enum_query_type query_type);
1834 bool const_item()
const {
return true; }
1835 table_map used_tables()
const {
return 0; }
1836 enum Item_result result_type()
const;
1837 enum_field_types field_type()
const;
1842 {
return val_decimal_from_real(dec_buf); }
1844 const char *func_name()
const {
return "get_system_var"; }
1854 bool eq(
const Item *item,
bool binary_cmp)
const;
1861 #include <ft_global.h>
1877 join_key(0), ft_handler(0), table(0), master(0), concat_ws(0) { }
1880 DBUG_ENTER(
"Item_func_match::cleanup");
1881 Item_real_func::cleanup();
1882 if (!master && ft_handler)
1883 ft_handler->please->close_search(ft_handler);
1889 enum Functype functype()
const {
return FT_FUNC; }
1890 const char *func_name()
const {
return "match"; }
1891 void update_used_tables() {}
1892 table_map not_null_tables()
const {
return 0; }
1893 bool fix_fields(THD *thd,
Item **ref);
1894 bool eq(
const Item *,
bool binary_cmp)
const;
1896 longlong val_int() { DBUG_ASSERT(fixed == 1);
return val_real() != 0.0; }
1898 virtual void print(
String *str, enum_query_type query_type);
1901 void init_search(
bool no_order);
1912 DBUG_ASSERT(ft_handler);
1913 DBUG_ASSERT(table->file->
ha_table_flags() & HA_CAN_FULLTEXT_EXT);
1927 if (flags & FT_SORTED)
1933 DBUG_ASSERT(ft_handler);
1934 return ((
FT_INFO_EXT *)ft_handler)->could_you->get_flags() &
1946 DBUG_ASSERT(ft_handler);
1951 return ((
FT_INFO_EXT *)ft_handler)->could_you->get_flags() &
1952 FTS_DOCID_IN_RESULT;
1974 bool allows_search_on_non_indexed_columns(
TABLE* table_arg)
1977 if (!(flags & FT_BOOL))
1980 DBUG_ASSERT(table_arg && table_arg->file);
1984 if ((table_arg->file->
ha_table_flags() & HA_CAN_FULLTEXT_EXT) == 0)
2005 unsigned_flag=
true;
2008 const char *func_name()
const {
return "docid"; }
2010 void update_used_tables()
2012 Item_int_func::update_used_tables();
2019 DBUG_ASSERT(ft_handler);
2020 return ft_handler->could_you->get_docid(ft_handler);
2029 const char *func_name()
const {
return "^"; }
2038 const char *func_name()
const {
return "is_free_lock"; }
2039 void fix_length_and_dec() { decimals=0; max_length=1; maybe_null=1;}
2048 const char *func_name()
const {
return "is_used_lock"; }
2049 void fix_length_and_dec() { decimals=0; max_length=10; maybe_null=1;}
2056 ITEM_CAST_BINARY, ITEM_CAST_SIGNED_INT, ITEM_CAST_UNSIGNED_INT,
2057 ITEM_CAST_DATE, ITEM_CAST_TIME, ITEM_CAST_DATETIME, ITEM_CAST_CHAR,
2067 const char *func_name()
const {
return "row_count"; }
2068 void fix_length_and_dec() { decimals= 0; maybe_null=0; }
2080 struct st_sp_security_context;
2089 uchar result_buf[64];
2093 Field *sp_result_field;
2096 bool execute_impl(THD *thd);
2097 bool init_result_field(THD *thd);
2100 bool is_expensive_processor(uchar *arg) {
return TRUE; }
2117 void update_used_tables();
2121 const char *func_name()
const;
2123 enum enum_field_types field_type()
const;
2129 Item_result result_type()
const;
2134 return (longlong) 0;
2135 return sp_result_field->val_int();
2142 return sp_result_field->val_real();
2145 bool get_date(
MYSQL_TIME *ltime, uint fuzzydate)
2149 return sp_result_field->get_date(ltime, fuzzydate);
2156 return sp_result_field->get_time(ltime);
2163 return sp_result_field->val_decimal(dec_buf);
2170 buf.set(buff, 20, str->charset());
2180 sp_result_field->val_str(&buf);
2185 virtual bool change_context_processor(uchar *cntx)
2189 virtual enum Functype functype()
const {
return FUNC_SP; }
2191 bool fix_fields(THD *thd,
Item **ref);
2193 bool is_expensive() {
return 1; }
2195 inline Field *get_sp_result_field()
2197 return sp_result_field;
2200 virtual void update_null_value();
2209 const char *func_name()
const {
return "found_rows"; }
2210 void fix_length_and_dec() { decimals= 0; maybe_null=0; }
2214 void uuid_short_init();
2220 const char *func_name()
const {
return "uuid_short"; }
2222 void fix_length_and_dec()
2223 { max_length= 21; unsigned_flag=1; }
2224 bool check_partition_func_processor(uchar *int_arg) {
return FALSE;}
2231 double my_double_round(
double value, longlong dec,
bool dec_unsigned,
2235 extern bool volatile mqh_used;