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