~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_lex.h

  • Committer: Jay Pipes
  • Date: 2009-03-01 03:08:20 UTC
  • mto: (910.2.6 mordred-noatomics)
  • mto: This revision was merged to the branch mainline in revision 912.
  • Revision ID: jpipes@serialcoder-20090301030820-8kxgypvo3yexa9d1
Final removal of timezones

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
 
45
45
/* These may not be declared yet */
46
46
class Table_ident;
47
 
class sql_exchange;
48
 
class LEX_COLUMN;
 
47
class file_exchange;
 
48
class Lex_Column;
49
49
class Item_outer_ref;
50
50
 
51
51
/*
88
88
  char *server_name, *host, *db, *username, *password, *scheme, *owner;
89
89
} LEX_SERVER_OPTIONS;
90
90
 
91
 
typedef struct st_lex_master_info
92
 
{
93
 
  char *host, *user, *password, *log_file_name;
94
 
  uint32_t port, connect_retry;
95
 
  float heartbeat_period;
96
 
  uint64_t pos;
97
 
  uint32_t server_id;
98
 
  /*
99
 
    Enum is used for making it possible to detect if the user
100
 
    changed variable or if it should be left at old value
101
 
   */
102
 
  enum {LEX_MI_UNCHANGED, LEX_MI_DISABLE, LEX_MI_ENABLE} heartbeat_opt;
103
 
  char *relay_log_name;
104
 
  uint32_t relay_log_pos;
105
 
} LEX_MASTER_INFO;
106
 
 
107
91
 
108
92
enum sub_select_type
109
93
{
279
263
*/
280
264
 
281
265
/*
282
 
    Base class for st_select_lex (SELECT_LEX) &
283
 
    st_select_lex_unit (SELECT_LEX_UNIT)
 
266
    Base class for Select_Lex (Select_Lex) &
 
267
    Select_Lex_Unit (Select_Lex_Unit)
284
268
*/
285
269
class LEX;
286
 
class st_select_lex;
287
 
class st_select_lex_unit;
288
 
class st_select_lex_node {
 
270
class Select_Lex;
 
271
class Select_Lex_Unit;
 
272
class Select_Lex_Node {
289
273
protected:
290
 
  st_select_lex_node *next, **prev,   /* neighbor list */
 
274
  Select_Lex_Node *next, **prev,   /* neighbor list */
291
275
    *master, *slave,                  /* vertical links */
292
 
    *link_next, **link_prev;          /* list of whole SELECT_LEX */
 
276
    *link_next, **link_prev;          /* list of whole Select_Lex */
293
277
public:
294
278
 
295
279
  uint64_t options;
317
301
  { TRASH(ptr, size); }
318
302
  static void operator delete(void *, MEM_ROOT *)
319
303
  {}
320
 
  st_select_lex_node(): linkage(UNSPECIFIED_TYPE) {}
321
 
  virtual ~st_select_lex_node() {}
322
 
  inline st_select_lex_node* get_master() { return master; }
 
304
  Select_Lex_Node(): linkage(UNSPECIFIED_TYPE) {}
 
305
  virtual ~Select_Lex_Node() {}
 
306
  inline Select_Lex_Node* get_master() { return master; }
323
307
  virtual void init_query();
324
308
  virtual void init_select();
325
 
  void include_down(st_select_lex_node *upper);
326
 
  void include_neighbour(st_select_lex_node *before);
327
 
  void include_standalone(st_select_lex_node *sel, st_select_lex_node **ref);
328
 
  void include_global(st_select_lex_node **plink);
 
309
  void include_down(Select_Lex_Node *upper);
 
310
  void include_neighbour(Select_Lex_Node *before);
 
311
  void include_standalone(Select_Lex_Node *sel, Select_Lex_Node **ref);
 
312
  void include_global(Select_Lex_Node **plink);
329
313
  void exclude();
330
314
 
331
 
  virtual st_select_lex_unit* master_unit()= 0;
332
 
  virtual st_select_lex* outer_select()= 0;
333
 
  virtual st_select_lex* return_after_parsing()= 0;
 
315
  virtual Select_Lex_Unit* master_unit()= 0;
 
316
  virtual Select_Lex* outer_select()= 0;
 
317
  virtual Select_Lex* return_after_parsing()= 0;
334
318
 
335
319
  virtual bool set_braces(bool value);
336
320
  virtual bool inc_in_sum_expr();
347
331
  virtual void set_lock_for_tables(thr_lock_type)
348
332
  {}
349
333
 
350
 
  friend class st_select_lex_unit;
 
334
  friend class Select_Lex_Unit;
351
335
  friend bool mysql_new_select(LEX *lex, bool move_down);
352
336
private:
353
337
  void fast_exclude();
354
338
};
355
 
typedef class st_select_lex_node SELECT_LEX_NODE;
356
339
 
357
340
/*
358
 
   SELECT_LEX_UNIT - unit of selects (UNION, INTERSECT, ...) group
359
 
   SELECT_LEXs
 
341
   Select_Lex_Unit - unit of selects (UNION, INTERSECT, ...) group
 
342
   Select_Lexs
360
343
*/
361
344
class Session;
362
345
class select_result;
363
346
class JOIN;
364
347
class select_union;
365
 
class st_select_lex_unit: public st_select_lex_node {
 
348
class Select_Lex_Unit: public Select_Lex_Node {
366
349
protected:
367
350
  TableList result_table_list;
368
351
  select_union *union_result;
396
379
    Pointer to 'last' select or pointer to unit where stored
397
380
    global parameters for union
398
381
  */
399
 
  st_select_lex *global_parameters;
 
382
  Select_Lex *global_parameters;
400
383
  //node on wich we should return current_select pointer after parsing subquery
401
 
  st_select_lex *return_to;
 
384
  Select_Lex *return_to;
402
385
  /* LIMIT clause runtime counters */
403
386
  ha_rows select_limit_cnt, offset_limit_cnt;
404
387
  /* not NULL if unit used in subselect, point to subselect item */
406
389
  /* thread handler */
407
390
  Session *session;
408
391
  /*
409
 
    SELECT_LEX for hidden SELECT in onion which process global
 
392
    Select_Lex for hidden SELECT in onion which process global
410
393
    ORDER BY and LIMIT
411
394
  */
412
 
  st_select_lex *fake_select_lex;
 
395
  Select_Lex *fake_select_lex;
413
396
 
414
 
  st_select_lex *union_distinct; /* pointer to the last UNION DISTINCT */
 
397
  Select_Lex *union_distinct; /* pointer to the last UNION DISTINCT */
415
398
  bool describe; /* union exec() called for EXPLAIN */
416
399
 
417
400
  void init_query();
418
 
  st_select_lex_unit* master_unit();
419
 
  st_select_lex* outer_select();
420
 
  st_select_lex* first_select()
421
 
  {
422
 
    return reinterpret_cast<st_select_lex*>(slave);
423
 
  }
424
 
  st_select_lex_unit* next_unit()
425
 
  {
426
 
    return reinterpret_cast<st_select_lex_unit*>(next);
427
 
  }
428
 
  st_select_lex* return_after_parsing() { return return_to; }
 
401
  Select_Lex_Unit* master_unit();
 
402
  Select_Lex* outer_select();
 
403
  Select_Lex* first_select()
 
404
  {
 
405
    return reinterpret_cast<Select_Lex*>(slave);
 
406
  }
 
407
  Select_Lex_Unit* next_unit()
 
408
  {
 
409
    return reinterpret_cast<Select_Lex_Unit*>(next);
 
410
  }
 
411
  Select_Lex* return_after_parsing() { return return_to; }
429
412
  void exclude_level();
430
413
  void exclude_tree();
431
414
 
432
415
  /* UNION methods */
433
 
  bool prepare(Session *session, select_result *result, uint32_t additional_options);
 
416
  bool prepare(Session *session, select_result *result,
 
417
               uint64_t additional_options);
434
418
  bool exec();
435
419
  bool cleanup();
436
420
  inline void unclean() { cleaned= 0; }
442
426
  void init_prepare_fake_select_lex(Session *session);
443
427
  bool change_result(select_result_interceptor *result,
444
428
                     select_result_interceptor *old_result);
445
 
  void set_limit(st_select_lex *values);
 
429
  void set_limit(Select_Lex *values);
446
430
  void set_session(Session *session_arg) { session= session_arg; }
447
431
  inline bool is_union ();
448
432
 
452
436
  List<Item> *get_unit_column_types();
453
437
};
454
438
 
455
 
typedef class st_select_lex_unit SELECT_LEX_UNIT;
456
 
 
457
439
/*
458
 
  SELECT_LEX - store information of parsed SELECT statment
 
440
  Select_Lex - store information of parsed SELECT statment
459
441
*/
460
 
class st_select_lex: public st_select_lex_node
 
442
class Select_Lex: public Select_Lex_Node
461
443
{
462
444
public:
463
445
  Name_resolution_context context;
553
535
    This is a copy of the original JOIN USING list that comes from
554
536
    the parser. The parser :
555
537
      1. Sets the natural_join of the second TableList in the join
556
 
         and the st_select_lex::prev_join_using.
 
538
         and the Select_Lex::prev_join_using.
557
539
      2. Makes a parent TableList and sets its is_natural_join/
558
540
       join_using_fields members.
559
541
      3. Uses the wrapper TableList as a table in the upper level.
575
557
  uint8_t full_group_by_flag;
576
558
  void init_query();
577
559
  void init_select();
578
 
  st_select_lex_unit* master_unit();
579
 
  st_select_lex_unit* first_inner_unit()
580
 
  {
581
 
    return (st_select_lex_unit*) slave;
582
 
  }
583
 
  st_select_lex* outer_select();
584
 
  st_select_lex* next_select() { return (st_select_lex*) next; }
585
 
  st_select_lex* next_select_in_list()
586
 
  {
587
 
    return (st_select_lex*) link_next;
588
 
  }
589
 
  st_select_lex_node** next_select_in_list_addr()
 
560
  Select_Lex_Unit* master_unit();
 
561
  Select_Lex_Unit* first_inner_unit()
 
562
  {
 
563
    return (Select_Lex_Unit*) slave;
 
564
  }
 
565
  Select_Lex* outer_select();
 
566
  Select_Lex* next_select() { return (Select_Lex*) next; }
 
567
  Select_Lex* next_select_in_list()
 
568
  {
 
569
    return (Select_Lex*) link_next;
 
570
  }
 
571
  Select_Lex_Node** next_select_in_list_addr()
590
572
  {
591
573
    return &link_next;
592
574
  }
593
 
  st_select_lex* return_after_parsing()
 
575
  Select_Lex* return_after_parsing()
594
576
  {
595
577
    return master_unit()->return_after_parsing();
596
578
  }
597
579
 
598
 
  void mark_as_dependent(st_select_lex *last);
 
580
  void mark_as_dependent(Select_Lex *last);
599
581
 
600
582
  bool set_braces(bool value);
601
583
  bool inc_in_sum_expr();
627
609
  }
628
610
  /*
629
611
    This method created for reiniting LEX in mysql_admin_table() and can be
630
 
    used only if you are going remove all SELECT_LEX & units except belonger
 
612
    used only if you are going remove all Select_Lex & units except belonger
631
613
    to LEX (LEX::unit & LEX::select, for other purposes there are
632
 
    SELECT_LEX_UNIT::exclude_level & SELECT_LEX_UNIT::exclude_tree
 
614
    Select_Lex_Unit::exclude_level & Select_Lex_Unit::exclude_tree
633
615
  */
634
616
  void cut_subtree() { slave= 0; }
635
617
  bool test_limit();
636
618
 
637
619
  friend void lex_start(Session *session);
638
 
  st_select_lex() : n_sum_items(0), n_child_sum_items(0) {}
 
620
  Select_Lex() : n_sum_items(0), n_child_sum_items(0) {}
639
621
  void make_empty_select()
640
622
  {
641
623
    init_query();
650
632
  void fix_prepare_information(Session *session, Item **conds, Item **having_conds);
651
633
  /*
652
634
    Destroy the used execution plan (JOIN) of this subtree (this
653
 
    SELECT_LEX and all nested SELECT_LEXes and SELECT_LEX_UNITs).
 
635
    Select_Lex and all nested Select_Lexes and Select_Lex_Units).
654
636
  */
655
637
  bool cleanup();
656
638
  /*
686
668
  /* a list of USE/FORCE/IGNORE INDEX */
687
669
  List<Index_hint> *index_hints;
688
670
};
689
 
typedef class st_select_lex SELECT_LEX;
690
671
 
691
 
inline bool st_select_lex_unit::is_union ()
 
672
inline bool Select_Lex_Unit::is_union ()
692
673
{
693
674
  return first_select()->next_select() &&
694
675
    first_select()->next_select()->linkage == UNION_TYPE;
1262
1243
class LEX : public Query_tables_list
1263
1244
{
1264
1245
public:
1265
 
  SELECT_LEX_UNIT unit;                         /* most upper unit */
1266
 
  SELECT_LEX select_lex;                        /* first SELECT_LEX */
1267
 
  /* current SELECT_LEX in parsing */
1268
 
  SELECT_LEX *current_select;
1269
 
  /* list of all SELECT_LEX */
1270
 
  SELECT_LEX *all_selects_list;
 
1246
  Select_Lex_Unit unit;                         /* most upper unit */
 
1247
  Select_Lex select_lex;                        /* first Select_Lex */
 
1248
  /* current Select_Lex in parsing */
 
1249
  Select_Lex *current_select;
 
1250
  /* list of all Select_Lex */
 
1251
  Select_Lex *all_selects_list;
1271
1252
 
1272
1253
  char *length,*dec,*change;
1273
1254
  LEX_STRING name;
1274
 
  char *help_arg;
1275
 
  char* to_log;                                 /* For PURGE MASTER LOGS TO */
1276
1255
  String *wild;
1277
 
  sql_exchange *exchange;
 
1256
  file_exchange *exchange;
1278
1257
  select_result *result;
1279
1258
  Item *default_value, *on_update_value;
1280
1259
  LEX_STRING comment, ident;
1291
1270
  List<Key_part_spec> col_list;
1292
1271
  List<Key_part_spec> ref_list;
1293
1272
  List<String>        interval_list;
1294
 
  List<LEX_COLUMN>    columns;
 
1273
  List<Lex_Column>    columns;
1295
1274
  List<Item>          *insert_list,field_list,value_list,update_list;
1296
1275
  List<List_item>     many_values;
1297
1276
  List<set_var_base>  var_list;
1319
1298
  HA_CHECK_OPT   check_opt;                     // check/repair options
1320
1299
  HA_CREATE_INFO create_info;
1321
1300
  KEY_CREATE_INFO key_create_info;
1322
 
  LEX_MASTER_INFO mi;                           // used by CHANGE MASTER
1323
1301
  uint32_t type;
1324
1302
  /*
1325
1303
    This variable is used in post-parse stage to declare that sum-functions,
1483
1461
  { /* Never called */ }
1484
1462
};
1485
1463
 
1486
 
extern void lex_init(void);
1487
 
extern void lex_free(void);
1488
1464
extern void lex_start(Session *session);
1489
1465
extern void lex_end(LEX *lex);
1490
1466
 
1492
1468
 
1493
1469
extern bool is_lex_native_function(const LEX_STRING *name);
1494
1470
 
1495
 
int lex_casecmp(const char *s, const char *t, uint32_t len);
1496
 
 
1497
1471
/**
1498
1472
  @} (End of group Semantic_Analysis)
1499
1473
*/