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