Drizzled Public API Documentation

dtcollation.h
1 /* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3  *
4  * Copyright (C) 2008 Sun Microsystems, Inc.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; version 2 of the License.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18  */
19 
20 #pragma once
21 
22 #include <drizzled/definitions.h>
23 #include <drizzled/visibility.h>
24 #include <drizzled/common_fwd.h>
25 
26 namespace drizzled {
27 
29 {
30 public:
31  const charset_info_st* collation;
32  Derivation derivation;
33 
34  DRIZZLED_LOCAL DTCollation();
35  DRIZZLED_LOCAL DTCollation(const charset_info_st*, Derivation);
36  void set(DTCollation &dt);
37  void set(const charset_info_st*, Derivation);
38  void set(const charset_info_st*);
39  void set(Derivation derivation_arg);
40  bool set(DTCollation &dt1, DTCollation &dt2, uint32_t flags= 0);
41 
78  DRIZZLED_LOCAL bool aggregate(DTCollation &dt, uint32_t flags= 0);
79 
80  DRIZZLED_LOCAL const char *derivation_name() const;
81 
82 };
83 
84 
85 bool agg_item_collations(DTCollation &c, const char *name,
86  Item **items, uint32_t nitems,
87  uint32_t flags, int item_sep);
88 bool agg_item_collations_for_comparison(DTCollation &c, const char *name,
89  Item **items, uint32_t nitems,
90  uint32_t flags);
91 
92 /*
93 
94  @note In Drizzle we have just one charset, so no conversion is required (though collation may).
95 
96  Collect arguments' character sets together.
97 
98  We allow to apply automatic character set conversion in some cases.
99  The conditions when conversion is possible are:
100  - arguments A and B have different charsets
101  - A wins according to coercibility rules
102  (i.e. a column is stronger than a string constant,
103  an explicit COLLATE clause is stronger than a column)
104  - character set of A is either superset for character set of B,
105  or B is a string constant which can be converted into the
106  character set of A without data loss.
107 
108  If all of the above is true, then it's possible to convert
109  B into the character set of A, and then compare according
110  to the collation of A.
111 
112  For functions with more than two arguments:
113  @code
114  collect(A,B,C) ::= collect(collect(A,B),C)
115  @endcode
116  Since this function calls Session::change_item_tree() on the passed Item **
117  pointers, it is necessary to pass the original Item **'s, not copies.
118  Otherwise their values will not be properly restored (see BUG#20769).
119  If the items are not consecutive (eg. args[2] and args[5]), use the
120  item_sep argument, ie.
121  @code
122  agg_item_charsets(coll, fname, &args[2], 2, flags, 3)
123  @endcode
124 */
125 bool agg_item_charsets(DTCollation &c, const char *name,
126  Item **items, uint32_t nitems, uint32_t flags,
127  int item_sep);
128 
129 
130 void my_coll_agg_error(DTCollation &c1, DTCollation &c2, const char *fname);
131 void my_coll_agg_error(DTCollation &c1, DTCollation &c2, DTCollation &c3,
132  const char *fname);
133 void my_coll_agg_error(Item** args, uint32_t count, const char *fname,
134  int item_sep);
135 
136 } /* namespace drizzled */
137