~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item/cmpfunc.h

  • Committer: Patrick Galbraith
  • Date: 2009-10-08 22:42:05 UTC
  • mto: (1166.5.3 memcached_functions)
  • mto: This revision was merged to the branch mainline in revision 1189.
  • Revision ID: patg@patrick-galbraiths-macbook-pro.local-20091008224205-gq1pehjsivvx0qo9
Starting over with a fresh tree, moved in memcached functions.

Memcached Functions for Drizzle. 

All tests pass.

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
#include "drizzled/item/sum.h"
28
28
#include "drizzled/item/int.h"
29
29
#include "drizzled/item/float.h"
30
 
#include "drizzled/item/string.h"
31
30
#include "drizzled/item/decimal.h"
32
31
#include "drizzled/function/math/int.h"
33
32
#include "drizzled/function/numhybrid.h"
34
33
#include "drizzled/session.h"
35
 
#include "drizzled/common.h"
36
 
#include "drizzled/qsort_cmp.h"
37
 
 
38
 
namespace drizzled
39
 
{
40
34
 
41
35
extern Item_result item_cmp_type(Item_result a,Item_result b);
42
36
class Item_bool_func2;
48
42
 
49
43
typedef int (*Item_field_cmpfunc)(Item_field *f1, Item_field *f2, void *arg);
50
44
 
51
 
uint64_t get_datetime_value(Session *session, 
52
 
                            Item ***item_arg, 
53
 
                            Item **cache_arg,
54
 
                            Item *warn_item, 
55
 
                            bool *is_null);
56
 
 
57
 
class Arg_comparator: public memory::SqlAlloc
 
45
class Arg_comparator: public Sql_alloc
58
46
{
59
47
  Item **a, **b;
60
48
  arg_cmp_func func;
766
754
 
767
755
/* A vector of values of some type  */
768
756
 
769
 
class in_vector :public memory::SqlAlloc
 
757
class in_vector :public Sql_alloc
770
758
{
771
759
public:
772
760
  char *base;
778
766
  in_vector() {}
779
767
  in_vector(uint32_t elements,uint32_t element_length,qsort2_cmp cmp_func,
780
768
            const CHARSET_INFO * const cmp_coll)
781
 
    :base((char*) memory::sql_calloc(elements*element_length)),
 
769
    :base((char*) sql_calloc(elements*element_length)),
782
770
     size(element_length), compare(cmp_func), collation(cmp_coll),
783
771
     count(elements), used_count(elements) {}
784
772
  virtual ~in_vector() {}
785
773
  virtual void set(uint32_t pos,Item *item)=0;
786
774
  virtual unsigned char *get_value(Item *item)=0;
787
 
  void sort();
 
775
  void sort()
 
776
  {
 
777
    my_qsort2(base,used_count,size,compare, (void *) collation);
 
778
  }
788
779
  int find(Item *item);
789
780
 
790
781
  /*
944
935
** Classes for easy comparing of non const items
945
936
*/
946
937
 
947
 
class cmp_item :public memory::SqlAlloc
 
938
class cmp_item :public Sql_alloc
948
939
{
949
940
public:
950
941
  const CHARSET_INFO *cmp_charset;
1150
1141
  Item_result cmp_type;
1151
1142
  DTCollation cmp_collation;
1152
1143
  enum_field_types cached_field_type;
1153
 
  cmp_item *cmp_items[DECIMAL_RESULT+1]; /* For all result types */
 
1144
  cmp_item *cmp_items[5]; /* For all result types */
1154
1145
  cmp_item *case_item;
1155
1146
public:
1156
1147
  Item_func_case(List<Item> &list, Item *first_expr_arg, Item *else_expr_arg)
1235
1226
  uint32_t decimal_precision() const { return 1; }
1236
1227
  void cleanup()
1237
1228
  {
 
1229
    uint32_t i;
1238
1230
    Item_int_func::cleanup();
1239
1231
    delete array;
1240
1232
    array= 0;
1241
 
    for (int i= STRING_RESULT; i <= DECIMAL_RESULT; i++)
 
1233
    for (i= 0; i <= (uint32_t)DECIMAL_RESULT + 1; i++)
1242
1234
    {
1243
1235
      delete cmp_items[i];
1244
1236
      cmp_items[i]= 0;
1580
1572
  { return fields.head()->collation.collation; }
1581
1573
};
1582
1574
 
1583
 
class COND_EQUAL: public memory::SqlAlloc
 
1575
class COND_EQUAL: public Sql_alloc
1584
1576
{
1585
1577
public:
1586
1578
  uint32_t max_members;               /* max number of members the current level
1694
1686
  void top_level_item() {}
1695
1687
};
1696
1688
 
1697
 
enum_field_types agg_field_type(Item **items, uint32_t nitems);
1698
 
 
1699
1689
 
1700
1690
/* Some useful inline functions */
1701
1691
 
1708
1698
 
1709
1699
Item *and_expressions(Item *a, Item *b, Item **org_item);
1710
1700
 
1711
 
} /* namespace drizzled */
1712
 
 
1713
1701
#endif /* DRIZZLED_ITEM_CMPFUNC_H */