~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_lex.h

  • Committer: Brian Aker
  • Date: 2011-02-22 06:12:02 UTC
  • mfrom: (2190.1.6 drizzle-build)
  • Revision ID: brian@tangent.org-20110222061202-k03czxykqy4x9hjs
List update, header fixes, multiple symbols, and David deletes some code.

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
 
4
 *  Copyright (C) 2008 Sun Microsystems, Inc.
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
25
25
*/
26
26
#include <drizzled/message/table.pb.h>
27
27
 
28
 
#include "drizzled/plugin/function.h"
29
 
#include "drizzled/name_resolution_context.h"
30
 
#include "drizzled/item/subselect.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/alter_info.h"
36
 
#include "drizzled/key_part_spec.h"
37
 
#include "drizzled/index_hint.h"
38
 
#include "drizzled/statement.h"
39
 
#include "drizzled/optimizer/explain_plan.h"
 
28
#include <drizzled/plugin/function.h>
 
29
#include <drizzled/name_resolution_context.h>
 
30
#include <drizzled/item/subselect.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/alter_info.h>
 
36
#include <drizzled/key_part_spec.h>
 
37
#include <drizzled/index_hint.h>
 
38
#include <drizzled/statement.h>
 
39
#include <drizzled/optimizer/explain_plan.h>
40
40
 
41
41
#include <bitset>
42
42
#include <string>
44
44
namespace drizzled
45
45
{
46
46
 
 
47
class st_lex_symbol;
47
48
class select_result_interceptor;
48
49
 
49
50
/* YACC and LEX Definitions */
62
63
*/
63
64
 
64
65
#ifdef DRIZZLE_SERVER
65
 
# include <drizzled/set_var.h>
 
66
/* set_var should change to set_var here ... */
 
67
# include <drizzled/sys_var.h>
66
68
# include <drizzled/item/func.h>
67
69
# ifdef DRIZZLE_YACC
68
70
#  define LEX_YYSTYPE void *
248
250
      UNCACHEABLE_EXPLAIN
249
251
      UNCACHEABLE_PREPARE
250
252
  */
251
 
  uint8_t uncacheable;
 
253
  std::bitset<8> uncacheable;
252
254
  enum sub_select_type linkage;
253
255
  bool no_table_names_allowed; /* used for global order by */
254
256
  bool no_error; /* suppress error message (convert it to warnings) */
283
285
  virtual uint32_t get_in_sum_expr();
284
286
  virtual TableList* get_table_list();
285
287
  virtual List<Item>* get_item_list();
286
 
  virtual uint32_t get_table_join_options();
287
288
  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);
 
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);
293
294
  virtual void set_lock_for_tables(thr_lock_type)
294
295
  {}
295
296
 
296
297
  friend class Select_Lex_Unit;
297
 
  friend bool mysql_new_select(LEX *lex, bool move_down);
 
298
  friend bool new_select(LEX *lex, bool move_down);
298
299
private:
299
300
  void fast_exclude();
300
301
};
404
405
class Select_Lex: public Select_Lex_Node
405
406
{
406
407
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
 
407
467
  Name_resolution_context context;
408
468
  char *db;
409
469
  /* An Item representing the WHERE clause */
458
518
  enum_parsing_place parsing_place; /* where we are parsing expression */
459
519
  bool with_sum_func;   /* sum function indicator */
460
520
 
461
 
  uint32_t table_join_options;
462
521
  uint32_t in_sum_expr;
463
522
  uint32_t select_number; /* number of select (used for EXPLAIN) */
464
523
  int8_t nest_level;     /* nesting level of select */
476
535
 
477
536
  /* explicit LIMIT clause was used */
478
537
  bool explicit_limit;
 
538
 
 
539
  /* explicit CROSS JOIN was used */
 
540
  bool is_cross;
 
541
 
479
542
  /*
480
543
    there are subquery in HAVING clause => we can't close tables before
481
544
    query processing end even if we use temporary table
552
615
  TableList* add_table_to_list(Session *session,
553
616
                               Table_ident *table,
554
617
                               LEX_STRING *alias,
555
 
                               uint32_t table_options,
 
618
                               const std::bitset<NUM_OF_TABLE_OPTIONS>& table_options,
556
619
                               thr_lock_type flags= TL_UNLOCK,
557
620
                               List<Index_hint> *hints= 0,
558
621
                               LEX_STRING *option= 0);
563
626
  void add_joined_table(TableList *table);
564
627
  TableList *convert_right_join();
565
628
  List<Item>* get_item_list();
566
 
  uint32_t get_table_join_options();
567
629
  void set_lock_for_tables(thr_lock_type lock_type);
568
630
  inline void init_order()
569
631
  {
572
634
    order_list.next= (unsigned char**) &order_list.first;
573
635
  }
574
636
  /*
575
 
    This method created for reiniting LEX in mysql_admin_table() and can be
 
637
    This method created for reiniting LEX in admin_table() and can be
576
638
    used only if you are going remove all Select_Lex & units except belonger
577
639
    to LEX (LEX::unit & LEX::select, for other purposes there are
578
640
    Select_Lex_Unit::exclude_level & Select_Lex_Unit::exclude_tree
584
646
  bool test_limit();
585
647
 
586
648
  friend void lex_start(Session *session);
587
 
  Select_Lex() : n_sum_items(0), n_child_sum_items(0) {}
588
649
  void make_empty_select()
589
650
  {
590
651
    init_query();
593
654
  bool setup_ref_array(Session *session, uint32_t order_group_num);
594
655
  void print(Session *session, String *str, enum_query_type query_type);
595
656
  static void print_order(String *str,
596
 
                          order_st *order,
 
657
                          Order *order,
597
658
                          enum_query_type query_type);
598
659
  void print_limit(Session *session, String *str, enum_query_type query_type);
599
660
  void fix_prepare_information(Session *session, Item **conds, Item **having_conds);
740
801
 
741
802
} /* namespace drizzled */
742
803
 
743
 
#include "drizzled/lex_input_stream.h"
 
804
#include <drizzled/lex_input_stream.h>
744
805
 
745
806
namespace drizzled
746
807
{
795
856
  List<Lex_Column>    columns;
796
857
  List<Item>          *insert_list,field_list,value_list,update_list;
797
858
  List<List_item>     many_values;
798
 
  List<set_var_base>  var_list;
 
859
  SetVarVector  var_list;
799
860
  /*
800
861
    A stack of name resolution contexts for the query. This stack is used
801
862
    at parse time to set local name resolution contexts for various parts
875
936
     statement in a session. It's re-used by doing lex_end, lex_start
876
937
     in sql_lex.cc
877
938
  */
878
 
  virtual ~LEX()
879
 
  {
880
 
  }
 
939
  virtual ~LEX();
881
940
 
882
941
  TableList *unlink_first_table(bool *link_to_local);
883
942
  void link_first_table_back(TableList *first, bool link_to_local);
901
960
  {
902
961
    return context_stack.head();
903
962
  }
904
 
  /*
905
 
    Restore the LEX and Session in case of a parse error.
906
 
  */
907
 
  static void cleanup_lex_after_parse_error(Session *session);
908
963
 
909
964
  /**
910
965
    @brief check if the statement is a single-level join
940
995
  void reset()
941
996
  {
942
997
    sum_expr_used= false;
 
998
    _exists= false;
943
999
  }
944
1000
 
945
1001
  void setSumExprUsed()
951
1007
  {
952
1008
    return sum_expr_used;
953
1009
  }
 
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
 
954
1042
private: 
955
1043
  bool cacheable;
956
1044
  bool sum_expr_used;
 
1045
  message::Table *_create_table;
 
1046
  message::Table::Field *_create_field;
 
1047
  bool _exists;
957
1048
};
958
1049
 
959
1050
extern void lex_start(Session *session);
960
 
extern void lex_end(LEX *lex);
961
1051
extern void trim_whitespace(const CHARSET_INFO * const cs, LEX_STRING *str);
962
1052
extern bool is_lex_native_function(const LEX_STRING *name);
963
1053
 
 
1054
bool check_for_sql_keyword(drizzled::st_lex_symbol const&);
 
1055
bool check_for_sql_keyword(drizzled::lex_string_t const&);
 
1056
 
964
1057
/**
965
1058
  @} (End of group Semantic_Analysis)
966
1059
*/