~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item/cmpfunc.h

  • Committer: Mark Atwood
  • Date: 2011-08-12 04:08:33 UTC
  • mfrom: (2385.2.17 refactor5)
  • Revision ID: me@mark.atwood.name-20110812040833-u6j85nc6ahuc0dtz
mergeĀ lp:~olafvdspek/drizzle/refactor5

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#ifndef DRIZZLED_ITEM_CMPFUNC_H
21
 
#define DRIZZLED_ITEM_CMPFUNC_H
 
20
#pragma once
22
21
 
23
22
/* compare and test functions */
24
23
 
25
 
#include "drizzled/comp_creator.h"
26
 
#include "drizzled/item/row.h"
27
 
#include "drizzled/item/sum.h"
28
 
#include "drizzled/item/int.h"
29
 
#include "drizzled/item/float.h"
30
 
#include "drizzled/item/string.h"
31
 
#include "drizzled/item/decimal.h"
32
 
#include "drizzled/function/math/int.h"
33
 
#include "drizzled/function/numhybrid.h"
34
 
#include "drizzled/common.h"
35
 
#include "drizzled/qsort_cmp.h"
36
 
#include "drizzled/item/function/boolean.h"
 
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>
37
36
 
38
 
namespace drizzled
39
 
{
 
37
namespace drizzled {
40
38
 
41
39
extern Item_result item_cmp_type(Item_result a,Item_result b);
42
40
 
43
 
class Item_bool_func2;
44
 
class Arg_comparator;
45
 
class Item_sum_hybrid;
46
 
class Item_row;
47
 
class Session;
48
 
 
49
41
typedef int (Arg_comparator::*arg_cmp_func)();
50
42
 
51
43
typedef int (*Item_field_cmpfunc)(Item_field *f1, Item_field *f2, void *arg);
75
67
public:
76
68
  DTCollation cmp_collation;
77
69
 
78
 
  Arg_comparator():
79
 
    session(current_session),
80
 
    a_cache(0),
81
 
    b_cache(0)
82
 
  {};
 
70
  Arg_comparator();
83
71
 
84
 
  Arg_comparator(Item **a1, Item **a2):
85
 
    a(a1),
86
 
    b(a2),
87
 
    session(current_session),
88
 
    a_cache(0),
89
 
    b_cache(0)
90
 
  {};
 
72
  Arg_comparator(Item **a1, Item **a2);
91
73
 
92
74
  int set_compare_func(Item_bool_func2 *owner, Item_result type);
93
75
  inline int set_compare_func(Item_bool_func2 *owner_arg)
149
131
  virtual bool val_bool();
150
132
  virtual int64_t val_int();
151
133
  virtual void fix_length_and_dec();
152
 
  virtual void print(String *str, enum_query_type query_type);
 
134
  virtual void print(String *str);
153
135
 
154
136
protected:
155
137
  Item_func_truth(Item *a, bool a_value, bool a_affirmative)
156
138
  : item::function::Boolean(a), value(a_value), affirmative(a_affirmative)
157
139
  {}
158
140
 
159
 
  ~Item_func_truth()
160
 
  {}
161
141
private:
162
142
  /**
163
143
    True for <code>X IS [NOT] TRUE</code>,
179
159
{
180
160
public:
181
161
  Item_func_istrue(Item *a) : Item_func_truth(a, true, true) {}
182
 
  ~Item_func_istrue() {}
183
162
  virtual const char* func_name() const { return "istrue"; }
184
163
};
185
164
 
192
171
{
193
172
public:
194
173
  Item_func_isnottrue(Item *a) : Item_func_truth(a, true, false) {}
195
 
  ~Item_func_isnottrue() {}
196
174
  virtual const char* func_name() const { return "isnottrue"; }
197
175
};
198
176
 
205
183
{
206
184
public:
207
185
  Item_func_isfalse(Item *a) : Item_func_truth(a, false, true) {}
208
 
  ~Item_func_isfalse() {}
209
186
  virtual const char* func_name() const { return "isfalse"; }
210
187
};
211
188
 
218
195
{
219
196
public:
220
197
  Item_func_isnotfalse(Item *a) : Item_func_truth(a, false, false) {}
221
 
  ~Item_func_isnotfalse() {}
222
198
  virtual const char* func_name() const { return "isnotfalse"; }
223
199
};
224
200
 
225
201
 
226
 
class Item_cache;
227
202
#define UNKNOWN ((bool)-1)
228
203
 
229
204
 
273
248
class Eq_creator :public Comp_creator
274
249
{
275
250
public:
276
 
  Eq_creator() {}                             /* Remove gcc warning */
277
 
  virtual ~Eq_creator() {}                    /* Remove gcc warning */
278
251
  virtual Item_bool_func2* create(Item *a, Item *b) const;
279
252
  virtual const char* symbol(bool invert) const { return invert? "<>" : "="; }
280
253
  virtual bool eqne_op() const { return 1; }
285
258
class Ne_creator :public Comp_creator
286
259
{
287
260
public:
288
 
  Ne_creator() {}                             /* Remove gcc warning */
289
 
  virtual ~Ne_creator() {}                    /* Remove gcc warning */
290
261
  virtual Item_bool_func2* create(Item *a, Item *b) const;
291
262
  virtual const char* symbol(bool invert) const { return invert? "=" : "<>"; }
292
263
  virtual bool eqne_op() const { return 1; }
297
268
class Gt_creator :public Comp_creator
298
269
{
299
270
public:
300
 
  Gt_creator() {}                             /* Remove gcc warning */
301
 
  virtual ~Gt_creator() {}                    /* Remove gcc warning */
302
271
  virtual Item_bool_func2* create(Item *a, Item *b) const;
303
272
  virtual const char* symbol(bool invert) const { return invert? "<=" : ">"; }
304
273
  virtual bool eqne_op() const { return 0; }
309
278
class Lt_creator :public Comp_creator
310
279
{
311
280
public:
312
 
  Lt_creator() {}                             /* Remove gcc warning */
313
 
  virtual ~Lt_creator() {}                    /* Remove gcc warning */
314
281
  virtual Item_bool_func2* create(Item *a, Item *b) const;
315
282
  virtual const char* symbol(bool invert) const { return invert? ">=" : "<"; }
316
283
  virtual bool eqne_op() const { return 0; }
321
288
class Ge_creator :public Comp_creator
322
289
{
323
290
public:
324
 
  Ge_creator() {}                             /* Remove gcc warning */
325
 
  virtual ~Ge_creator() {}                    /* Remove gcc warning */
326
291
  virtual Item_bool_func2* create(Item *a, Item *b) const;
327
292
  virtual const char* symbol(bool invert) const { return invert? "<" : ">="; }
328
293
  virtual bool eqne_op() const { return 0; }
333
298
class Le_creator :public Comp_creator
334
299
{
335
300
public:
336
 
  Le_creator() {}                             /* Remove gcc warning */
337
 
  virtual ~Le_creator() {}                    /* Remove gcc warning */
338
301
  virtual Item_bool_func2* create(Item *a, Item *b) const;
339
302
  virtual const char* symbol(bool invert) const { return invert? ">" : "<="; }
340
303
  virtual bool eqne_op() const { return 0; }
361
324
  virtual enum Functype rev_functype() const { return UNKNOWN_FUNC; }
362
325
  bool have_rev_func() const { return rev_functype() != UNKNOWN_FUNC; }
363
326
 
364
 
  virtual inline void print(String *str, enum_query_type query_type)
 
327
  virtual inline void print(String *str)
365
328
  {
366
 
    Item_func::print_op(str, query_type);
 
329
    Item_func::print_op(str);
367
330
  }
368
331
 
369
332
  bool is_null() { return test(args[0]->is_null() || args[1]->is_null()); }
370
333
  bool is_bool_func() { return 1; }
371
 
  const CHARSET_INFO *compare_collation() { return cmp.cmp_collation.collation; }
 
334
  const charset_info_st *compare_collation() { return cmp.cmp_collation.collation; }
372
335
  uint32_t decimal_precision() const { return 1; }
373
336
  void top_level_item() { abort_on_null= true; }
374
337
 
396
359
  enum Functype functype() const { return NOT_FUNC; }
397
360
  const char *func_name() const { return "not"; }
398
361
  Item *neg_transformer(Session *session);
399
 
  virtual void print(String *str, enum_query_type query_type);
 
362
  virtual void print(String *str);
400
363
};
401
364
 
402
 
class Item_maxmin_subselect;
403
 
 
404
365
/*
405
366
  trigcond<param>(arg) ::= param? arg : TRUE
406
367
 
463
424
  int64_t val_int();
464
425
  enum Functype functype() const { return NOT_ALL_FUNC; }
465
426
  const char *func_name() const { return "<not>"; }
466
 
  virtual void print(String *str, enum_query_type query_type);
 
427
  virtual void print(String *str);
467
428
  void set_sum_test(Item_sum_hybrid *item) { test_sum_item= item; };
468
429
  void set_sub_test(Item_maxmin_subselect *item) { test_sub_item= item; };
469
430
  bool empty_underlying_subquery();
625
586
  const char *func_name() const { return "between"; }
626
587
  bool fix_fields(Session *, Item **);
627
588
  void fix_length_and_dec();
628
 
  virtual void print(String *str, enum_query_type query_type);
 
589
  virtual void print(String *str);
629
590
  bool is_bool_func() { return 1; }
630
 
  const CHARSET_INFO *compare_collation() { return cmp_collation.collation; }
 
591
  const charset_info_st *compare_collation() { return cmp_collation.collation; }
631
592
  uint32_t decimal_precision() const { return 1; }
632
593
};
633
594
 
640
601
  optimize_type select_optimize() const { return OPTIMIZE_NONE; }
641
602
  const char *func_name() const { return "strcmp"; }
642
603
 
643
 
  virtual inline void print(String *str, enum_query_type query_type)
 
604
  virtual inline void print(String *str)
644
605
  {
645
 
    Item_func::print(str, query_type);
 
606
    Item_func::print(str);
646
607
  }
647
608
};
648
609
 
716
677
 
717
678
class Item_func_if :public Item_func
718
679
{
719
 
  enum Item_result cached_result_type;
 
680
  Item_result cached_result_type;
720
681
  enum_field_types cached_field_type;
 
682
 
721
683
public:
722
 
  Item_func_if(Item *a,Item *b,Item *c)
723
 
    :Item_func(a,b,c), cached_result_type(INT_RESULT)
 
684
  Item_func_if(Item *a, Item *b, Item *c) :
 
685
    Item_func(a,b,c),
 
686
    cached_result_type(INT_RESULT)
724
687
  {}
 
688
 
725
689
  double val_real();
726
690
  int64_t val_int();
727
691
  String *val_str(String *str);
728
692
  type::Decimal *val_decimal(type::Decimal *);
729
 
  enum Item_result result_type () const { return cached_result_type; }
 
693
  Item_result result_type () const { return cached_result_type; }
730
694
  enum_field_types field_type() const { return cached_field_type; }
731
695
  bool fix_fields(Session *, Item **);
732
696
  void fix_length_and_dec();
751
715
  uint32_t decimal_precision() const { return args[0]->decimal_precision(); }
752
716
  const char *func_name() const { return "nullif"; }
753
717
 
754
 
  virtual inline void print(String *str, enum_query_type query_type)
 
718
  virtual inline void print(String *str)
755
719
  {
756
 
    Item_func::print(str, query_type);
 
720
    Item_func::print(str);
757
721
  }
758
722
 
759
723
  table_map not_null_tables() const { return 0; }
772
736
  char *base;
773
737
  uint32_t size;
774
738
  qsort2_cmp compare;
775
 
  const CHARSET_INFO *collation;
 
739
  const charset_info_st *collation;
776
740
  uint32_t count;
777
741
  uint32_t used_count;
778
742
  in_vector() {}
779
743
  in_vector(uint32_t elements,uint32_t element_length,qsort2_cmp cmp_func,
780
 
            const CHARSET_INFO * const cmp_coll)
 
744
            const charset_info_st * const cmp_coll)
781
745
    :base((char*) memory::sql_calloc(elements*element_length)),
782
746
     size(element_length), compare(cmp_func), collation(cmp_coll),
783
747
     count(elements), used_count(elements) {}
820
784
  char buff[STRING_BUFFER_USUAL_SIZE];
821
785
  String tmp;
822
786
public:
823
 
  in_string(uint32_t elements,qsort2_cmp cmp_func, const CHARSET_INFO * const cs);
 
787
  in_string(uint32_t elements,qsort2_cmp cmp_func, const charset_info_st * const cs);
824
788
  ~in_string();
825
789
  void set(uint32_t pos,Item *item);
826
790
  unsigned char *get_value(Item *item);
890
854
  /* Cache for the left item. */
891
855
  Item *lval_cache;
892
856
 
893
 
  in_datetime(Item *warn_item_arg, uint32_t elements)
894
 
    :in_int64_t(elements), session(current_session), warn_item(warn_item_arg),
895
 
     lval_cache(0) {};
 
857
  in_datetime(Item *warn_item_arg, uint32_t elements);
 
858
 
896
859
  void set(uint32_t pos,Item *item);
897
860
  unsigned char *get_value(Item *item);
898
861
  friend int cmp_int64_t(void *cmp_arg, packed_int64_t *a,packed_int64_t *b);
947
910
class cmp_item :public memory::SqlAlloc
948
911
{
949
912
public:
950
 
  const CHARSET_INFO *cmp_charset;
 
913
  const charset_info_st *cmp_charset;
951
914
 
952
915
  cmp_item()
953
916
  {
959
922
  virtual int cmp(Item *item)= 0;
960
923
  // for optimized IN with row
961
924
  virtual int compare(cmp_item *item)= 0;
962
 
  static cmp_item* get_comparator(Item_result type, const CHARSET_INFO * const cs);
 
925
  static cmp_item* get_comparator(Item_result type, const charset_info_st * const cs);
963
926
  virtual cmp_item *make_same()= 0;
964
927
  virtual void store_value_by_template(cmp_item *, Item *item)
965
928
  {
973
936
  String *value_res;
974
937
public:
975
938
  cmp_item_string () {}
976
 
  cmp_item_string (const CHARSET_INFO * const cs) { cmp_charset= cs; }
977
 
  void set_charset(const CHARSET_INFO * const cs) { cmp_charset= cs; }
 
939
  cmp_item_string (const charset_info_st * const cs) { cmp_charset= cs; }
 
940
  void set_charset(const charset_info_st * const cs) { cmp_charset= cs; }
978
941
  friend class cmp_item_sort_string;
979
942
  friend class cmp_item_sort_string_in_static;
980
943
};
987
950
public:
988
951
  cmp_item_sort_string():
989
952
    cmp_item_string() {}
990
 
  cmp_item_sort_string(const CHARSET_INFO * const cs):
 
953
  cmp_item_sort_string(const charset_info_st * const cs):
991
954
    cmp_item_string(cs),
992
955
    value(value_buff, sizeof(value_buff), cs) {}
993
956
  void store_value(Item *item)
1008
971
    return sortcmp(value_res, l_cmp->value_res, cmp_charset);
1009
972
  }
1010
973
  cmp_item *make_same();
1011
 
  void set_charset(const CHARSET_INFO * const cs)
 
974
  void set_charset(const charset_info_st * const cs)
1012
975
  {
1013
976
    cmp_charset= cs;
1014
977
    value.set_quick(value_buff, sizeof(value_buff), cs);
1019
982
{
1020
983
  int64_t value;
1021
984
public:
1022
 
  cmp_item_int() {}                           /* Remove gcc warning */
1023
985
  void store_value(Item *item)
1024
986
  {
1025
987
    value= item->val_int();
1053
1015
  /* Cache for the left item. */
1054
1016
  Item *lval_cache;
1055
1017
 
1056
 
  cmp_item_datetime(Item *warn_item_arg)
1057
 
    :session(current_session), warn_item(warn_item_arg), lval_cache(0) {}
 
1018
  cmp_item_datetime(Item *warn_item_arg);
 
1019
 
1058
1020
  void store_value(Item *item);
1059
1021
  int cmp(Item *arg);
1060
1022
  int compare(cmp_item *ci);
1065
1027
{
1066
1028
  double value;
1067
1029
public:
1068
 
  cmp_item_real() {}                          /* Remove gcc warning */
1069
1030
  void store_value(Item *item)
1070
1031
  {
1071
1032
    value= item->val_real();
1087
1048
{
1088
1049
  type::Decimal value;
1089
1050
public:
1090
 
  cmp_item_decimal() {}                       /* Remove gcc warning */
1091
1051
  void store_value(Item *item);
1092
1052
  int cmp(Item *arg);
1093
1053
  int compare(cmp_item *c);
1105
1065
 protected:
1106
1066
  String value;
1107
1067
public:
1108
 
  cmp_item_sort_string_in_static(const CHARSET_INFO * const cs):
 
1068
  cmp_item_sort_string_in_static(const charset_info_st * const cs):
1109
1069
    cmp_item_string(cs) {}
1110
1070
  void store_value(Item *item)
1111
1071
  {
1163
1123
    :Item_func(), first_expr_num(-1), else_expr_num(-1),
1164
1124
    cached_result_type(INT_RESULT), left_result_type(INT_RESULT), case_item(0)
1165
1125
  {
1166
 
    ncases= list.elements;
 
1126
    ncases= list.size();
1167
1127
    if (first_expr_arg)
1168
1128
    {
1169
 
      first_expr_num= list.elements;
 
1129
      first_expr_num= list.size();
1170
1130
      list.push_back(first_expr_arg);
1171
1131
    }
1172
1132
    if (else_expr_arg)
1173
1133
    {
1174
 
      else_expr_num= list.elements;
 
1134
      else_expr_num= list.size();
1175
1135
      list.push_back(else_expr_arg);
1176
1136
    }
1177
1137
    set_arguments(list);
1188
1148
  enum Item_result result_type () const { return cached_result_type; }
1189
1149
  enum_field_types field_type() const { return cached_field_type; }
1190
1150
  const char *func_name() const { return "case"; }
1191
 
  virtual void print(String *str, enum_query_type query_type);
 
1151
  virtual void print(String *str);
1192
1152
  Item *find_item(String *str);
1193
 
  const CHARSET_INFO *compare_collation() { return cmp_collation.collation; }
 
1153
  const charset_info_st *compare_collation() { return cmp_collation.collation; }
1194
1154
  void cleanup();
1195
1155
  void agg_str_lengths(Item *arg);
1196
1156
  void agg_num_lengths(Item *arg);
1253
1213
  }
1254
1214
  optimize_type select_optimize() const
1255
1215
    { return OPTIMIZE_KEY; }
1256
 
  virtual void print(String *str, enum_query_type query_type);
 
1216
  virtual void print(String *str);
1257
1217
  enum Functype functype() const { return IN_FUNC; }
1258
1218
  const char *func_name() const { return " IN "; }
1259
1219
  bool nulls_in_row();
1260
1220
  bool is_bool_func() { return 1; }
1261
 
  const CHARSET_INFO *compare_collation() { return cmp_collation.collation; }
 
1221
  const charset_info_st *compare_collation() { return cmp_collation.collation; }
1262
1222
};
1263
1223
 
1264
1224
class cmp_item_row :public cmp_item
1329
1289
  table_map not_null_tables() const { return 0; }
1330
1290
  optimize_type select_optimize() const { return OPTIMIZE_NULL; }
1331
1291
  Item *neg_transformer(Session *session);
1332
 
  const CHARSET_INFO *compare_collation() { return args[0]->collation.collation; }
 
1292
  const charset_info_st *compare_collation() { return args[0]->collation.collation; }
1333
1293
};
1334
1294
 
1335
1295
/* Functions used by HAVING for rewriting IN subquery */
1336
1296
 
1337
 
class Item_in_subselect;
1338
 
 
1339
1297
/*
1340
1298
  This is like IS NOT NULL but it also remembers if it ever has
1341
1299
  encountered a NULL.
1375
1333
  table_map not_null_tables() const
1376
1334
  { return abort_on_null ? not_null_tables_cache : 0; }
1377
1335
  Item *neg_transformer(Session *session);
1378
 
  virtual void print(String *str, enum_query_type query_type);
1379
 
  const CHARSET_INFO *compare_collation() { return args[0]->collation.collation; }
 
1336
  virtual void print(String *str);
 
1337
  const charset_info_st *compare_collation() { return args[0]->collation.collation; }
1380
1338
  void top_level_item() { abort_on_null=1; }
1381
1339
};
1382
1340
 
1421
1379
};
1422
1380
 
1423
1381
 
1424
 
typedef class Item COND;
1425
 
 
1426
1382
class Item_cond :public item::function::Boolean
1427
1383
{
1428
1384
protected:
1446
1402
  Item_cond(Session *session, Item_cond *item);
1447
1403
  Item_cond(List<Item> &nlist)
1448
1404
    :item::function::Boolean(), list(nlist), abort_on_null(0) {}
1449
 
  bool add(Item *item) { return list.push_back(item); }
1450
 
  bool add_at_head(Item *item) { return list.push_front(item); }
 
1405
  void add(Item *item) { list.push_back(item); }
 
1406
  void add_at_head(Item *item) { list.push_front(item); }
1451
1407
  void add_at_head(List<Item> *nlist) { list.prepand(nlist); }
1452
1408
  bool fix_fields(Session *, Item **ref);
1453
1409
  void fix_after_pullout(Select_Lex *new_parent, Item **ref);
1456
1412
  List<Item>* argument_list() { return &list; }
1457
1413
  table_map used_tables() const;
1458
1414
  void update_used_tables();
1459
 
  virtual void print(String *str, enum_query_type query_type);
 
1415
  virtual void print(String *str);
1460
1416
  void split_sum_func(Session *session, Item **ref_pointer_array, List<Item> &fields);
1461
1417
  friend int setup_conds(Session *session, TableList *tables, TableList *leaves,
1462
1418
                         COND **conds);
1551
1507
 
1552
1508
class Item_equal: public item::function::Boolean
1553
1509
{
1554
 
  List<Item_field> fields; /* list of equal field items                    */
1555
 
  Item *const_item;        /* optional constant item equal to fields items */
1556
 
  cmp_item *eval_item;
1557
 
  bool cond_false;
 
1510
public:
 
1511
  typedef List<Item_field> fields_t;
1558
1512
 
1559
 
public:
1560
 
  inline Item_equal() :
1561
 
    item::function::Boolean(),
 
1513
  Item_equal() :
1562
1514
    const_item(0),
1563
1515
    eval_item(0),
1564
1516
    cond_false(0)
1566
1518
    const_item_cache=0;
1567
1519
  }
1568
1520
 
 
1521
  fields_t::iterator begin()
 
1522
  {
 
1523
    return fields.begin();
 
1524
  }
 
1525
 
1569
1526
  Item_equal(Item_field *f1, Item_field *f2);
1570
1527
  Item_equal(Item *c, Item_field *f);
1571
1528
  Item_equal(Item_equal *item_equal);
1574
1531
  void add(Item_field *f);
1575
1532
  uint32_t members();
1576
1533
  bool contains(Field *field);
1577
 
  Item_field* get_first() { return fields.head(); }
 
1534
  Item_field* get_first() { return &fields.front(); }
1578
1535
  void merge(Item_equal *item);
1579
1536
  void update_const();
1580
1537
  enum Functype functype() const { return MULT_EQUAL_FUNC; }
1582
1539
  const char *func_name() const { return "multiple equal"; }
1583
1540
  optimize_type select_optimize() const { return OPTIMIZE_EQUAL; }
1584
1541
  void sort(Item_field_cmpfunc cmp, void *arg);
1585
 
  friend class Item_equal_iterator;
1586
1542
  void fix_length_and_dec();
1587
1543
  bool fix_fields(Session *session, Item **ref);
1588
1544
  void update_used_tables();
1589
1545
  bool walk(Item_processor processor, bool walk_subquery, unsigned char *arg);
1590
1546
  Item *transform(Item_transformer transformer, unsigned char *arg);
1591
 
  virtual void print(String *str, enum_query_type query_type);
1592
 
  const CHARSET_INFO *compare_collation()
1593
 
  { return fields.head()->collation.collation; }
 
1547
  virtual void print(String *str);
 
1548
  const charset_info_st *compare_collation()
 
1549
  { return fields.front().collation.collation; }
 
1550
private:
 
1551
  fields_t fields; /* list of equal field items                    */
 
1552
  Item *const_item;        /* optional constant item equal to fields items */
 
1553
  cmp_item *eval_item;
 
1554
  bool cond_false;
 
1555
 
1594
1556
};
1595
1557
 
1596
1558
class COND_EQUAL: public memory::SqlAlloc
1607
1569
  }
1608
1570
};
1609
1571
 
1610
 
 
1611
 
class Item_equal_iterator : public List_iterator_fast<Item_field>
1612
 
{
1613
 
public:
1614
 
  inline Item_equal_iterator(Item_equal &item_equal)
1615
 
    :List_iterator_fast<Item_field> (item_equal.fields)
1616
 
  {}
1617
 
  inline Item_field* operator++(int)
1618
 
  {
1619
 
    Item_field *item= (*(List_iterator_fast<Item_field> *) this)++;
1620
 
    return  item;
1621
 
  }
1622
 
  inline void rewind(void)
1623
 
  {
1624
 
    List_iterator_fast<Item_field>::rewind();
1625
 
  }
1626
 
};
 
1572
typedef List<Item_field>::iterator Item_equal_iterator;
1627
1573
 
1628
1574
class Item_cond_and :public Item_cond
1629
1575
{
1643
1589
  Item* copy_andor_structure(Session *session)
1644
1590
  {
1645
1591
    Item_cond_and *item;
1646
 
    if ((item= new Item_cond_and(session, this)))
1647
 
       item->copy_andor_arguments(session, this);
 
1592
    item= new Item_cond_and(session, this);
 
1593
    item->copy_andor_arguments(session, this);
1648
1594
    return item;
1649
1595
  }
1650
1596
  Item *neg_transformer(Session *session);
1673
1619
  Item* copy_andor_structure(Session *session)
1674
1620
  {
1675
1621
    Item_cond_or *item;
1676
 
    if ((item= new Item_cond_or(session, this)))
1677
 
      item->copy_andor_arguments(session, this);
 
1622
    item= new Item_cond_or(session, this);
 
1623
    item->copy_andor_arguments(session, this);
1678
1624
    return item;
1679
1625
  }
1680
1626
  Item *neg_transformer(Session *session);
1723
1669
 
1724
1670
} /* namespace drizzled */
1725
1671
 
1726
 
#endif /* DRIZZLED_ITEM_CMPFUNC_H */