drizzle
C++ MySQL-protocol-compatible database server
Loading...
Searching...
No Matches
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
23#include <drizzled/visibility.h>
24#include <drizzled/common_fwd.h>
25
26namespace drizzled {
27
28class DRIZZLED_API DTCollation
29{
30public:
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
77
78 DRIZZLED_LOCAL bool aggregate(DTCollation &dt, uint32_t flags= 0);
79
80 DRIZZLED_LOCAL const char *derivation_name() const;
81
82};
83
84
85bool agg_item_collations(DTCollation &c, const char *name,
86 Item **items, uint32_t nitems,
87 uint32_t flags, int item_sep);
88bool 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*/
125bool agg_item_charsets(DTCollation &c, const char *name,
126 Item **items, uint32_t nitems, uint32_t flags,
127 int item_sep);
128
129
130void my_coll_agg_error(DTCollation &c1, DTCollation &c2, const char *fname);
131void my_coll_agg_error(DTCollation &c1, DTCollation &c2, DTCollation &c3,
132 const char *fname);
133void my_coll_agg_error(Item** args, uint32_t count, const char *fname,
134 int item_sep);
135
136} /* namespace drizzled */
137
DRIZZLED_LOCAL bool aggregate(DTCollation &dt, uint32_t flags=0)
TODO: Rename this file - func.h is stupid.
Derivation
Definition enum.h:39
Visibility Control Macros.
#define DRIZZLED_API
Definition visibility.h:38