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 |
|
1014.4.1
by Jay Pipes
Cosmetic: make sql_lex.h include guard match rest of drizzled/ headers. |
20 |
#ifndef DRIZZLED_SQL_LEX_H
|
21 |
#define DRIZZLED_SQL_LEX_H
|
|
243.1.8
by Jay Pipes
More cleanup and revert broken base.h |
22 |
|
1
by brian
clean slate |
23 |
/**
|
24 |
@defgroup Semantic_Analysis Semantic Analysis
|
|
25 |
*/
|
|
1008.3.17
by Stewart Smith
Start work to construct table proto in parser: |
26 |
#include <drizzled/message/table.pb.h> |
27 |
||
1130.1.12
by Monty Taylor
Moved service stuff into plugin/ |
28 |
#include "drizzled/plugin/function.h" |
934.2.1
by Jay Pipes
Split index hints out into their own file, removal from sql_lex.h and sql_select.cc |
29 |
#include "drizzled/name_resolution_context.h" |
30 |
#include "drizzled/item/subselect.h" |
|
31 |
#include "drizzled/table_list.h" |
|
32 |
#include "drizzled/function/math/real.h" |
|
33 |
#include "drizzled/alter_drop.h" |
|
34 |
#include "drizzled/alter_column.h" |
|
1126.3.3
by Jay Pipes
Moves Alter_info out into its own header and source file, cleans up some related include mess in sql_lex.h, and renames Alter_info to AlterInfo. |
35 |
#include "drizzled/alter_info.h" |
1237.9.4
by Padraig O'Sullivan
Removed the inclusion of drizzled/field.h in the server_includes header file. |
36 |
#include "drizzled/key_part_spec.h" |
934.2.1
by Jay Pipes
Split index hints out into their own file, removal from sql_lex.h and sql_select.cc |
37 |
#include "drizzled/index_hint.h" |
1100.3.30
by Padraig O'Sullivan
Renamed the Command class to be Statement. Renamed the command directory to |
38 |
#include "drizzled/statement.h" |
1237.13.30
by Padraig O'Sullivan
Corrected a valgrind warning due to using std::string in the Select_Lex class whose memory is |
39 |
#include "drizzled/optimizer/explain_plan.h" |
139.1.8
by Stewart Smith
UDFs are now normal Item_func objects. Simplifies handling them a lot. |
40 |
|
1089.6.3
by Padraig O'Sullivan
Replaced an instance where a uint8_t type was being used to hold a |
41 |
#include <bitset> |
1240.7.3
by Padraig O'Sullivan
Used std::string for the type in Select_Lex instead of char *. |
42 |
#include <string> |
1089.6.3
by Padraig O'Sullivan
Replaced an instance where a uint8_t type was being used to hold a |
43 |
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
44 |
namespace drizzled |
45 |
{
|
|
46 |
||
584.4.7
by Monty Taylor
Removed a big bank of includes from item.h. |
47 |
class select_result_interceptor; |
584.1.14
by Monty Taylor
Removed field.h from common_includes. |
48 |
|
1
by brian
clean slate |
49 |
/* YACC and LEX Definitions */
|
50 |
||
51 |
/* These may not be declared yet */
|
|
52 |
class Table_ident; |
|
831.1.2
by Brian Aker
Rename class file_exchange |
53 |
class file_exchange; |
851
by Brian Aker
Class rewrite of Session (aka get all of the junk out) |
54 |
class Lex_Column; |
675
by Brian Aker
Cleanup around item includes. |
55 |
class Item_outer_ref; |
1
by brian
clean slate |
56 |
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
57 |
} /* namespace drizzled */ |
58 |
||
1
by brian
clean slate |
59 |
/*
|
60 |
The following hack is needed because mysql_yacc.cc does not define
|
|
61 |
YYSTYPE before including this file
|
|
62 |
*/
|
|
63 |
||
722.1.4
by Monty Taylor
Removed all the setting of DEFS everywhere. Use configmake.h to get the values |
64 |
#ifdef DRIZZLE_SERVER
|
1878.3.1
by Monty Taylor
Split set_var.* into sys_var.* and set_var.* |
65 |
/* set_var should change to set_var here ... */
|
66 |
# include <drizzled/sys_var.h>
|
|
722.1.4
by Monty Taylor
Removed all the setting of DEFS everywhere. Use configmake.h to get the values |
67 |
# include <drizzled/item/func.h>
|
68 |
# ifdef DRIZZLE_YACC
|
|
69 |
# define LEX_YYSTYPE void *
|
|
70 |
# else
|
|
71 |
# if defined(DRIZZLE_LEX)
|
|
1237.9.4
by Padraig O'Sullivan
Removed the inclusion of drizzled/field.h in the server_includes header file. |
72 |
# include <drizzled/foreign_key.h>
|
722.1.4
by Monty Taylor
Removed all the setting of DEFS everywhere. Use configmake.h to get the values |
73 |
# include <drizzled/lex_symbol.h>
|
74 |
# include <drizzled/sql_yacc.h>
|
|
75 |
# define LEX_YYSTYPE YYSTYPE *
|
|
76 |
# else
|
|
77 |
# define LEX_YYSTYPE void *
|
|
78 |
# endif /* defined(DRIZZLE_LEX) */ |
|
79 |
# endif /* DRIZZLE_YACC */ |
|
80 |
#endif /* DRIZZLE_SERVER */ |
|
1
by brian
clean slate |
81 |
|
82 |
// describe/explain types
|
|
83 |
#define DESCRIBE_NORMAL 1
|
|
84 |
#define DESCRIBE_EXTENDED 2
|
|
85 |
||
319.1.1
by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_ |
86 |
#ifdef DRIZZLE_SERVER
|
1
by brian
clean slate |
87 |
|
88 |
#define DERIVED_NONE 0
|
|
89 |
#define DERIVED_SUBQUERY 1
|
|
90 |
||
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
91 |
namespace drizzled |
92 |
{
|
|
93 |
||
1
by brian
clean slate |
94 |
typedef List<Item> List_item; |
95 |
||
96 |
enum sub_select_type |
|
97 |
{
|
|
1027
by Brian Aker
Merge Jay |
98 |
UNSPECIFIED_TYPE, |
99 |
UNION_TYPE, |
|
100 |
INTERSECT_TYPE, |
|
101 |
EXCEPT_TYPE, |
|
102 |
GLOBAL_OPTIONS_TYPE, |
|
103 |
DERIVED_TABLE_TYPE, |
|
104 |
OLAP_TYPE
|
|
1
by brian
clean slate |
105 |
};
|
106 |
||
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
107 |
enum olap_type |
1
by brian
clean slate |
108 |
{
|
1027
by Brian Aker
Merge Jay |
109 |
UNSPECIFIED_OLAP_TYPE, |
110 |
CUBE_TYPE, |
|
111 |
ROLLUP_TYPE
|
|
1
by brian
clean slate |
112 |
};
|
113 |
||
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
114 |
/*
|
115 |
The state of the lex parsing for selects
|
|
116 |
||
1
by brian
clean slate |
117 |
master and slaves are pointers to select_lex.
|
118 |
master is pointer to upper level node.
|
|
119 |
slave is pointer to lower level node
|
|
120 |
select_lex is a SELECT without union
|
|
121 |
unit is container of either
|
|
122 |
- One SELECT
|
|
123 |
- UNION of selects
|
|
124 |
select_lex and unit are both inherited form select_lex_node
|
|
125 |
neighbors are two select_lex or units on the same level
|
|
126 |
||
127 |
All select describing structures linked with following pointers:
|
|
128 |
- list of neighbors (next/prev) (prev of first element point to slave
|
|
129 |
pointer of upper structure)
|
|
130 |
- For select this is a list of UNION's (or one element list)
|
|
131 |
- For units this is a list of sub queries for the upper level select
|
|
132 |
||
133 |
- pointer to master (master), which is
|
|
134 |
If this is a unit
|
|
135 |
- pointer to outer select_lex
|
|
136 |
If this is a select_lex
|
|
137 |
- pointer to outer unit structure for select
|
|
138 |
||
139 |
- pointer to slave (slave), which is either:
|
|
140 |
If this is a unit:
|
|
141 |
- first SELECT that belong to this unit
|
|
142 |
If this is a select_lex
|
|
143 |
- first unit that belong to this SELECT (subquries or derived tables)
|
|
144 |
||
145 |
- list of all select_lex (link_next/link_prev)
|
|
146 |
This is to be used for things like derived tables creation, where we
|
|
147 |
go through this list and create the derived tables.
|
|
148 |
||
149 |
If unit contain several selects (UNION now, INTERSECT etc later)
|
|
150 |
then it have special select_lex called fake_select_lex. It used for
|
|
151 |
storing global parameters (like ORDER BY, LIMIT) and executing union.
|
|
152 |
Subqueries used in global ORDER BY clause will be attached to this
|
|
153 |
fake_select_lex, which will allow them correctly resolve fields of
|
|
154 |
'upper' UNION and outer selects.
|
|
155 |
||
156 |
For example for following query:
|
|
157 |
||
158 |
select *
|
|
159 |
from table1
|
|
160 |
where table1.field IN (select * from table1_1_1 union
|
|
161 |
select * from table1_1_2)
|
|
162 |
union
|
|
163 |
select *
|
|
164 |
from table2
|
|
165 |
where table2.field=(select (select f1 from table2_1_1_1_1
|
|
166 |
where table2_1_1_1_1.f2=table2_1_1.f3)
|
|
167 |
from table2_1_1
|
|
168 |
where table2_1_1.f1=table2.f2)
|
|
169 |
union
|
|
170 |
select * from table3;
|
|
171 |
||
172 |
we will have following structure:
|
|
173 |
||
174 |
select1: (select * from table1 ...)
|
|
175 |
select2: (select * from table2 ...)
|
|
176 |
select3: (select * from table3)
|
|
177 |
select1.1.1: (select * from table1_1_1)
|
|
178 |
...
|
|
179 |
||
180 |
main unit
|
|
181 |
fake0
|
|
182 |
select1 select2 select3
|
|
183 |
|^^ |^
|
|
184 |
s||| ||master
|
|
185 |
l||| |+---------------------------------+
|
|
186 |
a||| +---------------------------------+|
|
|
187 |
v|||master slave ||
|
|
188 |
e||+-------------------------+ ||
|
|
189 |
V| neighbor | V|
|
|
190 |
unit1.1<+==================>unit1.2 unit2.1
|
|
191 |
fake1.1
|
|
192 |
select1.1.1 select 1.1.2 select1.2.1 select2.1.1
|
|
193 |
|^
|
|
194 |
||
|
|
195 |
V|
|
|
196 |
unit2.1.1.1
|
|
197 |
select2.1.1.1.1
|
|
198 |
||
199 |
||
200 |
relation in main unit will be following:
|
|
201 |
(bigger picture for:
|
|
202 |
main unit
|
|
203 |
fake0
|
|
204 |
select1 select2 select3
|
|
205 |
in the above picture)
|
|
206 |
||
207 |
main unit
|
|
208 |
|^^^^|fake_select_lex
|
|
209 |
|||||+--------------------------------------------+
|
|
210 |
||||+--------------------------------------------+|
|
|
211 |
|||+------------------------------+ ||
|
|
212 |
||+--------------+ | ||
|
|
213 |
slave||master | | ||
|
|
214 |
V| neighbor | neighbor | master|V
|
|
215 |
select1<========>select2<========>select3 fake0
|
|
216 |
||
217 |
list of all select_lex will be following (as it will be constructed by
|
|
218 |
parser):
|
|
219 |
||
220 |
select1->select2->select3->select2.1.1->select 2.1.2->select2.1.1.1.1-+
|
|
221 |
|
|
|
222 |
+---------------------------------------------------------------------+
|
|
223 |
|
|
|
224 |
+->select1.1.1->select1.1.2
|
|
225 |
||
226 |
*/
|
|
227 |
||
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
228 |
/*
|
846
by Brian Aker
Removing on typedeffed class. |
229 |
Base class for Select_Lex (Select_Lex) &
|
848
by Brian Aker
typdef class removal (just... use the name of the class). |
230 |
Select_Lex_Unit (Select_Lex_Unit)
|
1
by brian
clean slate |
231 |
*/
|
575.4.7
by Monty Taylor
More header cleanup. |
232 |
class LEX; |
846
by Brian Aker
Removing on typedeffed class. |
233 |
class Select_Lex; |
848
by Brian Aker
typdef class removal (just... use the name of the class). |
234 |
class Select_Lex_Unit; |
847
by Brian Aker
More typdef class removal. |
235 |
class Select_Lex_Node { |
1
by brian
clean slate |
236 |
protected: |
847
by Brian Aker
More typdef class removal. |
237 |
Select_Lex_Node *next, **prev, /* neighbor list */ |
1
by brian
clean slate |
238 |
*master, *slave, /* vertical links */ |
846
by Brian Aker
Removing on typedeffed class. |
239 |
*link_next, **link_prev; /* list of whole Select_Lex */ |
1
by brian
clean slate |
240 |
public: |
241 |
||
151
by Brian Aker
Ulonglong to uint64_t |
242 |
uint64_t options; |
1
by brian
clean slate |
243 |
|
244 |
/*
|
|
245 |
result of this query can't be cached, bit field, can be :
|
|
246 |
UNCACHEABLE_DEPENDENT
|
|
247 |
UNCACHEABLE_RAND
|
|
248 |
UNCACHEABLE_SIDEEFFECT
|
|
249 |
UNCACHEABLE_EXPLAIN
|
|
250 |
UNCACHEABLE_PREPARE
|
|
251 |
*/
|
|
1858.1.1
by Padraig O'Sullivan
Replaced a uint8_t member with a standard bitset since it was being used as a bitset.... |
252 |
std::bitset<8> uncacheable; |
1
by brian
clean slate |
253 |
enum sub_select_type linkage; |
254 |
bool no_table_names_allowed; /* used for global order by */ |
|
255 |
bool no_error; /* suppress error message (convert it to warnings) */ |
|
256 |
||
257 |
static void *operator new(size_t size) |
|
258 |
{
|
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
259 |
return memory::sql_alloc(size); |
1
by brian
clean slate |
260 |
}
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
261 |
static void *operator new(size_t size, memory::Root *mem_root) |
1485
by Brian Aker
Updates to confine memroot |
262 |
{ return (void*) mem_root->alloc_root((uint32_t) size); } |
644
by Brian Aker
Clean up warnings for Solaris. |
263 |
static void operator delete(void *, size_t) |
1241.9.57
by Monty Taylor
Oy. Bigger change than I normally like - but this stuff is all intertwined. |
264 |
{ } |
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
265 |
static void operator delete(void *, memory::Root *) |
77.1.7
by Monty Taylor
Heap builds clean. |
266 |
{}
|
847
by Brian Aker
More typdef class removal. |
267 |
Select_Lex_Node(): linkage(UNSPECIFIED_TYPE) {} |
268 |
virtual ~Select_Lex_Node() {} |
|
269 |
inline Select_Lex_Node* get_master() { return master; } |
|
1
by brian
clean slate |
270 |
virtual void init_query(); |
271 |
virtual void init_select(); |
|
847
by Brian Aker
More typdef class removal. |
272 |
void include_down(Select_Lex_Node *upper); |
273 |
void include_neighbour(Select_Lex_Node *before); |
|
274 |
void include_standalone(Select_Lex_Node *sel, Select_Lex_Node **ref); |
|
275 |
void include_global(Select_Lex_Node **plink); |
|
1
by brian
clean slate |
276 |
void exclude(); |
277 |
||
848
by Brian Aker
typdef class removal (just... use the name of the class). |
278 |
virtual Select_Lex_Unit* master_unit()= 0; |
846
by Brian Aker
Removing on typedeffed class. |
279 |
virtual Select_Lex* outer_select()= 0; |
280 |
virtual Select_Lex* return_after_parsing()= 0; |
|
1
by brian
clean slate |
281 |
|
282 |
virtual bool set_braces(bool value); |
|
283 |
virtual bool inc_in_sum_expr(); |
|
202
by Brian Aker
Cleanup sql_lex to modern types. |
284 |
virtual uint32_t get_in_sum_expr(); |
327.2.4
by Brian Aker
Refactoring table.h |
285 |
virtual TableList* get_table_list(); |
1
by brian
clean slate |
286 |
virtual List<Item>* get_item_list(); |
520.1.22
by Brian Aker
Second pass of thd cleanup |
287 |
virtual TableList *add_table_to_list(Session *session, Table_ident *table, |
1858.1.2
by Padraig O'Sullivan
Converted another uint8_t type to be a bitset. |
288 |
LEX_STRING *alias, |
289 |
const std::bitset<NUM_OF_TABLE_OPTIONS>& table_options, |
|
290 |
thr_lock_type flags= TL_UNLOCK, |
|
291 |
List<Index_hint> *hints= 0, |
|
292 |
LEX_STRING *option= 0); |
|
644
by Brian Aker
Clean up warnings for Solaris. |
293 |
virtual void set_lock_for_tables(thr_lock_type) |
77.1.7
by Monty Taylor
Heap builds clean. |
294 |
{}
|
1
by brian
clean slate |
295 |
|
848
by Brian Aker
typdef class removal (just... use the name of the class). |
296 |
friend class Select_Lex_Unit; |
575.4.7
by Monty Taylor
More header cleanup. |
297 |
friend bool mysql_new_select(LEX *lex, bool move_down); |
1
by brian
clean slate |
298 |
private: |
299 |
void fast_exclude(); |
|
300 |
};
|
|
301 |
||
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
302 |
/*
|
848
by Brian Aker
typdef class removal (just... use the name of the class). |
303 |
Select_Lex_Unit - unit of selects (UNION, INTERSECT, ...) group
|
846
by Brian Aker
Removing on typedeffed class. |
304 |
Select_Lexs
|
1
by brian
clean slate |
305 |
*/
|
520.1.21
by Brian Aker
THD -> Session rename |
306 |
class Session; |
1
by brian
clean slate |
307 |
class select_result; |
1541.1.1
by Brian Aker
JOIN -> Join rename |
308 |
class Join; |
1
by brian
clean slate |
309 |
class select_union; |
848
by Brian Aker
typdef class removal (just... use the name of the class). |
310 |
class Select_Lex_Unit: public Select_Lex_Node { |
1
by brian
clean slate |
311 |
protected: |
327.2.4
by Brian Aker
Refactoring table.h |
312 |
TableList result_table_list; |
1
by brian
clean slate |
313 |
select_union *union_result; |
327.1.5
by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h |
314 |
Table *table; /* temporary table using for appending UNION results */ |
1
by brian
clean slate |
315 |
|
316 |
select_result *result; |
|
151
by Brian Aker
Ulonglong to uint64_t |
317 |
uint64_t found_rows_for_union; |
1
by brian
clean slate |
318 |
bool saved_error; |
319 |
||
320 |
public: |
|
321 |
bool prepared, // prepare phase already performed for UNION (unit) |
|
322 |
optimized, // optimize phase already performed for UNION (unit) |
|
323 |
executed, // already executed |
|
324 |
cleaned; |
|
325 |
||
326 |
// list of fields which points to temporary table for union
|
|
327 |
List<Item> item_list; |
|
328 |
/*
|
|
329 |
list of types of items inside union (used for union & derived tables)
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
330 |
|
1
by brian
clean slate |
331 |
Item_type_holders from which this list consist may have pointers to Field,
|
332 |
pointers is valid only after preparing SELECTS of this unit and before
|
|
333 |
any SELECT of this unit execution
|
|
334 |
||
335 |
TODO:
|
|
336 |
Possibly this member should be protected, and its direct use replaced
|
|
337 |
by get_unit_column_types(). Check the places where it is used.
|
|
338 |
*/
|
|
339 |
List<Item> types; |
|
340 |
/*
|
|
341 |
Pointer to 'last' select or pointer to unit where stored
|
|
342 |
global parameters for union
|
|
343 |
*/
|
|
846
by Brian Aker
Removing on typedeffed class. |
344 |
Select_Lex *global_parameters; |
1
by brian
clean slate |
345 |
//node on wich we should return current_select pointer after parsing subquery
|
846
by Brian Aker
Removing on typedeffed class. |
346 |
Select_Lex *return_to; |
1
by brian
clean slate |
347 |
/* LIMIT clause runtime counters */
|
348 |
ha_rows select_limit_cnt, offset_limit_cnt; |
|
349 |
/* not NULL if unit used in subselect, point to subselect item */
|
|
350 |
Item_subselect *item; |
|
351 |
/* thread handler */
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
352 |
Session *session; |
1
by brian
clean slate |
353 |
/*
|
846
by Brian Aker
Removing on typedeffed class. |
354 |
Select_Lex for hidden SELECT in onion which process global
|
1
by brian
clean slate |
355 |
ORDER BY and LIMIT
|
356 |
*/
|
|
846
by Brian Aker
Removing on typedeffed class. |
357 |
Select_Lex *fake_select_lex; |
1
by brian
clean slate |
358 |
|
846
by Brian Aker
Removing on typedeffed class. |
359 |
Select_Lex *union_distinct; /* pointer to the last UNION DISTINCT */ |
1
by brian
clean slate |
360 |
bool describe; /* union exec() called for EXPLAIN */ |
361 |
||
362 |
void init_query(); |
|
848
by Brian Aker
typdef class removal (just... use the name of the class). |
363 |
Select_Lex_Unit* master_unit(); |
846
by Brian Aker
Removing on typedeffed class. |
364 |
Select_Lex* outer_select(); |
365 |
Select_Lex* first_select() |
|
366 |
{
|
|
367 |
return reinterpret_cast<Select_Lex*>(slave); |
|
368 |
}
|
|
848
by Brian Aker
typdef class removal (just... use the name of the class). |
369 |
Select_Lex_Unit* next_unit() |
846
by Brian Aker
Removing on typedeffed class. |
370 |
{
|
848
by Brian Aker
typdef class removal (just... use the name of the class). |
371 |
return reinterpret_cast<Select_Lex_Unit*>(next); |
846
by Brian Aker
Removing on typedeffed class. |
372 |
}
|
373 |
Select_Lex* return_after_parsing() { return return_to; } |
|
1
by brian
clean slate |
374 |
void exclude_level(); |
375 |
void exclude_tree(); |
|
376 |
||
377 |
/* UNION methods */
|
|
892.2.4
by Monty Taylor
Fixed more warnings. |
378 |
bool prepare(Session *session, select_result *result, |
379 |
uint64_t additional_options); |
|
1
by brian
clean slate |
380 |
bool exec(); |
381 |
bool cleanup(); |
|
382 |
inline void unclean() { cleaned= 0; } |
|
383 |
void reinit_exec_mechanism(); |
|
384 |
||
385 |
void print(String *str, enum_query_type query_type); |
|
386 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
387 |
bool add_fake_select_lex(Session *session); |
388 |
void init_prepare_fake_select_lex(Session *session); |
|
1
by brian
clean slate |
389 |
bool change_result(select_result_interceptor *result, |
390 |
select_result_interceptor *old_result); |
|
846
by Brian Aker
Removing on typedeffed class. |
391 |
void set_limit(Select_Lex *values); |
520.1.22
by Brian Aker
Second pass of thd cleanup |
392 |
void set_session(Session *session_arg) { session= session_arg; } |
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
393 |
inline bool is_union (); |
1
by brian
clean slate |
394 |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
395 |
friend void lex_start(Session *session); |
1
by brian
clean slate |
396 |
friend int subselect_union_engine::exec(); |
397 |
||
398 |
List<Item> *get_unit_column_types(); |
|
399 |
};
|
|
400 |
||
401 |
/*
|
|
846
by Brian Aker
Removing on typedeffed class. |
402 |
Select_Lex - store information of parsed SELECT statment
|
1
by brian
clean slate |
403 |
*/
|
847
by Brian Aker
More typdef class removal. |
404 |
class Select_Lex: public Select_Lex_Node |
1
by brian
clean slate |
405 |
{
|
406 |
public: |
|
1889.1.3
by Brian Aker
Merge in additional C++ warning fixes. |
407 |
|
408 |
Select_Lex() : |
|
409 |
context(), |
|
410 |
db(0), |
|
411 |
where(0), |
|
412 |
having(0), |
|
413 |
cond_value(), |
|
414 |
having_value(), |
|
415 |
parent_lex(0), |
|
416 |
olap(UNSPECIFIED_OLAP_TYPE), |
|
417 |
table_list(), |
|
418 |
group_list(), |
|
419 |
item_list(), |
|
420 |
interval_list(), |
|
421 |
is_item_list_lookup(false), |
|
422 |
join(0), |
|
423 |
top_join_list(), |
|
424 |
join_list(0), |
|
425 |
embedding(0), |
|
426 |
sj_nests(), |
|
427 |
leaf_tables(0), |
|
428 |
type(optimizer::ST_PRIMARY), |
|
429 |
order_list(), |
|
430 |
gorder_list(0), |
|
431 |
select_limit(0), |
|
432 |
offset_limit(0), |
|
433 |
ref_pointer_array(0), |
|
434 |
select_n_having_items(0), |
|
435 |
cond_count(0), |
|
436 |
between_count(0), |
|
437 |
max_equal_elems(0), |
|
438 |
select_n_where_fields(0), |
|
439 |
parsing_place(NO_MATTER), |
|
440 |
with_sum_func(0), |
|
441 |
in_sum_expr(0), |
|
442 |
select_number(0), |
|
443 |
nest_level(0), |
|
444 |
inner_sum_func_list(0), |
|
445 |
with_wild(0), |
|
446 |
braces(0), |
|
447 |
having_fix_field(0), |
|
448 |
inner_refs_list(), |
|
449 |
n_sum_items(0), |
|
450 |
n_child_sum_items(0), |
|
451 |
explicit_limit(0), |
|
452 |
subquery_in_having(0), |
|
453 |
is_correlated(0), |
|
454 |
exclude_from_table_unique_test(0), |
|
455 |
non_agg_fields(), |
|
456 |
cur_pos_in_select_list(0), |
|
457 |
prev_join_using(0), |
|
458 |
full_group_by_flag(), |
|
459 |
current_index_hint_type(INDEX_HINT_IGNORE), |
|
460 |
current_index_hint_clause(), |
|
461 |
index_hints(0) |
|
462 |
{
|
|
463 |
}
|
|
464 |
||
1
by brian
clean slate |
465 |
Name_resolution_context context; |
466 |
char *db; |
|
1014.4.9
by Jay Pipes
Code style cleanup and removal of dead LEX_SERVER_OPTIONS struct |
467 |
/* An Item representing the WHERE clause */
|
468 |
Item *where; |
|
469 |
/* An Item representing the HAVING clause */
|
|
470 |
Item *having; |
|
1
by brian
clean slate |
471 |
/* Saved values of the WHERE and HAVING clauses*/
|
1014.4.9
by Jay Pipes
Code style cleanup and removal of dead LEX_SERVER_OPTIONS struct |
472 |
Item::cond_result cond_value; |
473 |
Item::cond_result having_value; |
|
1
by brian
clean slate |
474 |
/* point on lex in which it was created, used in view subquery detection */
|
575.4.7
by Monty Taylor
More header cleanup. |
475 |
LEX *parent_lex; |
1
by brian
clean slate |
476 |
enum olap_type olap; |
327.2.4
by Brian Aker
Refactoring table.h |
477 |
/* FROM clause - points to the beginning of the TableList::next_local list. */
|
1014.4.9
by Jay Pipes
Code style cleanup and removal of dead LEX_SERVER_OPTIONS struct |
478 |
SQL_LIST table_list; |
479 |
SQL_LIST group_list; /* GROUP BY clause. */ |
|
480 |
List<Item> item_list; /* list of fields & expressions */ |
|
481 |
List<String> interval_list; |
|
482 |
bool is_item_list_lookup; |
|
1541.1.1
by Brian Aker
JOIN -> Join rename |
483 |
Join *join; /* after Join::prepare it is pointer to corresponding JOIN */ |
327.2.4
by Brian Aker
Refactoring table.h |
484 |
List<TableList> top_join_list; /* join list of the top level */ |
485 |
List<TableList> *join_list; /* list for the currently parsed join */ |
|
486 |
TableList *embedding; /* table embedding to the above list */ |
|
487 |
List<TableList> sj_nests; |
|
1
by brian
clean slate |
488 |
/*
|
489 |
Beginning of the list of leaves in a FROM clause, where the leaves
|
|
490 |
inlcude all base tables including view tables. The tables are connected
|
|
327.2.4
by Brian Aker
Refactoring table.h |
491 |
by TableList::next_leaf, so leaf_tables points to the left-most leaf.
|
1
by brian
clean slate |
492 |
*/
|
327.2.4
by Brian Aker
Refactoring table.h |
493 |
TableList *leaf_tables; |
1237.13.30
by Padraig O'Sullivan
Corrected a valgrind warning due to using std::string in the Select_Lex class whose memory is |
494 |
enum drizzled::optimizer::select_type type; /* type of select for EXPLAIN */ |
1
by brian
clean slate |
495 |
|
496 |
SQL_LIST order_list; /* ORDER clause */ |
|
497 |
SQL_LIST *gorder_list; |
|
498 |
Item *select_limit, *offset_limit; /* LIMIT clause parameters */ |
|
1014.4.9
by Jay Pipes
Code style cleanup and removal of dead LEX_SERVER_OPTIONS struct |
499 |
/* Arrays of pointers to top elements of all_fields list */
|
1
by brian
clean slate |
500 |
Item **ref_pointer_array; |
501 |
||
502 |
/*
|
|
503 |
number of items in select_list and HAVING clause used to get number
|
|
504 |
bigger then can be number of entries that will be added to all item
|
|
505 |
list during split_sum_func
|
|
506 |
*/
|
|
202
by Brian Aker
Cleanup sql_lex to modern types. |
507 |
uint32_t select_n_having_items; |
508 |
uint32_t cond_count; /* number of arguments of and/or/xor in where/having/on */ |
|
509 |
uint32_t between_count; /* number of between predicates in where/having/on */ |
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
510 |
uint32_t max_equal_elems; /* maximal number of elements in multiple equalities */ |
1
by brian
clean slate |
511 |
/*
|
512 |
Number of fields used in select list or where clause of current select
|
|
513 |
and all inner subselects.
|
|
514 |
*/
|
|
202
by Brian Aker
Cleanup sql_lex to modern types. |
515 |
uint32_t select_n_where_fields; |
1
by brian
clean slate |
516 |
enum_parsing_place parsing_place; /* where we are parsing expression */ |
517 |
bool with_sum_func; /* sum function indicator */ |
|
518 |
||
202
by Brian Aker
Cleanup sql_lex to modern types. |
519 |
uint32_t in_sum_expr; |
520 |
uint32_t select_number; /* number of select (used for EXPLAIN) */ |
|
937.2.6
by Stewart Smith
make set_if_bigger typesafe for C and C++. Fix up everywhere. |
521 |
int8_t nest_level; /* nesting level of select */ |
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
522 |
Item_sum *inner_sum_func_list; /* list of sum func in nested selects */ |
202
by Brian Aker
Cleanup sql_lex to modern types. |
523 |
uint32_t with_wild; /* item list contain '*' */ |
1014.4.9
by Jay Pipes
Code style cleanup and removal of dead LEX_SERVER_OPTIONS struct |
524 |
bool braces; /* SELECT ... UNION (SELECT ... ) <- this braces */ |
51.1.52
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE |
525 |
/* true when having fix field called in processing of this SELECT */
|
1
by brian
clean slate |
526 |
bool having_fix_field; |
527 |
/* List of references to fields referenced from inner selects */
|
|
528 |
List<Item_outer_ref> inner_refs_list; |
|
529 |
/* Number of Item_sum-derived objects in this SELECT */
|
|
202
by Brian Aker
Cleanup sql_lex to modern types. |
530 |
uint32_t n_sum_items; |
1
by brian
clean slate |
531 |
/* Number of Item_sum-derived objects in children and descendant SELECTs */
|
202
by Brian Aker
Cleanup sql_lex to modern types. |
532 |
uint32_t n_child_sum_items; |
1
by brian
clean slate |
533 |
|
534 |
/* explicit LIMIT clause was used */
|
|
535 |
bool explicit_limit; |
|
536 |
/*
|
|
537 |
there are subquery in HAVING clause => we can't close tables before
|
|
538 |
query processing end even if we use temporary table
|
|
539 |
*/
|
|
540 |
bool subquery_in_having; |
|
51.1.52
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE |
541 |
/* true <=> this SELECT is correlated w.r.t. some ancestor select */
|
1
by brian
clean slate |
542 |
bool is_correlated; |
543 |
/* exclude this select from check of unique_table() */
|
|
544 |
bool exclude_from_table_unique_test; |
|
545 |
/* List of fields that aren't under an aggregate function */
|
|
546 |
List<Item_field> non_agg_fields; |
|
547 |
/* index in the select list of the expression currently being fixed */
|
|
548 |
int cur_pos_in_select_list; |
|
549 |
||
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
550 |
/*
|
1
by brian
clean slate |
551 |
This is a copy of the original JOIN USING list that comes from
|
552 |
the parser. The parser :
|
|
327.2.4
by Brian Aker
Refactoring table.h |
553 |
1. Sets the natural_join of the second TableList in the join
|
846
by Brian Aker
Removing on typedeffed class. |
554 |
and the Select_Lex::prev_join_using.
|
327.2.4
by Brian Aker
Refactoring table.h |
555 |
2. Makes a parent TableList and sets its is_natural_join/
|
1
by brian
clean slate |
556 |
join_using_fields members.
|
327.2.4
by Brian Aker
Refactoring table.h |
557 |
3. Uses the wrapper TableList as a table in the upper level.
|
1
by brian
clean slate |
558 |
We cannot assign directly to join_using_fields in the parser because
|
327.2.4
by Brian Aker
Refactoring table.h |
559 |
at stage (1.) the parent TableList is not constructed yet and
|
1
by brian
clean slate |
560 |
the assignment will override the JOIN USING fields of the lower level
|
561 |
joins on the right.
|
|
562 |
*/
|
|
563 |
List<String> *prev_join_using; |
|
564 |
/*
|
|
565 |
Bitmap used in the ONLY_FULL_GROUP_BY_MODE to prevent mixture of aggregate
|
|
566 |
functions and non aggregated fields when GROUP BY list is absent.
|
|
567 |
Bits:
|
|
568 |
0 - non aggregated fields are used in this select,
|
|
569 |
defined as NON_AGG_FIELD_USED.
|
|
570 |
1 - aggregate functions are used in this select,
|
|
571 |
defined as SUM_FUNC_USED.
|
|
572 |
*/
|
|
1089.6.3
by Padraig O'Sullivan
Replaced an instance where a uint8_t type was being used to hold a |
573 |
std::bitset<2> full_group_by_flag; |
1637.1.3
by Brian Aker
This fixes the parser to no longer do the bad syntax around the cross join |
574 |
|
1
by brian
clean slate |
575 |
void init_query(); |
576 |
void init_select(); |
|
848
by Brian Aker
typdef class removal (just... use the name of the class). |
577 |
Select_Lex_Unit* master_unit(); |
578 |
Select_Lex_Unit* first_inner_unit() |
|
846
by Brian Aker
Removing on typedeffed class. |
579 |
{
|
848
by Brian Aker
typdef class removal (just... use the name of the class). |
580 |
return (Select_Lex_Unit*) slave; |
846
by Brian Aker
Removing on typedeffed class. |
581 |
}
|
582 |
Select_Lex* outer_select(); |
|
1014.4.9
by Jay Pipes
Code style cleanup and removal of dead LEX_SERVER_OPTIONS struct |
583 |
Select_Lex* next_select() |
584 |
{
|
|
585 |
return (Select_Lex*) next; |
|
586 |
}
|
|
846
by Brian Aker
Removing on typedeffed class. |
587 |
Select_Lex* next_select_in_list() |
588 |
{
|
|
589 |
return (Select_Lex*) link_next; |
|
590 |
}
|
|
847
by Brian Aker
More typdef class removal. |
591 |
Select_Lex_Node** next_select_in_list_addr() |
1
by brian
clean slate |
592 |
{
|
593 |
return &link_next; |
|
594 |
}
|
|
846
by Brian Aker
Removing on typedeffed class. |
595 |
Select_Lex* return_after_parsing() |
1
by brian
clean slate |
596 |
{
|
597 |
return master_unit()->return_after_parsing(); |
|
598 |
}
|
|
599 |
||
846
by Brian Aker
Removing on typedeffed class. |
600 |
void mark_as_dependent(Select_Lex *last); |
1
by brian
clean slate |
601 |
|
602 |
bool set_braces(bool value); |
|
603 |
bool inc_in_sum_expr(); |
|
202
by Brian Aker
Cleanup sql_lex to modern types. |
604 |
uint32_t get_in_sum_expr(); |
1
by brian
clean slate |
605 |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
606 |
bool add_item_to_list(Session *session, Item *item); |
607 |
bool add_group_to_list(Session *session, Item *item, bool asc); |
|
608 |
bool add_order_to_list(Session *session, Item *item, bool asc); |
|
1027
by Brian Aker
Merge Jay |
609 |
TableList* add_table_to_list(Session *session, |
610 |
Table_ident *table, |
|
611 |
LEX_STRING *alias, |
|
1858.1.2
by Padraig O'Sullivan
Converted another uint8_t type to be a bitset. |
612 |
const std::bitset<NUM_OF_TABLE_OPTIONS>& table_options, |
1027
by Brian Aker
Merge Jay |
613 |
thr_lock_type flags= TL_UNLOCK, |
614 |
List<Index_hint> *hints= 0, |
|
615 |
LEX_STRING *option= 0); |
|
327.2.4
by Brian Aker
Refactoring table.h |
616 |
TableList* get_table_list(); |
520.1.22
by Brian Aker
Second pass of thd cleanup |
617 |
bool init_nested_join(Session *session); |
618 |
TableList *end_nested_join(Session *session); |
|
619 |
TableList *nest_last_join(Session *session); |
|
327.2.4
by Brian Aker
Refactoring table.h |
620 |
void add_joined_table(TableList *table); |
621 |
TableList *convert_right_join(); |
|
1
by brian
clean slate |
622 |
List<Item>* get_item_list(); |
623 |
void set_lock_for_tables(thr_lock_type lock_type); |
|
624 |
inline void init_order() |
|
625 |
{
|
|
626 |
order_list.elements= 0; |
|
627 |
order_list.first= 0; |
|
481
by Brian Aker
Remove all of uchar. |
628 |
order_list.next= (unsigned char**) &order_list.first; |
1
by brian
clean slate |
629 |
}
|
630 |
/*
|
|
631 |
This method created for reiniting LEX in mysql_admin_table() and can be
|
|
846
by Brian Aker
Removing on typedeffed class. |
632 |
used only if you are going remove all Select_Lex & units except belonger
|
1
by brian
clean slate |
633 |
to LEX (LEX::unit & LEX::select, for other purposes there are
|
848
by Brian Aker
typdef class removal (just... use the name of the class). |
634 |
Select_Lex_Unit::exclude_level & Select_Lex_Unit::exclude_tree
|
1
by brian
clean slate |
635 |
*/
|
1014.4.9
by Jay Pipes
Code style cleanup and removal of dead LEX_SERVER_OPTIONS struct |
636 |
void cut_subtree() |
637 |
{
|
|
638 |
slave= 0; |
|
639 |
}
|
|
1
by brian
clean slate |
640 |
bool test_limit(); |
641 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
642 |
friend void lex_start(Session *session); |
1
by brian
clean slate |
643 |
void make_empty_select() |
644 |
{
|
|
645 |
init_query(); |
|
646 |
init_select(); |
|
647 |
}
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
648 |
bool setup_ref_array(Session *session, uint32_t order_group_num); |
649 |
void print(Session *session, String *str, enum_query_type query_type); |
|
1
by brian
clean slate |
650 |
static void print_order(String *str, |
1892.3.3
by tdavies
struct order_st changed and renamed to c++ class named:Order |
651 |
Order *order, |
1
by brian
clean slate |
652 |
enum_query_type query_type); |
520.1.22
by Brian Aker
Second pass of thd cleanup |
653 |
void print_limit(Session *session, String *str, enum_query_type query_type); |
654 |
void fix_prepare_information(Session *session, Item **conds, Item **having_conds); |
|
1
by brian
clean slate |
655 |
/*
|
656 |
Destroy the used execution plan (JOIN) of this subtree (this
|
|
848
by Brian Aker
typdef class removal (just... use the name of the class). |
657 |
Select_Lex and all nested Select_Lexes and Select_Lex_Units).
|
1
by brian
clean slate |
658 |
*/
|
659 |
bool cleanup(); |
|
660 |
/*
|
|
661 |
Recursively cleanup the join of this select lex and of all nested
|
|
662 |
select lexes.
|
|
663 |
*/
|
|
664 |
void cleanup_all_joins(bool full); |
|
665 |
||
666 |
void set_index_hint_type(enum index_hint_type type, index_clause_map clause); |
|
667 |
||
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
668 |
/*
|
1
by brian
clean slate |
669 |
Add a index hint to the tagged list of hints. The type and clause of the
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
670 |
hint will be the current ones (set by set_index_hint())
|
1
by brian
clean slate |
671 |
*/
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
672 |
bool add_index_hint (Session *session, char *str, uint32_t length); |
1
by brian
clean slate |
673 |
|
674 |
/* make a list to hold index hints */
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
675 |
void alloc_index_hints (Session *session); |
1
by brian
clean slate |
676 |
/* read and clear the index hints */
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
677 |
List<Index_hint>* pop_index_hints(void) |
1
by brian
clean slate |
678 |
{
|
679 |
List<Index_hint> *hints= index_hints; |
|
680 |
index_hints= NULL; |
|
681 |
return hints; |
|
682 |
}
|
|
683 |
||
684 |
void clear_index_hints(void) { index_hints= NULL; } |
|
685 |
||
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
686 |
private: |
1
by brian
clean slate |
687 |
/* current index hint kind. used in filling up index_hints */
|
688 |
enum index_hint_type current_index_hint_type; |
|
689 |
index_clause_map current_index_hint_clause; |
|
690 |
/* a list of USE/FORCE/IGNORE INDEX */
|
|
691 |
List<Index_hint> *index_hints; |
|
692 |
};
|
|
693 |
||
848
by Brian Aker
typdef class removal (just... use the name of the class). |
694 |
inline bool Select_Lex_Unit::is_union () |
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
695 |
{
|
696 |
return first_select()->next_select() && |
|
1
by brian
clean slate |
697 |
first_select()->next_select()->linkage == UNION_TYPE; |
698 |
}
|
|
699 |
||
1014.4.9
by Jay Pipes
Code style cleanup and removal of dead LEX_SERVER_OPTIONS struct |
700 |
enum xa_option_words |
701 |
{
|
|
702 |
XA_NONE
|
|
703 |
, XA_JOIN |
|
704 |
, XA_RESUME |
|
705 |
, XA_ONE_PHASE |
|
706 |
, XA_SUSPEND |
|
707 |
, XA_FOR_MIGRATE |
|
708 |
};
|
|
1
by brian
clean slate |
709 |
|
710 |
extern const LEX_STRING null_lex_str; |
|
711 |
||
712 |
/*
|
|
713 |
Class representing list of all tables used by statement.
|
|
714 |
It also contains information about stored functions used by statement
|
|
715 |
since during its execution we may have to add all tables used by its
|
|
716 |
stored functions/triggers to this list in order to pre-open and lock
|
|
717 |
them.
|
|
718 |
||
719 |
Also used by st_lex::reset_n_backup/restore_backup_query_tables_list()
|
|
720 |
methods to save and restore this information.
|
|
721 |
*/
|
|
722 |
class Query_tables_list |
|
723 |
{
|
|
724 |
public: |
|
725 |
/* Global list of all tables used by this statement */
|
|
327.2.4
by Brian Aker
Refactoring table.h |
726 |
TableList *query_tables; |
1
by brian
clean slate |
727 |
/* Pointer to next_global member of last element in the previous list. */
|
327.2.4
by Brian Aker
Refactoring table.h |
728 |
TableList **query_tables_last; |
1
by brian
clean slate |
729 |
/*
|
730 |
If non-0 then indicates that query requires prelocking and points to
|
|
731 |
next_global member of last own element in query table list (i.e. last
|
|
732 |
table which was not added to it as part of preparation to prelocking).
|
|
733 |
0 - indicates that this query does not need prelocking.
|
|
734 |
*/
|
|
327.2.4
by Brian Aker
Refactoring table.h |
735 |
TableList **query_tables_own_last; |
1
by brian
clean slate |
736 |
|
737 |
/*
|
|
738 |
These constructor and destructor serve for creation/destruction
|
|
739 |
of Query_tables_list instances which are used as backup storage.
|
|
740 |
*/
|
|
741 |
Query_tables_list() {} |
|
1240.9.3
by Monty Taylor
remark #444: destructor for base class "Query_tables_list" (declared at line 656) is not virtual |
742 |
virtual ~Query_tables_list() {} |
1
by brian
clean slate |
743 |
|
744 |
/* Initializes (or resets) Query_tables_list object for "real" use. */
|
|
745 |
void reset_query_tables_list(bool init); |
|
746 |
||
747 |
/*
|
|
748 |
Direct addition to the list of query tables.
|
|
749 |
If you are using this function, you must ensure that the table
|
|
750 |
object, in particular table->db member, is initialized.
|
|
751 |
*/
|
|
327.2.4
by Brian Aker
Refactoring table.h |
752 |
void add_to_query_tables(TableList *table) |
1
by brian
clean slate |
753 |
{
|
754 |
*(table->prev_global= query_tables_last)= table; |
|
755 |
query_tables_last= &table->next_global; |
|
756 |
}
|
|
757 |
/* Return pointer to first not-own table in query-tables or 0 */
|
|
327.2.4
by Brian Aker
Refactoring table.h |
758 |
TableList* first_not_own_table() |
1
by brian
clean slate |
759 |
{
|
760 |
return ( query_tables_own_last ? *query_tables_own_last : 0); |
|
761 |
}
|
|
762 |
void chop_off_not_own_tables() |
|
763 |
{
|
|
764 |
if (query_tables_own_last) |
|
765 |
{
|
|
766 |
*query_tables_own_last= 0; |
|
767 |
query_tables_last= query_tables_own_last; |
|
768 |
query_tables_own_last= 0; |
|
769 |
}
|
|
770 |
}
|
|
771 |
};
|
|
772 |
||
773 |
/**
|
|
774 |
The state of the lexical parser, when parsing comments.
|
|
775 |
*/
|
|
776 |
enum enum_comment_state |
|
777 |
{
|
|
778 |
/**
|
|
779 |
Not parsing comments.
|
|
780 |
*/
|
|
781 |
NO_COMMENT, |
|
782 |
/**
|
|
783 |
Parsing comments that need to be preserved.
|
|
784 |
Typically, these are user comments '/' '*' ... '*' '/'.
|
|
785 |
*/
|
|
786 |
PRESERVE_COMMENT, |
|
787 |
/**
|
|
788 |
Parsing comments that need to be discarded.
|
|
789 |
Typically, these are special comments '/' '*' '!' ... '*' '/',
|
|
790 |
or '/' '*' '!' 'M' 'M' 'm' 'm' 'm' ... '*' '/', where the comment
|
|
791 |
markers should not be expanded.
|
|
792 |
*/
|
|
793 |
DISCARD_COMMENT
|
|
794 |
};
|
|
795 |
||
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
796 |
} /* namespace drizzled */ |
797 |
||
1014.4.8
by Jay Pipes
Split Lex_input_stream out into its own header. |
798 |
#include "drizzled/lex_input_stream.h" |
1
by brian
clean slate |
799 |
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
800 |
namespace drizzled |
801 |
{
|
|
802 |
||
520.1.21
by Brian Aker
THD -> Session rename |
803 |
/* The state of the lex parsing. This is saved in the Session struct */
|
575.4.7
by Monty Taylor
More header cleanup. |
804 |
class LEX : public Query_tables_list |
1
by brian
clean slate |
805 |
{
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
806 |
public: |
848
by Brian Aker
typdef class removal (just... use the name of the class). |
807 |
Select_Lex_Unit unit; /* most upper unit */ |
846
by Brian Aker
Removing on typedeffed class. |
808 |
Select_Lex select_lex; /* first Select_Lex */ |
809 |
/* current Select_Lex in parsing */
|
|
810 |
Select_Lex *current_select; |
|
811 |
/* list of all Select_Lex */
|
|
812 |
Select_Lex *all_selects_list; |
|
1
by brian
clean slate |
813 |
|
1014.4.5
by Jay Pipes
Cleanup of LEX structure. Removed unused xid member variable, documented a number of member variables. |
814 |
/* This is the "scale" for DECIMAL (S,P) notation */
|
815 |
char *length; |
|
816 |
/* This is the decimal precision in DECIMAL(S,P) notation */
|
|
817 |
char *dec; |
|
818 |
||
1014.4.7
by Jay Pipes
More documentation of LEX member variables and removal of slave_session_opt unused member variable. |
819 |
/**
|
820 |
* This is used kind of like the "ident" member variable below, as
|
|
821 |
* a place to store certain names of identifiers. Unfortunately, it
|
|
822 |
* is used differently depending on the Command (SELECT on a derived
|
|
823 |
* table vs CREATE)
|
|
824 |
*/
|
|
1
by brian
clean slate |
825 |
LEX_STRING name; |
1014.4.7
by Jay Pipes
More documentation of LEX member variables and removal of slave_session_opt unused member variable. |
826 |
/* The string literal used in a LIKE expression */
|
1
by brian
clean slate |
827 |
String *wild; |
831.1.2
by Brian Aker
Rename class file_exchange |
828 |
file_exchange *exchange; |
1
by brian
clean slate |
829 |
select_result *result; |
1014.4.5
by Jay Pipes
Cleanup of LEX structure. Removed unused xid member variable, documented a number of member variables. |
830 |
|
1014.4.7
by Jay Pipes
More documentation of LEX member variables and removal of slave_session_opt unused member variable. |
831 |
/**
|
832 |
* This is current used to store the name of a named key cache
|
|
833 |
* or a named savepoint. It should probably be refactored out into
|
|
834 |
* the eventual Command class built for the Keycache and Savepoint
|
|
835 |
* commands.
|
|
836 |
*/
|
|
1014.4.5
by Jay Pipes
Cleanup of LEX structure. Removed unused xid member variable, documented a number of member variables. |
837 |
LEX_STRING ident; |
838 |
||
481
by Brian Aker
Remove all of uchar. |
839 |
unsigned char* yacc_yyss, *yacc_yyvs; |
1014.4.7
by Jay Pipes
More documentation of LEX member variables and removal of slave_session_opt unused member variable. |
840 |
/* The owning Session of this LEX */
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
841 |
Session *session; |
264.2.6
by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code. |
842 |
const CHARSET_INFO *charset; |
1
by brian
clean slate |
843 |
bool text_string_is_7bit; |
844 |
/* store original leaf_tables for INSERT SELECT and PS/SP */
|
|
327.2.4
by Brian Aker
Refactoring table.h |
845 |
TableList *leaf_tables_insert; |
1
by brian
clean slate |
846 |
|
847 |
List<Key_part_spec> col_list; |
|
848 |
List<Key_part_spec> ref_list; |
|
849 |
List<String> interval_list; |
|
851
by Brian Aker
Class rewrite of Session (aka get all of the junk out) |
850 |
List<Lex_Column> columns; |
1
by brian
clean slate |
851 |
List<Item> *insert_list,field_list,value_list,update_list; |
852 |
List<List_item> many_values; |
|
853 |
List<set_var_base> var_list; |
|
854 |
/*
|
|
855 |
A stack of name resolution contexts for the query. This stack is used
|
|
856 |
at parse time to set local name resolution contexts for various parts
|
|
857 |
of a query. For example, in a JOIN ... ON (some_condition) clause the
|
|
858 |
Items in 'some_condition' must be resolved only against the operands
|
|
859 |
of the the join, and not against the whole clause. Similarly, Items in
|
|
860 |
subqueries should be resolved against the subqueries (and outer queries).
|
|
861 |
The stack is used in the following way: when the parser detects that
|
|
862 |
all Items in some clause need a local context, it creates a new context
|
|
863 |
and pushes it on the stack. All newly created Items always store the
|
|
864 |
top-most context in the stack. Once the parser leaves the clause that
|
|
865 |
required a local context, the parser pops the top-most context.
|
|
866 |
*/
|
|
867 |
List<Name_resolution_context> context_stack; |
|
868 |
||
1014.4.5
by Jay Pipes
Cleanup of LEX structure. Removed unused xid member variable, documented a number of member variables. |
869 |
SQL_LIST auxiliary_table_list; |
870 |
SQL_LIST save_list; |
|
1052.2.3
by Nathan Williams
No actual code changes. Changed Create_field to CreateField to be consistent with coding standards. |
871 |
CreateField *last_field; |
1
by brian
clean slate |
872 |
Item_sum *in_sum_func; |
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
873 |
plugin::Function *udf; |
202
by Brian Aker
Cleanup sql_lex to modern types. |
874 |
uint32_t type; |
1
by brian
clean slate |
875 |
/*
|
876 |
This variable is used in post-parse stage to declare that sum-functions,
|
|
877 |
or functions which have sense only if GROUP BY is present, are allowed.
|
|
878 |
For example in a query
|
|
879 |
SELECT ... FROM ...WHERE MIN(i) == 1 GROUP BY ... HAVING MIN(i) > 2
|
|
880 |
MIN(i) in the WHERE clause is not allowed in the opposite to MIN(i)
|
|
881 |
in the HAVING clause. Due to possible nesting of select construct
|
|
882 |
the variable can contain 0 or 1 for each nest level.
|
|
883 |
*/
|
|
884 |
nesting_map allow_sum_func; |
|
885 |
enum_sql_command sql_command; |
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
886 |
statement::Statement *statement; |
1
by brian
clean slate |
887 |
/*
|
888 |
Usually `expr` rule of yacc is quite reused but some commands better
|
|
889 |
not support subqueries which comes standard with this rule, like
|
|
890 |
KILL, HA_READ, CREATE/ALTER EVENT etc. Set this to `false` to get
|
|
891 |
syntax error back.
|
|
892 |
*/
|
|
893 |
bool expr_allows_subselect; |
|
894 |
||
895 |
thr_lock_type lock_option; |
|
896 |
enum enum_duplicates duplicates; |
|
897 |
union { |
|
898 |
enum ha_rkey_function ha_rkey_mode; |
|
899 |
enum xa_option_words xa_opt; |
|
900 |
};
|
|
1273.13.24
by Brian Aker
Updating style, simplified code. |
901 |
sql_var_t option_type; |
1
by brian
clean slate |
902 |
|
903 |
int nest_level; |
|
202
by Brian Aker
Cleanup sql_lex to modern types. |
904 |
uint8_t describe; |
1
by brian
clean slate |
905 |
/*
|
906 |
A flag that indicates what kinds of derived tables are present in the
|
|
907 |
query (0 if no derived tables, otherwise DERIVED_SUBQUERY).
|
|
908 |
*/
|
|
202
by Brian Aker
Cleanup sql_lex to modern types. |
909 |
uint8_t derived_tables; |
1014.4.7
by Jay Pipes
More documentation of LEX member variables and removal of slave_session_opt unused member variable. |
910 |
|
911 |
/* Was the IGNORE symbol found in statement */
|
|
1014.4.5
by Jay Pipes
Cleanup of LEX structure. Removed unused xid member variable, documented a number of member variables. |
912 |
bool ignore; |
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
913 |
|
1
by brian
clean slate |
914 |
/**
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
915 |
During name resolution search only in the table list given by
|
1
by brian
clean slate |
916 |
Name_resolution_context::first_name_resolution_table and
|
917 |
Name_resolution_context::last_name_resolution_table
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
918 |
(see Item_field::fix_fields()).
|
1
by brian
clean slate |
919 |
*/
|
920 |
bool use_only_table_context; |
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
921 |
|
1014.4.7
by Jay Pipes
More documentation of LEX member variables and removal of slave_session_opt unused member variable. |
922 |
/* Was the ESCAPE keyword used? */
|
1
by brian
clean slate |
923 |
bool escape_used; |
924 |
bool is_lex_started; /* If lex_start() did run. For debugging. */ |
|
925 |
||
575.4.7
by Monty Taylor
More header cleanup. |
926 |
LEX(); |
1
by brian
clean slate |
927 |
|
1008.3.17
by Stewart Smith
Start work to construct table proto in parser: |
928 |
/* Note that init and de-init mostly happen in lex_start and lex_end
|
929 |
and not here. This is because LEX isn't delete/new for each new
|
|
930 |
statement in a session. It's re-used by doing lex_end, lex_start
|
|
931 |
in sql_lex.cc
|
|
932 |
*/
|
|
575.4.7
by Monty Taylor
More header cleanup. |
933 |
virtual ~LEX() |
1
by brian
clean slate |
934 |
{
|
935 |
}
|
|
936 |
||
327.2.4
by Brian Aker
Refactoring table.h |
937 |
TableList *unlink_first_table(bool *link_to_local); |
938 |
void link_first_table_back(TableList *first, bool link_to_local); |
|
1
by brian
clean slate |
939 |
void first_lists_tables_same(); |
940 |
||
941 |
void cleanup_after_one_table_open(); |
|
942 |
||
943 |
bool push_context(Name_resolution_context *context) |
|
944 |
{
|
|
945 |
return context_stack.push_front(context); |
|
946 |
}
|
|
947 |
||
948 |
void pop_context() |
|
949 |
{
|
|
950 |
context_stack.pop(); |
|
951 |
}
|
|
952 |
||
953 |
bool copy_db_to(char **p_db, size_t *p_db_length) const; |
|
954 |
||
955 |
Name_resolution_context *current_context() |
|
956 |
{
|
|
957 |
return context_stack.head(); |
|
958 |
}
|
|
959 |
/*
|
|
520.1.21
by Brian Aker
THD -> Session rename |
960 |
Restore the LEX and Session in case of a parse error.
|
1
by brian
clean slate |
961 |
*/
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
962 |
static void cleanup_lex_after_parse_error(Session *session); |
1
by brian
clean slate |
963 |
|
964 |
/**
|
|
965 |
@brief check if the statement is a single-level join
|
|
966 |
@return result of the check
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
967 |
@retval true The statement doesn't contain subqueries, unions and
|
1
by brian
clean slate |
968 |
stored procedure calls.
|
51.1.52
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE |
969 |
@retval false There are subqueries, UNIONs or stored procedure calls.
|
1
by brian
clean slate |
970 |
*/
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
971 |
bool is_single_level_stmt() |
972 |
{
|
|
973 |
/*
|
|
1
by brian
clean slate |
974 |
This check exploits the fact that the last added to all_select_list is
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
975 |
on its top. So select_lex (as the first added) will be at the tail
|
1
by brian
clean slate |
976 |
of the list.
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
977 |
*/
|
628
by Brian Aker
Collection of dead code removal |
978 |
if (&select_lex == all_selects_list) |
1
by brian
clean slate |
979 |
{
|
51.1.52
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE |
980 |
assert(!all_selects_list->next_select_in_list()); |
981 |
return true; |
|
1
by brian
clean slate |
982 |
}
|
51.1.52
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE |
983 |
return false; |
1
by brian
clean slate |
984 |
}
|
1637.1.3
by Brian Aker
This fixes the parser to no longer do the bad syntax around the cross join |
985 |
bool is_cross; // CROSS keyword was used |
1643.6.13
by Djellel E. Difallah
adding tests |
986 |
bool isCacheable() |
987 |
{
|
|
988 |
return cacheable; |
|
989 |
}
|
|
990 |
void setCacheable(bool val) |
|
991 |
{
|
|
992 |
cacheable= val; |
|
993 |
}
|
|
1751.3.1
by Brian Aker
This add a couple of utility table functions to be used with testing. |
994 |
|
995 |
void reset() |
|
996 |
{
|
|
997 |
sum_expr_used= false; |
|
998 |
}
|
|
999 |
||
1000 |
void setSumExprUsed() |
|
1001 |
{
|
|
1002 |
sum_expr_used= true; |
|
1003 |
}
|
|
1004 |
||
1005 |
bool isSumExprUsed() |
|
1006 |
{
|
|
1007 |
return sum_expr_used; |
|
1008 |
}
|
|
1897.1.5
by Brian Aker
Move lex_end to be class member. |
1009 |
|
1897.1.7
by Brian Aker
Partial encapsulation of lex_start. |
1010 |
void start(Session *session); |
1897.1.5
by Brian Aker
Move lex_end to be class member. |
1011 |
void end(); |
1012 |
||
1643.6.13
by Djellel E. Difallah
adding tests |
1013 |
private: |
1014 |
bool cacheable; |
|
1751.3.1
by Brian Aker
This add a couple of utility table functions to be used with testing. |
1015 |
bool sum_expr_used; |
575.4.7
by Monty Taylor
More header cleanup. |
1016 |
};
|
1
by brian
clean slate |
1017 |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1018 |
extern void lex_start(Session *session); |
264.2.6
by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code. |
1019 |
extern void trim_whitespace(const CHARSET_INFO * const cs, LEX_STRING *str); |
1
by brian
clean slate |
1020 |
extern bool is_lex_native_function(const LEX_STRING *name); |
1021 |
||
1022 |
/**
|
|
1023 |
@} (End of group Semantic_Analysis)
|
|
1024 |
*/
|
|
1025 |
||
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
1026 |
} /* namespace drizzled */ |
1027 |
||
319.1.1
by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_ |
1028 |
#endif /* DRIZZLE_SERVER */ |
1014.4.1
by Jay Pipes
Cosmetic: make sql_lex.h include guard match rest of drizzled/ headers. |
1029 |
#endif /* DRIZZLED_SQL_LEX_H */ |