~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/foreign_key.h

  • Committer: Monty Taylor
  • Date: 2009-04-14 19:16:51 UTC
  • mto: (997.2.5 mordred)
  • mto: This revision was merged to the branch mainline in revision 994.
  • Revision ID: mordred@inaugust.com-20090414191651-ltbww6hpqks8k7qk
Clarified instructions in README.

Show diffs side-by-side

added added

removed removed

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