~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_lex.h

Merged Nathan from lp:~nlws/drizzle/fix-string-c-ptr-overrun

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#ifndef DRIZZLE_SERVER_SQL_LEX_H
21
 
#define DRIZZLE_SERVER_SQL_LEX_H
 
20
#ifndef DRIZZLED_SQL_LEX_H
 
21
#define DRIZZLED_SQL_LEX_H
22
22
 
23
23
/**
24
24
  @defgroup Semantic_Analysis Semantic Analysis
25
25
*/
26
 
 
27
 
#include <drizzled/sql_udf.h>
28
 
#include <drizzled/name_resolution_context.h>
29
 
#include <drizzled/item/subselect.h>
30
 
#include <drizzled/table_list.h>
31
 
#include <drizzled/functions/real.h>
32
 
#include <drizzled/alter_drop.h>
33
 
#include <drizzled/alter_column.h>
34
 
#include <drizzled/key.h>
35
 
#include <drizzled/foreign_key.h>
 
26
#include "drizzled/sql_udf.h"
 
27
#include "drizzled/name_resolution_context.h"
 
28
#include "drizzled/item/subselect.h"
 
29
#include "drizzled/item/param.h"
 
30
#include "drizzled/item/outer_ref.h"
 
31
#include "drizzled/table_list.h"
 
32
#include "drizzled/function/math/real.h"
 
33
#include "drizzled/alter_drop.h"
 
34
#include "drizzled/alter_column.h"
 
35
#include "drizzled/key.h"
 
36
#include "drizzled/foreign_key.h"
 
37
#include "drizzled/item/param.h"
 
38
#include "drizzled/index_hint.h"
36
39
 
37
40
class select_result_interceptor;
38
 
class virtual_column_info;
39
41
 
40
42
/* YACC and LEX Definitions */
41
43
 
42
44
/* These may not be declared yet */
43
45
class Table_ident;
44
 
class sql_exchange;
45
 
class LEX_COLUMN;
 
46
class file_exchange;
 
47
class Lex_Column;
 
48
class Item_outer_ref;
46
49
 
47
 
#ifdef DRIZZLE_SERVER
48
50
/*
49
51
  The following hack is needed because mysql_yacc.cc does not define
50
52
  YYSTYPE before including this file
51
53
*/
52
54
 
53
 
#include <drizzled/set_var.h>
54
 
#include <drizzled/item/func.h>
55
 
#ifdef DRIZZLE_YACC
56
 
#define LEX_YYSTYPE void *
57
 
#else
58
 
#if defined(DRIZZLE_LEX)
59
 
#include <drizzled/lex_symbol.h>
60
 
#include <drizzled/sql_yacc.h>
61
 
#define LEX_YYSTYPE YYSTYPE *
62
 
#else
63
 
#define LEX_YYSTYPE void *
64
 
#endif
65
 
#endif
66
 
#endif
 
55
#ifdef DRIZZLE_SERVER
 
56
# include <drizzled/set_var.h>
 
57
# include <drizzled/item/func.h>
 
58
# ifdef DRIZZLE_YACC
 
59
#  define LEX_YYSTYPE void *
 
60
# else
 
61
#  if defined(DRIZZLE_LEX)
 
62
#   include <drizzled/lex_symbol.h>
 
63
#   include <drizzled/sql_yacc.h>
 
64
#   define LEX_YYSTYPE YYSTYPE *
 
65
#  else
 
66
#   define LEX_YYSTYPE void *
 
67
#  endif /* defined(DRIZZLE_LEX) */
 
68
# endif /* DRIZZLE_YACC */
 
69
#endif /* DRIZZLE_SERVER */
67
70
 
68
71
// describe/explain types
69
72
#define DESCRIBE_NORMAL         1
84
87
  char *server_name, *host, *db, *username, *password, *scheme, *owner;
85
88
} LEX_SERVER_OPTIONS;
86
89
 
87
 
typedef struct st_lex_master_info
88
 
{
89
 
  char *host, *user, *password, *log_file_name;
90
 
  uint32_t port, connect_retry;
91
 
  float heartbeat_period;
92
 
  uint64_t pos;
93
 
  uint32_t server_id;
94
 
  /*
95
 
    Enum is used for making it possible to detect if the user
96
 
    changed variable or if it should be left at old value
97
 
   */
98
 
  enum {LEX_MI_UNCHANGED, LEX_MI_DISABLE, LEX_MI_ENABLE} heartbeat_opt;
99
 
  char *relay_log_name;
100
 
  uint32_t relay_log_pos;
101
 
} LEX_MASTER_INFO;
102
 
 
103
90
 
104
91
enum sub_select_type
105
92
{
107
94
  EXCEPT_TYPE, GLOBAL_OPTIONS_TYPE, DERIVED_TABLE_TYPE, OLAP_TYPE
108
95
};
109
96
 
110
 
enum olap_type 
 
97
enum olap_type
111
98
{
112
99
  UNSPECIFIED_OLAP_TYPE, CUBE_TYPE, ROLLUP_TYPE
113
100
};
117
104
  NO_TABLESPACE_OP, DISCARD_TABLESPACE, IMPORT_TABLESPACE
118
105
};
119
106
 
120
 
/* 
121
 
  String names used to print a statement with index hints.
122
 
  Keep in sync with index_hint_type.
123
 
*/
124
 
extern const char * index_hint_type_name[];
125
 
typedef unsigned char index_clause_map;
126
 
 
127
107
/*
128
 
  Bits in index_clause_map : one for each possible FOR clause in
129
 
  USE/FORCE/IGNORE INDEX index hint specification
130
 
*/
131
 
#define INDEX_HINT_MASK_JOIN  (1)
132
 
#define INDEX_HINT_MASK_GROUP (1 << 1)
133
 
#define INDEX_HINT_MASK_ORDER (1 << 2)
134
 
 
135
 
#define INDEX_HINT_MASK_ALL (INDEX_HINT_MASK_JOIN | INDEX_HINT_MASK_GROUP | \
136
 
                             INDEX_HINT_MASK_ORDER)
137
 
 
138
 
/* Single element of an USE/FORCE/IGNORE INDEX list specified as a SQL hint  */
139
 
class Index_hint : public Sql_alloc
140
 
{
141
 
public:
142
 
  /* The type of the hint : USE/FORCE/IGNORE */
143
 
  enum index_hint_type type;
144
 
  /* Where the hit applies to. A bitmask of INDEX_HINT_MASK_<place> values */
145
 
  index_clause_map clause;
146
 
  /* 
147
 
    The index name. Empty (str=NULL) name represents an empty list 
148
 
    USE INDEX () clause 
149
 
  */ 
150
 
  LEX_STRING key_name;
151
 
 
152
 
  Index_hint (enum index_hint_type type_arg, index_clause_map clause_arg,
153
 
              char *str, uint32_t length) :
154
 
    type(type_arg), clause(clause_arg)
155
 
  {
156
 
    key_name.str= str;
157
 
    key_name.length= length;
158
 
  }
159
 
 
160
 
  void print(Session *session, String *str);
161
 
}; 
162
 
 
163
 
/* 
164
 
  The state of the lex parsing for selects 
165
 
   
 
108
  The state of the lex parsing for selects
 
109
 
166
110
   master and slaves are pointers to select_lex.
167
111
   master is pointer to upper level node.
168
112
   slave is pointer to lower level node
274
218
 
275
219
*/
276
220
 
277
 
/* 
278
 
    Base class for st_select_lex (SELECT_LEX) & 
279
 
    st_select_lex_unit (SELECT_LEX_UNIT)
 
221
/*
 
222
    Base class for Select_Lex (Select_Lex) &
 
223
    Select_Lex_Unit (Select_Lex_Unit)
280
224
*/
281
225
class LEX;
282
 
class st_select_lex;
283
 
class st_select_lex_unit;
284
 
class st_select_lex_node {
 
226
class Select_Lex;
 
227
class Select_Lex_Unit;
 
228
class Select_Lex_Node {
285
229
protected:
286
 
  st_select_lex_node *next, **prev,   /* neighbor list */
 
230
  Select_Lex_Node *next, **prev,   /* neighbor list */
287
231
    *master, *slave,                  /* vertical links */
288
 
    *link_next, **link_prev;          /* list of whole SELECT_LEX */
 
232
    *link_next, **link_prev;          /* list of whole Select_Lex */
289
233
public:
290
234
 
291
235
  uint64_t options;
309
253
  }
310
254
  static void *operator new(size_t size, MEM_ROOT *mem_root)
311
255
  { return (void*) alloc_root(mem_root, (uint32_t) size); }
312
 
  static void operator delete(void *ptr __attribute__((unused)),
313
 
                              size_t size __attribute__((unused)))
 
256
  static void operator delete(void *, size_t)
314
257
  { TRASH(ptr, size); }
315
 
  static void operator delete(void *ptr __attribute__((unused)),
316
 
                              MEM_ROOT *mem_root __attribute__((unused)))
 
258
  static void operator delete(void *, MEM_ROOT *)
317
259
  {}
318
 
  st_select_lex_node(): linkage(UNSPECIFIED_TYPE) {}
319
 
  virtual ~st_select_lex_node() {}
320
 
  inline st_select_lex_node* get_master() { return master; }
 
260
  Select_Lex_Node(): linkage(UNSPECIFIED_TYPE) {}
 
261
  virtual ~Select_Lex_Node() {}
 
262
  inline Select_Lex_Node* get_master() { return master; }
321
263
  virtual void init_query();
322
264
  virtual void init_select();
323
 
  void include_down(st_select_lex_node *upper);
324
 
  void include_neighbour(st_select_lex_node *before);
325
 
  void include_standalone(st_select_lex_node *sel, st_select_lex_node **ref);
326
 
  void include_global(st_select_lex_node **plink);
 
265
  void include_down(Select_Lex_Node *upper);
 
266
  void include_neighbour(Select_Lex_Node *before);
 
267
  void include_standalone(Select_Lex_Node *sel, Select_Lex_Node **ref);
 
268
  void include_global(Select_Lex_Node **plink);
327
269
  void exclude();
328
270
 
329
 
  virtual st_select_lex_unit* master_unit()= 0;
330
 
  virtual st_select_lex* outer_select()= 0;
331
 
  virtual st_select_lex* return_after_parsing()= 0;
 
271
  virtual Select_Lex_Unit* master_unit()= 0;
 
272
  virtual Select_Lex* outer_select()= 0;
 
273
  virtual Select_Lex* return_after_parsing()= 0;
332
274
 
333
275
  virtual bool set_braces(bool value);
334
276
  virtual bool inc_in_sum_expr();
342
284
                                        thr_lock_type flags= TL_UNLOCK,
343
285
                                        List<Index_hint> *hints= 0,
344
286
                                        LEX_STRING *option= 0);
345
 
  virtual void set_lock_for_tables(thr_lock_type lock_type __attribute__((unused)))
 
287
  virtual void set_lock_for_tables(thr_lock_type)
346
288
  {}
347
289
 
348
 
  friend class st_select_lex_unit;
 
290
  friend class Select_Lex_Unit;
349
291
  friend bool mysql_new_select(LEX *lex, bool move_down);
350
292
private:
351
293
  void fast_exclude();
352
294
};
353
 
typedef class st_select_lex_node SELECT_LEX_NODE;
354
295
 
355
 
/* 
356
 
   SELECT_LEX_UNIT - unit of selects (UNION, INTERSECT, ...) group 
357
 
   SELECT_LEXs
 
296
/*
 
297
   Select_Lex_Unit - unit of selects (UNION, INTERSECT, ...) group
 
298
   Select_Lexs
358
299
*/
359
300
class Session;
360
301
class select_result;
361
302
class JOIN;
362
303
class select_union;
363
 
class st_select_lex_unit: public st_select_lex_node {
 
304
class Select_Lex_Unit: public Select_Lex_Node {
364
305
protected:
365
306
  TableList result_table_list;
366
307
  select_union *union_result;
380
321
  List<Item> item_list;
381
322
  /*
382
323
    list of types of items inside union (used for union & derived tables)
383
 
    
 
324
 
384
325
    Item_type_holders from which this list consist may have pointers to Field,
385
326
    pointers is valid only after preparing SELECTS of this unit and before
386
327
    any SELECT of this unit execution
394
335
    Pointer to 'last' select or pointer to unit where stored
395
336
    global parameters for union
396
337
  */
397
 
  st_select_lex *global_parameters;
 
338
  Select_Lex *global_parameters;
398
339
  //node on wich we should return current_select pointer after parsing subquery
399
 
  st_select_lex *return_to;
 
340
  Select_Lex *return_to;
400
341
  /* LIMIT clause runtime counters */
401
342
  ha_rows select_limit_cnt, offset_limit_cnt;
402
343
  /* not NULL if unit used in subselect, point to subselect item */
404
345
  /* thread handler */
405
346
  Session *session;
406
347
  /*
407
 
    SELECT_LEX for hidden SELECT in onion which process global
 
348
    Select_Lex for hidden SELECT in onion which process global
408
349
    ORDER BY and LIMIT
409
350
  */
410
 
  st_select_lex *fake_select_lex;
 
351
  Select_Lex *fake_select_lex;
411
352
 
412
 
  st_select_lex *union_distinct; /* pointer to the last UNION DISTINCT */
 
353
  Select_Lex *union_distinct; /* pointer to the last UNION DISTINCT */
413
354
  bool describe; /* union exec() called for EXPLAIN */
414
355
 
415
356
  void init_query();
416
 
  st_select_lex_unit* master_unit();
417
 
  st_select_lex* outer_select();
418
 
  st_select_lex* first_select()
419
 
  {
420
 
    return reinterpret_cast<st_select_lex*>(slave);
421
 
  }
422
 
  st_select_lex_unit* next_unit()
423
 
  {
424
 
    return reinterpret_cast<st_select_lex_unit*>(next);
425
 
  }
426
 
  st_select_lex* return_after_parsing() { return return_to; }
 
357
  Select_Lex_Unit* master_unit();
 
358
  Select_Lex* outer_select();
 
359
  Select_Lex* first_select()
 
360
  {
 
361
    return reinterpret_cast<Select_Lex*>(slave);
 
362
  }
 
363
  Select_Lex_Unit* next_unit()
 
364
  {
 
365
    return reinterpret_cast<Select_Lex_Unit*>(next);
 
366
  }
 
367
  Select_Lex* return_after_parsing() { return return_to; }
427
368
  void exclude_level();
428
369
  void exclude_tree();
429
370
 
430
371
  /* UNION methods */
431
 
  bool prepare(Session *session, select_result *result, uint32_t additional_options);
 
372
  bool prepare(Session *session, select_result *result,
 
373
               uint64_t additional_options);
432
374
  bool exec();
433
375
  bool cleanup();
434
376
  inline void unclean() { cleaned= 0; }
440
382
  void init_prepare_fake_select_lex(Session *session);
441
383
  bool change_result(select_result_interceptor *result,
442
384
                     select_result_interceptor *old_result);
443
 
  void set_limit(st_select_lex *values);
 
385
  void set_limit(Select_Lex *values);
444
386
  void set_session(Session *session_arg) { session= session_arg; }
445
 
  inline bool is_union (); 
 
387
  inline bool is_union ();
446
388
 
447
389
  friend void lex_start(Session *session);
448
390
  friend int subselect_union_engine::exec();
450
392
  List<Item> *get_unit_column_types();
451
393
};
452
394
 
453
 
typedef class st_select_lex_unit SELECT_LEX_UNIT;
454
 
 
455
395
/*
456
 
  SELECT_LEX - store information of parsed SELECT statment
 
396
  Select_Lex - store information of parsed SELECT statment
457
397
*/
458
 
class st_select_lex: public st_select_lex_node
 
398
class Select_Lex: public Select_Lex_Node
459
399
{
460
400
public:
461
401
  Name_resolution_context context;
472
412
  List<Item>          item_list;  /* list of fields & expressions */
473
413
  List<String>        interval_list;
474
414
  bool                is_item_list_lookup;
475
 
  /* 
476
 
    Despite their names, the following are used in unions. This should 
477
 
    be rewritten. -Brian
478
 
  */
479
 
  List<Item_real_func> *ftfunc_list;
480
 
  List<Item_real_func> ftfunc_list_alloc;
481
415
  JOIN *join; /* after JOIN::prepare it is pointer to corresponding JOIN */
482
416
  List<TableList> top_join_list; /* join list of the top level          */
483
417
  List<TableList> *join_list;    /* list for the currently parsed join  */
505
439
  uint32_t select_n_having_items;
506
440
  uint32_t cond_count;    /* number of arguments of and/or/xor in where/having/on */
507
441
  uint32_t between_count; /* number of between predicates in where/having/on      */
508
 
  uint32_t max_equal_elems; /* maximal number of elements in multiple equalities  */   
 
442
  uint32_t max_equal_elems; /* maximal number of elements in multiple equalities  */
509
443
  /*
510
444
    Number of fields used in select list or where clause of current select
511
445
    and all inner subselects.
513
447
  uint32_t select_n_where_fields;
514
448
  enum_parsing_place parsing_place; /* where we are parsing expression */
515
449
  bool with_sum_func;   /* sum function indicator */
516
 
  /* 
517
 
    PS or SP cond natural joins was alredy processed with permanent
518
 
    arena and all additional items which we need alredy stored in it
519
 
  */
520
 
  bool conds_processed_with_permanent_arena;
521
450
 
522
451
  uint32_t table_join_options;
523
452
  uint32_t in_sum_expr;
524
453
  uint32_t select_number; /* number of select (used for EXPLAIN) */
525
 
  int nest_level;     /* nesting level of select */
526
 
  Item_sum *inner_sum_func_list; /* list of sum func in nested selects */ 
 
454
  int8_t nest_level;     /* nesting level of select */
 
455
  Item_sum *inner_sum_func_list; /* list of sum func in nested selects */
527
456
  uint32_t with_wild; /* item list contain '*' */
528
457
  bool  braces;         /* SELECT ... UNION (SELECT ... ) <- this braces */
529
458
  /* true when having fix field called in processing of this SELECT */
551
480
  /* index in the select list of the expression currently being fixed */
552
481
  int cur_pos_in_select_list;
553
482
 
554
 
  List<udf_func>     udf_list;                  /* udf function calls stack */
555
 
  /* 
 
483
  /*
556
484
    This is a copy of the original JOIN USING list that comes from
557
485
    the parser. The parser :
558
486
      1. Sets the natural_join of the second TableList in the join
559
 
         and the st_select_lex::prev_join_using.
 
487
         and the Select_Lex::prev_join_using.
560
488
      2. Makes a parent TableList and sets its is_natural_join/
561
489
       join_using_fields members.
562
490
      3. Uses the wrapper TableList as a table in the upper level.
578
506
  uint8_t full_group_by_flag;
579
507
  void init_query();
580
508
  void init_select();
581
 
  st_select_lex_unit* master_unit();
582
 
  st_select_lex_unit* first_inner_unit() 
583
 
  { 
584
 
    return (st_select_lex_unit*) slave; 
585
 
  }
586
 
  st_select_lex* outer_select();
587
 
  st_select_lex* next_select() { return (st_select_lex*) next; }
588
 
  st_select_lex* next_select_in_list() 
589
 
  {
590
 
    return (st_select_lex*) link_next;
591
 
  }
592
 
  st_select_lex_node** next_select_in_list_addr()
 
509
  Select_Lex_Unit* master_unit();
 
510
  Select_Lex_Unit* first_inner_unit()
 
511
  {
 
512
    return (Select_Lex_Unit*) slave;
 
513
  }
 
514
  Select_Lex* outer_select();
 
515
  Select_Lex* next_select() { return (Select_Lex*) next; }
 
516
  Select_Lex* next_select_in_list()
 
517
  {
 
518
    return (Select_Lex*) link_next;
 
519
  }
 
520
  Select_Lex_Node** next_select_in_list_addr()
593
521
  {
594
522
    return &link_next;
595
523
  }
596
 
  st_select_lex* return_after_parsing()
 
524
  Select_Lex* return_after_parsing()
597
525
  {
598
526
    return master_unit()->return_after_parsing();
599
527
  }
600
528
 
601
 
  void mark_as_dependent(st_select_lex *last);
 
529
  void mark_as_dependent(Select_Lex *last);
602
530
 
603
531
  bool set_braces(bool value);
604
532
  bool inc_in_sum_expr();
630
558
  }
631
559
  /*
632
560
    This method created for reiniting LEX in mysql_admin_table() and can be
633
 
    used only if you are going remove all SELECT_LEX & units except belonger
 
561
    used only if you are going remove all Select_Lex & units except belonger
634
562
    to LEX (LEX::unit & LEX::select, for other purposes there are
635
 
    SELECT_LEX_UNIT::exclude_level & SELECT_LEX_UNIT::exclude_tree
 
563
    Select_Lex_Unit::exclude_level & Select_Lex_Unit::exclude_tree
636
564
  */
637
565
  void cut_subtree() { slave= 0; }
638
566
  bool test_limit();
639
567
 
640
568
  friend void lex_start(Session *session);
641
 
  st_select_lex() : n_sum_items(0), n_child_sum_items(0) {}
 
569
  Select_Lex() : n_sum_items(0), n_child_sum_items(0) {}
642
570
  void make_empty_select()
643
571
  {
644
572
    init_query();
653
581
  void fix_prepare_information(Session *session, Item **conds, Item **having_conds);
654
582
  /*
655
583
    Destroy the used execution plan (JOIN) of this subtree (this
656
 
    SELECT_LEX and all nested SELECT_LEXes and SELECT_LEX_UNITs).
 
584
    Select_Lex and all nested Select_Lexes and Select_Lex_Units).
657
585
  */
658
586
  bool cleanup();
659
587
  /*
664
592
 
665
593
  void set_index_hint_type(enum index_hint_type type, index_clause_map clause);
666
594
 
667
 
  /* 
 
595
  /*
668
596
   Add a index hint to the tagged list of hints. The type and clause of the
669
 
   hint will be the current ones (set by set_index_hint()) 
 
597
   hint will be the current ones (set by set_index_hint())
670
598
  */
671
599
  bool add_index_hint (Session *session, char *str, uint32_t length);
672
600
 
673
601
  /* make a list to hold index hints */
674
602
  void alloc_index_hints (Session *session);
675
603
  /* read and clear the index hints */
676
 
  List<Index_hint>* pop_index_hints(void) 
 
604
  List<Index_hint>* pop_index_hints(void)
677
605
  {
678
606
    List<Index_hint> *hints= index_hints;
679
607
    index_hints= NULL;
682
610
 
683
611
  void clear_index_hints(void) { index_hints= NULL; }
684
612
 
685
 
private:  
 
613
private:
686
614
  /* current index hint kind. used in filling up index_hints */
687
615
  enum index_hint_type current_index_hint_type;
688
616
  index_clause_map current_index_hint_clause;
689
617
  /* a list of USE/FORCE/IGNORE INDEX */
690
618
  List<Index_hint> *index_hints;
691
619
};
692
 
typedef class st_select_lex SELECT_LEX;
693
620
 
694
 
inline bool st_select_lex_unit::is_union ()
695
 
696
 
  return first_select()->next_select() && 
 
621
inline bool Select_Lex_Unit::is_union ()
 
622
{
 
623
  return first_select()->next_select() &&
697
624
    first_select()->next_select()->linkage == UNION_TYPE;
698
625
}
699
626
 
812
739
 
813
740
  /* Initializes (or resets) Query_tables_list object for "real" use. */
814
741
  void reset_query_tables_list(bool init);
815
 
  void destroy_query_tables_list();
816
742
  void set_query_tables_list(Query_tables_list *state)
817
743
  {
818
744
    *this= *state;
852
778
 
853
779
struct st_parsing_options
854
780
{
855
 
  bool allows_variable;
856
 
  bool allows_select_into;
857
781
  bool allows_select_procedure;
858
 
  bool allows_derived;
859
782
 
860
783
  st_parsing_options() { reset(); }
861
784
  void reset();
1267
1190
 
1268
1191
class LEX : public Query_tables_list
1269
1192
{
1270
 
public: 
1271
 
  SELECT_LEX_UNIT unit;                         /* most upper unit */
1272
 
  SELECT_LEX select_lex;                        /* first SELECT_LEX */
1273
 
  /* current SELECT_LEX in parsing */
1274
 
  SELECT_LEX *current_select;
1275
 
  /* list of all SELECT_LEX */
1276
 
  SELECT_LEX *all_selects_list;
 
1193
public:
 
1194
  Select_Lex_Unit unit;                         /* most upper unit */
 
1195
  Select_Lex select_lex;                        /* first Select_Lex */
 
1196
  /* current Select_Lex in parsing */
 
1197
  Select_Lex *current_select;
 
1198
  /* list of all Select_Lex */
 
1199
  Select_Lex *all_selects_list;
1277
1200
 
1278
1201
  char *length,*dec,*change;
1279
1202
  LEX_STRING name;
1280
 
  char *help_arg;
1281
 
  char* to_log;                                 /* For PURGE MASTER LOGS TO */
1282
1203
  String *wild;
1283
 
  sql_exchange *exchange;
 
1204
  file_exchange *exchange;
1284
1205
  select_result *result;
1285
1206
  Item *default_value, *on_update_value;
1286
1207
  LEX_STRING comment, ident;
1287
1208
  XID *xid;
1288
1209
  unsigned char* yacc_yyss, *yacc_yyvs;
1289
1210
  Session *session;
1290
 
  virtual_column_info *vcol_info;
1291
 
 
1292
 
  /* maintain a list of used plugins for this LEX */
1293
 
  DYNAMIC_ARRAY plugins;
1294
 
  plugin_ref plugins_static_buffer[INITIAL_LEX_PLUGIN_LIST_SIZE];
1295
1211
 
1296
1212
  const CHARSET_INFO *charset;
1297
1213
  bool text_string_is_7bit;
1301
1217
  List<Key_part_spec> col_list;
1302
1218
  List<Key_part_spec> ref_list;
1303
1219
  List<String>        interval_list;
1304
 
  List<LEX_COLUMN>    columns;
 
1220
  List<Lex_Column>    columns;
1305
1221
  List<Item>          *insert_list,field_list,value_list,update_list;
1306
1222
  List<List_item>     many_values;
1307
1223
  List<set_var_base>  var_list;
1322
1238
  List<Name_resolution_context> context_stack;
1323
1239
  List<LEX_STRING>     db_list;
1324
1240
 
1325
 
  SQL_LIST            proc_list, auxiliary_table_list, save_list;
 
1241
  SQL_LIST            auxiliary_table_list, save_list;
1326
1242
  Create_field        *last_field;
1327
1243
  Item_sum *in_sum_func;
1328
 
  udf_func udf;
 
1244
  Function_builder *udf;
1329
1245
  HA_CHECK_OPT   check_opt;                     // check/repair options
1330
1246
  HA_CREATE_INFO create_info;
1331
1247
  KEY_CREATE_INFO key_create_info;
1332
 
  LEX_MASTER_INFO mi;                           // used by CHANGE MASTER
1333
1248
  uint32_t type;
1334
1249
  /*
1335
1250
    This variable is used in post-parse stage to declare that sum-functions,
1349
1264
    syntax error back.
1350
1265
  */
1351
1266
  bool expr_allows_subselect;
1352
 
  /*
1353
 
    A special command "PARSE_VCOL_EXPR" is defined for the parser 
1354
 
    to translate an expression statement of a virtual column \
1355
 
    (stored in the *.frm file as a string) into an Item object.
1356
 
    The following flag is used to prevent other applications to use 
1357
 
    this command.
1358
 
  */
1359
 
  bool parse_vcol_expr;
1360
1267
 
1361
1268
  thr_lock_type lock_option;
1362
1269
  enum enum_duplicates duplicates;
1390
1297
    query (0 if no derived tables, otherwise DERIVED_SUBQUERY).
1391
1298
  */
1392
1299
  uint8_t derived_tables;
1393
 
  bool drop_if_exists, drop_temporary, local_file, one_shot_set;
 
1300
  bool drop_if_exists, drop_temporary, one_shot_set;
1394
1301
  bool autocommit;
1395
1302
  bool verbose;
1396
1303
 
1400
1307
  Alter_info alter_info;
1401
1308
 
1402
1309
  /*
1403
 
    field_list was created for view and should be removed before PS/SP
1404
 
    rexecuton
1405
 
  */
1406
 
  bool empty_field_list_on_rset;
1407
 
 
1408
 
  /*
1409
1310
    Pointers to part of LOAD DATA statement that should be rewritten
1410
1311
    during replication ("LOCAL 'filename' REPLACE INTO" part).
1411
1312
  */
1412
1313
  const char *fname_start;
1413
1314
  const char *fname_end;
1414
 
  
 
1315
 
1415
1316
  /**
1416
 
    During name resolution search only in the table list given by 
 
1317
    During name resolution search only in the table list given by
1417
1318
    Name_resolution_context::first_name_resolution_table and
1418
1319
    Name_resolution_context::last_name_resolution_table
1419
 
    (see Item_field::fix_fields()). 
 
1320
    (see Item_field::fix_fields()).
1420
1321
  */
1421
1322
  bool use_only_table_context;
1422
 
  
 
1323
 
1423
1324
  bool escape_used;
1424
1325
  bool is_lex_started; /* If lex_start() did run. For debugging. */
1425
1326
 
1427
1328
 
1428
1329
  virtual ~LEX()
1429
1330
  {
1430
 
    destroy_query_tables_list();
1431
 
    plugin_unlock_list(NULL, (plugin_ref *)plugins.buffer, plugins.elements);
1432
 
    delete_dynamic(&plugins);
1433
1331
  }
1434
1332
 
1435
1333
  TableList *unlink_first_table(bool *link_to_local);
1462
1360
  */
1463
1361
  static void cleanup_lex_after_parse_error(Session *session);
1464
1362
 
1465
 
  void reset_n_backup_query_tables_list(Query_tables_list *backup);
1466
 
  void restore_backup_query_tables_list(Query_tables_list *backup);
1467
 
 
1468
 
  bool table_or_sp_used();
1469
 
 
1470
1363
  /**
1471
1364
    @brief check if the statement is a single-level join
1472
1365
    @return result of the check
1473
 
      @retval true  The statement doesn't contain subqueries, unions and 
 
1366
      @retval true  The statement doesn't contain subqueries, unions and
1474
1367
                    stored procedure calls.
1475
1368
      @retval false There are subqueries, UNIONs or stored procedure calls.
1476
1369
  */
1477
 
  bool is_single_level_stmt() 
1478
 
  { 
1479
 
    /* 
 
1370
  bool is_single_level_stmt()
 
1371
  {
 
1372
    /*
1480
1373
      This check exploits the fact that the last added to all_select_list is
1481
 
      on its top. So select_lex (as the first added) will be at the tail 
 
1374
      on its top. So select_lex (as the first added) will be at the tail
1482
1375
      of the list.
1483
 
    */ 
 
1376
    */
1484
1377
    if (&select_lex == all_selects_list)
1485
1378
    {
1486
1379
      assert(!all_selects_list->next_select_in_list());
1490
1383
  }
1491
1384
};
1492
1385
 
1493
 
struct st_lex_local: public LEX
1494
 
{
1495
 
  static void *operator new(size_t size) throw()
1496
 
  {
1497
 
    return sql_alloc(size);
1498
 
  }
1499
 
  static void *operator new(size_t size, MEM_ROOT *mem_root) throw()
1500
 
  {
1501
 
    return (void*) alloc_root(mem_root, (uint32_t) size);
1502
 
  }
1503
 
  static void operator delete(void *ptr __attribute__((unused)),
1504
 
                              size_t size __attribute__((unused)))
1505
 
  { TRASH(ptr, size); }
1506
 
  static void operator delete(void *ptr __attribute__((unused)),
1507
 
                              MEM_ROOT *mem_root __attribute__((unused)))
1508
 
  { /* Never called */ }
1509
 
};
1510
 
 
1511
 
extern void lex_init(void);
1512
 
extern void lex_free(void);
1513
1386
extern void lex_start(Session *session);
1514
1387
extern void lex_end(LEX *lex);
1515
1388
 
1517
1390
 
1518
1391
extern bool is_lex_native_function(const LEX_STRING *name);
1519
1392
 
1520
 
int lex_casecmp(const char *s, const char *t, uint32_t len);
1521
 
 
1522
1393
/**
1523
1394
  @} (End of group Semantic_Analysis)
1524
1395
*/
1525
1396
 
1526
1397
#endif /* DRIZZLE_SERVER */
1527
 
#endif /* DRIZZLE_SERVER_SQL_LEX_H */
 
1398
#endif /* DRIZZLED_SQL_LEX_H */