390.1.2
by Monty Taylor
Fixed copyright headers in drizzled/ |
1 |
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
|
2 |
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
|
|
3 |
*
|
|
1999.6.1
by kalebral at gmail
update Copyright strings to a more common format to help with creating the master debian copyright file |
4 |
* Copyright (C) 2008 Sun Microsystems, Inc.
|
390.1.2
by Monty Taylor
Fixed copyright headers in drizzled/ |
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 |
*/
|
|
1
by brian
clean slate |
19 |
|
2119.4.1
by Monty Taylor
Turns on -fvisibility=hidden by default. Symbols intended to be used by |
20 |
|
21 |
||
2234
by Brian Aker
Mass removal of ifdef/endif in favor of pragma once. |
22 |
#pragma once
|
489.1.8
by Monty Taylor
Split out Item_int_func and Item_func from Item_func. (don't think too hard about the second one) |
23 |
|
2187.7.3
by Brian Aker
Simple encapsulation of Lex |
24 |
#include <drizzled/dtcollation.h> |
2281.5.1
by Muhammad Umair
Merged charset declarations of global_charset_info.h and charset_info.h into charset.h header file. |
25 |
#include <drizzled/charset.h> |
2187.7.3
by Brian Aker
Simple encapsulation of Lex |
26 |
#include <drizzled/item_result.h> |
27 |
#include <drizzled/memory/sql_alloc.h> |
|
584.1.15
by Monty Taylor
The mega-patch from hell. Renamed sql_class to session (since that's what it is) and removed it and field and table from common_includes. |
28 |
#include <drizzled/sql_list.h> |
2154.2.4
by Brian Aker
This fixes 716459 |
29 |
#include <drizzled/sql_string.h> |
584.4.1
by Monty Taylor
Split out DTCollation. |
30 |
|
2173.2.1
by Monty Taylor
Fixes incorrect usage of include |
31 |
#include <drizzled/visibility.h> |
2119.4.1
by Monty Taylor
Turns on -fvisibility=hidden by default. Symbols intended to be used by |
32 |
|
2252.1.14
by Olaf van der Spek
Common fwd |
33 |
namespace drizzled { |
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
34 |
|
1
by brian
clean slate |
35 |
/*
|
36 |
Analyzer function
|
|
37 |
SYNOPSIS
|
|
38 |
argp in/out IN: Analysis parameter
|
|
39 |
OUT: Parameter to be passed to the transformer
|
|
40 |
||
584.4.2
by Monty Taylor
Split out hybrid_type_traits. |
41 |
RETURN
|
163
by Brian Aker
Merge Monty's code. |
42 |
true Invoke the transformer
|
43 |
false Don't do it
|
|
1
by brian
clean slate |
44 |
|
45 |
*/
|
|
481
by Brian Aker
Remove all of uchar. |
46 |
typedef bool (Item::*Item_analyzer) (unsigned char **argp); |
47 |
typedef Item* (Item::*Item_transformer) (unsigned char *arg); |
|
1
by brian
clean slate |
48 |
typedef void (*Cond_traverser) (const Item *item, void *arg); |
584.4.2
by Monty Taylor
Split out hybrid_type_traits. |
49 |
typedef bool (Item::*Item_processor) (unsigned char *arg); |
1
by brian
clean slate |
50 |
|
1055.2.11
by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h |
51 |
/**
|
1237.6.7
by Brian Aker
More removal of field |
52 |
* The Item class is the base class for all items in the parsed
|
1055.2.11
by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h |
53 |
* statement "tree" or Lex. Each item represents something in the
|
54 |
* execution plan.
|
|
55 |
*/
|
|
2385.3.16
by Olaf van der Spek
Remove unnecessary constructors and destructors |
56 |
class DRIZZLED_API Item : public memory::SqlAlloc, boost::noncopyable |
1
by brian
clean slate |
57 |
{
|
58 |
/* Cache of the result of is_expensive(). */
|
|
206
by Brian Aker
Removed final uint dead types. |
59 |
int8_t is_expensive_cache; |
584.4.8
by Monty Taylor
Moved stuff from item.h to item.cc |
60 |
virtual bool is_expensive_processor(unsigned char *arg); |
1
by brian
clean slate |
61 |
|
62 |
public: |
|
63 |
||
1237.6.7
by Brian Aker
More removal of field |
64 |
enum Type |
1055.2.11
by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h |
65 |
{
|
66 |
FIELD_ITEM= 0, |
|
608
by Brian Aker
Adding snowman test (plus a dead variable removal). |
67 |
FUNC_ITEM, |
68 |
SUM_FUNC_ITEM, |
|
69 |
STRING_ITEM, |
|
70 |
INT_ITEM, |
|
71 |
REAL_ITEM, |
|
72 |
NULL_ITEM, |
|
73 |
VARBIN_ITEM, |
|
74 |
COPY_STR_ITEM, |
|
75 |
FIELD_AVG_ITEM, |
|
76 |
DEFAULT_VALUE_ITEM, |
|
77 |
PROC_ITEM, |
|
78 |
COND_ITEM, |
|
79 |
REF_ITEM, |
|
80 |
FIELD_STD_ITEM, |
|
81 |
FIELD_VARIANCE_ITEM, |
|
82 |
INSERT_VALUE_ITEM, |
|
83 |
SUBSELECT_ITEM, |
|
84 |
ROW_ITEM, CACHE_ITEM, |
|
85 |
TYPE_HOLDER, |
|
86 |
PARAM_ITEM, |
|
2023.2.7
by Brian Aker
Create an Bool primtive type for item. |
87 |
BOOLEAN_ITEM, |
608
by Brian Aker
Adding snowman test (plus a dead variable removal). |
88 |
DECIMAL_ITEM
|
89 |
};
|
|
1055.2.11
by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h |
90 |
enum traverse_order |
1237.6.7
by Brian Aker
More removal of field |
91 |
{
|
1055.2.11
by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h |
92 |
T_POSTFIX, |
93 |
T_PREFIX
|
|
94 |
};
|
|
95 |
enum cond_result |
|
96 |
{
|
|
97 |
COND_UNDEF, |
|
98 |
COND_OK, |
|
99 |
COND_TRUE, |
|
100 |
COND_FALSE
|
|
101 |
};
|
|
102 |
||
103 |
/**
|
|
104 |
* str_values's main purpose is to be used to cache the value in
|
|
105 |
* save_in_field
|
|
106 |
*/
|
|
1
by brian
clean slate |
107 |
String str_value; |
584.4.8
by Monty Taylor
Moved stuff from item.h to item.cc |
108 |
|
1055.2.11
by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h |
109 |
/** Name from select */
|
2318.6.97
by Olaf van der Spek
Remove unused Item::orig_name |
110 |
const char *name; |
2015.1.3
by Brian Aker
Merge in CAST operators for SIGNED/UNSIGNED |
111 |
|
1055.2.12
by Jay Pipes
Documentation and style cleanup on Item class |
112 |
/** Length of name */
|
113 |
uint32_t name_length; |
|
584.4.8
by Monty Taylor
Moved stuff from item.h to item.cc |
114 |
|
1
by brian
clean slate |
115 |
Item *next; |
203
by Brian Aker
Small cleanup around uint32 types (need to merge). |
116 |
uint32_t max_length; |
584.4.8
by Monty Taylor
Moved stuff from item.h to item.cc |
117 |
|
206
by Brian Aker
Removed final uint dead types. |
118 |
int8_t marker; |
119 |
uint8_t decimals; |
|
1055.2.12
by Jay Pipes
Documentation and style cleanup on Item class |
120 |
bool fixed; /**< If item fixed with fix_fields */ |
1055.2.11
by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h |
121 |
bool maybe_null; /**< True if item may be null */ |
122 |
bool null_value; /**< True if item is null */ |
|
275
by Brian Aker
Full removal of my_bool from central server. |
123 |
bool unsigned_flag; |
2015.1.3
by Brian Aker
Merge in CAST operators for SIGNED/UNSIGNED |
124 |
|
125 |
bool is_unsigned() const |
|
126 |
{
|
|
127 |
return unsigned_flag; |
|
128 |
}
|
|
129 |
||
130 |
virtual bool negative() const |
|
131 |
{
|
|
132 |
return false; |
|
133 |
}
|
|
134 |
||
275
by Brian Aker
Full removal of my_bool from central server. |
135 |
bool with_sum_func; |
1055.2.11
by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h |
136 |
bool is_autogenerated_name; /**< indicates whether name of this Item was autogenerated or set by user */ |
2137.1.10
by Brian Aker
Fix item so that we have session (ie, it always exists within the context so |
137 |
|
1055.2.11
by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h |
138 |
/**
|
139 |
* If this item is a subselect or some of its arguments is or contains a
|
|
1237.6.7
by Brian Aker
More removal of field |
140 |
* subselect. Computed by fix_fields.
|
1055.2.11
by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h |
141 |
*/
|
142 |
bool with_subselect; |
|
1055.2.12
by Jay Pipes
Documentation and style cleanup on Item class |
143 |
DTCollation collation; |
1055.2.11
by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h |
144 |
Item_result cmp_context; /**< Comparison context */ |
2137.1.10
by Brian Aker
Fix item so that we have session (ie, it always exists within the context so |
145 |
|
1055.2.11
by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h |
146 |
/**
|
147 |
* Constructor
|
|
148 |
*
|
|
149 |
* @note
|
|
150 |
*
|
|
1253.1.6
by Monty Taylor
Moved mem_root functions into drizzled::memory:: namespace. |
151 |
* Alloc & destruct is done as start of select using memory::sql_alloc
|
1055.2.11
by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h |
152 |
*/
|
1
by brian
clean slate |
153 |
Item(); |
2023.2.7
by Brian Aker
Create an Bool primtive type for item. |
154 |
|
1055.2.11
by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h |
155 |
/**
|
156 |
* Constructor used by Item_field, Item_ref & aggregate (sum) functions.
|
|
1237.6.7
by Brian Aker
More removal of field |
157 |
*
|
1055.2.11
by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h |
158 |
* Used for duplicating lists in processing queries with temporary
|
1055.2.12
by Jay Pipes
Documentation and style cleanup on Item class |
159 |
* tables.
|
1237.6.7
by Brian Aker
More removal of field |
160 |
*
|
1055.2.11
by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h |
161 |
* Also it used for Item_cond_and/Item_cond_or for creating
|
162 |
* top AND/OR structure of WHERE clause to protect it of
|
|
163 |
* optimisation changes in prepared statements
|
|
164 |
*/
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
165 |
Item(Session *session, Item *item); |
2137.1.10
by Brian Aker
Fix item so that we have session (ie, it always exists within the context so |
166 |
|
1
by brian
clean slate |
167 |
virtual ~Item() |
168 |
{
|
|
584.4.8
by Monty Taylor
Moved stuff from item.h to item.cc |
169 |
}
|
1273.16.4
by Brian Aker
Added columsn for COLUMNS |
170 |
|
171 |
void set_name(const std::string &arg) |
|
172 |
{
|
|
2318.9.1
by Olaf van der Spek
Refactor Item::set_name() calls |
173 |
set_name(arg.c_str(), arg.length()); |
1273.16.4
by Brian Aker
Added columsn for COLUMNS |
174 |
}
|
175 |
||
2318.9.1
by Olaf van der Spek
Refactor Item::set_name() calls |
176 |
void set_name(const char *str, uint32_t length, const charset_info_st* cs= system_charset_info); |
1052.2.4
by Nathan Williams
No actual code changes. Changed Send_field to SendField to be consistent with coding standards. |
177 |
void init_make_field(SendField *tmp_field,enum enum_field_types type); |
1
by brian
clean slate |
178 |
virtual void cleanup(); |
1052.2.4
by Nathan Williams
No actual code changes. Changed Send_field to SendField to be consistent with coding standards. |
179 |
virtual void make_field(SendField *field); |
1055.2.12
by Jay Pipes
Documentation and style cleanup on Item class |
180 |
/**
|
181 |
Create a field to hold a string value from an item.
|
|
182 |
||
183 |
If max_length > CONVERT_IF_BIGGER_TO_BLOB create a blob @n
|
|
184 |
If max_length > 0 create a varchar @n
|
|
185 |
If max_length == 0 create a CHAR(0)
|
|
186 |
||
187 |
@param table Table for which the field is created
|
|
188 |
*/
|
|
327.1.5
by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h |
189 |
Field *make_string_field(Table *table); |
520.1.21
by Brian Aker
THD -> Session rename |
190 |
virtual bool fix_fields(Session *, Item **); |
584.4.8
by Monty Taylor
Moved stuff from item.h to item.cc |
191 |
|
1055.2.11
by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h |
192 |
/**
|
193 |
* Fix after some tables has been pulled out. Basically re-calculate all
|
|
194 |
* attributes that are dependent on the tables.
|
|
195 |
*/
|
|
846
by Brian Aker
Removing on typedeffed class. |
196 |
virtual void fix_after_pullout(Select_Lex *new_parent, Item **ref); |
1
by brian
clean slate |
197 |
|
1055.2.11
by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h |
198 |
/**
|
199 |
* Should be used in case where we are sure that we do not need
|
|
1237.6.7
by Brian Aker
More removal of field |
200 |
* complete fix_fields() procedure.
|
1055.2.11
by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h |
201 |
*/
|
202 |
inline void quick_fix_field() |
|
203 |
{
|
|
1055.2.12
by Jay Pipes
Documentation and style cleanup on Item class |
204 |
fixed= true; |
1055.2.11
by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h |
205 |
}
|
206 |
||
1
by brian
clean slate |
207 |
virtual int save_in_field(Field *field, bool no_conversions); |
208 |
virtual void save_org_in_field(Field *field) |
|
1055.2.11
by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h |
209 |
{
|
210 |
(void) save_in_field(field, true); |
|
211 |
}
|
|
1
by brian
clean slate |
212 |
virtual int save_safe_in_field(Field *field) |
1055.2.11
by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h |
213 |
{
|
214 |
return save_in_field(field, true); |
|
215 |
}
|
|
1055.2.12
by Jay Pipes
Documentation and style cleanup on Item class |
216 |
/**
|
217 |
* This is only called from items that is not of type item_field.
|
|
218 |
*/
|
|
2313.3.7
by Olaf van der Spek
Return void |
219 |
virtual void send(plugin::Client *client, String *str); |
1055.2.12
by Jay Pipes
Documentation and style cleanup on Item class |
220 |
/**
|
1237.6.7
by Brian Aker
More removal of field |
221 |
Compares this Item to another Item, returning true if Item's
|
1055.2.12
by Jay Pipes
Documentation and style cleanup on Item class |
222 |
are functionally equal.
|
223 |
||
224 |
@details
|
|
225 |
||
226 |
This function is called when:
|
|
227 |
- Comparing items in the WHERE clause (when doing where optimization)
|
|
228 |
- When trying to find an order_st BY/GROUP BY item in the SELECT part
|
|
229 |
*/
|
|
1
by brian
clean slate |
230 |
virtual bool eq(const Item *, bool binary_cmp) const; |
1055.2.11
by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h |
231 |
virtual Item_result result_type() const |
232 |
{
|
|
233 |
return REAL_RESULT; |
|
234 |
}
|
|
235 |
virtual Item_result cast_to_int_type() const |
|
236 |
{
|
|
237 |
return result_type(); |
|
238 |
}
|
|
1
by brian
clean slate |
239 |
virtual enum_field_types string_field_type() const; |
240 |
virtual enum_field_types field_type() const; |
|
241 |
virtual enum Type type() const =0; |
|
584.4.8
by Monty Taylor
Moved stuff from item.h to item.cc |
242 |
|
1055.2.11
by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h |
243 |
/**
|
244 |
* Converts
|
|
245 |
* "func_arg $CMP$ const" half-interval
|
|
246 |
* into
|
|
247 |
* "FUNC(func_arg) $CMP2$ const2"
|
|
248 |
*
|
|
249 |
* @details
|
|
250 |
*
|
|
251 |
* left_endp false <=> The interval is "x < const" or "x <= const"
|
|
252 |
* true <=> The interval is "x > const" or "x >= const"
|
|
253 |
*
|
|
254 |
* incl_endp IN true <=> the comparison is '<' or '>'
|
|
255 |
* false <=> the comparison is '<=' or '>='
|
|
256 |
* OUT The same but for the "F(x) $CMP$ F(const)" comparison
|
|
257 |
*
|
|
258 |
* This function is defined only for unary monotonic functions. The caller
|
|
259 |
* supplies the source half-interval
|
|
1237.6.7
by Brian Aker
More removal of field |
260 |
*
|
1055.2.11
by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h |
261 |
* x $CMP$ const
|
262 |
*
|
|
263 |
* The value of const is supplied implicitly as the value this item's
|
|
264 |
* argument, the form of $CMP$ comparison is specified through the
|
|
265 |
* function's arguments. The calle returns the result interval
|
|
1237.6.7
by Brian Aker
More removal of field |
266 |
*
|
1055.2.11
by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h |
267 |
* F(x) $CMP2$ F(const)
|
268 |
*
|
|
269 |
* passing back F(const) as the return value, and the form of $CMP2$
|
|
270 |
* through the out parameter. NULL values are assumed to be comparable and
|
|
271 |
* be less than any non-NULL values.
|
|
272 |
*
|
|
273 |
* @retval
|
|
274 |
*
|
|
275 |
* The output range bound, which equal to the value of val_int()
|
|
276 |
* - If the value of the function is NULL then the bound is the
|
|
277 |
* smallest possible value of INT64_MIN
|
|
278 |
*/
|
|
584.4.8
by Monty Taylor
Moved stuff from item.h to item.cc |
279 |
virtual int64_t val_int_endpoint(bool left_endp, bool *incl_endp); |
1
by brian
clean slate |
280 |
|
281 |
/* valXXX methods must return NULL or 0 or 0.0 if null_value is set. */
|
|
1055.2.11
by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h |
282 |
/**
|
283 |
* Returns double precision floating point representation of item.
|
|
284 |
*
|
|
285 |
* @retval
|
|
286 |
*
|
|
287 |
* In case of NULL value return 0.0 and set null_value flag to true.
|
|
288 |
* If value is not null null_value flag will be reset to false.
|
|
289 |
*/
|
|
1
by brian
clean slate |
290 |
virtual double val_real()=0; |
1055.2.11
by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h |
291 |
/**
|
292 |
* Returns integer representation of item.
|
|
293 |
*
|
|
294 |
* @retval
|
|
1237.6.7
by Brian Aker
More removal of field |
295 |
*
|
1055.2.11
by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h |
296 |
* In case of NULL value return 0 and set null_value flag to true.
|
297 |
* If value is not null null_value flag will be reset to false.
|
|
298 |
*/
|
|
152
by Brian Aker
longlong replacement |
299 |
virtual int64_t val_int()=0; |
1055.2.11
by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h |
300 |
/**
|
301 |
* This is just a shortcut to avoid the cast. You should still use
|
|
302 |
* unsigned_flag to check the sign of the item.
|
|
303 |
*/
|
|
304 |
inline uint64_t val_uint() |
|
305 |
{
|
|
306 |
return (uint64_t) val_int(); |
|
307 |
}
|
|
308 |
/**
|
|
309 |
* Return string representation of this item object.
|
|
310 |
*
|
|
311 |
* @param an allocated buffer this or any nested Item object can use to
|
|
312 |
* store return value of this method.
|
|
313 |
*
|
|
314 |
* @note
|
|
315 |
*
|
|
316 |
* Buffer passed via argument should only be used if the item itself
|
|
317 |
* doesn't have an own String buffer. In case when the item maintains
|
|
318 |
* it's own string buffer, it's preferable to return it instead to
|
|
319 |
* minimize number of mallocs/memcpys.
|
|
320 |
*
|
|
321 |
* The caller of this method can modify returned string, but only in case
|
|
322 |
* when it was allocated on heap, (is_alloced() is true). This allows
|
|
323 |
* the caller to efficiently use a buffer allocated by a child without
|
|
324 |
* having to allocate a buffer of it's own. The buffer, given to
|
|
325 |
* val_str() as argument, belongs to the caller and is later used by the
|
|
326 |
* caller at it's own choosing.
|
|
327 |
*
|
|
328 |
* A few implications from the above:
|
|
329 |
* - unless you return a string object which only points to your buffer
|
|
330 |
* but doesn't manages it you should be ready that it will be
|
|
331 |
* modified.
|
|
332 |
* - even for not allocated strings (is_alloced() == false) the caller
|
|
333 |
* can change charset (see Item_func_{typecast/binary}. XXX: is this
|
|
334 |
* a bug?
|
|
335 |
* - still you should try to minimize data copying and return internal
|
|
336 |
* object whenever possible.
|
|
337 |
*
|
|
338 |
* @retval
|
|
339 |
* In case of NULL value return 0 (NULL pointer) and set null_value flag
|
|
340 |
* to true.
|
|
341 |
* If value is not null null_value flag will be reset to false.
|
|
342 |
*/
|
|
1
by brian
clean slate |
343 |
virtual String *val_str(String *str)=0; |
2023.2.4
by Brian Aker
Merge in cast() for BOOLEAN. |
344 |
|
1055.2.11
by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h |
345 |
/**
|
346 |
* Return decimal representation of item with fixed point.
|
|
347 |
*
|
|
348 |
* @param buffer which can be used by Item for returning value
|
|
349 |
* (but can be not)
|
|
350 |
*
|
|
351 |
* @note
|
|
352 |
*
|
|
353 |
* Returned value should not be changed if it is not the same which was
|
|
354 |
* passed via argument.
|
|
355 |
*
|
|
356 |
* @retval
|
|
357 |
*
|
|
2030.1.4
by Brian Aker
Change my_decimal to Decimal |
358 |
* Return pointer on type::Decimal (it can be other then passed via argument)
|
1055.2.11
by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h |
359 |
* if value is not NULL (null_value flag will be reset to false).
|
360 |
* In case of NULL value it return 0 pointer and set null_value flag
|
|
361 |
* to true.
|
|
362 |
*/
|
|
2030.1.4
by Brian Aker
Change my_decimal to Decimal |
363 |
virtual type::Decimal *val_decimal(type::Decimal *decimal_buffer)= 0; |
2015.1.3
by Brian Aker
Merge in CAST operators for SIGNED/UNSIGNED |
364 |
|
1055.2.11
by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h |
365 |
/**
|
366 |
* Return boolean value of item.
|
|
367 |
*
|
|
368 |
* @retval
|
|
369 |
*
|
|
370 |
* false value is false or NULL
|
|
371 |
* true value is true (not equal to 0)
|
|
372 |
*/
|
|
1
by brian
clean slate |
373 |
virtual bool val_bool(); |
2015.1.3
by Brian Aker
Merge in CAST operators for SIGNED/UNSIGNED |
374 |
|
1
by brian
clean slate |
375 |
/* Helper functions, see item_sum.cc */
|
376 |
String *val_string_from_real(String *str); |
|
377 |
String *val_string_from_int(String *str); |
|
378 |
String *val_string_from_decimal(String *str); |
|
2030.1.4
by Brian Aker
Change my_decimal to Decimal |
379 |
type::Decimal *val_decimal_from_real(type::Decimal *decimal_value); |
380 |
type::Decimal *val_decimal_from_int(type::Decimal *decimal_value); |
|
381 |
type::Decimal *val_decimal_from_string(type::Decimal *decimal_value); |
|
382 |
type::Decimal *val_decimal_from_date(type::Decimal *decimal_value); |
|
383 |
type::Decimal *val_decimal_from_time(type::Decimal *decimal_value); |
|
152
by Brian Aker
longlong replacement |
384 |
int64_t val_int_from_decimal(); |
1
by brian
clean slate |
385 |
double val_real_from_decimal(); |
386 |
||
2126.3.1
by Brian Aker
Add bool int patch |
387 |
bool save_time_in_field(Field *field); |
388 |
bool save_date_in_field(Field *field); |
|
389 |
||
1055.2.12
by Jay Pipes
Documentation and style cleanup on Item class |
390 |
/**
|
391 |
* Stores a string value in field directly
|
|
392 |
*
|
|
393 |
* @details
|
|
394 |
*
|
|
395 |
* The method is used by Item_*::save_in_field implementations
|
|
396 |
* when we don't need to calculate the value to store
|
|
1237.6.7
by Brian Aker
More removal of field |
397 |
*
|
1055.2.12
by Jay Pipes
Documentation and style cleanup on Item class |
398 |
* @see Item_string::save_in_field() implementation for example
|
399 |
*
|
|
400 |
* @param Pointer to field where to store
|
|
401 |
* @param Pointer to the string value to be stored
|
|
402 |
*
|
|
403 |
* @retval
|
|
404 |
* Nonzero value if error
|
|
405 |
*
|
|
406 |
*/
|
|
1
by brian
clean slate |
407 |
int save_str_value_in_field(Field *field, String *result); |
408 |
||
1055.2.11
by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h |
409 |
virtual Field *get_tmp_table_field(void) |
410 |
{
|
|
1055.2.12
by Jay Pipes
Documentation and style cleanup on Item class |
411 |
return NULL; |
1055.2.11
by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h |
412 |
}
|
1
by brian
clean slate |
413 |
/* This is also used to create fields in CREATE ... SELECT: */
|
584.4.8
by Monty Taylor
Moved stuff from item.h to item.cc |
414 |
virtual Field *tmp_table_field(Table *t_arg); |
415 |
virtual const char *full_name(void) const; |
|
1
by brian
clean slate |
416 |
|
417 |
/*
|
|
418 |
*result* family of methods is analog of *val* family (see above) but
|
|
419 |
return value of result_field of item if it is present. If Item have not
|
|
420 |
result field, it return val(). This methods set null_value flag in same
|
|
421 |
way as *val* methods do it.
|
|
422 |
*/
|
|
1055.2.11
by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h |
423 |
virtual double val_result() |
424 |
{
|
|
425 |
return val_real(); |
|
426 |
}
|
|
427 |
virtual int64_t val_int_result() |
|
428 |
{
|
|
429 |
return val_int(); |
|
430 |
}
|
|
431 |
virtual String *str_result(String* tmp) |
|
432 |
{
|
|
433 |
return val_str(tmp); |
|
434 |
}
|
|
2030.1.4
by Brian Aker
Change my_decimal to Decimal |
435 |
virtual type::Decimal *val_decimal_result(type::Decimal *val) |
1055.2.11
by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h |
436 |
{
|
437 |
return val_decimal(val); |
|
438 |
}
|
|
439 |
virtual bool val_bool_result() |
|
440 |
{
|
|
441 |
return val_bool(); |
|
442 |
}
|
|
443 |
/**
|
|
444 |
* Returns bit map of tables used by item
|
|
445 |
*/
|
|
446 |
virtual table_map used_tables() const |
|
447 |
{
|
|
448 |
return (table_map) 0L; |
|
449 |
}
|
|
450 |
/**
|
|
1
by brian
clean slate |
451 |
Return table map of tables that can't be NULL tables (tables that are
|
452 |
used in a context where if they would contain a NULL row generated
|
|
453 |
by a LEFT or RIGHT join, the item would not be true).
|
|
454 |
This expression is used on WHERE item to determinate if a LEFT JOIN can be
|
|
455 |
converted to a normal join.
|
|
456 |
Generally this function should return used_tables() if the function
|
|
457 |
would return null if any of the arguments are null
|
|
458 |
As this is only used in the beginning of optimization, the value don't
|
|
459 |
have to be updated in update_used_tables()
|
|
460 |
*/
|
|
1055.2.11
by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h |
461 |
virtual table_map not_null_tables() const |
462 |
{
|
|
463 |
return used_tables(); |
|
464 |
}
|
|
465 |
/**
|
|
1
by brian
clean slate |
466 |
Returns true if this is a simple constant item like an integer, not
|
467 |
a constant expression. Used in the optimizer to propagate basic constants.
|
|
468 |
*/
|
|
1055.2.11
by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h |
469 |
virtual bool basic_const_item() const |
470 |
{
|
|
1055.2.12
by Jay Pipes
Documentation and style cleanup on Item class |
471 |
return false; |
1055.2.11
by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h |
472 |
}
|
1055.2.12
by Jay Pipes
Documentation and style cleanup on Item class |
473 |
/* cloning of constant items (NULL if it is not const) */
|
1055.2.11
by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h |
474 |
virtual Item *clone_item() |
475 |
{
|
|
1055.2.12
by Jay Pipes
Documentation and style cleanup on Item class |
476 |
return NULL; |
1055.2.11
by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h |
477 |
}
|
478 |
virtual cond_result eq_cmp_result() const |
|
479 |
{
|
|
480 |
return COND_OK; |
|
481 |
}
|
|
1241.9.1
by Monty Taylor
Removed global.h. Fixed all the headers. |
482 |
uint32_t float_length(uint32_t decimals_par) const; |
482
by Brian Aker
Remove uint. |
483 |
virtual uint32_t decimal_precision() const; |
584.1.14
by Monty Taylor
Removed field.h from common_includes. |
484 |
int decimal_int_part() const; |
485 |
||
1055.2.11
by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h |
486 |
/**
|
1
by brian
clean slate |
487 |
Returns true if this is constant (during query execution, i.e. its value
|
488 |
will not change until next fix_fields) and its value is known.
|
|
489 |
*/
|
|
1055.2.11
by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h |
490 |
virtual bool const_item() const |
491 |
{
|
|
492 |
return used_tables() == 0; |
|
493 |
}
|
|
494 |
/**
|
|
1
by brian
clean slate |
495 |
Returns true if this is constant but its value may be not known yet.
|
496 |
(Can be used for parameters of prep. stmts or of stored procedures.)
|
|
497 |
*/
|
|
584.4.8
by Monty Taylor
Moved stuff from item.h to item.cc |
498 |
virtual bool const_during_execution() const |
1055.2.11
by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h |
499 |
{
|
500 |
return (used_tables() & ~PARAM_TABLE_BIT) == 0; |
|
501 |
}
|
|
1
by brian
clean slate |
502 |
|
503 |
/**
|
|
504 |
This method is used for to:
|
|
505 |
- to generate a view definition query (SELECT-statement);
|
|
506 |
- to generate a SQL-query for EXPLAIN EXTENDED;
|
|
507 |
- to generate a SQL-query to be shown in INFORMATION_SCHEMA;
|
|
508 |
- debug.
|
|
509 |
||
510 |
For more information about view definition query, INFORMATION_SCHEMA
|
|
511 |
query and why they should be generated from the Item-tree, @see
|
|
2026.2.1
by Monty Taylor
Renamed things prefixed mysql_ or mysqld_ |
512 |
register_view().
|
1
by brian
clean slate |
513 |
*/
|
2215.2.1
by Stewart Smith
remove enum_query_type which was effectively unused. It was set to one value once, compared to it once (i.e. always true) and passed around everywhere doing nothing. |
514 |
virtual void print(String *str); |
1
by brian
clean slate |
515 |
|
2215.2.1
by Stewart Smith
remove enum_query_type which was effectively unused. It was set to one value once, compared to it once (i.e. always true) and passed around everywhere doing nothing. |
516 |
void print_item_w_name(String *); |
1
by brian
clean slate |
517 |
virtual void update_used_tables() {} |
1055.2.12
by Jay Pipes
Documentation and style cleanup on Item class |
518 |
virtual void split_sum_func(Session *session, |
519 |
Item **ref_pointer_array, |
|
584.4.8
by Monty Taylor
Moved stuff from item.h to item.cc |
520 |
List<Item> &fields); |
1055.2.12
by Jay Pipes
Documentation and style cleanup on Item class |
521 |
/**
|
522 |
Move SUM items out from item tree and replace with reference.
|
|
523 |
||
524 |
@param session Thread handler
|
|
525 |
@param ref_pointer_array Pointer to array of reference fields
|
|
526 |
@param fields All fields in select
|
|
527 |
@param ref Pointer to item
|
|
528 |
@param skip_registered <=> function be must skipped for registered
|
|
529 |
SUM items
|
|
530 |
||
531 |
@note
|
|
532 |
This is from split_sum_func() for items that should be split
|
|
533 |
||
534 |
All found SUM items are added FIRST in the fields list and
|
|
535 |
we replace the item with a reference.
|
|
536 |
||
537 |
session->fatal_error() may be called if we are out of memory
|
|
538 |
*/
|
|
539 |
void split_sum_func(Session *session, |
|
540 |
Item **ref_pointer_array, |
|
779.3.18
by Monty Taylor
Cleaned up warnings up through innodb. |
541 |
List<Item> &fields, |
1055.2.12
by Jay Pipes
Documentation and style cleanup on Item class |
542 |
Item **ref, |
543 |
bool skip_registered); |
|
584.4.9
by Monty Taylor
Renamed split_sum_func2 to split_sum_func. It's C++. |
544 |
|
1055.2.12
by Jay Pipes
Documentation and style cleanup on Item class |
545 |
/**
|
2030.1.5
by Brian Aker
Update for moving DRIZZLE_TIME to type::Time |
546 |
Get the value of the function as a type::Time structure.
|
1055.2.12
by Jay Pipes
Documentation and style cleanup on Item class |
547 |
As a extra convenience the time structure is reset on error!
|
548 |
*/
|
|
2104.2.8
by Brian Aker
Merge in reference from pointer. |
549 |
virtual bool get_date(type::Time <ime, uint32_t fuzzydate); |
1055.2.12
by Jay Pipes
Documentation and style cleanup on Item class |
550 |
/**
|
551 |
Get time of first argument.
|
|
552 |
||
553 |
As a extra convenience the time structure is reset on error!
|
|
554 |
*/
|
|
2104.2.8
by Brian Aker
Merge in reference from pointer. |
555 |
virtual bool get_time(type::Time <ime); |
556 |
virtual bool get_date_result(type::Time <ime,uint32_t fuzzydate); |
|
584.4.8
by Monty Taylor
Moved stuff from item.h to item.cc |
557 |
|
1055.2.11
by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h |
558 |
/**
|
584.4.8
by Monty Taylor
Moved stuff from item.h to item.cc |
559 |
The method allows to determine nullness of a complex expression
|
560 |
without fully evaluating it, instead of calling val/result*() then
|
|
1
by brian
clean slate |
561 |
checking null_value. Used in Item_func_isnull/Item_func_isnotnull
|
562 |
and Item_sum_count/Item_sum_count_distinct.
|
|
563 |
Any new item which can be NULL must implement this method.
|
|
564 |
*/
|
|
584.4.8
by Monty Taylor
Moved stuff from item.h to item.cc |
565 |
virtual bool is_null(); |
1
by brian
clean slate |
566 |
|
1055.2.11
by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h |
567 |
/** Make sure the null_value member has a correct value. */
|
584.4.8
by Monty Taylor
Moved stuff from item.h to item.cc |
568 |
virtual void update_null_value (); |
1
by brian
clean slate |
569 |
|
1055.2.11
by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h |
570 |
/**
|
1
by brian
clean slate |
571 |
Inform the item that there will be no distinction between its result
|
163
by Brian Aker
Merge Monty's code. |
572 |
being false or NULL.
|
1
by brian
clean slate |
573 |
|
1055.2.11
by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h |
574 |
@note
|
575 |
||
1
by brian
clean slate |
576 |
This function will be called for eg. Items that are top-level AND-parts
|
577 |
of the WHERE clause. Items implementing this function (currently
|
|
578 |
Item_cond_and and subquery-related item) enable special optimizations
|
|
579 |
when they are "top level".
|
|
580 |
*/
|
|
584.4.8
by Monty Taylor
Moved stuff from item.h to item.cc |
581 |
virtual void top_level_item(void); |
1055.2.11
by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h |
582 |
/**
|
583 |
* Sets field of temporary table for Item which can be switched on temporary
|
|
584 |
* table during query processing (grouping and so on)
|
|
585 |
*/
|
|
584.4.8
by Monty Taylor
Moved stuff from item.h to item.cc |
586 |
virtual void set_result_field(Field *field); |
587 |
virtual bool is_result_field(void); |
|
588 |
virtual bool is_bool_func(void); |
|
589 |
virtual void save_in_result_field(bool no_conversions); |
|
590 |
||
1055.2.11
by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h |
591 |
/**
|
592 |
* Sets value of aggregate function in case of no rows for grouping were found
|
|
593 |
*/
|
|
584.4.8
by Monty Taylor
Moved stuff from item.h to item.cc |
594 |
virtual void no_rows_in_result(void); |
595 |
virtual Item *copy_or_same(Session *session); |
|
596 |
||
597 |
virtual Item *copy_andor_structure(Session *session); |
|
598 |
||
599 |
virtual Item *real_item(void); |
|
779.3.10
by Monty Taylor
Turned on -Wshadow. |
600 |
virtual const Item *real_item(void) const; |
584.4.8
by Monty Taylor
Moved stuff from item.h to item.cc |
601 |
virtual Item *get_tmp_table_item(Session *session); |
1
by brian
clean slate |
602 |
|
2254
by Brian Aker
Shift CHARSET_INFO to charset_info_st |
603 |
static const charset_info_st *default_charset(); |
604 |
virtual const charset_info_st *compare_collation(); |
|
1
by brian
clean slate |
605 |
|
584.4.8
by Monty Taylor
Moved stuff from item.h to item.cc |
606 |
virtual bool walk(Item_processor processor, |
607 |
bool walk_subquery, |
|
608 |
unsigned char *arg); |
|
1
by brian
clean slate |
609 |
|
1055.2.12
by Jay Pipes
Documentation and style cleanup on Item class |
610 |
/**
|
611 |
Traverse item tree possibly transforming it (replacing items).
|
|
612 |
||
613 |
If you don't need to transform an item tree, but only traverse
|
|
614 |
it, please use Item::walk() instead.
|
|
615 |
||
616 |
@param transformer functor that performs transformation of a subtree
|
|
617 |
@param arg opaque argument passed to the functor
|
|
618 |
||
619 |
@return
|
|
620 |
Returns pointer to the new subtree root. Session::change_item_tree()
|
|
621 |
should be called for it if transformation took place, i.e. if a
|
|
622 |
pointer to newly allocated item is returned.
|
|
623 |
*/
|
|
481
by Brian Aker
Remove all of uchar. |
624 |
virtual Item* transform(Item_transformer transformer, unsigned char *arg); |
1
by brian
clean slate |
625 |
|
1055.2.11
by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h |
626 |
/**
|
1
by brian
clean slate |
627 |
This function performs a generic "compilation" of the Item tree.
|
584.4.8
by Monty Taylor
Moved stuff from item.h to item.cc |
628 |
The process of compilation is assumed to go as follows:
|
629 |
||
1055.2.11
by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h |
630 |
@code
|
1
by brian
clean slate |
631 |
compile()
|
584.4.8
by Monty Taylor
Moved stuff from item.h to item.cc |
632 |
{
|
1
by brian
clean slate |
633 |
if (this->*some_analyzer(...))
|
634 |
{
|
|
635 |
compile children if any;
|
|
636 |
this->*some_transformer(...);
|
|
637 |
}
|
|
638 |
}
|
|
1055.2.11
by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h |
639 |
@endcode
|
1
by brian
clean slate |
640 |
|
641 |
i.e. analysis is performed top-down while transformation is done
|
|
584.4.8
by Monty Taylor
Moved stuff from item.h to item.cc |
642 |
bottom-up.
|
1
by brian
clean slate |
643 |
*/
|
1055.2.11
by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h |
644 |
virtual Item* compile(Item_analyzer analyzer, |
645 |
unsigned char **arg_p, |
|
646 |
Item_transformer transformer, |
|
647 |
unsigned char *arg_t); |
|
584.4.8
by Monty Taylor
Moved stuff from item.h to item.cc |
648 |
|
649 |
virtual void traverse_cond(Cond_traverser traverser, |
|
650 |
void *arg, |
|
651 |
traverse_order order); |
|
652 |
||
653 |
virtual bool remove_dependence_processor(unsigned char * arg); |
|
654 |
virtual bool collect_item_field_processor(unsigned char * arg); |
|
655 |
virtual bool find_item_in_field_list_processor(unsigned char *arg); |
|
656 |
virtual bool change_context_processor(unsigned char *context); |
|
657 |
virtual bool register_field_in_read_map(unsigned char *arg); |
|
658 |
virtual bool subst_argument_checker(unsigned char **arg); |
|
1
by brian
clean slate |
659 |
|
1240.8.4
by Dennis Schoen
add Item functions |
660 |
virtual bool cache_const_expr_analyzer(unsigned char **arg); |
661 |
virtual Item* cache_const_expr_transformer(unsigned char *arg); |
|
662 |
||
584.4.8
by Monty Taylor
Moved stuff from item.h to item.cc |
663 |
virtual Item *equal_fields_propagator(unsigned char * arg); |
664 |
virtual bool set_no_const_sub(unsigned char *arg); |
|
665 |
virtual Item *replace_equal_field(unsigned char * arg); |
|
1
by brian
clean slate |
666 |
|
667 |
// Row emulation
|
|
584.4.8
by Monty Taylor
Moved stuff from item.h to item.cc |
668 |
virtual uint32_t cols(); |
669 |
virtual Item* element_index(uint32_t i); |
|
670 |
virtual Item** addr(uint32_t i); |
|
482
by Brian Aker
Remove uint. |
671 |
virtual bool check_cols(uint32_t c); |
1
by brian
clean slate |
672 |
// It is not row => null inside is impossible
|
584.4.8
by Monty Taylor
Moved stuff from item.h to item.cc |
673 |
virtual bool null_inside(); |
1
by brian
clean slate |
674 |
// used in row subselects to get value of elements
|
584.4.8
by Monty Taylor
Moved stuff from item.h to item.cc |
675 |
virtual void bring_value(); |
1
by brian
clean slate |
676 |
|
1055.2.12
by Jay Pipes
Documentation and style cleanup on Item class |
677 |
/**
|
678 |
Create a field based on field_type of argument.
|
|
679 |
||
680 |
For now, this is only used to create a field for
|
|
681 |
IFNULL(x,something) and time functions
|
|
682 |
||
683 |
@retval
|
|
684 |
NULL error
|
|
685 |
@retval
|
|
686 |
\# Created field
|
|
687 |
*/
|
|
327.1.5
by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h |
688 |
Field *tmp_table_field_from_field_type(Table *table, bool fixed_length); |
1
by brian
clean slate |
689 |
|
584.4.8
by Monty Taylor
Moved stuff from item.h to item.cc |
690 |
virtual Item *neg_transformer(Session *session); |
691 |
virtual Item *update_value_transformer(unsigned char *select_arg); |
|
2254
by Brian Aker
Shift CHARSET_INFO to charset_info_st |
692 |
virtual Item *safe_charset_converter(const charset_info_st * const tocs); |
584.4.8
by Monty Taylor
Moved stuff from item.h to item.cc |
693 |
void delete_self(); |
1
by brian
clean slate |
694 |
|
1055.2.11
by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h |
695 |
/**
|
696 |
* Returns true for Items representing DATE/TIME functions and DATE/TIME table fields.
|
|
697 |
* Those Items have result_type()==STRING_RESULT (and not INT_RESULT), but
|
|
698 |
* their values should be compared as integers (because the integer
|
|
699 |
* representation is more precise than the string one).
|
|
700 |
*/
|
|
584.4.8
by Monty Taylor
Moved stuff from item.h to item.cc |
701 |
virtual bool result_as_int64_t(); |
1
by brian
clean slate |
702 |
bool is_datetime(); |
703 |
||
1055.2.11
by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h |
704 |
/**
|
705 |
* Tests whether an expression is expensive to compute. Used during
|
|
706 |
* optimization to avoid computing expensive expressions during this
|
|
707 |
* phase. Also used to force temp tables when sorting on expensive
|
|
708 |
* functions.
|
|
709 |
*
|
|
710 |
* @todo
|
|
711 |
*
|
|
712 |
* Normally we should have a method:
|
|
713 |
* cost Item::execution_cost(),
|
|
714 |
* where 'cost' is either 'double' or some structure of various cost
|
|
715 |
* parameters.
|
|
1637.5.6
by Prafulla Tekawade
This bug is simillar to mysql bug 36133 |
716 |
*
|
717 |
*NOTE
|
|
718 |
* This function is now used to prevent evaluation of materialized IN
|
|
719 |
* subquery predicates before it is allowed. grep for
|
|
720 |
* DontEvaluateMaterializedSubqueryTooEarly to see the uses.
|
|
1055.2.11
by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h |
721 |
*/
|
584.4.8
by Monty Taylor
Moved stuff from item.h to item.cc |
722 |
virtual bool is_expensive(); |
723 |
||
1
by brian
clean slate |
724 |
String *check_well_formed_result(String *str, bool send_error= 0); |
1055.2.12
by Jay Pipes
Documentation and style cleanup on Item class |
725 |
/**
|
726 |
* Compares two items using a given collation
|
|
727 |
*
|
|
728 |
* @details
|
|
729 |
*
|
|
730 |
* This method works exactly as Item::eq if the collation cs coincides with
|
|
731 |
* the collation of the compared objects. Otherwise, first the collations that
|
|
732 |
* differ from cs are replaced for cs and then the items are compared by
|
|
733 |
* Item::eq. After the comparison the original collations of items are
|
|
734 |
* restored.
|
|
735 |
*
|
|
736 |
* @param Pointer to the item to compare with
|
|
737 |
* @param Compare as binary?
|
|
738 |
* @param Pointer to the collation to use when comparing strings
|
|
739 |
*
|
|
740 |
* @retval
|
|
741 |
* true if compared items has been detected as equal
|
|
742 |
* @retval
|
|
743 |
* false otherwise
|
|
744 |
*/
|
|
2254
by Brian Aker
Shift CHARSET_INFO to charset_info_st |
745 |
bool eq_by_collation(Item *item, bool binary_cmp, const charset_info_st * const cs); |
2015.1.3
by Brian Aker
Merge in CAST operators for SIGNED/UNSIGNED |
746 |
|
747 |
inline uint32_t char_to_byte_length_safe(uint32_t char_length_arg, uint32_t mbmaxlen_arg) |
|
748 |
{
|
|
749 |
uint64_t tmp= ((uint64_t) char_length_arg) * mbmaxlen_arg; |
|
750 |
return (tmp > UINT32_MAX) ? (uint32_t) UINT32_MAX : (uint32_t) tmp; |
|
751 |
}
|
|
752 |
||
2154.2.4
by Brian Aker
This fixes 716459 |
753 |
uint32_t max_char_length() const; |
754 |
||
755 |
void fix_char_length(uint32_t max_char_length_arg); |
|
756 |
||
2137.1.10
by Brian Aker
Fix item so that we have session (ie, it always exists within the context so |
757 |
protected: |
758 |
Session &getSession() |
|
759 |
{
|
|
760 |
return _session; |
|
761 |
}
|
|
762 |
||
763 |
private: |
|
764 |
Session &_session; |
|
1
by brian
clean slate |
765 |
};
|
766 |
||
1992.5.1
by Brian Aker
Additional cerr output bits for a few classes (Item, Field,...) |
767 |
namespace display { |
768 |
const std::string &type(Item::Type type); |
|
769 |
} /* namespace display */ |
|
770 |
||
771 |
std::ostream& operator<<(std::ostream& output, const Item &item); |
|
772 |
||
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
773 |
} /* namespace drizzled */ |
774 |
||
775 |
/** @TODO Why is this in the middle? */
|
|
642.1.1
by Lee
move functions from item.cc/item.h to item directory |
776 |
#include <drizzled/item/ident.h> |
777 |
||
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
778 |
namespace drizzled |
779 |
{
|
|
780 |
||
1055.2.12
by Jay Pipes
Documentation and style cleanup on Item class |
781 |
/**
|
782 |
Mark item and Select_Lexs as dependent if item was resolved in
|
|
783 |
outer SELECT.
|
|
784 |
||
785 |
@param session thread handler
|
|
786 |
@param last select from which current item depend
|
|
787 |
@param current current select
|
|
788 |
@param resolved_item item which was resolved in outer SELECT(for warning)
|
|
789 |
@param mark_item item which should be marked (can be differ in case of
|
|
790 |
substitution)
|
|
791 |
*/
|
|
656.1.6
by Monty Taylor
Merged in Eric's whitespace cleanup. |
792 |
void mark_as_dependent(Session *session, |
846
by Brian Aker
Removing on typedeffed class. |
793 |
Select_Lex *last, |
794 |
Select_Lex *current, |
|
642.1.1
by Lee
move functions from item.cc/item.h to item directory |
795 |
Item_ident *resolved_item, |
796 |
Item_ident *mark_item); |
|
797 |
||
1055.2.12
by Jay Pipes
Documentation and style cleanup on Item class |
798 |
/**
|
799 |
Resolve a column reference in a sub-select.
|
|
800 |
||
801 |
Resolve a column reference (usually inside a HAVING clause) against the
|
|
802 |
SELECT and GROUP BY clauses of the query described by 'select'. The name
|
|
803 |
resolution algorithm searches both the SELECT and GROUP BY clauses, and in
|
|
804 |
case of a name conflict prefers GROUP BY column names over SELECT names. If
|
|
805 |
both clauses contain different fields with the same names, a warning is
|
|
806 |
issued that name of 'ref' is ambiguous. We extend ANSI SQL in that when no
|
|
807 |
GROUP BY column is found, then a HAVING name is resolved as a possibly
|
|
808 |
derived SELECT column. This extension is allowed only if the
|
|
809 |
MODE_ONLY_FULL_GROUP_BY sql mode isn't enabled.
|
|
810 |
||
811 |
@param session current thread
|
|
812 |
@param ref column reference being resolved
|
|
813 |
@param select the select that ref is resolved against
|
|
814 |
||
815 |
@note
|
|
816 |
The resolution procedure is:
|
|
817 |
- Search for a column or derived column named col_ref_i [in table T_j]
|
|
818 |
in the SELECT clause of Q.
|
|
819 |
- Search for a column named col_ref_i [in table T_j]
|
|
820 |
in the GROUP BY clause of Q.
|
|
821 |
- If found different columns with the same name in GROUP BY and SELECT
|
|
822 |
- issue a warning and return the GROUP BY column,
|
|
823 |
- otherwise
|
|
824 |
- if the MODE_ONLY_FULL_GROUP_BY mode is enabled return error
|
|
825 |
- else return the found SELECT column.
|
|
826 |
||
827 |
||
828 |
@return
|
|
829 |
- NULL - there was an error, and the error was already reported
|
|
830 |
- not_found_item - the item was not resolved, no error was reported
|
|
831 |
- resolved item - if the item was resolved
|
|
832 |
*/
|
|
833 |
Item** resolve_ref_in_select_and_group(Session *session, Item_ident *ref, Select_Lex *select); |
|
834 |
||
835 |
/**
|
|
836 |
Mark range of selects and resolved identifier (field/reference)
|
|
837 |
item as dependent.
|
|
838 |
||
839 |
@param session thread handler
|
|
840 |
@param last_select select where resolved_item was resolved
|
|
841 |
@param current_sel current select (select where resolved_item was placed)
|
|
842 |
@param found_field field which was found during resolving
|
|
843 |
@param found_item Item which was found during resolving (if resolved
|
|
844 |
identifier belongs to VIEW)
|
|
845 |
@param resolved_item Identifier which was resolved
|
|
846 |
||
847 |
@note
|
|
848 |
We have to mark all items between current_sel (including) and
|
|
849 |
last_select (excluding) as dependend (select before last_select should
|
|
850 |
be marked with actual table mask used by resolved item, all other with
|
|
851 |
OUTER_REF_TABLE_BIT) and also write dependence information to Item of
|
|
852 |
resolved identifier.
|
|
853 |
*/
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
854 |
void mark_select_range_as_dependent(Session *session, |
846
by Brian Aker
Removing on typedeffed class. |
855 |
Select_Lex *last_select, |
856 |
Select_Lex *current_sel, |
|
1
by brian
clean slate |
857 |
Field *found_field, Item *found_item, |
858 |
Item_ident *resolved_item); |
|
859 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
860 |
extern void resolve_const_item(Session *session, Item **ref, Item *cmp_item); |
1055.2.12
by Jay Pipes
Documentation and style cleanup on Item class |
861 |
/**
|
862 |
Return true if the value stored in the field is equal to the const
|
|
863 |
item.
|
|
864 |
||
865 |
We need to use this on the range optimizer because in some cases
|
|
866 |
we can't store the value in the field without some precision/character loss.
|
|
867 |
*/
|
|
1
by brian
clean slate |
868 |
extern bool field_is_equal_to_item(Field *field,Item *item); |
489.1.8
by Monty Taylor
Split out Item_int_func and Item_func from Item_func. (don't think too hard about the second one) |
869 |
|
575.4.7
by Monty Taylor
More header cleanup. |
870 |
/**
|
871 |
Create field for temporary table.
|
|
872 |
||
1235.1.11
by Brian Aker
Small cleanups, did in MERGE table only engine flag. |
873 |
@todo:
|
874 |
||
1055.2.11
by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h |
875 |
This is here for now because it needs the Item::Type. It should live
|
876 |
in Field or Table once item.h is clean enough to actually include
|
|
877 |
||
575.4.7
by Monty Taylor
More header cleanup. |
878 |
@param session Thread handler
|
879 |
@param table Temporary table
|
|
880 |
@param item Item to create a field for
|
|
881 |
@param type Type of item (normally item->type)
|
|
882 |
@param copy_func If set and item is a function, store copy of item
|
|
883 |
in this array
|
|
884 |
@param from_field if field will be created using other field as example,
|
|
885 |
pointer example field will be written here
|
|
886 |
@param default_field If field has a default value field, store it here
|
|
887 |
@param group 1 if we are going to do a relative group by on result
|
|
888 |
@param modify_item 1 if item->result_field should point to new item.
|
|
889 |
This is relevent for how fill_record() is going to
|
|
890 |
work:
|
|
891 |
If modify_item is 1 then fill_record() will update
|
|
892 |
the record in the original table.
|
|
893 |
If modify_item is 0 then fill_record() will update
|
|
894 |
the temporary table
|
|
895 |
@param convert_blob_length If >0 create a varstring(convert_blob_length)
|
|
896 |
field instead of blob.
|
|
897 |
||
898 |
@retval
|
|
899 |
0 on error
|
|
900 |
@retval
|
|
901 |
new_created field
|
|
902 |
*/
|
|
1055.2.11
by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h |
903 |
Field *create_tmp_field(Session *session, |
1235.1.11
by Brian Aker
Small cleanups, did in MERGE table only engine flag. |
904 |
Table *table, |
1055.2.11
by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h |
905 |
Item *item, |
575.4.7
by Monty Taylor
More header cleanup. |
906 |
Item::Type type, |
1235.1.11
by Brian Aker
Small cleanups, did in MERGE table only engine flag. |
907 |
Item ***copy_func, |
1055.2.11
by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h |
908 |
Field **from_field, |
575.4.7
by Monty Taylor
More header cleanup. |
909 |
Field **def_field, |
1235.1.11
by Brian Aker
Small cleanups, did in MERGE table only engine flag. |
910 |
bool group, |
1055.2.11
by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h |
911 |
bool modify_item, |
575.4.7
by Monty Taylor
More header cleanup. |
912 |
bool make_copy_field, |
913 |
uint32_t convert_blob_length); |
|
914 |
||
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
915 |
} /* namespace drizzled */ |
916 |