~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/foreign_key.h

  • Committer: Monty Taylor
  • Date: 2008-11-18 22:12:56 UTC
  • mto: (589.1.3 devel)
  • mto: This revision was merged to the branch mainline in revision 589.
  • Revision ID: monty@inaugust.com-20081118221256-ap2kmj073pdw7uap
The mega-patch from hell. Renamed sql_class to session (since that's what it is) and removed it and field and table from common_includes. 

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/sql_alloc.h>
 
25
#include <drizzled/key.h>
 
26
#include <drizzled/sql_list.h>
 
27
 
 
28
class Item;
 
29
typedef struct st_mem_root MEM_ROOT;
 
30
 
 
31
class Foreign_key: public Key {
 
32
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};
 
37
 
 
38
  Table_ident *ref_table;
 
39
  List<Key_part_spec> ref_columns;
 
40
  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
    {}
 
50
  Foreign_key(const Foreign_key &rhs, MEM_ROOT *mem_root);
 
51
  /**
 
52
     Used to make a clone of this object for ALTER/CREATE TABLE
 
53
     @sa comment for Key_part_spec::clone
 
54
  */
 
55
  virtual Key *clone(MEM_ROOT *mem_root) const
 
56
  { return new (mem_root) Foreign_key(*this, mem_root); }
 
57
  /* Used to validate foreign key options */
 
58
  bool validate(List<Create_field> &table_fields);
 
59
};
 
60
 
 
61
#endif /* DRIZZLED_FOREIGN_KEY_H */