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