~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_lex.h

  • Committer: Brian Aker
  • Date: 2010-11-08 18:54:26 UTC
  • mto: (1921.1.1 trunk)
  • mto: This revision was merged to the branch mainline in revision 1916.
  • Revision ID: brian@tangent.org-20101108185426-fymkf2xnelupf11x
Rename lock methods to be style + well make sense.

Show diffs side-by-side

added added

removed removed

Lines of Context:
62
62
*/
63
63
 
64
64
#ifdef DRIZZLE_SERVER
65
 
# include <drizzled/set_var.h>
 
65
/* set_var should change to set_var here ... */
 
66
# include <drizzled/sys_var.h>
66
67
# include <drizzled/item/func.h>
67
68
# ifdef DRIZZLE_YACC
68
69
#  define LEX_YYSTYPE void *
248
249
      UNCACHEABLE_EXPLAIN
249
250
      UNCACHEABLE_PREPARE
250
251
  */
251
 
  uint8_t uncacheable;
 
252
  std::bitset<8> uncacheable;
252
253
  enum sub_select_type linkage;
253
254
  bool no_table_names_allowed; /* used for global order by */
254
255
  bool no_error; /* suppress error message (convert it to warnings) */
258
259
    return memory::sql_alloc(size);
259
260
  }
260
261
  static void *operator new(size_t size, memory::Root *mem_root)
261
 
  { return (void*) alloc_root(mem_root, (uint32_t) size); }
 
262
  { return (void*) mem_root->alloc_root((uint32_t) size); }
262
263
  static void operator delete(void *, size_t)
263
264
  {  }
264
265
  static void operator delete(void *, memory::Root *)
283
284
  virtual uint32_t get_in_sum_expr();
284
285
  virtual TableList* get_table_list();
285
286
  virtual List<Item>* get_item_list();
286
 
  virtual uint32_t get_table_join_options();
287
287
  virtual TableList *add_table_to_list(Session *session, Table_ident *table,
288
 
                                        LEX_STRING *alias,
289
 
                                        uint32_t table_options,
290
 
                                        thr_lock_type flags= TL_UNLOCK,
291
 
                                        List<Index_hint> *hints= 0,
292
 
                                        LEX_STRING *option= 0);
 
288
                                       LEX_STRING *alias,
 
289
                                       const std::bitset<NUM_OF_TABLE_OPTIONS>& table_options,
 
290
                                       thr_lock_type flags= TL_UNLOCK,
 
291
                                       List<Index_hint> *hints= 0,
 
292
                                       LEX_STRING *option= 0);
293
293
  virtual void set_lock_for_tables(thr_lock_type)
294
294
  {}
295
295
 
305
305
*/
306
306
class Session;
307
307
class select_result;
308
 
class JOIN;
 
308
class Join;
309
309
class select_union;
310
310
class Select_Lex_Unit: public Select_Lex_Node {
311
311
protected:
404
404
class Select_Lex: public Select_Lex_Node
405
405
{
406
406
public:
 
407
 
 
408
  Select_Lex() :
 
409
    context(),
 
410
    db(0),
 
411
    where(0),
 
412
    having(0),
 
413
    cond_value(),
 
414
    having_value(),
 
415
    parent_lex(0),
 
416
    olap(UNSPECIFIED_OLAP_TYPE),
 
417
    table_list(),
 
418
    group_list(),
 
419
    item_list(),
 
420
    interval_list(),
 
421
    is_item_list_lookup(false),
 
422
    join(0),
 
423
    top_join_list(),
 
424
    join_list(0),
 
425
    embedding(0),
 
426
    sj_nests(),
 
427
    leaf_tables(0),
 
428
    type(optimizer::ST_PRIMARY),
 
429
    order_list(),
 
430
    gorder_list(0),
 
431
    select_limit(0),
 
432
    offset_limit(0),
 
433
    ref_pointer_array(0),
 
434
    select_n_having_items(0),
 
435
    cond_count(0),
 
436
    between_count(0),
 
437
    max_equal_elems(0),
 
438
    select_n_where_fields(0),
 
439
    parsing_place(NO_MATTER),
 
440
    with_sum_func(0),
 
441
    in_sum_expr(0),
 
442
    select_number(0),
 
443
    nest_level(0),
 
444
    inner_sum_func_list(0),
 
445
    with_wild(0),
 
446
    braces(0),
 
447
    having_fix_field(0),
 
448
    inner_refs_list(),
 
449
    n_sum_items(0),
 
450
    n_child_sum_items(0),
 
451
    explicit_limit(0),
 
452
    subquery_in_having(0),
 
453
    is_correlated(0),
 
454
    exclude_from_table_unique_test(0),
 
455
    non_agg_fields(),
 
456
    cur_pos_in_select_list(0),
 
457
    prev_join_using(0),
 
458
    full_group_by_flag(),
 
459
    current_index_hint_type(INDEX_HINT_IGNORE),
 
460
    current_index_hint_clause(),
 
461
    index_hints(0)
 
462
  {
 
463
  }
 
464
 
407
465
  Name_resolution_context context;
408
466
  char *db;
409
467
  /* An Item representing the WHERE clause */
422
480
  List<Item> item_list;  /* list of fields & expressions */
423
481
  List<String> interval_list;
424
482
  bool is_item_list_lookup;
425
 
  JOIN *join; /* after JOIN::prepare it is pointer to corresponding JOIN */
 
483
  Join *join; /* after Join::prepare it is pointer to corresponding JOIN */
426
484
  List<TableList> top_join_list; /* join list of the top level          */
427
485
  List<TableList> *join_list;    /* list for the currently parsed join  */
428
486
  TableList *embedding;          /* table embedding to the above list   */
458
516
  enum_parsing_place parsing_place; /* where we are parsing expression */
459
517
  bool with_sum_func;   /* sum function indicator */
460
518
 
461
 
  uint32_t table_join_options;
462
519
  uint32_t in_sum_expr;
463
520
  uint32_t select_number; /* number of select (used for EXPLAIN) */
464
521
  int8_t nest_level;     /* nesting level of select */
514
571
          defined as SUM_FUNC_USED.
515
572
  */
516
573
  std::bitset<2> full_group_by_flag;
 
574
 
517
575
  void init_query();
518
576
  void init_select();
519
577
  Select_Lex_Unit* master_unit();
551
609
  TableList* add_table_to_list(Session *session,
552
610
                               Table_ident *table,
553
611
                               LEX_STRING *alias,
554
 
                               uint32_t table_options,
 
612
                               const std::bitset<NUM_OF_TABLE_OPTIONS>& table_options,
555
613
                               thr_lock_type flags= TL_UNLOCK,
556
614
                               List<Index_hint> *hints= 0,
557
615
                               LEX_STRING *option= 0);
562
620
  void add_joined_table(TableList *table);
563
621
  TableList *convert_right_join();
564
622
  List<Item>* get_item_list();
565
 
  uint32_t get_table_join_options();
566
623
  void set_lock_for_tables(thr_lock_type lock_type);
567
624
  inline void init_order()
568
625
  {
583
640
  bool test_limit();
584
641
 
585
642
  friend void lex_start(Session *session);
586
 
  Select_Lex() : n_sum_items(0), n_child_sum_items(0) {}
587
643
  void make_empty_select()
588
644
  {
589
645
    init_query();
592
648
  bool setup_ref_array(Session *session, uint32_t order_group_num);
593
649
  void print(Session *session, String *str, enum_query_type query_type);
594
650
  static void print_order(String *str,
595
 
                          order_st *order,
 
651
                          Order *order,
596
652
                          enum_query_type query_type);
597
653
  void print_limit(Session *session, String *str, enum_query_type query_type);
598
654
  void fix_prepare_information(Session *session, Item **conds, Item **having_conds);
882
938
  void link_first_table_back(TableList *first, bool link_to_local);
883
939
  void first_lists_tables_same();
884
940
 
885
 
  bool only_view_structure();
886
 
  bool need_correct_ident();
887
 
 
888
941
  void cleanup_after_one_table_open();
889
942
 
890
943
  bool push_context(Name_resolution_context *context)
929
982
    }
930
983
    return false;
931
984
  }
 
985
  bool is_cross; // CROSS keyword was used
 
986
  bool isCacheable()
 
987
  {
 
988
    return cacheable;
 
989
  }
 
990
  void setCacheable(bool val)
 
991
  {
 
992
    cacheable= val;
 
993
  }
 
994
 
 
995
  void reset()
 
996
  {
 
997
    sum_expr_used= false;
 
998
  }
 
999
 
 
1000
  void setSumExprUsed()
 
1001
  {
 
1002
    sum_expr_used= true;
 
1003
  }
 
1004
 
 
1005
  bool isSumExprUsed()
 
1006
  {
 
1007
    return sum_expr_used;
 
1008
  }
 
1009
 
 
1010
  void start(Session *session);
 
1011
  void end();
 
1012
 
 
1013
private: 
 
1014
  bool cacheable;
 
1015
  bool sum_expr_used;
932
1016
};
933
1017
 
934
1018
extern void lex_start(Session *session);
935
 
extern void lex_end(LEX *lex);
936
1019
extern void trim_whitespace(const CHARSET_INFO * const cs, LEX_STRING *str);
937
1020
extern bool is_lex_native_function(const LEX_STRING *name);
938
1021