~drizzle-trunk/drizzle/development

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
/*
  Message format for tables.
*/
package drizzled.message;
option optimize_for = SPEED;

option java_package = "org.drizzle.messages";
option java_outer_classname = "TableMessage";

import "engine.proto";

message Table {

  enum TableType {
    STANDARD = 0;
    TEMPORARY = 1;
    INTERNAL = 2;
    FUNCTION = 3;
  }

  message TableOptions {
    optional bool has_user_set_auto_increment_value = 1;
    optional string collation = 2;
    optional uint32 collation_id = 3;
    optional string data_file_name = 5;
    optional string index_file_name = 6;
    optional uint64 max_rows = 7;
    optional uint64 min_rows = 8;
    optional uint64 auto_increment_value = 9;
    optional uint32 avg_row_length = 11;
    optional uint32 block_size = 13;
    optional string comment = 14;
    optional bool pack_record = 16;
    optional bool checksum = 17;
    optional bool page_checksum = 18;
    optional bool delay_key_write = 19;
  }

  message ForeignKeyConstraint {
    optional string name = 1;
    repeated string column_names = 2;
    required string references_table_name = 3;
    repeated string references_columns = 4;

    enum ForeignKeyMatchOption {
      MATCH_UNDEFINED = 0;
      MATCH_FULL = 1;
      MATCH_PARTIAL = 2;
      MATCH_SIMPLE = 3;
    }
    required ForeignKeyMatchOption match = 5;

    enum ForeignKeyOption {
      OPTION_UNDEF = 0;
      OPTION_RESTRICT = 1;
      OPTION_CASCADE = 2;
      OPTION_SET_NULL = 3;
      OPTION_NO_ACTION = 4;
      OPTION_SET_DEFAULT = 5;
    }

    required ForeignKeyOption update_option = 6 [ default = OPTION_UNDEF ];
    required ForeignKeyOption delete_option = 7 [ default = OPTION_UNDEF ];
  }

  message Field {

    enum FieldType {
      DOUBLE = 0;
      VARCHAR = 1;
      BLOB = 2;
      ENUM = 3;
      INTEGER = 4;
      BIGINT = 5;
      DECIMAL = 6;
      DATE = 7;
      TIMESTAMP = 9;
      DATETIME = 10;
    }

    message FieldOptions {
      optional string default_value = 1;
      optional string update_value = 2;
      optional bool default_null = 3 [default = false];
      optional bytes default_bin_value = 4;
      optional string default_expression = 5;
      optional string update_expression = 6;
    }

    message FieldConstraints {
      required bool is_nullable = 1 [default = true];
      optional bool is_unsigned = 2 [default = false];
      repeated string expression = 16; /* Reserve 0-15 for frequenty accessed attributes */
    }

    message NumericFieldOptions {
      optional bool is_autoincrement = 1 [default = false];
      optional uint32 scale = 2;
      optional uint32 precision = 3;
    }

    message StringFieldOptions {
      optional bool is_fixed_width = 1 [default = false];
      optional uint32 length = 2;
      optional uint32 collation_id = 3;
      optional string collation = 4;
    }

    message EnumerationValues {
      optional uint32 collation_id = 2;
      optional string collation = 3;
      repeated string field_value = 4;
    }

    required string name = 1;
    required FieldType type = 2;
    optional FieldOptions options = 4;
    optional FieldConstraints constraints = 5;
    optional NumericFieldOptions numeric_options = 6;
    optional StringFieldOptions string_options = 7;

    optional string comment = 16; /* Reserve 0-15 for frequently accessed attributes */
    optional EnumerationValues enumeration_values = 17;
  }

  message Index {

    enum IndexType {
    /* Kept in sync with enum ha_key_alg if only for stewart sanity. */
      UNKNOWN_INDEX = 0;
      BTREE = 1;
      RTREE = 2;
      HASH  = 3;
      FULLTEXT = 4;
    }

    message IndexPart {
      required uint32 fieldnr = 1;
      optional uint32 compare_length = 2;
      optional bool in_reverse_order = 3 [default = false];
    }

    message Options {
      optional bool pack_key = 1;
      optional bool binary_pack_key = 2;
      optional bool var_length_key = 3;
      optional bool null_part_key = 4;
      optional uint32 key_block_size = 5;
      optional bool has_partial_segments =6;
      optional bool auto_generated_key = 7;
    }      

    required string name = 1;
    required bool is_primary = 2;
    required bool is_unique = 3;
    required IndexType type = 4 [default = UNKNOWN_INDEX];
    required uint32 key_length = 5;
    repeated IndexPart index_part = 6;
    optional Options options= 7;
    optional string comment = 8;
  }

  required string name = 1;
  required string schema = 6;
  required TableType type = 5;
  required Engine engine = 2;
  repeated Field field = 3;
  repeated Index indexes = 4;

  repeated ForeignKeyConstraint fk_constraint = 8;
  optional TableOptions options = 9;
  required uint64 creation_timestamp= 11 [default = 0];
  required uint64 update_timestamp= 12 [default = 0];
  optional string catalog = 13;
  optional string uuid = 14;
  /*
    A version value of 0, means that it was never set.
    */
  optional uint64 version = 15;
}

message AlterTable {
  repeated Table.Field added_field = 1;
}