~drizzle-trunk/drizzle/development

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