~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
934.2.1 by Jay Pipes
Split index hints out into their own file, removal from sql_lex.h and sql_select.cc
28
#include "drizzled/sql_udf.h"
29
#include "drizzled/name_resolution_context.h"
30
#include "drizzled/item/subselect.h"
31
#include "drizzled/item/param.h"
32
#include "drizzled/item/outer_ref.h"
33
#include "drizzled/table_list.h"
34
#include "drizzled/function/math/real.h"
35
#include "drizzled/alter_drop.h"
36
#include "drizzled/alter_column.h"
37
#include "drizzled/key.h"
38
#include "drizzled/foreign_key.h"
39
#include "drizzled/item/param.h"
40
#include "drizzled/index_hint.h"
139.1.8 by Stewart Smith
UDFs are now normal Item_func objects. Simplifies handling them a lot.
41
1089.6.3 by Padraig O'Sullivan
Replaced an instance where a uint8_t type was being used to hold a
42
#include <bitset>
43
584.4.7 by Monty Taylor
Removed a big bank of includes from item.h.
44
class select_result_interceptor;
584.1.14 by Monty Taylor
Removed field.h from common_includes.
45
1 by brian
clean slate
46
/* YACC and LEX Definitions */
47
48
/* These may not be declared yet */
49
class Table_ident;
831.1.2 by Brian Aker
Rename class file_exchange
50
class file_exchange;
851 by Brian Aker
Class rewrite of Session (aka get all of the junk out)
51
class Lex_Column;
675 by Brian Aker
Cleanup around item includes.
52
class Item_outer_ref;
1 by brian
clean slate
53
54
/*
55
  The following hack is needed because mysql_yacc.cc does not define
56
  YYSTYPE before including this file
57
*/
58
722.1.4 by Monty Taylor
Removed all the setting of DEFS everywhere. Use configmake.h to get the values
59
#ifdef DRIZZLE_SERVER
60
# include <drizzled/set_var.h>
61
# include <drizzled/item/func.h>
62
# ifdef DRIZZLE_YACC
63
#  define LEX_YYSTYPE void *
64
# else
65
#  if defined(DRIZZLE_LEX)
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
104
enum tablespace_op_type
105
{
1027 by Brian Aker
Merge Jay
106
  NO_TABLESPACE_OP,
107
  DISCARD_TABLESPACE,
108
  IMPORT_TABLESPACE
1 by brian
clean slate
109
};
110
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
111
/*
112
  The state of the lex parsing for selects
113
1 by brian
clean slate
114
   master and slaves are pointers to select_lex.
115
   master is pointer to upper level node.
116
   slave is pointer to lower level node
117
   select_lex is a SELECT without union
118
   unit is container of either
119
     - One SELECT
120
     - UNION of selects
121
   select_lex and unit are both inherited form select_lex_node
122
   neighbors are two select_lex or units on the same level
123
124
   All select describing structures linked with following pointers:
125
   - list of neighbors (next/prev) (prev of first element point to slave
126
     pointer of upper structure)
127
     - For select this is a list of UNION's (or one element list)
128
     - For units this is a list of sub queries for the upper level select
129
130
   - pointer to master (master), which is
131
     If this is a unit
132
       - pointer to outer select_lex
133
     If this is a select_lex
134
       - pointer to outer unit structure for select
135
136
   - pointer to slave (slave), which is either:
137
     If this is a unit:
138
       - first SELECT that belong to this unit
139
     If this is a select_lex
140
       - first unit that belong to this SELECT (subquries or derived tables)
141
142
   - list of all select_lex (link_next/link_prev)
143
     This is to be used for things like derived tables creation, where we
144
     go through this list and create the derived tables.
145
146
   If unit contain several selects (UNION now, INTERSECT etc later)
147
   then it have special select_lex called fake_select_lex. It used for
148
   storing global parameters (like ORDER BY, LIMIT) and executing union.
149
   Subqueries used in global ORDER BY clause will be attached to this
150
   fake_select_lex, which will allow them correctly resolve fields of
151
   'upper' UNION and outer selects.
152
153
   For example for following query:
154
155
   select *
156
     from table1
157
     where table1.field IN (select * from table1_1_1 union
158
                            select * from table1_1_2)
159
     union
160
   select *
161
     from table2
162
     where table2.field=(select (select f1 from table2_1_1_1_1
163
                                   where table2_1_1_1_1.f2=table2_1_1.f3)
164
                           from table2_1_1
165
                           where table2_1_1.f1=table2.f2)
166
     union
167
   select * from table3;
168
169
   we will have following structure:
170
171
   select1: (select * from table1 ...)
172
   select2: (select * from table2 ...)
173
   select3: (select * from table3)
174
   select1.1.1: (select * from table1_1_1)
175
   ...
176
177
     main unit
178
     fake0
179
     select1 select2 select3
180
     |^^     |^
181
    s|||     ||master
182
    l|||     |+---------------------------------+
183
    a|||     +---------------------------------+|
184
    v|||master                         slave   ||
185
    e||+-------------------------+             ||
186
     V|            neighbor      |             V|
187
     unit1.1<+==================>unit1.2       unit2.1
188
     fake1.1
189
     select1.1.1 select 1.1.2    select1.2.1   select2.1.1
190
                                               |^
191
                                               ||
192
                                               V|
193
                                               unit2.1.1.1
194
                                               select2.1.1.1.1
195
196
197
   relation in main unit will be following:
198
   (bigger picture for:
199
      main unit
200
      fake0
201
      select1 select2 select3
202
   in the above picture)
203
204
         main unit
205
         |^^^^|fake_select_lex
206
         |||||+--------------------------------------------+
207
         ||||+--------------------------------------------+|
208
         |||+------------------------------+              ||
209
         ||+--------------+                |              ||
210
    slave||master         |                |              ||
211
         V|      neighbor |       neighbor |        master|V
212
         select1<========>select2<========>select3        fake0
213
214
    list of all select_lex will be following (as it will be constructed by
215
    parser):
216
217
    select1->select2->select3->select2.1.1->select 2.1.2->select2.1.1.1.1-+
218
                                                                          |
219
    +---------------------------------------------------------------------+
220
    |
221
    +->select1.1.1->select1.1.2
222
223
*/
224
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
225
/*
846 by Brian Aker
Removing on typedeffed class.
226
    Base class for Select_Lex (Select_Lex) &
848 by Brian Aker
typdef class removal (just... use the name of the class).
227
    Select_Lex_Unit (Select_Lex_Unit)
1 by brian
clean slate
228
*/
575.4.7 by Monty Taylor
More header cleanup.
229
class LEX;
846 by Brian Aker
Removing on typedeffed class.
230
class Select_Lex;
848 by Brian Aker
typdef class removal (just... use the name of the class).
231
class Select_Lex_Unit;
847 by Brian Aker
More typdef class removal.
232
class Select_Lex_Node {
1 by brian
clean slate
233
protected:
847 by Brian Aker
More typdef class removal.
234
  Select_Lex_Node *next, **prev,   /* neighbor list */
1 by brian
clean slate
235
    *master, *slave,                  /* vertical links */
846 by Brian Aker
Removing on typedeffed class.
236
    *link_next, **link_prev;          /* list of whole Select_Lex */
1 by brian
clean slate
237
public:
238
151 by Brian Aker
Ulonglong to uint64_t
239
  uint64_t options;
1 by brian
clean slate
240
241
  /*
242
    result of this query can't be cached, bit field, can be :
243
      UNCACHEABLE_DEPENDENT
244
      UNCACHEABLE_RAND
245
      UNCACHEABLE_SIDEEFFECT
246
      UNCACHEABLE_EXPLAIN
247
      UNCACHEABLE_PREPARE
248
  */
202 by Brian Aker
Cleanup sql_lex to modern types.
249
  uint8_t uncacheable;
1 by brian
clean slate
250
  enum sub_select_type linkage;
251
  bool no_table_names_allowed; /* used for global order by */
252
  bool no_error; /* suppress error message (convert it to warnings) */
253
254
  static void *operator new(size_t size)
255
  {
256
    return sql_alloc(size);
257
  }
258
  static void *operator new(size_t size, MEM_ROOT *mem_root)
202 by Brian Aker
Cleanup sql_lex to modern types.
259
  { return (void*) alloc_root(mem_root, (uint32_t) size); }
644 by Brian Aker
Clean up warnings for Solaris.
260
  static void operator delete(void *, size_t)
77.1.7 by Monty Taylor
Heap builds clean.
261
  { TRASH(ptr, size); }
644 by Brian Aker
Clean up warnings for Solaris.
262
  static void operator delete(void *, MEM_ROOT *)
77.1.7 by Monty Taylor
Heap builds clean.
263
  {}
847 by Brian Aker
More typdef class removal.
264
  Select_Lex_Node(): linkage(UNSPECIFIED_TYPE) {}
265
  virtual ~Select_Lex_Node() {}
266
  inline Select_Lex_Node* get_master() { return master; }
1 by brian
clean slate
267
  virtual void init_query();
268
  virtual void init_select();
847 by Brian Aker
More typdef class removal.
269
  void include_down(Select_Lex_Node *upper);
270
  void include_neighbour(Select_Lex_Node *before);
271
  void include_standalone(Select_Lex_Node *sel, Select_Lex_Node **ref);
272
  void include_global(Select_Lex_Node **plink);
1 by brian
clean slate
273
  void exclude();
274
848 by Brian Aker
typdef class removal (just... use the name of the class).
275
  virtual Select_Lex_Unit* master_unit()= 0;
846 by Brian Aker
Removing on typedeffed class.
276
  virtual Select_Lex* outer_select()= 0;
277
  virtual Select_Lex* return_after_parsing()= 0;
1 by brian
clean slate
278
279
  virtual bool set_braces(bool value);
280
  virtual bool inc_in_sum_expr();
202 by Brian Aker
Cleanup sql_lex to modern types.
281
  virtual uint32_t get_in_sum_expr();
327.2.4 by Brian Aker
Refactoring table.h
282
  virtual TableList* get_table_list();
1 by brian
clean slate
283
  virtual List<Item>* get_item_list();
202 by Brian Aker
Cleanup sql_lex to modern types.
284
  virtual uint32_t get_table_join_options();
520.1.22 by Brian Aker
Second pass of thd cleanup
285
  virtual TableList *add_table_to_list(Session *session, Table_ident *table,
77.1.7 by Monty Taylor
Heap builds clean.
286
                                        LEX_STRING *alias,
202 by Brian Aker
Cleanup sql_lex to modern types.
287
                                        uint32_t table_options,
77.1.7 by Monty Taylor
Heap builds clean.
288
                                        thr_lock_type flags= TL_UNLOCK,
289
                                        List<Index_hint> *hints= 0,
1 by brian
clean slate
290
                                        LEX_STRING *option= 0);
644 by Brian Aker
Clean up warnings for Solaris.
291
  virtual void set_lock_for_tables(thr_lock_type)
77.1.7 by Monty Taylor
Heap builds clean.
292
  {}
1 by brian
clean slate
293
848 by Brian Aker
typdef class removal (just... use the name of the class).
294
  friend class Select_Lex_Unit;
575.4.7 by Monty Taylor
More header cleanup.
295
  friend bool mysql_new_select(LEX *lex, bool move_down);
1 by brian
clean slate
296
private:
297
  void fast_exclude();
298
};
299
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
300
/*
848 by Brian Aker
typdef class removal (just... use the name of the class).
301
   Select_Lex_Unit - unit of selects (UNION, INTERSECT, ...) group
846 by Brian Aker
Removing on typedeffed class.
302
   Select_Lexs
1 by brian
clean slate
303
*/
520.1.21 by Brian Aker
THD -> Session rename
304
class Session;
1 by brian
clean slate
305
class select_result;
306
class JOIN;
307
class select_union;
848 by Brian Aker
typdef class removal (just... use the name of the class).
308
class Select_Lex_Unit: public Select_Lex_Node {
1 by brian
clean slate
309
protected:
327.2.4 by Brian Aker
Refactoring table.h
310
  TableList result_table_list;
1 by brian
clean slate
311
  select_union *union_result;
327.1.5 by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h
312
  Table *table; /* temporary table using for appending UNION results */
1 by brian
clean slate
313
314
  select_result *result;
151 by Brian Aker
Ulonglong to uint64_t
315
  uint64_t found_rows_for_union;
1 by brian
clean slate
316
  bool saved_error;
317
318
public:
319
  bool  prepared, // prepare phase already performed for UNION (unit)
320
    optimized, // optimize phase already performed for UNION (unit)
321
    executed, // already executed
322
    cleaned;
323
324
  // list of fields which points to temporary table for union
325
  List<Item> item_list;
326
  /*
327
    list of types of items inside union (used for union & derived tables)
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
328
1 by brian
clean slate
329
    Item_type_holders from which this list consist may have pointers to Field,
330
    pointers is valid only after preparing SELECTS of this unit and before
331
    any SELECT of this unit execution
332
333
    TODO:
334
    Possibly this member should be protected, and its direct use replaced
335
    by get_unit_column_types(). Check the places where it is used.
336
  */
337
  List<Item> types;
338
  /*
339
    Pointer to 'last' select or pointer to unit where stored
340
    global parameters for union
341
  */
846 by Brian Aker
Removing on typedeffed class.
342
  Select_Lex *global_parameters;
1 by brian
clean slate
343
  //node on wich we should return current_select pointer after parsing subquery
846 by Brian Aker
Removing on typedeffed class.
344
  Select_Lex *return_to;
1 by brian
clean slate
345
  /* LIMIT clause runtime counters */
346
  ha_rows select_limit_cnt, offset_limit_cnt;
347
  /* not NULL if unit used in subselect, point to subselect item */
348
  Item_subselect *item;
349
  /* thread handler */
520.1.22 by Brian Aker
Second pass of thd cleanup
350
  Session *session;
1 by brian
clean slate
351
  /*
846 by Brian Aker
Removing on typedeffed class.
352
    Select_Lex for hidden SELECT in onion which process global
1 by brian
clean slate
353
    ORDER BY and LIMIT
354
  */
846 by Brian Aker
Removing on typedeffed class.
355
  Select_Lex *fake_select_lex;
1 by brian
clean slate
356
846 by Brian Aker
Removing on typedeffed class.
357
  Select_Lex *union_distinct; /* pointer to the last UNION DISTINCT */
1 by brian
clean slate
358
  bool describe; /* union exec() called for EXPLAIN */
359
360
  void init_query();
848 by Brian Aker
typdef class removal (just... use the name of the class).
361
  Select_Lex_Unit* master_unit();
846 by Brian Aker
Removing on typedeffed class.
362
  Select_Lex* outer_select();
363
  Select_Lex* first_select()
364
  {
365
    return reinterpret_cast<Select_Lex*>(slave);
366
  }
848 by Brian Aker
typdef class removal (just... use the name of the class).
367
  Select_Lex_Unit* next_unit()
846 by Brian Aker
Removing on typedeffed class.
368
  {
848 by Brian Aker
typdef class removal (just... use the name of the class).
369
    return reinterpret_cast<Select_Lex_Unit*>(next);
846 by Brian Aker
Removing on typedeffed class.
370
  }
371
  Select_Lex* return_after_parsing() { return return_to; }
1 by brian
clean slate
372
  void exclude_level();
373
  void exclude_tree();
374
375
  /* UNION methods */
892.2.4 by Monty Taylor
Fixed more warnings.
376
  bool prepare(Session *session, select_result *result,
377
               uint64_t additional_options);
1 by brian
clean slate
378
  bool exec();
379
  bool cleanup();
380
  inline void unclean() { cleaned= 0; }
381
  void reinit_exec_mechanism();
382
383
  void print(String *str, enum_query_type query_type);
384
520.1.22 by Brian Aker
Second pass of thd cleanup
385
  bool add_fake_select_lex(Session *session);
386
  void init_prepare_fake_select_lex(Session *session);
1 by brian
clean slate
387
  bool change_result(select_result_interceptor *result,
388
                     select_result_interceptor *old_result);
846 by Brian Aker
Removing on typedeffed class.
389
  void set_limit(Select_Lex *values);
520.1.22 by Brian Aker
Second pass of thd cleanup
390
  void set_session(Session *session_arg) { session= session_arg; }
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
391
  inline bool is_union ();
1 by brian
clean slate
392
520.1.22 by Brian Aker
Second pass of thd cleanup
393
  friend void lex_start(Session *session);
1 by brian
clean slate
394
  friend int subselect_union_engine::exec();
395
396
  List<Item> *get_unit_column_types();
397
};
398
399
/*
846 by Brian Aker
Removing on typedeffed class.
400
  Select_Lex - store information of parsed SELECT statment
1 by brian
clean slate
401
*/
847 by Brian Aker
More typdef class removal.
402
class Select_Lex: public Select_Lex_Node
1 by brian
clean slate
403
{
404
public:
405
  Name_resolution_context context;
406
  char *db;
1014.4.9 by Jay Pipes
Code style cleanup and removal of dead LEX_SERVER_OPTIONS struct
407
  /* An Item representing the WHERE clause */
408
  Item *where;
409
  /* An Item representing the HAVING clause */
410
  Item *having;
1 by brian
clean slate
411
  /* 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
412
  Item::cond_result cond_value;
413
  Item::cond_result having_value;
1 by brian
clean slate
414
  /* point on lex in which it was created, used in view subquery detection */
575.4.7 by Monty Taylor
More header cleanup.
415
  LEX *parent_lex;
1 by brian
clean slate
416
  enum olap_type olap;
327.2.4 by Brian Aker
Refactoring table.h
417
  /* 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
418
  SQL_LIST table_list;
419
  SQL_LIST group_list; /* GROUP BY clause. */
420
  List<Item> item_list;  /* list of fields & expressions */
421
  List<String> interval_list;
422
  bool is_item_list_lookup;
1 by brian
clean slate
423
  JOIN *join; /* after JOIN::prepare it is pointer to corresponding JOIN */
327.2.4 by Brian Aker
Refactoring table.h
424
  List<TableList> top_join_list; /* join list of the top level          */
425
  List<TableList> *join_list;    /* list for the currently parsed join  */
426
  TableList *embedding;          /* table embedding to the above list   */
427
  List<TableList> sj_nests;
1 by brian
clean slate
428
  /*
429
    Beginning of the list of leaves in a FROM clause, where the leaves
430
    inlcude all base tables including view tables. The tables are connected
327.2.4 by Brian Aker
Refactoring table.h
431
    by TableList::next_leaf, so leaf_tables points to the left-most leaf.
1 by brian
clean slate
432
  */
327.2.4 by Brian Aker
Refactoring table.h
433
  TableList *leaf_tables;
1 by brian
clean slate
434
  const char *type;               /* type of select for EXPLAIN          */
435
436
  SQL_LIST order_list;                /* ORDER clause */
437
  SQL_LIST *gorder_list;
438
  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
439
  /* Arrays of pointers to top elements of all_fields list */
1 by brian
clean slate
440
  Item **ref_pointer_array;
441
442
  /*
443
    number of items in select_list and HAVING clause used to get number
444
    bigger then can be number of entries that will be added to all item
445
    list during split_sum_func
446
  */
202 by Brian Aker
Cleanup sql_lex to modern types.
447
  uint32_t select_n_having_items;
448
  uint32_t cond_count;    /* number of arguments of and/or/xor in where/having/on */
449
  uint32_t between_count; /* number of between predicates in where/having/on      */
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
450
  uint32_t max_equal_elems; /* maximal number of elements in multiple equalities  */
1 by brian
clean slate
451
  /*
452
    Number of fields used in select list or where clause of current select
453
    and all inner subselects.
454
  */
202 by Brian Aker
Cleanup sql_lex to modern types.
455
  uint32_t select_n_where_fields;
1 by brian
clean slate
456
  enum_parsing_place parsing_place; /* where we are parsing expression */
457
  bool with_sum_func;   /* sum function indicator */
458
202 by Brian Aker
Cleanup sql_lex to modern types.
459
  uint32_t table_join_options;
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;
1 by brian
clean slate
515
  void init_query();
516
  void init_select();
848 by Brian Aker
typdef class removal (just... use the name of the class).
517
  Select_Lex_Unit* master_unit();
518
  Select_Lex_Unit* first_inner_unit()
846 by Brian Aker
Removing on typedeffed class.
519
  {
848 by Brian Aker
typdef class removal (just... use the name of the class).
520
    return (Select_Lex_Unit*) slave;
846 by Brian Aker
Removing on typedeffed class.
521
  }
522
  Select_Lex* outer_select();
1014.4.9 by Jay Pipes
Code style cleanup and removal of dead LEX_SERVER_OPTIONS struct
523
  Select_Lex* next_select()
524
  {
525
    return (Select_Lex*) next;
526
  }
846 by Brian Aker
Removing on typedeffed class.
527
  Select_Lex* next_select_in_list()
528
  {
529
    return (Select_Lex*) link_next;
530
  }
847 by Brian Aker
More typdef class removal.
531
  Select_Lex_Node** next_select_in_list_addr()
1 by brian
clean slate
532
  {
533
    return &link_next;
534
  }
846 by Brian Aker
Removing on typedeffed class.
535
  Select_Lex* return_after_parsing()
1 by brian
clean slate
536
  {
537
    return master_unit()->return_after_parsing();
538
  }
539
846 by Brian Aker
Removing on typedeffed class.
540
  void mark_as_dependent(Select_Lex *last);
1 by brian
clean slate
541
542
  bool set_braces(bool value);
543
  bool inc_in_sum_expr();
202 by Brian Aker
Cleanup sql_lex to modern types.
544
  uint32_t get_in_sum_expr();
1 by brian
clean slate
545
520.1.22 by Brian Aker
Second pass of thd cleanup
546
  bool add_item_to_list(Session *session, Item *item);
547
  bool add_group_to_list(Session *session, Item *item, bool asc);
548
  bool add_order_to_list(Session *session, Item *item, bool asc);
1027 by Brian Aker
Merge Jay
549
  TableList* add_table_to_list(Session *session,
550
                               Table_ident *table,
551
                               LEX_STRING *alias,
552
                               uint32_t table_options,
553
                               thr_lock_type flags= TL_UNLOCK,
554
                               List<Index_hint> *hints= 0,
555
                               LEX_STRING *option= 0);
327.2.4 by Brian Aker
Refactoring table.h
556
  TableList* get_table_list();
520.1.22 by Brian Aker
Second pass of thd cleanup
557
  bool init_nested_join(Session *session);
558
  TableList *end_nested_join(Session *session);
559
  TableList *nest_last_join(Session *session);
327.2.4 by Brian Aker
Refactoring table.h
560
  void add_joined_table(TableList *table);
561
  TableList *convert_right_join();
1 by brian
clean slate
562
  List<Item>* get_item_list();
202 by Brian Aker
Cleanup sql_lex to modern types.
563
  uint32_t get_table_join_options();
1 by brian
clean slate
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
1089.6.4 by Padraig O'Sullivan
Modified the flags member of the Alter_info class to be std::bitset instead
642
enum enum_alter_info_flags
643
{
644
  ALTER_ADD_COLUMN= 0,
645
  ALTER_DROP_COLUMN,
646
  ALTER_CHANGE_COLUMN,
647
  ALTER_COLUMN_STORAGE,
648
  ALTER_COLUMN_FORMAT,
649
  ALTER_COLUMN_ORDER,
650
  ALTER_ADD_INDEX,
651
  ALTER_DROP_INDEX,
652
  ALTER_RENAME,
653
  ALTER_ORDER,
654
  ALTER_OPTIONS,
655
  ALTER_COLUMN_DEFAULT,
656
  ALTER_KEYS_ONOFF,
657
  ALTER_STORAGE,
658
  ALTER_ROW_FORMAT,
659
  ALTER_CONVERT,
660
  ALTER_FORCE,
661
  ALTER_RECREATE,
662
  ALTER_TABLE_REORG,
663
  ALTER_FOREIGN_KEY
664
};
1 by brian
clean slate
665
666
/**
327.1.5 by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h
667
  @brief Parsing data for CREATE or ALTER Table.
1 by brian
clean slate
668
669
  This structure contains a list of columns or indexes to be created,
670
  altered or dropped.
671
*/
672
673
class Alter_info
674
{
675
public:
1014.4.9 by Jay Pipes
Code style cleanup and removal of dead LEX_SERVER_OPTIONS struct
676
  List<Alter_drop> drop_list;
677
  List<Alter_column> alter_list;
678
  List<Key> key_list;
1052.2.3 by Nathan Williams
No actual code changes. Changed Create_field to CreateField to be consistent with coding standards.
679
  List<CreateField> create_list;
1089.6.4 by Padraig O'Sullivan
Modified the flags member of the Alter_info class to be std::bitset instead
680
  std::bitset<32> flags;
1014.4.9 by Jay Pipes
Code style cleanup and removal of dead LEX_SERVER_OPTIONS struct
681
  enum enum_enable_or_disable keys_onoff;
682
  enum tablespace_op_type tablespace_op;
683
  uint32_t no_parts;
684
  enum ha_build_method build_method;
1052.2.3 by Nathan Williams
No actual code changes. Changed Create_field to CreateField to be consistent with coding standards.
685
  CreateField *datetime_field;
1014.4.9 by Jay Pipes
Code style cleanup and removal of dead LEX_SERVER_OPTIONS struct
686
  bool error_if_not_empty;
1 by brian
clean slate
687
688
  Alter_info() :
1089.6.4 by Padraig O'Sullivan
Modified the flags member of the Alter_info class to be std::bitset instead
689
    flags(),
1 by brian
clean slate
690
    keys_onoff(LEAVE_AS_IS),
691
    tablespace_op(NO_TABLESPACE_OP),
692
    no_parts(0),
693
    build_method(HA_BUILD_DEFAULT),
694
    datetime_field(NULL),
51.1.52 by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE
695
    error_if_not_empty(false)
1 by brian
clean slate
696
  {}
697
698
  void reset()
699
  {
700
    drop_list.empty();
701
    alter_list.empty();
702
    key_list.empty();
703
    create_list.empty();
1089.6.4 by Padraig O'Sullivan
Modified the flags member of the Alter_info class to be std::bitset instead
704
    flags.reset();
1 by brian
clean slate
705
    keys_onoff= LEAVE_AS_IS;
706
    tablespace_op= NO_TABLESPACE_OP;
707
    no_parts= 0;
708
    build_method= HA_BUILD_DEFAULT;
709
    datetime_field= 0;
51.1.52 by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE
710
    error_if_not_empty= false;
1 by brian
clean slate
711
  }
712
  Alter_info(const Alter_info &rhs, MEM_ROOT *mem_root);
713
private:
714
  Alter_info &operator=(const Alter_info &rhs); // not implemented
715
  Alter_info(const Alter_info &rhs);            // not implemented
716
};
717
1014.4.9 by Jay Pipes
Code style cleanup and removal of dead LEX_SERVER_OPTIONS struct
718
enum xa_option_words
719
{
720
  XA_NONE
721
, XA_JOIN
722
, XA_RESUME
723
, XA_ONE_PHASE
724
, XA_SUSPEND
725
, XA_FOR_MIGRATE
726
};
1 by brian
clean slate
727
728
extern const LEX_STRING null_lex_str;
729
730
/*
731
  Class representing list of all tables used by statement.
732
  It also contains information about stored functions used by statement
733
  since during its execution we may have to add all tables used by its
734
  stored functions/triggers to this list in order to pre-open and lock
735
  them.
736
737
  Also used by st_lex::reset_n_backup/restore_backup_query_tables_list()
738
  methods to save and restore this information.
739
*/
740
class Query_tables_list
741
{
742
public:
743
  /* Global list of all tables used by this statement */
327.2.4 by Brian Aker
Refactoring table.h
744
  TableList *query_tables;
1 by brian
clean slate
745
  /* Pointer to next_global member of last element in the previous list. */
327.2.4 by Brian Aker
Refactoring table.h
746
  TableList **query_tables_last;
1 by brian
clean slate
747
  /*
748
    If non-0 then indicates that query requires prelocking and points to
749
    next_global member of last own element in query table list (i.e. last
750
    table which was not added to it as part of preparation to prelocking).
751
    0 - indicates that this query does not need prelocking.
752
  */
327.2.4 by Brian Aker
Refactoring table.h
753
  TableList **query_tables_own_last;
1 by brian
clean slate
754
755
  /*
756
    These constructor and destructor serve for creation/destruction
757
    of Query_tables_list instances which are used as backup storage.
758
  */
759
  Query_tables_list() {}
760
  ~Query_tables_list() {}
761
762
  /* Initializes (or resets) Query_tables_list object for "real" use. */
763
  void reset_query_tables_list(bool init);
764
765
  /*
766
    Direct addition to the list of query tables.
767
    If you are using this function, you must ensure that the table
768
    object, in particular table->db member, is initialized.
769
  */
327.2.4 by Brian Aker
Refactoring table.h
770
  void add_to_query_tables(TableList *table)
1 by brian
clean slate
771
  {
772
    *(table->prev_global= query_tables_last)= table;
773
    query_tables_last= &table->next_global;
774
  }
775
  /* Return pointer to first not-own table in query-tables or 0 */
327.2.4 by Brian Aker
Refactoring table.h
776
  TableList* first_not_own_table()
1 by brian
clean slate
777
  {
778
    return ( query_tables_own_last ? *query_tables_own_last : 0);
779
  }
780
  void chop_off_not_own_tables()
781
  {
782
    if (query_tables_own_last)
783
    {
784
      *query_tables_own_last= 0;
785
      query_tables_last= query_tables_own_last;
786
      query_tables_own_last= 0;
787
    }
788
  }
789
};
790
791
/**
792
  The state of the lexical parser, when parsing comments.
793
*/
794
enum enum_comment_state
795
{
796
  /**
797
    Not parsing comments.
798
  */
799
  NO_COMMENT,
800
  /**
801
    Parsing comments that need to be preserved.
802
    Typically, these are user comments '/' '*' ... '*' '/'.
803
  */
804
  PRESERVE_COMMENT,
805
  /**
806
    Parsing comments that need to be discarded.
807
    Typically, these are special comments '/' '*' '!' ... '*' '/',
808
    or '/' '*' '!' 'M' 'M' 'm' 'm' 'm' ... '*' '/', where the comment
809
    markers should not be expanded.
810
  */
811
  DISCARD_COMMENT
812
};
813
1014.4.8 by Jay Pipes
Split Lex_input_stream out into its own header.
814
#include "drizzled/lex_input_stream.h"
1 by brian
clean slate
815
520.1.21 by Brian Aker
THD -> Session rename
816
/* The state of the lex parsing. This is saved in the Session struct */
575.4.7 by Monty Taylor
More header cleanup.
817
class LEX : public Query_tables_list
1 by brian
clean slate
818
{
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
819
public:
848 by Brian Aker
typdef class removal (just... use the name of the class).
820
  Select_Lex_Unit unit;                         /* most upper unit */
846 by Brian Aker
Removing on typedeffed class.
821
  Select_Lex select_lex;                        /* first Select_Lex */
822
  /* current Select_Lex in parsing */
823
  Select_Lex *current_select;
824
  /* list of all Select_Lex */
825
  Select_Lex *all_selects_list;
1 by brian
clean slate
826
1014.4.5 by Jay Pipes
Cleanup of LEX structure. Removed unused xid member variable, documented a number of member variables.
827
  /* This is the "scale" for DECIMAL (S,P) notation */ 
828
  char *length;
829
  /* This is the decimal precision in DECIMAL(S,P) notation */
830
  char *dec;
831
  /* The text in a CHANGE COLUMN clause in ALTER TABLE */
832
  char *change;
833
  
1014.4.7 by Jay Pipes
More documentation of LEX member variables and removal of slave_session_opt unused member variable.
834
  /**
835
   * This is used kind of like the "ident" member variable below, as 
836
   * a place to store certain names of identifiers.  Unfortunately, it
837
   * is used differently depending on the Command (SELECT on a derived
838
   * table vs CREATE)
839
   */
1 by brian
clean slate
840
  LEX_STRING name;
1014.4.7 by Jay Pipes
More documentation of LEX member variables and removal of slave_session_opt unused member variable.
841
  /* The string literal used in a LIKE expression */
1 by brian
clean slate
842
  String *wild;
831.1.2 by Brian Aker
Rename class file_exchange
843
  file_exchange *exchange;
1 by brian
clean slate
844
  select_result *result;
1014.4.5 by Jay Pipes
Cleanup of LEX structure. Removed unused xid member variable, documented a number of member variables.
845
1014.4.7 by Jay Pipes
More documentation of LEX member variables and removal of slave_session_opt unused member variable.
846
  /* An item representing the DEFAULT clause in CREATE/ALTER TABLE */
1014.4.5 by Jay Pipes
Cleanup of LEX structure. Removed unused xid member variable, documented a number of member variables.
847
  Item *default_value;
1014.4.7 by Jay Pipes
More documentation of LEX member variables and removal of slave_session_opt unused member variable.
848
  /* An item representing the ON UPDATE clause in CREATE/ALTER TABLE */
1014.4.5 by Jay Pipes
Cleanup of LEX structure. Removed unused xid member variable, documented a number of member variables.
849
  Item *on_update_value;
1014.4.7 by Jay Pipes
More documentation of LEX member variables and removal of slave_session_opt unused member variable.
850
  /* Not really sure what exactly goes in here... Comment text at beginning of statement? */
1014.4.5 by Jay Pipes
Cleanup of LEX structure. Removed unused xid member variable, documented a number of member variables.
851
  LEX_STRING comment;
1014.4.7 by Jay Pipes
More documentation of LEX member variables and removal of slave_session_opt unused member variable.
852
853
  /**
854
   * This is current used to store the name of a named key cache
855
   * or a named savepoint.  It should probably be refactored out into
856
   * the eventual Command class built for the Keycache and Savepoint
857
   * commands.
858
   */ 
1014.4.5 by Jay Pipes
Cleanup of LEX structure. Removed unused xid member variable, documented a number of member variables.
859
  LEX_STRING ident;
860
481 by Brian Aker
Remove all of uchar.
861
  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.
862
  /* The owning Session of this LEX */
520.1.22 by Brian Aker
Second pass of thd cleanup
863
  Session *session;
264.2.6 by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code.
864
  const CHARSET_INFO *charset;
1 by brian
clean slate
865
  bool text_string_is_7bit;
866
  /* store original leaf_tables for INSERT SELECT and PS/SP */
327.2.4 by Brian Aker
Refactoring table.h
867
  TableList *leaf_tables_insert;
1 by brian
clean slate
868
869
  List<Key_part_spec> col_list;
870
  List<Key_part_spec> ref_list;
871
  List<String>	      interval_list;
851 by Brian Aker
Class rewrite of Session (aka get all of the junk out)
872
  List<Lex_Column>    columns;
1 by brian
clean slate
873
  List<Item>	      *insert_list,field_list,value_list,update_list;
874
  List<List_item>     many_values;
875
  List<set_var_base>  var_list;
876
  List<Item_param>    param_list;
877
  /*
878
    A stack of name resolution contexts for the query. This stack is used
879
    at parse time to set local name resolution contexts for various parts
880
    of a query. For example, in a JOIN ... ON (some_condition) clause the
881
    Items in 'some_condition' must be resolved only against the operands
882
    of the the join, and not against the whole clause. Similarly, Items in
883
    subqueries should be resolved against the subqueries (and outer queries).
884
    The stack is used in the following way: when the parser detects that
885
    all Items in some clause need a local context, it creates a new context
886
    and pushes it on the stack. All newly created Items always store the
887
    top-most context in the stack. Once the parser leaves the clause that
888
    required a local context, the parser pops the top-most context.
889
  */
890
  List<Name_resolution_context> context_stack;
891
1014.4.5 by Jay Pipes
Cleanup of LEX structure. Removed unused xid member variable, documented a number of member variables.
892
  SQL_LIST auxiliary_table_list;
893
  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.
894
  CreateField *last_field;
1 by brian
clean slate
895
  Item_sum *in_sum_func;
942.1.12 by Monty Taylor
Converted udf_func into a factory.
896
  Function_builder *udf;
1014.4.5 by Jay Pipes
Cleanup of LEX structure. Removed unused xid member variable, documented a number of member variables.
897
  HA_CHECK_OPT check_opt;			// check/repair options
1 by brian
clean slate
898
  HA_CREATE_INFO create_info;
1008.3.17 by Stewart Smith
Start work to construct table proto in parser:
899
  drizzled::message::Table *create_table_proto;
1067.1.6 by Stewart Smith
have SHOW_ENGINE_STATUS use Lex->show_engine instead of HA_CREATE_INFO.db_type as it will be going away shortly (and just use table proto)
900
  StorageEngine *show_engine;
1 by brian
clean slate
901
  KEY_CREATE_INFO key_create_info;
202 by Brian Aker
Cleanup sql_lex to modern types.
902
  uint32_t type;
1 by brian
clean slate
903
  /*
904
    This variable is used in post-parse stage to declare that sum-functions,
905
    or functions which have sense only if GROUP BY is present, are allowed.
906
    For example in a query
907
    SELECT ... FROM ...WHERE MIN(i) == 1 GROUP BY ... HAVING MIN(i) > 2
908
    MIN(i) in the WHERE clause is not allowed in the opposite to MIN(i)
909
    in the HAVING clause. Due to possible nesting of select construct
910
    the variable can contain 0 or 1 for each nest level.
911
  */
912
  nesting_map allow_sum_func;
913
  enum_sql_command sql_command;
914
  /*
915
    Usually `expr` rule of yacc is quite reused but some commands better
916
    not support subqueries which comes standard with this rule, like
917
    KILL, HA_READ, CREATE/ALTER EVENT etc. Set this to `false` to get
918
    syntax error back.
919
  */
920
  bool expr_allows_subselect;
921
922
  thr_lock_type lock_option;
923
  enum enum_duplicates duplicates;
924
  enum enum_tx_isolation tx_isolation;
925
  enum enum_ha_read_modes ha_read_mode;
926
  union {
927
    enum ha_rkey_function ha_rkey_mode;
928
    enum xa_option_words xa_opt;
929
  };
930
  enum enum_var_type option_type;
931
932
  enum column_format_type column_format;
933
  enum Foreign_key::fk_match_opt fk_match_option;
934
  enum Foreign_key::fk_option fk_update_opt;
935
  enum Foreign_key::fk_option fk_delete_opt;
1014.4.7 by Jay Pipes
More documentation of LEX member variables and removal of slave_session_opt unused member variable.
936
  /* Options used in START TRANSACTION statement */
1014.4.5 by Jay Pipes
Cleanup of LEX structure. Removed unused xid member variable, documented a number of member variables.
937
  uint32_t start_transaction_opt;
1 by brian
clean slate
938
  int nest_level;
939
  /*
940
    In LEX representing update which were transformed to multi-update
941
    stores total number of tables. For LEX representing multi-delete
942
    holds number of tables from which we will delete records.
943
  */
202 by Brian Aker
Cleanup sql_lex to modern types.
944
  uint32_t table_count;
945
  uint8_t describe;
1 by brian
clean slate
946
  /*
947
    A flag that indicates what kinds of derived tables are present in the
948
    query (0 if no derived tables, otherwise DERIVED_SUBQUERY).
949
  */
202 by Brian Aker
Cleanup sql_lex to modern types.
950
  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.
951
952
  /* True if "IF EXISTS" used in DROP statement */
1014.4.5 by Jay Pipes
Cleanup of LEX structure. Removed unused xid member variable, documented a number of member variables.
953
  bool drop_if_exists;
1014.4.7 by Jay Pipes
More documentation of LEX member variables and removal of slave_session_opt unused member variable.
954
  /* True if "TEMPORARY" used in DROP/CREATE statement */
1014.4.5 by Jay Pipes
Cleanup of LEX structure. Removed unused xid member variable, documented a number of member variables.
955
  bool drop_temporary;
956
  bool one_shot_set;
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
957
958
  /* 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
959
  bool verbose;
1014.4.5 by Jay Pipes
Cleanup of LEX structure. Removed unused xid member variable, documented a number of member variables.
960
  
961
  /* Was the CHAIN option using in COMMIT/ROLLBACK? */
962
  bool tx_chain;
963
  /* Was the RELEASE option used in COMMIT/ROLLBACK? */
964
  bool tx_release;
1014.4.7 by Jay Pipes
More documentation of LEX member variables and removal of slave_session_opt unused member variable.
965
  /* 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.
966
  bool ignore;
1 by brian
clean slate
967
  Alter_info alter_info;
968
969
  /*
970
    Pointers to part of LOAD DATA statement that should be rewritten
971
    during replication ("LOCAL 'filename' REPLACE INTO" part).
972
  */
973
  const char *fname_start;
974
  const char *fname_end;
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
975
1 by brian
clean slate
976
  /**
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
977
    During name resolution search only in the table list given by
1 by brian
clean slate
978
    Name_resolution_context::first_name_resolution_table and
979
    Name_resolution_context::last_name_resolution_table
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
980
    (see Item_field::fix_fields()).
1 by brian
clean slate
981
  */
982
  bool use_only_table_context;
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
983
1014.4.7 by Jay Pipes
More documentation of LEX member variables and removal of slave_session_opt unused member variable.
984
  /* Was the ESCAPE keyword used? */
1 by brian
clean slate
985
  bool escape_used;
986
  bool is_lex_started; /* If lex_start() did run. For debugging. */
987
575.4.7 by Monty Taylor
More header cleanup.
988
  LEX();
1 by brian
clean slate
989
1008.3.17 by Stewart Smith
Start work to construct table proto in parser:
990
  /* Note that init and de-init mostly happen in lex_start and lex_end
991
     and not here. This is because LEX isn't delete/new for each new
992
     statement in a session. It's re-used by doing lex_end, lex_start
993
     in sql_lex.cc
994
  */
575.4.7 by Monty Taylor
More header cleanup.
995
  virtual ~LEX()
1 by brian
clean slate
996
  {
997
  }
998
327.2.4 by Brian Aker
Refactoring table.h
999
  TableList *unlink_first_table(bool *link_to_local);
1000
  void link_first_table_back(TableList *first, bool link_to_local);
1 by brian
clean slate
1001
  void first_lists_tables_same();
1002
1003
  bool only_view_structure();
1004
  bool need_correct_ident();
1005
1006
  void cleanup_after_one_table_open();
1007
1008
  bool push_context(Name_resolution_context *context)
1009
  {
1010
    return context_stack.push_front(context);
1011
  }
1012
1013
  void pop_context()
1014
  {
1015
    context_stack.pop();
1016
  }
1017
1018
  bool copy_db_to(char **p_db, size_t *p_db_length) const;
1019
1020
  Name_resolution_context *current_context()
1021
  {
1022
    return context_stack.head();
1023
  }
1024
  /*
520.1.21 by Brian Aker
THD -> Session rename
1025
    Restore the LEX and Session in case of a parse error.
1 by brian
clean slate
1026
  */
520.1.22 by Brian Aker
Second pass of thd cleanup
1027
  static void cleanup_lex_after_parse_error(Session *session);
1 by brian
clean slate
1028
1029
  /**
1030
    @brief check if the statement is a single-level join
1031
    @return result of the check
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
1032
      @retval true  The statement doesn't contain subqueries, unions and
1 by brian
clean slate
1033
                    stored procedure calls.
51.1.52 by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE
1034
      @retval false There are subqueries, UNIONs or stored procedure calls.
1 by brian
clean slate
1035
  */
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
1036
  bool is_single_level_stmt()
1037
  {
1038
    /*
1 by brian
clean slate
1039
      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:
1040
      on its top. So select_lex (as the first added) will be at the tail
1 by brian
clean slate
1041
      of the list.
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
1042
    */
628 by Brian Aker
Collection of dead code removal
1043
    if (&select_lex == all_selects_list)
1 by brian
clean slate
1044
    {
51.1.52 by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE
1045
      assert(!all_selects_list->next_select_in_list());
1046
      return true;
1 by brian
clean slate
1047
    }
51.1.52 by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE
1048
    return false;
1 by brian
clean slate
1049
  }
575.4.7 by Monty Taylor
More header cleanup.
1050
};
1 by brian
clean slate
1051
520.1.22 by Brian Aker
Second pass of thd cleanup
1052
extern void lex_start(Session *session);
1 by brian
clean slate
1053
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.
1054
extern void trim_whitespace(const CHARSET_INFO * const cs, LEX_STRING *str);
1 by brian
clean slate
1055
extern bool is_lex_native_function(const LEX_STRING *name);
1056
1057
/**
1058
  @} (End of group Semantic_Analysis)
1059
*/
1060
319.1.1 by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_
1061
#endif /* DRIZZLE_SERVER */
1014.4.1 by Jay Pipes
Cosmetic: make sql_lex.h include guard match rest of drizzled/ headers.
1062
#endif /* DRIZZLED_SQL_LEX_H */