~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_lex.h

  • Committer: Padraig O'Sullivan
  • Date: 2009-09-17 00:08:20 UTC
  • mto: (1126.9.3 captain-20090915-01)
  • mto: This revision was merged to the branch mainline in revision 1133.
  • Revision ID: osullivan.padraig@gmail.com-20090917000820-urd6p46qngi1okjp
Updated calls to some dtrace probes to cast the parameter to const char *
appropriately. Also, removed the additional variable in places that I was
using.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
*/
26
26
#include <drizzled/message/table.pb.h>
27
27
 
28
 
#include "drizzled/plugin/function.h"
 
28
#include "drizzled/slot/function.h"
29
29
#include "drizzled/name_resolution_context.h"
30
30
#include "drizzled/item/subselect.h"
 
31
#include "drizzled/item/param.h"
 
32
#include "drizzled/item/outer_ref.h"
31
33
#include "drizzled/table_list.h"
32
34
#include "drizzled/function/math/real.h"
33
35
#include "drizzled/alter_drop.h"
34
36
#include "drizzled/alter_column.h"
35
 
#include "drizzled/alter_info.h"
36
 
#include "drizzled/key_part_spec.h"
 
37
#include "drizzled/key.h"
 
38
#include "drizzled/foreign_key.h"
 
39
#include "drizzled/item/param.h"
37
40
#include "drizzled/index_hint.h"
38
41
#include "drizzled/statement.h"
39
 
#include "drizzled/optimizer/explain_plan.h"
40
42
 
41
43
#include <bitset>
42
 
#include <string>
43
 
 
44
 
namespace drizzled
45
 
{
46
44
 
47
45
class select_result_interceptor;
48
46
 
54
52
class Lex_Column;
55
53
class Item_outer_ref;
56
54
 
57
 
} /* namespace drizzled */
58
 
 
59
55
/*
60
56
  The following hack is needed because mysql_yacc.cc does not define
61
57
  YYSTYPE before including this file
68
64
#  define LEX_YYSTYPE void *
69
65
# else
70
66
#  if defined(DRIZZLE_LEX)
71
 
#   include <drizzled/foreign_key.h>
72
67
#   include <drizzled/lex_symbol.h>
73
68
#   include <drizzled/sql_yacc.h>
74
69
#   define LEX_YYSTYPE YYSTYPE *
87
82
#define DERIVED_NONE    0
88
83
#define DERIVED_SUBQUERY        1
89
84
 
90
 
namespace drizzled
91
 
{
92
 
 
93
85
typedef List<Item> List_item;
94
86
 
95
87
enum sub_select_type
110
102
  ROLLUP_TYPE
111
103
};
112
104
 
 
105
enum tablespace_op_type
 
106
{
 
107
  NO_TABLESPACE_OP,
 
108
  DISCARD_TABLESPACE,
 
109
  IMPORT_TABLESPACE
 
110
};
 
111
 
113
112
/*
114
113
  The state of the lex parsing for selects
115
114
 
255
254
 
256
255
  static void *operator new(size_t size)
257
256
  {
258
 
    return memory::sql_alloc(size);
 
257
    return sql_alloc(size);
259
258
  }
260
 
  static void *operator new(size_t size, memory::Root *mem_root)
 
259
  static void *operator new(size_t size, MEM_ROOT *mem_root)
261
260
  { return (void*) alloc_root(mem_root, (uint32_t) size); }
262
261
  static void operator delete(void *, size_t)
263
 
  {  }
264
 
  static void operator delete(void *, memory::Root *)
 
262
  { TRASH(ptr, size); }
 
263
  static void operator delete(void *, MEM_ROOT *)
265
264
  {}
266
265
  Select_Lex_Node(): linkage(UNSPECIFIED_TYPE) {}
267
266
  virtual ~Select_Lex_Node() {}
433
432
    by TableList::next_leaf, so leaf_tables points to the left-most leaf.
434
433
  */
435
434
  TableList *leaf_tables;
436
 
  enum drizzled::optimizer::select_type type; /* type of select for EXPLAIN */
 
435
  const char *type;               /* type of select for EXPLAIN          */
437
436
 
438
437
  SQL_LIST order_list;                /* ORDER clause */
439
438
  SQL_LIST *gorder_list;
641
640
    first_select()->next_select()->linkage == UNION_TYPE;
642
641
}
643
642
 
 
643
enum enum_alter_info_flags
 
644
{
 
645
  ALTER_ADD_COLUMN= 0,
 
646
  ALTER_DROP_COLUMN,
 
647
  ALTER_CHANGE_COLUMN,
 
648
  ALTER_COLUMN_STORAGE,
 
649
  ALTER_COLUMN_FORMAT,
 
650
  ALTER_COLUMN_ORDER,
 
651
  ALTER_ADD_INDEX,
 
652
  ALTER_DROP_INDEX,
 
653
  ALTER_RENAME,
 
654
  ALTER_ORDER,
 
655
  ALTER_OPTIONS,
 
656
  ALTER_COLUMN_DEFAULT,
 
657
  ALTER_KEYS_ONOFF,
 
658
  ALTER_STORAGE,
 
659
  ALTER_ROW_FORMAT,
 
660
  ALTER_CONVERT,
 
661
  ALTER_FORCE,
 
662
  ALTER_RECREATE,
 
663
  ALTER_TABLE_REORG,
 
664
  ALTER_FOREIGN_KEY
 
665
};
 
666
 
 
667
/**
 
668
  @brief Parsing data for CREATE or ALTER Table.
 
669
 
 
670
  This structure contains a list of columns or indexes to be created,
 
671
  altered or dropped.
 
672
*/
 
673
 
 
674
class Alter_info
 
675
{
 
676
public:
 
677
  List<Alter_drop> drop_list;
 
678
  List<Alter_column> alter_list;
 
679
  List<Key> key_list;
 
680
  List<CreateField> create_list;
 
681
  std::bitset<32> flags;
 
682
  enum enum_enable_or_disable keys_onoff;
 
683
  enum tablespace_op_type tablespace_op;
 
684
  uint32_t no_parts;
 
685
  enum ha_build_method build_method;
 
686
  CreateField *datetime_field;
 
687
  bool error_if_not_empty;
 
688
 
 
689
  Alter_info() :
 
690
    flags(),
 
691
    keys_onoff(LEAVE_AS_IS),
 
692
    tablespace_op(NO_TABLESPACE_OP),
 
693
    no_parts(0),
 
694
    build_method(HA_BUILD_DEFAULT),
 
695
    datetime_field(NULL),
 
696
    error_if_not_empty(false)
 
697
  {}
 
698
 
 
699
  void reset()
 
700
  {
 
701
    drop_list.empty();
 
702
    alter_list.empty();
 
703
    key_list.empty();
 
704
    create_list.empty();
 
705
    flags.reset();
 
706
    keys_onoff= LEAVE_AS_IS;
 
707
    tablespace_op= NO_TABLESPACE_OP;
 
708
    no_parts= 0;
 
709
    build_method= HA_BUILD_DEFAULT;
 
710
    datetime_field= 0;
 
711
    error_if_not_empty= false;
 
712
  }
 
713
  Alter_info(const Alter_info &rhs, MEM_ROOT *mem_root);
 
714
private:
 
715
  Alter_info &operator=(const Alter_info &rhs); // not implemented
 
716
  Alter_info(const Alter_info &rhs);            // not implemented
 
717
};
 
718
 
644
719
enum xa_option_words
645
720
{
646
721
  XA_NONE
683
758
    of Query_tables_list instances which are used as backup storage.
684
759
  */
685
760
  Query_tables_list() {}
686
 
  virtual ~Query_tables_list() {}
 
761
  ~Query_tables_list() {}
687
762
 
688
763
  /* Initializes (or resets) Query_tables_list object for "real" use. */
689
764
  void reset_query_tables_list(bool init);
737
812
  DISCARD_COMMENT
738
813
};
739
814
 
740
 
} /* namespace drizzled */
741
 
 
742
815
#include "drizzled/lex_input_stream.h"
743
816
 
744
 
namespace drizzled
745
 
{
746
 
 
747
817
/* The state of the lex parsing. This is saved in the Session struct */
748
818
class LEX : public Query_tables_list
749
819
{
759
829
  char *length;
760
830
  /* This is the decimal precision in DECIMAL(S,P) notation */
761
831
  char *dec;
 
832
  /* The text in a CHANGE COLUMN clause in ALTER TABLE */
 
833
  char *change;
762
834
  
763
835
  /**
764
836
   * This is used kind of like the "ident" member variable below, as 
772
844
  file_exchange *exchange;
773
845
  select_result *result;
774
846
 
 
847
  /* An item representing the DEFAULT clause in CREATE/ALTER TABLE */
 
848
  Item *default_value;
 
849
  /* An item representing the ON UPDATE clause in CREATE/ALTER TABLE */
 
850
  Item *on_update_value;
 
851
  /* Not really sure what exactly goes in here... Comment text at beginning of statement? */
 
852
  LEX_STRING comment;
 
853
 
775
854
  /**
776
855
   * This is current used to store the name of a named key cache
777
856
   * or a named savepoint.  It should probably be refactored out into
795
874
  List<Item>          *insert_list,field_list,value_list,update_list;
796
875
  List<List_item>     many_values;
797
876
  List<set_var_base>  var_list;
 
877
  List<Item_param>    param_list;
798
878
  /*
799
879
    A stack of name resolution contexts for the query. This stack is used
800
880
    at parse time to set local name resolution contexts for various parts
814
894
  SQL_LIST save_list;
815
895
  CreateField *last_field;
816
896
  Item_sum *in_sum_func;
817
 
  plugin::Function *udf;
 
897
  drizzled::plugin::Function *udf;
 
898
  HA_CHECK_OPT check_opt;                       // check/repair options
 
899
  HA_CREATE_INFO create_info;
 
900
  drizzled::message::Table *create_table_proto;
 
901
  StorageEngine *show_engine;
 
902
  KEY_CREATE_INFO key_create_info;
818
903
  uint32_t type;
819
904
  /*
820
905
    This variable is used in post-parse stage to declare that sum-functions,
827
912
  */
828
913
  nesting_map allow_sum_func;
829
914
  enum_sql_command sql_command;
830
 
  statement::Statement *statement;
 
915
  drizzled::statement::Statement *statement;
831
916
  /*
832
917
    Usually `expr` rule of yacc is quite reused but some commands better
833
918
    not support subqueries which comes standard with this rule, like
838
923
 
839
924
  thr_lock_type lock_option;
840
925
  enum enum_duplicates duplicates;
 
926
  enum enum_tx_isolation tx_isolation;
 
927
  enum enum_ha_read_modes ha_read_mode;
841
928
  union {
842
929
    enum ha_rkey_function ha_rkey_mode;
843
930
    enum xa_option_words xa_opt;
844
931
  };
845
 
  sql_var_t option_type;
 
932
  enum enum_var_type option_type;
846
933
 
 
934
  enum column_format_type column_format;
 
935
  enum Foreign_key::fk_match_opt fk_match_option;
 
936
  enum Foreign_key::fk_option fk_update_opt;
 
937
  enum Foreign_key::fk_option fk_delete_opt;
 
938
  /* Options used in START TRANSACTION statement */
 
939
  uint32_t start_transaction_opt;
847
940
  int nest_level;
848
941
  uint8_t describe;
849
942
  /*
852
945
  */
853
946
  uint8_t derived_tables;
854
947
 
 
948
  /* True if "IF EXISTS" used in DROP statement */
 
949
  bool drop_if_exists;
 
950
  /* True if "TEMPORARY" used in DROP/CREATE statement */
 
951
  bool drop_temporary;
 
952
  bool one_shot_set;
 
953
 
 
954
  /* Only true when FULL symbol is found (e.g. SHOW FULL PROCESSLIST) */
 
955
  bool verbose;
 
956
  
 
957
  /* Was the CHAIN option using in COMMIT/ROLLBACK? */
 
958
  bool tx_chain;
 
959
  /* Was the RELEASE option used in COMMIT/ROLLBACK? */
 
960
  bool tx_release;
855
961
  /* Was the IGNORE symbol found in statement */
856
962
  bool ignore;
 
963
  Alter_info alter_info;
 
964
 
 
965
  /*
 
966
    Pointers to part of LOAD DATA statement that should be rewritten
 
967
    during replication ("LOCAL 'filename' REPLACE INTO" part).
 
968
  */
 
969
  const char *fname_start;
 
970
  const char *fname_end;
857
971
 
858
972
  /**
859
973
    During name resolution search only in the table list given by
940
1054
  @} (End of group Semantic_Analysis)
941
1055
*/
942
1056
 
943
 
} /* namespace drizzled */
944
 
 
945
1057
#endif /* DRIZZLE_SERVER */
946
1058
#endif /* DRIZZLED_SQL_LEX_H */