~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item/cmpfunc.h

  • Committer: Brian Aker
  • Date: 2011-01-12 06:45:23 UTC
  • mto: (2073.1.4 catalogs)
  • mto: This revision was merged to the branch mainline in revision 2080.
  • Revision ID: brian@tangent.org-20110112064523-rqhptaqbph22qmj1
RemoveĀ customĀ error.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
 
23
23
/* compare and test functions */
24
24
 
25
 
#include <drizzled/common.h>
26
 
#include <drizzled/comp_creator.h>
27
 
#include <drizzled/function/math/int.h>
28
 
#include <drizzled/function/numhybrid.h>
29
 
#include <drizzled/item/decimal.h>
30
 
#include <drizzled/item/float.h>
31
 
#include <drizzled/item/function/boolean.h>
32
 
#include <drizzled/item/int.h>
33
 
#include <drizzled/item/row.h>
34
 
#include <drizzled/item/string.h>
35
 
#include <drizzled/item/sum.h>
36
 
#include <drizzled/qsort_cmp.h>
 
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/session.h"
 
35
#include "drizzled/common.h"
 
36
#include "drizzled/qsort_cmp.h"
 
37
#include "drizzled/item/function/boolean.h"
37
38
 
38
39
namespace drizzled
39
40
{
40
41
 
41
42
extern Item_result item_cmp_type(Item_result a,Item_result b);
42
 
 
43
43
class Item_bool_func2;
44
44
class Arg_comparator;
45
45
class Item_sum_hybrid;
46
46
class Item_row;
47
 
class Session;
48
47
 
49
48
typedef int (Arg_comparator::*arg_cmp_func)();
50
49
 
51
50
typedef int (*Item_field_cmpfunc)(Item_field *f1, Item_field *f2, void *arg);
52
51
 
53
 
int64_t get_datetime_value(Session *session, 
54
 
                           Item ***item_arg, 
55
 
                           Item **cache_arg,
56
 
                           Item *warn_item, 
57
 
                           bool *is_null);
 
52
uint64_t get_datetime_value(Session *session, 
 
53
                            Item ***item_arg, 
 
54
                            Item **cache_arg,
 
55
                            Item *warn_item, 
 
56
                            bool *is_null);
58
57
 
59
58
class Arg_comparator: public memory::SqlAlloc
60
59
{
70
69
  bool is_nulls_eq;                // TRUE <=> compare for the EQUAL_FUNC
71
70
  enum enum_date_cmp_type { CMP_DATE_DFLT= 0, CMP_DATE_WITH_DATE,
72
71
                            CMP_DATE_WITH_STR, CMP_STR_WITH_DATE };
73
 
  int64_t (*get_value_func)(Session *session, Item ***item_arg, Item **cache_arg,
74
 
                            Item *warn_item, bool *is_null);
 
72
  uint64_t (*get_value_func)(Session *session, Item ***item_arg, Item **cache_arg,
 
73
                              Item *warn_item, bool *is_null);
75
74
public:
76
75
  DTCollation cmp_collation;
77
76
 
78
 
  Arg_comparator();
79
 
 
80
 
  Arg_comparator(Item **a1, Item **a2);
 
77
  Arg_comparator(): session(0), a_cache(0), b_cache(0) {};
 
78
  Arg_comparator(Item **a1, Item **a2): a(a1), b(a2), session(0),
 
79
    a_cache(0), b_cache(0) {};
81
80
 
82
81
  int set_compare_func(Item_bool_func2 *owner, Item_result type);
83
82
  inline int set_compare_func(Item_bool_func2 *owner_arg)
119
118
  int compare_datetime();        // compare args[0] & args[1] as DATETIMEs
120
119
 
121
120
  static enum enum_date_cmp_type can_compare_as_dates(Item *a, Item *b,
122
 
                                                      int64_t *const_val_arg);
 
121
                                                      uint64_t *const_val_arg);
123
122
 
124
123
  void set_datetime_cmp_func(Item **a1, Item **b1);
125
124
  static arg_cmp_func comparator_matrix [5][2];
880
879
  /* Cache for the left item. */
881
880
  Item *lval_cache;
882
881
 
883
 
  in_datetime(Item *warn_item_arg, uint32_t elements);
884
 
 
 
882
  in_datetime(Item *warn_item_arg, uint32_t elements)
 
883
    :in_int64_t(elements), session(current_session), warn_item(warn_item_arg),
 
884
     lval_cache(0) {};
885
885
  void set(uint32_t pos,Item *item);
886
886
  unsigned char *get_value(Item *item);
887
887
  friend int cmp_int64_t(void *cmp_arg, packed_int64_t *a,packed_int64_t *b);
937
937
{
938
938
public:
939
939
  const CHARSET_INFO *cmp_charset;
940
 
 
941
 
  cmp_item()
942
 
  {
943
 
    cmp_charset= &my_charset_bin;
944
 
  }
945
 
 
 
940
  cmp_item() { cmp_charset= &my_charset_bin; }
946
941
  virtual ~cmp_item() {}
947
942
  virtual void store_value(Item *item)= 0;
948
943
  virtual int cmp(Item *item)= 0;
1033
1028
*/
1034
1029
class cmp_item_datetime :public cmp_item
1035
1030
{
1036
 
  int64_t value;
1037
 
 
 
1031
  uint64_t value;
1038
1032
public:
1039
1033
  Session *session;
1040
1034
  /* Item used for issuing warnings. */
1042
1036
  /* Cache for the left item. */
1043
1037
  Item *lval_cache;
1044
1038
 
1045
 
  cmp_item_datetime(Item *warn_item_arg);
1046
 
 
 
1039
  cmp_item_datetime(Item *warn_item_arg)
 
1040
    :session(current_session), warn_item(warn_item_arg), lval_cache(0) {}
1047
1041
  void store_value(Item *item);
1048
1042
  int cmp(Item *arg);
1049
1043
  int compare(cmp_item *ci);
1540
1534
 
1541
1535
class Item_equal: public item::function::Boolean
1542
1536
{
 
1537
  List<Item_field> fields; /* list of equal field items                    */
 
1538
  Item *const_item;        /* optional constant item equal to fields items */
 
1539
  cmp_item *eval_item;
 
1540
  bool cond_false;
 
1541
 
1543
1542
public:
1544
 
  typedef List<Item_field> fields_t;
1545
 
 
1546
 
  Item_equal() :
 
1543
  inline Item_equal() :
 
1544
    item::function::Boolean(),
1547
1545
    const_item(0),
1548
1546
    eval_item(0),
1549
1547
    cond_false(0)
1551
1549
    const_item_cache=0;
1552
1550
  }
1553
1551
 
1554
 
  fields_t::iterator begin()
1555
 
  {
1556
 
    return fields.begin();
1557
 
  }
1558
 
 
1559
1552
  Item_equal(Item_field *f1, Item_field *f2);
1560
1553
  Item_equal(Item *c, Item_field *f);
1561
1554
  Item_equal(Item_equal *item_equal);
1581
1574
  virtual void print(String *str, enum_query_type query_type);
1582
1575
  const CHARSET_INFO *compare_collation()
1583
1576
  { return fields.head()->collation.collation; }
1584
 
private:
1585
 
  fields_t fields; /* list of equal field items                    */
1586
 
  Item *const_item;        /* optional constant item equal to fields items */
1587
 
  cmp_item *eval_item;
1588
 
  bool cond_false;
1589
 
 
1590
1577
};
1591
1578
 
1592
1579
class COND_EQUAL: public memory::SqlAlloc
1604
1591
};
1605
1592
 
1606
1593
 
1607
 
class Item_equal_iterator : public List<Item_field>::iterator
 
1594
class Item_equal_iterator : public List_iterator_fast<Item_field>
1608
1595
{
1609
1596
public:
1610
1597
  inline Item_equal_iterator(Item_equal &item_equal)
1611
 
    :List<Item_field>::iterator (item_equal.fields.begin() )
 
1598
    :List_iterator_fast<Item_field> (item_equal.fields)
1612
1599
  {}
1613
1600
  inline Item_field* operator++(int)
1614
1601
  {
1615
 
    Item_field *item= (*(List<Item_field>::iterator *) this)++;
 
1602
    Item_field *item= (*(List_iterator_fast<Item_field> *) this)++;
1616
1603
    return  item;
1617
1604
  }
 
1605
  inline void rewind(void)
 
1606
  {
 
1607
    List_iterator_fast<Item_field>::rewind();
 
1608
  }
1618
1609
};
1619
1610
 
1620
1611
class Item_cond_and :public Item_cond