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