~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_lex.h

Merged in Eric's whitespace cleanup.

Show diffs side-by-side

added added

removed removed

Lines of Context:
107
107
  EXCEPT_TYPE, GLOBAL_OPTIONS_TYPE, DERIVED_TABLE_TYPE, OLAP_TYPE
108
108
};
109
109
 
110
 
enum olap_type 
 
110
enum olap_type
111
111
{
112
112
  UNSPECIFIED_OLAP_TYPE, CUBE_TYPE, ROLLUP_TYPE
113
113
};
117
117
  NO_TABLESPACE_OP, DISCARD_TABLESPACE, IMPORT_TABLESPACE
118
118
};
119
119
 
120
 
/* 
 
120
/*
121
121
  String names used to print a statement with index hints.
122
122
  Keep in sync with index_hint_type.
123
123
*/
143
143
  enum index_hint_type type;
144
144
  /* Where the hit applies to. A bitmask of INDEX_HINT_MASK_<place> values */
145
145
  index_clause_map clause;
146
 
  /* 
147
 
    The index name. Empty (str=NULL) name represents an empty list 
148
 
    USE INDEX () clause 
149
 
  */ 
 
146
  /*
 
147
    The index name. Empty (str=NULL) name represents an empty list
 
148
    USE INDEX () clause
 
149
  */
150
150
  LEX_STRING key_name;
151
151
 
152
152
  Index_hint (enum index_hint_type type_arg, index_clause_map clause_arg,
158
158
  }
159
159
 
160
160
  void print(Session *session, String *str);
161
 
}; 
162
 
 
163
 
/* 
164
 
  The state of the lex parsing for selects 
165
 
   
 
161
};
 
162
 
 
163
/*
 
164
  The state of the lex parsing for selects
 
165
 
166
166
   master and slaves are pointers to select_lex.
167
167
   master is pointer to upper level node.
168
168
   slave is pointer to lower level node
274
274
 
275
275
*/
276
276
 
277
 
/* 
278
 
    Base class for st_select_lex (SELECT_LEX) & 
 
277
/*
 
278
    Base class for st_select_lex (SELECT_LEX) &
279
279
    st_select_lex_unit (SELECT_LEX_UNIT)
280
280
*/
281
281
class LEX;
350
350
};
351
351
typedef class st_select_lex_node SELECT_LEX_NODE;
352
352
 
353
 
/* 
354
 
   SELECT_LEX_UNIT - unit of selects (UNION, INTERSECT, ...) group 
 
353
/*
 
354
   SELECT_LEX_UNIT - unit of selects (UNION, INTERSECT, ...) group
355
355
   SELECT_LEXs
356
356
*/
357
357
class Session;
378
378
  List<Item> item_list;
379
379
  /*
380
380
    list of types of items inside union (used for union & derived tables)
381
 
    
 
381
 
382
382
    Item_type_holders from which this list consist may have pointers to Field,
383
383
    pointers is valid only after preparing SELECTS of this unit and before
384
384
    any SELECT of this unit execution
440
440
                     select_result_interceptor *old_result);
441
441
  void set_limit(st_select_lex *values);
442
442
  void set_session(Session *session_arg) { session= session_arg; }
443
 
  inline bool is_union (); 
 
443
  inline bool is_union ();
444
444
 
445
445
  friend void lex_start(Session *session);
446
446
  friend int subselect_union_engine::exec();
470
470
  List<Item>          item_list;  /* list of fields & expressions */
471
471
  List<String>        interval_list;
472
472
  bool                is_item_list_lookup;
473
 
  /* 
474
 
    Despite their names, the following are used in unions. This should 
 
473
  /*
 
474
    Despite their names, the following are used in unions. This should
475
475
    be rewritten. -Brian
476
476
  */
477
477
  List<Item_real_func> *ftfunc_list;
503
503
  uint32_t select_n_having_items;
504
504
  uint32_t cond_count;    /* number of arguments of and/or/xor in where/having/on */
505
505
  uint32_t between_count; /* number of between predicates in where/having/on      */
506
 
  uint32_t max_equal_elems; /* maximal number of elements in multiple equalities  */   
 
506
  uint32_t max_equal_elems; /* maximal number of elements in multiple equalities  */
507
507
  /*
508
508
    Number of fields used in select list or where clause of current select
509
509
    and all inner subselects.
516
516
  uint32_t in_sum_expr;
517
517
  uint32_t select_number; /* number of select (used for EXPLAIN) */
518
518
  int nest_level;     /* nesting level of select */
519
 
  Item_sum *inner_sum_func_list; /* list of sum func in nested selects */ 
 
519
  Item_sum *inner_sum_func_list; /* list of sum func in nested selects */
520
520
  uint32_t with_wild; /* item list contain '*' */
521
521
  bool  braces;         /* SELECT ... UNION (SELECT ... ) <- this braces */
522
522
  /* true when having fix field called in processing of this SELECT */
545
545
  int cur_pos_in_select_list;
546
546
 
547
547
  List<udf_func>     udf_list;                  /* udf function calls stack */
548
 
  /* 
 
548
  /*
549
549
    This is a copy of the original JOIN USING list that comes from
550
550
    the parser. The parser :
551
551
      1. Sets the natural_join of the second TableList in the join
572
572
  void init_query();
573
573
  void init_select();
574
574
  st_select_lex_unit* master_unit();
575
 
  st_select_lex_unit* first_inner_unit() 
576
 
  { 
577
 
    return (st_select_lex_unit*) slave; 
 
575
  st_select_lex_unit* first_inner_unit()
 
576
  {
 
577
    return (st_select_lex_unit*) slave;
578
578
  }
579
579
  st_select_lex* outer_select();
580
580
  st_select_lex* next_select() { return (st_select_lex*) next; }
581
 
  st_select_lex* next_select_in_list() 
 
581
  st_select_lex* next_select_in_list()
582
582
  {
583
583
    return (st_select_lex*) link_next;
584
584
  }
657
657
 
658
658
  void set_index_hint_type(enum index_hint_type type, index_clause_map clause);
659
659
 
660
 
  /* 
 
660
  /*
661
661
   Add a index hint to the tagged list of hints. The type and clause of the
662
 
   hint will be the current ones (set by set_index_hint()) 
 
662
   hint will be the current ones (set by set_index_hint())
663
663
  */
664
664
  bool add_index_hint (Session *session, char *str, uint32_t length);
665
665
 
666
666
  /* make a list to hold index hints */
667
667
  void alloc_index_hints (Session *session);
668
668
  /* read and clear the index hints */
669
 
  List<Index_hint>* pop_index_hints(void) 
 
669
  List<Index_hint>* pop_index_hints(void)
670
670
  {
671
671
    List<Index_hint> *hints= index_hints;
672
672
    index_hints= NULL;
675
675
 
676
676
  void clear_index_hints(void) { index_hints= NULL; }
677
677
 
678
 
private:  
 
678
private:
679
679
  /* current index hint kind. used in filling up index_hints */
680
680
  enum index_hint_type current_index_hint_type;
681
681
  index_clause_map current_index_hint_clause;
685
685
typedef class st_select_lex SELECT_LEX;
686
686
 
687
687
inline bool st_select_lex_unit::is_union ()
688
 
689
 
  return first_select()->next_select() && 
 
688
{
 
689
  return first_select()->next_select() &&
690
690
    first_select()->next_select()->linkage == UNION_TYPE;
691
691
}
692
692
 
1260
1260
 
1261
1261
class LEX : public Query_tables_list
1262
1262
{
1263
 
public: 
 
1263
public:
1264
1264
  SELECT_LEX_UNIT unit;                         /* most upper unit */
1265
1265
  SELECT_LEX select_lex;                        /* first SELECT_LEX */
1266
1266
  /* current SELECT_LEX in parsing */
1343
1343
  */
1344
1344
  bool expr_allows_subselect;
1345
1345
  /*
1346
 
    A special command "PARSE_VCOL_EXPR" is defined for the parser 
 
1346
    A special command "PARSE_VCOL_EXPR" is defined for the parser
1347
1347
    to translate an expression statement of a virtual column \
1348
1348
    (stored in the *.frm file as a string) into an Item object.
1349
 
    The following flag is used to prevent other applications to use 
 
1349
    The following flag is used to prevent other applications to use
1350
1350
    this command.
1351
1351
  */
1352
1352
  bool parse_vcol_expr;
1398
1398
  */
1399
1399
  const char *fname_start;
1400
1400
  const char *fname_end;
1401
 
  
 
1401
 
1402
1402
  /**
1403
 
    During name resolution search only in the table list given by 
 
1403
    During name resolution search only in the table list given by
1404
1404
    Name_resolution_context::first_name_resolution_table and
1405
1405
    Name_resolution_context::last_name_resolution_table
1406
 
    (see Item_field::fix_fields()). 
 
1406
    (see Item_field::fix_fields()).
1407
1407
  */
1408
1408
  bool use_only_table_context;
1409
 
  
 
1409
 
1410
1410
  bool escape_used;
1411
1411
  bool is_lex_started; /* If lex_start() did run. For debugging. */
1412
1412
 
1454
1454
  /**
1455
1455
    @brief check if the statement is a single-level join
1456
1456
    @return result of the check
1457
 
      @retval true  The statement doesn't contain subqueries, unions and 
 
1457
      @retval true  The statement doesn't contain subqueries, unions and
1458
1458
                    stored procedure calls.
1459
1459
      @retval false There are subqueries, UNIONs or stored procedure calls.
1460
1460
  */
1461
 
  bool is_single_level_stmt() 
1462
 
  { 
1463
 
    /* 
 
1461
  bool is_single_level_stmt()
 
1462
  {
 
1463
    /*
1464
1464
      This check exploits the fact that the last added to all_select_list is
1465
 
      on its top. So select_lex (as the first added) will be at the tail 
 
1465
      on its top. So select_lex (as the first added) will be at the tail
1466
1466
      of the list.
1467
 
    */ 
 
1467
    */
1468
1468
    if (&select_lex == all_selects_list)
1469
1469
    {
1470
1470
      assert(!all_selects_list->next_select_in_list());