~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item.h

  • Committer: Monty Taylor
  • Date: 2008-11-14 23:27:02 UTC
  • mto: (584.1.7 devel)
  • mto: This revision was merged to the branch mainline in revision 588.
  • Revision ID: monty@inaugust.com-20081114232702-xd6jzs32qw21akyc
Split out DTCollation.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
#ifndef drizzled_item_h
21
21
#define drizzled_item_h
22
22
 
 
23
#include <drizzled/dtcollation.h>
 
24
 
23
25
class Protocol;
24
26
struct TableList;
25
27
void item_init(void);                   /* Init item functions */
26
28
class Item_field;
27
29
 
28
 
/*
29
 
   "Declared Type Collation"
30
 
   A combination of collation and its derivation.
31
 
 
32
 
  Flags for collation aggregation modes:
33
 
  MY_COLL_ALLOW_SUPERSET_CONV  - allow conversion to a superset
34
 
  MY_COLL_ALLOW_COERCIBLE_CONV - allow conversion of a coercible value
35
 
                                 (i.e. constant).
36
 
  MY_COLL_ALLOW_CONV           - allow any kind of conversion
37
 
                                 (combination of the above two)
38
 
  MY_COLL_DISALLOW_NONE        - don't allow return DERIVATION_NONE
39
 
                                 (e.g. when aggregating for comparison)
40
 
  MY_COLL_CMP_CONV             - combination of MY_COLL_ALLOW_CONV
41
 
                                 and MY_COLL_DISALLOW_NONE
42
 
*/
43
 
 
44
 
#define MY_COLL_ALLOW_SUPERSET_CONV   1
45
 
#define MY_COLL_ALLOW_COERCIBLE_CONV  2
46
 
#define MY_COLL_ALLOW_CONV            3
47
 
#define MY_COLL_DISALLOW_NONE         4
48
 
#define MY_COLL_CMP_CONV              7
49
 
 
50
 
class DTCollation {
51
 
public:
52
 
  const CHARSET_INFO *collation;
53
 
  enum Derivation derivation;
54
 
  uint32_t repertoire;
55
 
  
56
 
  void set_repertoire_from_charset(const CHARSET_INFO * const cs)
57
 
  {
58
 
    repertoire= cs->state & MY_CS_PUREASCII ?
59
 
                MY_REPERTOIRE_ASCII : MY_REPERTOIRE_UNICODE30;
60
 
  }
61
 
  DTCollation()
62
 
  {
63
 
    collation= &my_charset_bin;
64
 
    derivation= DERIVATION_NONE;
65
 
    repertoire= MY_REPERTOIRE_UNICODE30;
66
 
  }
67
 
  DTCollation(const CHARSET_INFO * const collation_arg, Derivation derivation_arg)
68
 
  {
69
 
    collation= collation_arg;
70
 
    derivation= derivation_arg;
71
 
    set_repertoire_from_charset(collation_arg);
72
 
  }
73
 
  void set(DTCollation &dt)
74
 
  { 
75
 
    collation= dt.collation;
76
 
    derivation= dt.derivation;
77
 
    repertoire= dt.repertoire;
78
 
  }
79
 
  void set(const CHARSET_INFO * const collation_arg, Derivation derivation_arg)
80
 
  {
81
 
    collation= collation_arg;
82
 
    derivation= derivation_arg;
83
 
    set_repertoire_from_charset(collation_arg);
84
 
  }
85
 
  void set(const CHARSET_INFO * const collation_arg,
86
 
           Derivation derivation_arg,
87
 
           uint32_t repertoire_arg)
88
 
  {
89
 
    collation= collation_arg;
90
 
    derivation= derivation_arg;
91
 
    repertoire= repertoire_arg;
92
 
  }
93
 
  void set(const CHARSET_INFO * const collation_arg)
94
 
  {
95
 
    collation= collation_arg;
96
 
    set_repertoire_from_charset(collation_arg);
97
 
  }
98
 
  void set(Derivation derivation_arg)
99
 
  { derivation= derivation_arg; }
100
 
  bool aggregate(DTCollation &dt, uint32_t flags= 0);
101
 
  bool set(DTCollation &dt1, DTCollation &dt2, uint32_t flags= 0)
102
 
  { set(dt1); return aggregate(dt2, flags); }
103
 
  const char *derivation_name() const
104
 
  {
105
 
    switch(derivation)
106
 
    {
107
 
      case DERIVATION_IGNORABLE: return "IGNORABLE";
108
 
      case DERIVATION_COERCIBLE: return "COERCIBLE";
109
 
      case DERIVATION_IMPLICIT:  return "IMPLICIT";
110
 
      case DERIVATION_SYSCONST:  return "SYSCONST";
111
 
      case DERIVATION_EXPLICIT:  return "EXPLICIT";
112
 
      case DERIVATION_NONE:      return "NONE";
113
 
      default: return "UNKNOWN";
114
 
    }
115
 
  }
116
 
};
117
30
 
118
31
/*************************************************************************/
119
32
/*
1002
915
  }
1003
916
};
1004
917
 
1005
 
bool agg_item_collations(DTCollation &c, const char *name,
1006
 
                         Item **items, uint32_t nitems, uint32_t flags, int item_sep);
1007
 
bool agg_item_collations_for_comparison(DTCollation &c, const char *name,
1008
 
                                        Item **items, uint32_t nitems, uint32_t flags);
1009
 
bool agg_item_charsets(DTCollation &c, const char *name,
1010
 
                       Item **items, uint32_t nitems, uint32_t flags, int item_sep);
1011
 
 
1012
918
 
1013
919
class Item_num: public Item_basic_constant
1014
920
{