~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/foreign_key.h

  • Committer: Brian Aker
  • Date: 2009-03-20 18:24:23 UTC
  • mfrom: (934.2.23 small-cleanups)
  • Revision ID: brian@tangent.org-20090320182423-81kb4a70bfv73c26
Merge from Jay

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
#include <drizzled/sql_list.h>
27
27
 
28
28
class Item;
 
29
class Table_ident;
 
30
 
29
31
typedef struct st_mem_root MEM_ROOT;
30
32
 
31
33
class Foreign_key: public Key {
32
34
public:
33
 
  enum fk_match_opt { FK_MATCH_UNDEF, FK_MATCH_FULL,
34
 
                      FK_MATCH_PARTIAL, FK_MATCH_SIMPLE};
35
 
  enum fk_option { FK_OPTION_UNDEF, FK_OPTION_RESTRICT, FK_OPTION_CASCADE,
36
 
                   FK_OPTION_SET_NULL, FK_OPTION_NO_ACTION, FK_OPTION_DEFAULT};
 
35
  enum fk_match_opt 
 
36
  {
 
37
    FK_MATCH_UNDEF
 
38
  , FK_MATCH_FULL
 
39
  , FK_MATCH_PARTIAL
 
40
  , FK_MATCH_SIMPLE
 
41
  };
 
42
  enum fk_option 
 
43
  {
 
44
    FK_OPTION_UNDEF
 
45
  , FK_OPTION_RESTRICT
 
46
  , FK_OPTION_CASCADE
 
47
  , FK_OPTION_SET_NULL
 
48
  , FK_OPTION_NO_ACTION
 
49
  , FK_OPTION_DEFAULT
 
50
  };
37
51
 
38
52
  Table_ident *ref_table;
39
53
  List<Key_part_spec> ref_columns;
40
54
  uint32_t delete_opt, update_opt, match_opt;
41
 
Foreign_key(const LEX_STRING &name_arg, List<Key_part_spec> &cols,
42
 
            Table_ident *table,   List<Key_part_spec> &ref_cols,
43
 
            uint32_t delete_opt_arg, uint32_t update_opt_arg,
44
 
            uint32_t match_opt_arg)
45
 
  :Key(FOREIGN_KEY, name_arg, &default_key_create_info, 0, cols),
46
 
    ref_table(table), ref_columns(ref_cols),
47
 
    delete_opt(delete_opt_arg), update_opt(update_opt_arg),
48
 
    match_opt(match_opt_arg)
49
 
    {}
 
55
  Foreign_key(const LEX_STRING &name_arg
 
56
            , List<Key_part_spec> &cols
 
57
            , Table_ident *table
 
58
            , List<Key_part_spec> &ref_cols
 
59
            , uint32_t delete_opt_arg
 
60
            , uint32_t update_opt_arg
 
61
            , uint32_t match_opt_arg)
 
62
  :Key(FOREIGN_KEY
 
63
     , name_arg
 
64
     , &default_key_create_info
 
65
     , 0
 
66
     , cols)
 
67
   , ref_table(table)
 
68
   , ref_columns(ref_cols)
 
69
   , delete_opt(delete_opt_arg)
 
70
   , update_opt(update_opt_arg)
 
71
   , match_opt(match_opt_arg)
 
72
  {}
 
73
  /**
 
74
   * Constructs an (almost) deep copy of this foreign key. Only those
 
75
   * elements that are known to never change are not copied.
 
76
   * If out of memory, a partial copy is returned and an error is set
 
77
   * in Session.
 
78
   */
50
79
  Foreign_key(const Foreign_key &rhs, MEM_ROOT *mem_root);
51
80
  /**
52
 
     Used to make a clone of this object for ALTER/CREATE TABLE
53
 
     @sa comment for Key_part_spec::clone
54
 
  */
 
81
   * Used to make a clone of this object for ALTER/CREATE TABLE
 
82
   * 
 
83
   * @see comment for Key_part_spec::clone
 
84
   */
55
85
  virtual Key *clone(MEM_ROOT *mem_root) const
56
 
  { return new (mem_root) Foreign_key(*this, mem_root); }
 
86
  {
 
87
    return new (mem_root) Foreign_key(*this, mem_root);
 
88
  }
57
89
  /* Used to validate foreign key options */
58
90
  bool validate(List<Create_field> &table_fields);
59
91
};