~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/foreign_key.h

Reverted 1103

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
 
 *  Copyright (C) 2008 Sun Microsystems, Inc.
 
4
 *  Copyright (C) 2008 Sun Microsystems
5
5
 *
6
6
 *  This program is free software; you can redistribute it and/or modify
7
7
 *  it under the terms of the GNU General Public License as published by
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
 
#include "drizzled/message/table.pb.h"
30
 
 
31
 
namespace drizzled
32
 
{
 
24
#include <drizzled/sql_alloc.h>
 
25
#include <drizzled/key.h>
 
26
#include <drizzled/sql_list.h>
33
27
 
34
28
class Item;
35
29
class Table_ident;
36
30
 
37
 
namespace memory { class Root; }
38
 
 
39
 
void add_foreign_key_to_table_message(
40
 
    message::Table *table_message,
41
 
    const char* fkey_name,
42
 
    List<Key_part_spec> &cols,
43
 
    Table_ident *table,
44
 
    List<Key_part_spec> &ref_cols,
45
 
    message::Table::ForeignKeyConstraint::ForeignKeyOption delete_opt_arg,
46
 
    message::Table::ForeignKeyConstraint::ForeignKeyOption update_opt_arg,
47
 
    message::Table::ForeignKeyConstraint::ForeignKeyMatchOption match_opt_arg);
48
 
 
49
 
 
50
 
class Foreign_key: public Key 
51
 
{
 
31
typedef struct st_mem_root MEM_ROOT;
 
32
 
 
33
class Foreign_key: public Key {
52
34
public:
 
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
  };
 
51
 
53
52
  Table_ident *ref_table;
54
53
  List<Key_part_spec> ref_columns;
55
 
 
56
 
  message::Table::ForeignKeyConstraint::ForeignKeyOption delete_opt;
57
 
  message::Table::ForeignKeyConstraint::ForeignKeyOption update_opt;
58
 
  message::Table::ForeignKeyConstraint::ForeignKeyMatchOption match_opt;
59
 
 
 
54
  uint32_t delete_opt, update_opt, match_opt;
60
55
  Foreign_key(const LEX_STRING &name_arg,
61
56
              List<Key_part_spec> &cols,
62
57
              Table_ident *table,
63
58
              List<Key_part_spec> &ref_cols,
64
 
              message::Table::ForeignKeyConstraint::ForeignKeyOption delete_opt_arg,
65
 
              message::Table::ForeignKeyConstraint::ForeignKeyOption update_opt_arg,
66
 
              message::Table::ForeignKeyConstraint::ForeignKeyMatchOption match_opt_arg) :
 
59
              uint32_t delete_opt_arg,
 
60
              uint32_t update_opt_arg,
 
61
              uint32_t match_opt_arg) :
67
62
    Key(FOREIGN_KEY, name_arg, &default_key_create_info, 0, cols), ref_table(table),
68
63
    ref_columns(ref_cols),
69
64
    delete_opt(delete_opt_arg),
78
73
   * If out of memory, a partial copy is returned and an error is set
79
74
   * in Session.
80
75
   */
81
 
  Foreign_key(const Foreign_key &rhs, memory::Root *mem_root);
 
76
  Foreign_key(const Foreign_key &rhs, MEM_ROOT *mem_root);
82
77
 
83
78
 
84
79
  /**
86
81
   * 
87
82
   * @see comment for Key_part_spec::clone
88
83
   */
89
 
  virtual Key *clone(memory::Root *mem_root) const
 
84
  virtual Key *clone(MEM_ROOT *mem_root) const
90
85
  {
91
86
    return new (mem_root) Foreign_key(*this, mem_root);
92
87
  }
96
91
  bool validate(List<CreateField> &table_fields);
97
92
};
98
93
 
99
 
} /* namespace drizzled */
100
 
 
101
94
#endif /* DRIZZLED_FOREIGN_KEY_H */