~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item/cmpfunc.h

  • Committer: Brian Aker
  • Date: 2011-01-26 18:29:34 UTC
  • mto: (2122.1.3 build)
  • mto: This revision was merged to the branch mainline in revision 2123.
  • Revision ID: brian@tangent.org-20110126182934-hsboi3ab5105on1g
fix test case along with the error message for TIME.

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
 
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)
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;
1042
1037
  /* Cache for the left item. */
1043
1038
  Item *lval_cache;
1044
1039
 
1045
 
  cmp_item_datetime(Item *warn_item_arg);
1046
 
 
 
1040
  cmp_item_datetime(Item *warn_item_arg)
 
1041
    :session(current_session), warn_item(warn_item_arg), lval_cache(0) {}
1047
1042
  void store_value(Item *item);
1048
1043
  int cmp(Item *arg);
1049
1044
  int compare(cmp_item *ci);
1540
1535
 
1541
1536
class Item_equal: public item::function::Boolean
1542
1537
{
 
1538
  List<Item_field> fields; /* list of equal field items                    */
 
1539
  Item *const_item;        /* optional constant item equal to fields items */
 
1540
  cmp_item *eval_item;
 
1541
  bool cond_false;
 
1542
 
1543
1543
public:
1544
 
  typedef List<Item_field> fields_t;
1545
 
 
1546
 
  Item_equal() :
 
1544
  inline Item_equal() :
 
1545
    item::function::Boolean(),
1547
1546
    const_item(0),
1548
1547
    eval_item(0),
1549
1548
    cond_false(0)
1551
1550
    const_item_cache=0;
1552
1551
  }
1553
1552
 
1554
 
  fields_t::iterator begin()
1555
 
  {
1556
 
    return fields.begin();
1557
 
  }
1558
 
 
1559
1553
  Item_equal(Item_field *f1, Item_field *f2);
1560
1554
  Item_equal(Item *c, Item_field *f);
1561
1555
  Item_equal(Item_equal *item_equal);
1581
1575
  virtual void print(String *str, enum_query_type query_type);
1582
1576
  const CHARSET_INFO *compare_collation()
1583
1577
  { 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
1578
};
1591
1579
 
1592
1580
class COND_EQUAL: public memory::SqlAlloc
1604
1592
};
1605
1593
 
1606
1594
 
1607
 
class Item_equal_iterator : public List<Item_field>::iterator
 
1595
class Item_equal_iterator : public List_iterator_fast<Item_field>
1608
1596
{
1609
1597
public:
1610
1598
  inline Item_equal_iterator(Item_equal &item_equal)
1611
 
    :List<Item_field>::iterator (item_equal.fields.begin() )
 
1599
    :List_iterator_fast<Item_field> (item_equal.fields)
1612
1600
  {}
1613
1601
  inline Item_field* operator++(int)
1614
1602
  {
1615
 
    Item_field *item= (*(List<Item_field>::iterator *) this)++;
 
1603
    Item_field *item= (*(List_iterator_fast<Item_field> *) this)++;
1616
1604
    return  item;
1617
1605
  }
 
1606
  inline void rewind(void)
 
1607
  {
 
1608
    List_iterator_fast<Item_field>::rewind();
 
1609
  }
1618
1610
};
1619
1611
 
1620
1612
class Item_cond_and :public Item_cond