~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/foreign_key.h

  • Committer: Brian Aker
  • Date: 2008-07-28 18:01:38 UTC
  • Revision ID: brian@tangent.org-20080728180138-q2pxlq0qiapvqsdn
Remove YEAR field type

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 
 *
4
 
 *  Copyright (C) 2008 Sun Microsystems
5
 
 *
6
 
 *  This program is free software; you can redistribute it and/or modify
7
 
 *  it under the terms of the GNU General Public License as published by
8
 
 *  the Free Software Foundation; version 2 of the License.
9
 
 *
10
 
 *  This program is distributed in the hope that it will be useful,
11
 
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
 *  GNU General Public License for more details.
14
 
 *
15
 
 *  You should have received a copy of the GNU General Public License
16
 
 *  along with this program; if not, write to the Free Software
17
 
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
 
 */
19
 
 
20
 
 
21
 
#ifndef DRIZZLED_FOREIGN_KEY_H
22
 
#define DRIZZLED_FOREIGN_KEY_H
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
 
class Item;
31
 
class Table_ident;
32
 
 
33
 
namespace drizzled { namespace memory { class Root; } }
34
 
 
35
 
class Foreign_key: public Key 
36
 
{
37
 
public:
38
 
  enum fk_match_opt 
39
 
  {
40
 
    FK_MATCH_UNDEF, 
41
 
    FK_MATCH_FULL, 
42
 
    FK_MATCH_PARTIAL, 
43
 
    FK_MATCH_SIMPLE
44
 
  };
45
 
  enum fk_option 
46
 
  {
47
 
    FK_OPTION_UNDEF, 
48
 
    FK_OPTION_RESTRICT, 
49
 
    FK_OPTION_CASCADE, 
50
 
    FK_OPTION_SET_NULL, 
51
 
    FK_OPTION_NO_ACTION, 
52
 
    FK_OPTION_DEFAULT
53
 
  };
54
 
 
55
 
  Table_ident *ref_table;
56
 
  List<Key_part_spec> ref_columns;
57
 
  uint32_t delete_opt, update_opt, match_opt;
58
 
  Foreign_key(const LEX_STRING &name_arg,
59
 
              List<Key_part_spec> &cols,
60
 
              Table_ident *table,
61
 
              List<Key_part_spec> &ref_cols,
62
 
              uint32_t delete_opt_arg,
63
 
              uint32_t update_opt_arg,
64
 
              uint32_t match_opt_arg) :
65
 
    Key(FOREIGN_KEY, name_arg, &default_key_create_info, 0, cols), ref_table(table),
66
 
    ref_columns(ref_cols),
67
 
    delete_opt(delete_opt_arg),
68
 
    update_opt(update_opt_arg),
69
 
    match_opt(match_opt_arg)
70
 
  { }
71
 
 
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
 
   */
79
 
  Foreign_key(const Foreign_key &rhs, drizzled::memory::Root *mem_root);
80
 
 
81
 
 
82
 
  /**
83
 
   * Used to make a clone of this object for ALTER/CREATE TABLE
84
 
   * 
85
 
   * @see comment for Key_part_spec::clone
86
 
   */
87
 
  virtual Key *clone(drizzled::memory::Root *mem_root) const
88
 
  {
89
 
    return new (mem_root) Foreign_key(*this, mem_root);
90
 
  }
91
 
 
92
 
 
93
 
  /* Used to validate foreign key options */
94
 
  bool validate(List<CreateField> &table_fields);
95
 
};
96
 
 
97
 
#endif /* DRIZZLED_FOREIGN_KEY_H */