24#include <drizzled/common.h>
25#include <drizzled/comp_creator.h>
26#include <drizzled/function/math/int.h>
27#include <drizzled/function/numhybrid.h>
28#include <drizzled/item/decimal.h>
29#include <drizzled/item/float.h>
30#include <drizzled/item/function/boolean.h>
31#include <drizzled/item/int.h>
32#include <drizzled/item/row.h>
33#include <drizzled/item/string.h>
34#include <drizzled/item/sum.h>
35#include <drizzled/qsort_cmp.h>
38#include "drizzled/compare_double.h"
42extern Item_result item_cmp_type(Item_result a,Item_result b);
48int64_t get_datetime_value(
Session *session,
59 Arg_comparator *comparators;
63 enum_field_types a_type, b_type;
64 Item *a_cache, *b_cache;
66 enum enum_date_cmp_type { CMP_DATE_DFLT= 0, CMP_DATE_WITH_DATE,
67 CMP_DATE_WITH_STR, CMP_STR_WITH_DATE };
68 int64_t (*get_value_func)(
Session *session,
Item ***item_arg,
Item **cache_arg,
69 Item *warn_item,
bool *is_null);
75 Arg_comparator(
Item **a1,
Item **a2);
80 return set_compare_func(owner_arg, item_cmp_type((*a)->result_type(),
81 (*b)->result_type()));
90 return set_cmp_func(owner_arg, a1, a2,
91 item_cmp_type((*a1)->result_type(),
92 (*a2)->result_type()));
94 inline int compare() {
return (this->*func)(); }
99 int compare_decimal();
100 int compare_int_signed();
106 int compare_e_binary_string();
107 int compare_e_real();
108 int compare_e_decimal();
112 int compare_real_fixed();
113 int compare_e_real_fixed();
114 int compare_datetime();
116 static enum enum_date_cmp_type can_compare_as_dates(
Item *a,
Item *b,
117 int64_t *const_val_arg);
119 void set_datetime_cmp_func(
Item **a1,
Item **b1);
120 static arg_cmp_func comparator_matrix [5][2];
122 friend class Item_func;
136 virtual void fix_length_and_dec();
140 Item_func_truth(
Item *a,
bool a_value,
bool a_affirmative)
161class Item_func_istrue :
public Item_func_truth
164 Item_func_istrue(
Item *a) : Item_func_truth(a,
true,
true) {}
165 virtual const char* func_name()
const {
return "istrue"; }
173class Item_func_isnottrue :
public Item_func_truth
176 Item_func_isnottrue(
Item *a) : Item_func_truth(a,
true,
false) {}
177 virtual const char* func_name()
const {
return "isnottrue"; }
185class Item_func_isfalse :
public Item_func_truth
188 Item_func_isfalse(
Item *a) : Item_func_truth(a,
false,
true) {}
189 virtual const char* func_name()
const {
return "isfalse"; }
197class Item_func_isnotfalse :
public Item_func_truth
200 Item_func_isnotfalse(
Item *a) : Item_func_truth(a,
false,
false) {}
201 virtual const char* func_name()
const {
return "isnotfalse"; }
205#define UNKNOWN ((bool)-1)
234 bool result_for_null_param;
238 save_cache(0), result_for_null_param(UNKNOWN)
245 const char *func_name()
const {
return "<in_optimizer>"; }
247 void keep_top_level_cache();
248 Item *
transform(Item_transformer transformer,
unsigned char *arg);
255 virtual const char* symbol(
bool invert)
const {
return invert?
"<>" :
"="; }
256 virtual bool eqne_op()
const {
return 1; }
257 virtual bool l_op()
const {
return 0; }
265 virtual const char* symbol(
bool invert)
const {
return invert?
"=" :
"<>"; }
266 virtual bool eqne_op()
const {
return 1; }
267 virtual bool l_op()
const {
return 0; }
275 virtual const char* symbol(
bool invert)
const {
return invert?
"<=" :
">"; }
276 virtual bool eqne_op()
const {
return 0; }
277 virtual bool l_op()
const {
return 0; }
285 virtual const char* symbol(
bool invert)
const {
return invert?
">=" :
"<"; }
286 virtual bool eqne_op()
const {
return 0; }
287 virtual bool l_op()
const {
return 1; }
295 virtual const char* symbol(
bool invert)
const {
return invert?
"<" :
">="; }
296 virtual bool eqne_op()
const {
return 0; }
297 virtual bool l_op()
const {
return 0; }
305 virtual const char* symbol(
bool invert)
const {
return invert?
">" :
"<="; }
306 virtual bool eqne_op()
const {
return 0; }
307 virtual bool l_op()
const {
return 1; }
311class Item_bool_func2 :
public Item_int_func
315 String tmp_value1,tmp_value2;
320 :Item_int_func(a,b), cmp(tmp_arg, tmp_arg+1), abort_on_null(
false) {}
321 void fix_length_and_dec();
324 cmp.set_cmp_func(
this, tmp_arg, tmp_arg+1);
326 optimize_type select_optimize()
const {
return OPTIMIZE_OP; }
327 virtual enum Functype rev_functype()
const {
return UNKNOWN_FUNC; }
328 bool have_rev_func()
const {
return rev_functype() != UNKNOWN_FUNC; }
332 Item_func::print_op(str);
336 bool is_bool_func() {
return 1; }
337 const charset_info_st *compare_collation() {
return cmp.cmp_collation.collation; }
338 uint32_t decimal_precision()
const {
return 1; }
344class Item_bool_rowready_func2 :
public Item_bool_func2
347 Item_bool_rowready_func2(
Item *a,
Item *b) :Item_bool_func2(a, b)
353 bool subst_argument_checker(
unsigned char **)
362 enum Functype functype()
const {
return NOT_FUNC; }
363 const char *func_name()
const {
return "not"; }
402 int64_t
val_int() {
return *trig_var ? args[0]->val_int() : 1; }
403 enum Functype functype()
const {
return TRIG_COND_FUNC; };
404 const char *func_name()
const {
return "trigcond"; };
406 bool *get_trig_var() {
return trig_var; }
411class Item_func_not_all :
public Item_func_not
421 Item_func_not_all(
Item *a)
422 :Item_func_not(a), test_sum_item(0), test_sub_item(0), abort_on_null(0),
426 bool top_level() {
return abort_on_null; }
428 enum Functype functype()
const {
return NOT_ALL_FUNC; }
429 const char *func_name()
const {
return "<not>"; }
430 virtual void print(String *str);
431 void set_sum_test(Item_sum_hybrid *item) { test_sum_item= item; };
432 void set_sub_test(Item_maxmin_subselect *item) { test_sub_item= item; };
433 bool empty_underlying_subquery();
438class Item_func_nop_all :
public Item_func_not_all
442 Item_func_nop_all(
Item *a) :Item_func_not_all(a) {}
444 const char *func_name()
const {
return "<nop>"; }
449class Item_func_eq :
public Item_bool_rowready_func2
452 Item_func_eq(
Item *a,
Item *b) :Item_bool_rowready_func2(a,b) {}
454 enum Functype functype()
const {
return EQ_FUNC; }
455 enum Functype rev_functype()
const {
return EQ_FUNC; }
456 cond_result eq_cmp_result()
const {
return COND_TRUE; }
457 const char *func_name()
const {
return "="; }
461class Item_func_equal :
public Item_bool_rowready_func2
464 Item_func_equal(
Item *a,
Item *b) :Item_bool_rowready_func2(a,b) {};
468 enum Functype functype()
const {
return EQUAL_FUNC; }
469 enum Functype rev_functype()
const {
return EQUAL_FUNC; }
470 cond_result eq_cmp_result()
const {
return COND_TRUE; }
471 const char *func_name()
const {
return "<=>"; }
472 Item *neg_transformer(Session *) {
return 0; }
476class Item_func_ge :
public Item_bool_rowready_func2
479 Item_func_ge(
Item *a,
Item *b) :Item_bool_rowready_func2(a,b) {};
481 enum Functype functype()
const {
return GE_FUNC; }
482 enum Functype rev_functype()
const {
return LE_FUNC; }
483 cond_result eq_cmp_result()
const {
return COND_TRUE; }
484 const char *func_name()
const {
return ">="; }
489class Item_func_gt :
public Item_bool_rowready_func2
492 Item_func_gt(
Item *a,
Item *b) :Item_bool_rowready_func2(a,b) {};
494 enum Functype functype()
const {
return GT_FUNC; }
495 enum Functype rev_functype()
const {
return LT_FUNC; }
496 cond_result eq_cmp_result()
const {
return COND_FALSE; }
497 const char *func_name()
const {
return ">"; }
502class Item_func_le :
public Item_bool_rowready_func2
505 Item_func_le(
Item *a,
Item *b) :Item_bool_rowready_func2(a,b) {};
507 enum Functype functype()
const {
return LE_FUNC; }
508 enum Functype rev_functype()
const {
return GE_FUNC; }
509 cond_result eq_cmp_result()
const {
return COND_TRUE; }
510 const char *func_name()
const {
return "<="; }
515class Item_func_lt :
public Item_bool_rowready_func2
518 Item_func_lt(
Item *a,
Item *b) :Item_bool_rowready_func2(a,b) {}
520 enum Functype functype()
const {
return LT_FUNC; }
521 enum Functype rev_functype()
const {
return GT_FUNC; }
522 cond_result eq_cmp_result()
const {
return COND_FALSE; }
523 const char *func_name()
const {
return "<"; }
528class Item_func_ne :
public Item_bool_rowready_func2
531 Item_func_ne(
Item *a,
Item *b) :Item_bool_rowready_func2(a,b) {}
533 enum Functype functype()
const {
return NE_FUNC; }
534 cond_result eq_cmp_result()
const {
return COND_FALSE; }
535 optimize_type select_optimize()
const {
return OPTIMIZE_KEY; }
536 const char *func_name()
const {
return "<>"; }
550class Item_func_opt_neg :
public Item_int_func
557 :Item_int_func(a, b, c), negated(0), pred_level(0) {}
559 :Item_int_func(list), negated(0), pred_level(0) {}
561 inline void negate() { negated= !negated; }
568 bool eq(
const Item *item,
bool binary_cmp)
const;
569 bool subst_argument_checker(
unsigned char **)
574class Item_func_between :
public Item_func_opt_neg
578 Item_result cmp_type;
579 String value0,value1,value2;
581 bool compare_as_dates;
585 :Item_func_opt_neg(a, b, c), compare_as_dates(
false) {}
587 optimize_type select_optimize()
const {
return OPTIMIZE_KEY; }
588 enum Functype functype()
const {
return BETWEEN; }
589 const char *func_name()
const {
return "between"; }
591 void fix_length_and_dec();
593 bool is_bool_func() {
return 1; }
594 const charset_info_st *compare_collation() {
return cmp_collation.collation; }
595 uint32_t decimal_precision()
const {
return 1; }
599class Item_func_strcmp :
public Item_bool_func2
602 Item_func_strcmp(
Item *a,
Item *b) :Item_bool_func2(a,b) {}
604 optimize_type select_optimize()
const {
return OPTIMIZE_NONE; }
605 const char *func_name()
const {
return "strcmp"; }
621class Item_func_interval :
public Item_int_func
624 bool use_decimal_comparison;
628 :Item_int_func(a),row(a),intervals(0)
633 void fix_length_and_dec();
634 const char *func_name()
const {
return "interval"; }
635 uint32_t decimal_precision()
const {
return 2; }
639class Item_func_coalesce :
public Item_func_numhybrid
642 enum_field_types cached_field_type;
643 Item_func_coalesce(
Item *a,
Item *b) :Item_func_numhybrid(a, b) {}
645 Item_func_coalesce(
List<Item> &list) :Item_func_numhybrid(list) {}
650 void fix_length_and_dec();
651 void find_num_type() {}
652 enum Item_result result_type ()
const {
return hybrid_type; }
653 const char *func_name()
const {
return "coalesce"; }
655 enum_field_types field_type()
const {
return cached_field_type; }
659class Item_func_ifnull :
public Item_func_coalesce
662 bool field_type_defined;
664 Item_func_ifnull(
Item *a,
Item *b) :Item_func_coalesce(a,b) {}
669 enum_field_types field_type()
const;
670 void fix_length_and_dec();
671 const char *func_name()
const {
return "ifnull"; }
672 Field *tmp_table_field()
674 return Item_func::tmp_table_field();
677 uint32_t decimal_precision()
const;
681class Item_func_if :
public Item_func
683 Item_result cached_result_type;
684 enum_field_types cached_field_type;
689 cached_result_type(INT_RESULT)
696 Item_result result_type ()
const {
return cached_result_type; }
697 enum_field_types field_type()
const {
return cached_field_type; }
699 void fix_length_and_dec();
700 uint32_t decimal_precision()
const;
701 const char *func_name()
const {
return "if"; }
705class Item_func_nullif :
public Item_bool_func2
707 enum Item_result cached_result_type;
710 :Item_bool_func2(a,b), cached_result_type(INT_RESULT)
716 enum Item_result result_type ()
const {
return cached_result_type; }
717 void fix_length_and_dec();
718 uint32_t decimal_precision()
const {
return args[0]->decimal_precision(); }
719 const char *func_name()
const {
return "nullif"; }
746 in_vector(uint32_t elements,uint32_t element_length,qsort2_cmp cmp_func,
748 :base((
char*) memory::sql_calloc(elements*element_length)),
749 size(element_length), compare(cmp_func), collation(cmp_coll),
750 count(elements), used_count(elements) {}
751 virtual ~in_vector() {}
752 virtual void set(uint32_t pos,
Item *item)=0;
753 virtual unsigned char *get_value(
Item *item)=0;
755 int find(
Item *item);
765 virtual Item* create_item() {
return NULL; }
775 virtual void value_to_item(uint32_t,
Item *) { }
778 bool compare_elems(uint32_t pos1, uint32_t pos2)
780 return test(compare(collation, base + pos1*size, base + pos2*size));
782 virtual Item_result result_type()= 0;
785class in_string :
public in_vector
787 char buff[STRING_BUFFER_USUAL_SIZE];
790 in_string(uint32_t elements,qsort2_cmp cmp_func,
const charset_info_st *
const cs);
792 void set(uint32_t pos,
Item *item);
793 unsigned char *get_value(
Item *item);
798 void value_to_item(uint32_t pos,
Item *item)
804 Item_result result_type() {
return STRING_RESULT; }
807class in_int64_t :
public in_vector
818 int64_t unsigned_flag;
821 in_int64_t(uint32_t elements);
822 void set(uint32_t pos,
Item *item);
823 unsigned char *get_value(
Item *item);
833 void value_to_item(uint32_t pos,
Item *item)
835 ((
Item_int*) item)->value= ((packed_int64_t*) base)[pos].val;
836 ((
Item_int*) item)->unsigned_flag= (bool)
837 ((packed_int64_t*) base)[pos].unsigned_flag;
839 Item_result result_type() {
return INT_RESULT; }
851class in_datetime :
public in_int64_t
860 in_datetime(
Item *warn_item_arg, uint32_t elements);
862 void set(uint32_t pos,
Item *item);
863 unsigned char *get_value(
Item *item);
868class in_double :
public in_vector
872 in_double(uint32_t elements);
873 void set(uint32_t pos,
Item *item);
874 unsigned char *get_value(
Item *item);
879 void value_to_item(uint32_t pos,
Item *item)
881 ((
Item_float*)item)->value= ((
double*) base)[pos];
883 Item_result result_type() {
return REAL_RESULT; }
887class in_decimal :
public in_vector
891 in_decimal(uint32_t elements);
892 void set(uint32_t pos,
Item *item);
893 unsigned char *get_value(
Item *item);
898 void value_to_item(uint32_t pos,
Item *item)
902 item_dec->set_decimal_value(dec);
904 Item_result result_type() {
return DECIMAL_RESULT; }
920 cmp_charset= &my_charset_bin;
923 virtual ~cmp_item() {}
924 virtual void store_value(
Item *item)= 0;
925 virtual int cmp(
Item *item)= 0;
927 virtual int compare(cmp_item *item)= 0;
929 virtual cmp_item *make_same()= 0;
930 virtual void store_value_by_template(cmp_item *,
Item *item)
936class cmp_item_string :
public cmp_item
941 cmp_item_string () {}
942 cmp_item_string (
const charset_info_st *
const cs) { cmp_charset= cs; }
943 void set_charset(
const charset_info_st *
const cs) { cmp_charset= cs; }
944 friend class cmp_item_sort_string;
945 friend class cmp_item_sort_string_in_static;
948class cmp_item_sort_string :
public cmp_item_string
951 char value_buff[STRING_BUFFER_USUAL_SIZE];
954 cmp_item_sort_string():
958 value(value_buff,
sizeof(value_buff), cs) {}
959 void store_value(
Item *item)
961 value_res= item->val_str(&value);
965 char buff[STRING_BUFFER_USUAL_SIZE];
966 String tmp(buff,
sizeof(buff), cmp_charset), *res;
968 return (value_res ? (res ? sortcmp(value_res, res, cmp_charset) : 1) :
973 cmp_item_string *l_cmp= (cmp_item_string *) ci;
974 return sortcmp(value_res, l_cmp->value_res, cmp_charset);
980 value.set_quick(value_buff,
sizeof(value_buff), cs);
988 void store_value(
Item *item)
990 value= item->val_int();
994 return value != arg->
val_int();
996 int compare(cmp_item *ci)
999 return (value < l_cmp->value) ? -1 : ((value == l_cmp->value) ? 0 : 1);
1001 cmp_item *make_same();
1010class cmp_item_datetime :
public cmp_item
1021 cmp_item_datetime(
Item *warn_item_arg);
1023 void store_value(
Item *item);
1025 int compare(cmp_item *ci);
1026 cmp_item *make_same();
1033 void store_value(
Item *item)
1035 value= item->val_real();
1039 return compare_ne_double(value, arg->
val_real());
1041 int compare(cmp_item *ci)
1044 return (value < l_cmp->value)? -1 : (compare_double(value, l_cmp->value) ? 0 : 1);
1046 cmp_item *make_same();
1054 void store_value(
Item *item);
1056 int compare(cmp_item *c);
1057 cmp_item *make_same();
1066class cmp_item_sort_string_in_static :
public cmp_item_string
1072 cmp_item_string(cs) {}
1073 void store_value(
Item *item)
1075 value_res= item->val_str(&value);
1085 cmp_item_string *l_cmp= (cmp_item_string *) ci;
1086 return sortcmp(value_res, l_cmp->value_res, cmp_charset);
1090 return new cmp_item_sort_string_in_static(cmp_charset);
1113class Item_func_case :
public Item_func
1115 int first_expr_num, else_expr_num;
1116 enum Item_result cached_result_type, left_result_type;
1119 Item_result cmp_type;
1121 enum_field_types cached_field_type;
1122 cmp_item *cmp_items[DECIMAL_RESULT+1];
1126 :Item_func(), first_expr_num(-1), else_expr_num(-1),
1127 cached_result_type(INT_RESULT), left_result_type(INT_RESULT), case_item(0)
1129 ncases= list.size();
1132 first_expr_num= list.size();
1133 list.push_back(first_expr_arg);
1137 else_expr_num= list.size();
1138 list.push_back(else_expr_arg);
1140 set_arguments(list);
1141 memset(&cmp_items, 0,
sizeof(cmp_items));
1148 void fix_length_and_dec();
1149 uint32_t decimal_precision()
const;
1151 enum Item_result result_type ()
const {
return cached_result_type; }
1152 enum_field_types field_type()
const {
return cached_field_type; }
1153 const char *func_name()
const {
return "case"; }
1154 virtual void print(String *str);
1156 const charset_info_st *compare_collation() {
return cmp_collation.collation; }
1158 void agg_str_lengths(
Item *arg);
1159 void agg_num_lengths(
Item *arg);
1176class Item_func_in :
public Item_func_opt_neg
1189 bool arg_types_compatible;
1190 Item_result left_result_type;
1195 :Item_func_opt_neg(list), array(0), have_null(0),
1196 arg_types_compatible(
false)
1198 memset(&cmp_items, 0,
sizeof(cmp_items));
1199 allowed_arg_cols= 0;
1203 void fix_length_and_dec();
1204 uint32_t decimal_precision()
const {
return 1; }
1207 Item_int_func::cleanup();
1210 for (
int i= STRING_RESULT; i <= DECIMAL_RESULT; i++)
1212 delete cmp_items[i];
1217 optimize_type select_optimize()
const
1218 {
return OPTIMIZE_KEY; }
1220 enum Functype functype()
const {
return IN_FUNC; }
1221 const char *func_name()
const {
return " IN "; }
1222 bool nulls_in_row();
1223 bool is_bool_func() {
return 1; }
1224 const charset_info_st *compare_collation() {
return cmp_collation.collation; }
1227class cmp_item_row :
public cmp_item
1229 cmp_item **comparators;
1232 cmp_item_row(): comparators(0), n(0) {}
1234 void store_value(
Item *item);
1235 inline void alloc_comparators();
1237 int compare(cmp_item *arg);
1238 cmp_item *make_same();
1239 void store_value_by_template(cmp_item *tmpl,
Item *);
1240 friend void Item_func_in::fix_length_and_dec();
1244class in_row :
public in_vector
1248 in_row(uint32_t elements,
Item *);
1250 void set(uint32_t pos,
Item *item);
1251 unsigned char *get_value(
Item *item);
1252 friend void Item_func_in::fix_length_and_dec();
1253 Item_result result_type() {
return ROW_RESULT; }
1261 int64_t cached_value;
1265 enum Functype functype()
const {
return ISNULL_FUNC; }
1266 void fix_length_and_dec()
1269 update_used_tables();
1271 const char *func_name()
const {
return "isnull"; }
1273 virtual void update_used_tables()
1277 used_tables_cache= 0;
1278 const_item_cache= 1;
1279 cached_value= (int64_t) 0;
1283 args[0]->update_used_tables();
1284 if ((const_item_cache= !(used_tables_cache= args[0]->
used_tables())) &&
1288 cached_value= (int64_t) args[0]->
is_null();
1293 optimize_type select_optimize()
const {
return OPTIMIZE_NULL; }
1295 const charset_info_st *compare_collation() {
return args[0]->collation.collation; }
1304class Item_is_not_null_test :
public Item_func_isnull
1309 :Item_func_isnull(a), owner(ow)
1311 enum Functype functype()
const {
return ISNOTNULLTEST_FUNC; }
1313 const char *func_name()
const {
return "<is_not_null_test>"; }
1319 {
return used_tables_cache | RAND_TABLE_BIT; }
1329 enum Functype functype()
const {
return ISNOTNULL_FUNC; }
1330 void fix_length_and_dec()
1334 const char *func_name()
const {
return "isnotnull"; }
1335 optimize_type select_optimize()
const {
return OPTIMIZE_NULL; }
1337 {
return abort_on_null ? not_null_tables_cache : 0; }
1340 const charset_info_st *compare_collation() {
return args[0]->collation.collation; }
1345class Item_func_like :
public Item_bool_func2
1349 const char* pattern;
1360 enum { alphabet_size = 256 };
1364 bool escape_used_in_parsing;
1371 Item_func_like(
Item *a,
Item *b,
Item *escape_arg,
bool escape_used)
1372 :Item_bool_func2(a,b), canDoTurboBM(
false), pattern(0), pattern_len(0),
1373 bmGs(0), bmBc(0), escape_item(escape_arg),
1374 escape_used_in_parsing(escape_used), escape(NULL) {}
1376 enum Functype functype()
const {
return LIKE_FUNC; }
1378 cond_result eq_cmp_result()
const {
return COND_TRUE; }
1379 const char *func_name()
const {
return "like"; }
1390 table_map and_tables_cache;
1394 using Item::split_sum_func;
1398 { const_item_cache=0; }
1405 Item_cond(
Session *session, Item_cond *item);
1408 void add(
Item *item) { list.push_back(item); }
1409 void add_at_head(
Item *item) { list.push_front(item); }
1410 void add_at_head(
List<Item> *nlist) { list.prepand(nlist); }
1414 enum Type type()
const {
return COND_ITEM; }
1415 List<Item>* argument_list() {
return &list; }
1417 void update_used_tables();
1424 bool walk(Item_processor processor,
bool walk_subquery,
unsigned char *arg);
1425 Item *
transform(Item_transformer transformer,
unsigned char *arg);
1426 void traverse_cond(Cond_traverser,
void *arg, traverse_order order);
1427 void neg_arguments(
Session *session);
1428 enum_field_types field_type()
const {
return DRIZZLE_TYPE_LONGLONG; }
1429 bool subst_argument_checker(
unsigned char **)
1431 Item *
compile(Item_analyzer analyzer,
unsigned char **arg_p,
1432 Item_transformer transformer,
unsigned char *arg_t);
1524 fields_t::iterator begin()
1526 return fields.begin();
1531 Item_equal(Item_equal *item_equal);
1532 inline Item* get_const() {
return const_item; }
1537 Item_field* get_first() {
return &fields.front(); }
1538 void merge(Item_equal *item);
1540 enum Functype functype()
const {
return MULT_EQUAL_FUNC; }
1542 const char *func_name()
const {
return "multiple equal"; }
1543 optimize_type select_optimize()
const {
return OPTIMIZE_EQUAL; }
1544 void sort(Item_field_cmpfunc cmp,
void *arg);
1545 void fix_length_and_dec();
1547 void update_used_tables();
1548 bool walk(Item_processor processor,
bool walk_subquery,
unsigned char *arg);
1549 Item *
transform(Item_transformer transformer,
unsigned char *arg);
1552 {
return fields.front().collation.collation; }
1564 uint32_t max_members;
1566 COND_EQUAL *upper_levels;
1569 COND_EQUAL() : max_members(0), upper_levels(NULL) {}
1572typedef List<Item_field>::iterator Item_equal_iterator;
1574class Item_cond_and :
public Item_cond
1580 Item_cond_and() :Item_cond() {}
1581 Item_cond_and(
Item *i1,
Item *i2) :Item_cond(i1,i2) {}
1582 Item_cond_and(
Session *session, Item_cond_and *item) :Item_cond(session, item) {}
1583 Item_cond_and(
List<Item> &list_arg): Item_cond(list_arg) {}
1584 enum Functype functype()
const {
return COND_AND_FUNC; }
1586 const char *func_name()
const {
return "and"; }
1588 {
return abort_on_null ? not_null_tables_cache: and_tables_cache; }
1593 item->copy_andor_arguments(session,
this);
1596 Item *neg_transformer(Session *session);
1599inline bool is_cond_and(
Item *item)
1601 if (item->type() != Item::COND_ITEM)
1605 return (cond_item->functype() == Item_func::COND_AND_FUNC);
1608class Item_cond_or :
public Item_cond
1611 Item_cond_or() :Item_cond() {}
1612 Item_cond_or(
Item *i1,
Item *i2) :Item_cond(i1,i2) {}
1613 Item_cond_or(
Session *session, Item_cond_or *item) :Item_cond(session, item) {}
1614 Item_cond_or(
List<Item> &list_arg): Item_cond(list_arg) {}
1615 enum Functype functype()
const {
return COND_OR_FUNC; }
1617 const char *func_name()
const {
return "or"; }
1623 item->copy_andor_arguments(session,
this);
1626 Item *neg_transformer(Session *session);
1629inline bool is_cond_or(
Item *item)
1631 if (item->type() != Item::COND_ITEM)
1635 return (cond_item->functype() == Item_func::COND_OR_FUNC);
1643class Item_cond_xor :
public Item_cond
1646 Item_cond_xor() :Item_cond() {}
1647 Item_cond_xor(
Item *i1,
Item *i2) :Item_cond(i1,i2) {}
1648 enum Functype functype()
const {
return COND_XOR_FUNC; }
1650 enum Type type()
const {
return FUNC_ITEM; }
1652 const char *func_name()
const {
return "xor"; }
1661inline Item *and_conds(Item *a, Item *b)
1665 return new Item_cond_and(a, b);
int compare_e_int_diff_signedness()
int compare_int_signed_unsigned()
int compare_int_unsigned_signed()
int compare_binary_string()
int compare_int_unsigned()
virtual void print(String *str)
virtual Item * negated_item()
table_map not_null_tables() const
table_map not_null_tables() const
void split_sum_func(Session *session, Item **ref_pointer_array, List< Item > &fields)
table_map used_tables() const
Item * compile(Item_analyzer analyzer, unsigned char **arg_p, Item_transformer transformer, unsigned char *arg_t)
virtual void print(String *str)
Item * transform(Item_transformer transformer, unsigned char *arg)
void fix_after_pullout(Select_Lex *new_parent, Item **ref)
void merge(Item_equal *item)
void sort(Item_field_cmpfunc cmp, void *arg)
virtual void print(String *str)
Item * transform(Item_transformer transformer, unsigned char *arg)
bool contains(Field *field)
bool fix_fields(Session *, Item **)
virtual void print(String *str)
virtual void print(String *str)
type::Decimal * val_decimal(type::Decimal *)
Item * find_item(String *str)
table_map not_null_tables() const
String * val_str(String *)
table_map not_null_tables() const
type::Decimal * decimal_op(type::Decimal *)
Performs the operation that this functions implements when the result type is DECIMAL.
double real_op()
Performs the operation that this functions implements when the result type is REAL.
String * str_op(String *)
int64_t int_op()
Performs the operation that this functions implements when the result type is INT.
void fix_length_and_dec()
table_map not_null_tables() const
String * val_str(String *str)
type::Decimal * val_decimal(type::Decimal *)
bool fix_fields(Session *, Item **)
String * str_op(String *str)
int64_t int_op()
Performs the operation that this functions implements when the result type is INT.
type::Decimal * decimal_op(type::Decimal *)
Performs the operation that this functions implements when the result type is DECIMAL.
double real_op()
Performs the operation that this functions implements when the result type is REAL.
bool fix_fields(Session *, Item **)
virtual void print(String *str)
Item * neg_transformer(Session *session)
virtual void print(String *str)
table_map not_null_tables() const
table_map not_null_tables() const
Item * neg_transformer(Session *session)
optimize_type select_optimize() const
bool turboBM_matches(const char *text, int text_len) const
void turboBM_compute_bad_character_shifts()
void turboBM_compute_good_suffix_shifts(int *suff)
void turboBM_compute_suffixes(int *suff)
virtual void top_level_item()
virtual void print(String *str)
Item * neg_transformer(Session *session)
virtual void print(String *str)
Item * neg_transformer(Session *session)
type::Decimal * val_decimal(type::Decimal *)
String * val_str(String *str)
virtual void print(String *str)
table_map not_null_tables() const
bool eq(const Item *item, bool binary_cmp) const
virtual void print(String *str)
table_map used_tables() const
virtual void print(String *str)
virtual int64_t val_int()
table_map used_tables() const
virtual bool const_item() const
virtual void print(String *str)
Item * transform(Item_transformer transformer, unsigned char *arg)
table_map used_tables() const
void update_used_tables()
virtual int64_t val_int()=0
virtual double val_real()=0
virtual String * val_str(String *str)=0
Convert from decimal to binary representation.
TODO: Rename this file - func.h is stupid.
enum_field_types agg_field_type(Item **items, uint32_t nitems)
Aggregates field types from the array of items.
Item * and_expressions(Item *a, Item *b, Item **org_item)