~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_lex.h

  • Committer: Brian Aker
  • Date: 2010-09-22 22:25:29 UTC
  • mto: (1791.1.1 drizzle)
  • mto: This revision was merged to the branch mainline in revision 1792.
  • Revision ID: brian@tangent.org-20100922222529-geo4wggmu5ntqa5k
Current boost work (more conversion).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
 
 *  Copyright (C) 2008 Sun Microsystems, Inc.
 
4
 *  Copyright (C) 2008 Sun Microsystems
5
5
 *
6
6
 *  This program is free software; you can redistribute it and/or modify
7
7
 *  it under the terms of the GNU General Public License as published by
44
44
namespace drizzled
45
45
{
46
46
 
47
 
class st_lex_symbol;
48
47
class select_result_interceptor;
49
48
 
50
49
/* YACC and LEX Definitions */
63
62
*/
64
63
 
65
64
#ifdef DRIZZLE_SERVER
66
 
/* set_var should change to set_var here ... */
67
 
# include <drizzled/sys_var.h>
 
65
# include <drizzled/set_var.h>
68
66
# include <drizzled/item/func.h>
69
67
# ifdef DRIZZLE_YACC
70
68
#  define LEX_YYSTYPE void *
250
248
      UNCACHEABLE_EXPLAIN
251
249
      UNCACHEABLE_PREPARE
252
250
  */
253
 
  std::bitset<8> uncacheable;
 
251
  uint8_t uncacheable;
254
252
  enum sub_select_type linkage;
255
253
  bool no_table_names_allowed; /* used for global order by */
256
254
  bool no_error; /* suppress error message (convert it to warnings) */
285
283
  virtual uint32_t get_in_sum_expr();
286
284
  virtual TableList* get_table_list();
287
285
  virtual List<Item>* get_item_list();
 
286
  virtual uint32_t get_table_join_options();
288
287
  virtual TableList *add_table_to_list(Session *session, Table_ident *table,
289
 
                                       LEX_STRING *alias,
290
 
                                       const std::bitset<NUM_OF_TABLE_OPTIONS>& table_options,
291
 
                                       thr_lock_type flags= TL_UNLOCK,
292
 
                                       List<Index_hint> *hints= 0,
293
 
                                       LEX_STRING *option= 0);
 
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);
294
293
  virtual void set_lock_for_tables(thr_lock_type)
295
294
  {}
296
295
 
297
296
  friend class Select_Lex_Unit;
298
 
  friend bool new_select(LEX *lex, bool move_down);
 
297
  friend bool mysql_new_select(LEX *lex, bool move_down);
299
298
private:
300
299
  void fast_exclude();
301
300
};
405
404
class Select_Lex: public Select_Lex_Node
406
405
{
407
406
public:
408
 
 
409
 
  Select_Lex() :
410
 
    context(),
411
 
    db(0),
412
 
    where(0),
413
 
    having(0),
414
 
    cond_value(),
415
 
    having_value(),
416
 
    parent_lex(0),
417
 
    olap(UNSPECIFIED_OLAP_TYPE),
418
 
    table_list(),
419
 
    group_list(),
420
 
    item_list(),
421
 
    interval_list(),
422
 
    is_item_list_lookup(false),
423
 
    join(0),
424
 
    top_join_list(),
425
 
    join_list(0),
426
 
    embedding(0),
427
 
    sj_nests(),
428
 
    leaf_tables(0),
429
 
    type(optimizer::ST_PRIMARY),
430
 
    order_list(),
431
 
    gorder_list(0),
432
 
    select_limit(0),
433
 
    offset_limit(0),
434
 
    ref_pointer_array(0),
435
 
    select_n_having_items(0),
436
 
    cond_count(0),
437
 
    between_count(0),
438
 
    max_equal_elems(0),
439
 
    select_n_where_fields(0),
440
 
    parsing_place(NO_MATTER),
441
 
    with_sum_func(0),
442
 
    in_sum_expr(0),
443
 
    select_number(0),
444
 
    nest_level(0),
445
 
    inner_sum_func_list(0),
446
 
    with_wild(0),
447
 
    braces(0),
448
 
    having_fix_field(0),
449
 
    inner_refs_list(),
450
 
    n_sum_items(0),
451
 
    n_child_sum_items(0),
452
 
    explicit_limit(0),
453
 
    is_cross(false),
454
 
    subquery_in_having(0),
455
 
    is_correlated(0),
456
 
    exclude_from_table_unique_test(0),
457
 
    non_agg_fields(),
458
 
    cur_pos_in_select_list(0),
459
 
    prev_join_using(0),
460
 
    full_group_by_flag(),
461
 
    current_index_hint_type(INDEX_HINT_IGNORE),
462
 
    current_index_hint_clause(),
463
 
    index_hints(0)
464
 
  {
465
 
  }
466
 
 
467
407
  Name_resolution_context context;
468
408
  char *db;
469
409
  /* An Item representing the WHERE clause */
518
458
  enum_parsing_place parsing_place; /* where we are parsing expression */
519
459
  bool with_sum_func;   /* sum function indicator */
520
460
 
 
461
  uint32_t table_join_options;
521
462
  uint32_t in_sum_expr;
522
463
  uint32_t select_number; /* number of select (used for EXPLAIN) */
523
464
  int8_t nest_level;     /* nesting level of select */
535
476
 
536
477
  /* explicit LIMIT clause was used */
537
478
  bool explicit_limit;
538
 
 
539
 
  /* explicit CROSS JOIN was used */
540
 
  bool is_cross;
541
 
 
542
479
  /*
543
480
    there are subquery in HAVING clause => we can't close tables before
544
481
    query processing end even if we use temporary table
615
552
  TableList* add_table_to_list(Session *session,
616
553
                               Table_ident *table,
617
554
                               LEX_STRING *alias,
618
 
                               const std::bitset<NUM_OF_TABLE_OPTIONS>& table_options,
 
555
                               uint32_t table_options,
619
556
                               thr_lock_type flags= TL_UNLOCK,
620
557
                               List<Index_hint> *hints= 0,
621
558
                               LEX_STRING *option= 0);
626
563
  void add_joined_table(TableList *table);
627
564
  TableList *convert_right_join();
628
565
  List<Item>* get_item_list();
 
566
  uint32_t get_table_join_options();
629
567
  void set_lock_for_tables(thr_lock_type lock_type);
630
568
  inline void init_order()
631
569
  {
634
572
    order_list.next= (unsigned char**) &order_list.first;
635
573
  }
636
574
  /*
637
 
    This method created for reiniting LEX in admin_table() and can be
 
575
    This method created for reiniting LEX in mysql_admin_table() and can be
638
576
    used only if you are going remove all Select_Lex & units except belonger
639
577
    to LEX (LEX::unit & LEX::select, for other purposes there are
640
578
    Select_Lex_Unit::exclude_level & Select_Lex_Unit::exclude_tree
646
584
  bool test_limit();
647
585
 
648
586
  friend void lex_start(Session *session);
 
587
  Select_Lex() : n_sum_items(0), n_child_sum_items(0) {}
649
588
  void make_empty_select()
650
589
  {
651
590
    init_query();
654
593
  bool setup_ref_array(Session *session, uint32_t order_group_num);
655
594
  void print(Session *session, String *str, enum_query_type query_type);
656
595
  static void print_order(String *str,
657
 
                          Order *order,
 
596
                          order_st *order,
658
597
                          enum_query_type query_type);
659
598
  void print_limit(Session *session, String *str, enum_query_type query_type);
660
599
  void fix_prepare_information(Session *session, Item **conds, Item **having_conds);
856
795
  List<Lex_Column>    columns;
857
796
  List<Item>          *insert_list,field_list,value_list,update_list;
858
797
  List<List_item>     many_values;
859
 
  SetVarVector  var_list;
 
798
  List<set_var_base>  var_list;
860
799
  /*
861
800
    A stack of name resolution contexts for the query. This stack is used
862
801
    at parse time to set local name resolution contexts for various parts
936
875
     statement in a session. It's re-used by doing lex_end, lex_start
937
876
     in sql_lex.cc
938
877
  */
939
 
  virtual ~LEX();
 
878
  virtual ~LEX()
 
879
  {
 
880
  }
940
881
 
941
882
  TableList *unlink_first_table(bool *link_to_local);
942
883
  void link_first_table_back(TableList *first, bool link_to_local);
943
884
  void first_lists_tables_same();
944
885
 
 
886
  bool only_view_structure();
 
887
  bool need_correct_ident();
 
888
 
945
889
  void cleanup_after_one_table_open();
946
890
 
947
891
  bool push_context(Name_resolution_context *context)
960
904
  {
961
905
    return context_stack.head();
962
906
  }
 
907
  /*
 
908
    Restore the LEX and Session in case of a parse error.
 
909
  */
 
910
  static void cleanup_lex_after_parse_error(Session *session);
963
911
 
964
912
  /**
965
913
    @brief check if the statement is a single-level join
995
943
  void reset()
996
944
  {
997
945
    sum_expr_used= false;
998
 
    _exists= false;
999
946
  }
1000
947
 
1001
948
  void setSumExprUsed()
1007
954
  {
1008
955
    return sum_expr_used;
1009
956
  }
1010
 
 
1011
 
  void start(Session *session);
1012
 
  void end();
1013
 
 
1014
 
  message::Table *table()
1015
 
  {
1016
 
    if (not _create_table)
1017
 
      _create_table= new message::Table;
1018
 
 
1019
 
    return _create_table;
1020
 
  }
1021
 
 
1022
 
  message::Table::Field *field()
1023
 
  {
1024
 
    return _create_field;
1025
 
  }
1026
 
 
1027
 
  void setField(message::Table::Field *arg)
1028
 
  {
1029
 
    _create_field= arg;
1030
 
  }
1031
 
 
1032
 
  void setExists()
1033
 
  {
1034
 
    _exists= true;
1035
 
  }
1036
 
 
1037
 
  bool exists() const
1038
 
  {
1039
 
    return _exists;
1040
 
  }
1041
 
 
1042
957
private: 
1043
958
  bool cacheable;
1044
959
  bool sum_expr_used;
1045
 
  message::Table *_create_table;
1046
 
  message::Table::Field *_create_field;
1047
 
  bool _exists;
1048
960
};
1049
961
 
1050
962
extern void lex_start(Session *session);
 
963
extern void lex_end(LEX *lex);
1051
964
extern void trim_whitespace(const CHARSET_INFO * const cs, LEX_STRING *str);
1052
965
extern bool is_lex_native_function(const LEX_STRING *name);
1053
966
 
1054
 
bool check_for_sql_keyword(drizzled::st_lex_symbol const&);
1055
 
bool check_for_sql_keyword(drizzled::lex_string_t const&);
1056
 
 
1057
967
/**
1058
968
  @} (End of group Semantic_Analysis)
1059
969
*/