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