~drizzle-trunk/drizzle/development

1502.1.31 by Brian Aker
Merge engine options for schema/table.
1
/*
2
  Message format for tables.
3
*/
988.1.1 by Jay Pipes
Changes libserialize to libdrizzledmessage per ML discussion. All GPB messages are now in the drizzled::message namespace.
4
package drizzled.message;
919.2.5 by Monty Taylor
Changed protos to be optmized for speed. INCOMPATIBLE CHANGE - .dfe files created prior to this will no longer work.
5
option optimize_for = SPEED;
323 by Brian Aker
Updated proto file for table (not FRM work).
6
1502.1.31 by Brian Aker
Merge engine options for schema/table.
7
import "engine.proto";
8
323 by Brian Aker
Updated proto file for table (not FRM work).
9
message Table {
352.1.1 by Jay Pipes
New table definition and updated reader and writer test programs
10
11
  enum TableType {
12
    STANDARD = 0;
13
    TEMPORARY = 1;
1211.1.1 by Brian Aker
Updating with my change to to DECIMAL from NEWDECIMAL and Stewart's update
14
    INTERNAL = 2;
1273.13.11 by Brian Aker
First pass through tables.
15
    FUNCTION = 3;
352.1.1 by Jay Pipes
New table definition and updated reader and writer test programs
16
  }
17
18
  message TableOptions {
1638.10.116 by Stewart Smith
only display AUTO_INCREMENT value if explicitly set by user (and preserve across ALTER TABLE).
19
    optional bool has_user_set_auto_increment_value = 1;
1638.1.5 by Stewart Smith
explicit collation in table proto (from review)
20
    optional string collation = 2;
21
    optional uint32 collation_id = 3;
584.2.2 by Stewart Smith
Brian's table(_reader|_writer|.proto) fixes
22
    optional string data_file_name = 5;
23
    optional string index_file_name = 6;
24
    optional uint64 max_rows = 7;
25
    optional uint64 min_rows = 8;
26
    optional uint64 auto_increment_value = 9;
27
    optional uint32 avg_row_length = 11;
820.1.8 by Stewart Smith
start reading table definition from proto instead of FRM.
28
    optional uint32 block_size = 13;
29
    optional string comment = 14;
869.1.24 by Stewart Smith
Generate all the info needed to get a record size on proto read instead of FRM create time.
30
    optional bool pack_record = 16;
31
    optional bool checksum = 17;
32
    optional bool page_checksum = 18;
33
    optional bool delay_key_write = 19;
352.1.1 by Jay Pipes
New table definition and updated reader and writer test programs
34
  }
35
36
  message ForeignKeyConstraint {
1638.9.1 by Stewart Smith
Add FOREIGN KEY constraints to the table proto. set them, add code in statement_transform for them, which means we now get foreign keys in the transaction_log. We don't go changing any existing code manipulating foreign key data structures and instead just create our own (minimal changes FTW).
37
    optional string name = 1;
38
    repeated string column_names = 2;
39
    required string references_table_name = 3;
40
    repeated string references_columns = 4;
41
42
    enum ForeignKeyMatchOption {
43
      MATCH_UNDEFINED = 0;
44
      MATCH_FULL = 1;
45
      MATCH_PARTIAL = 2;
46
      MATCH_SIMPLE = 3;
47
    }
48
    required ForeignKeyMatchOption match = 5;
49
50
    enum ForeignKeyOption {
51
      OPTION_UNDEF = 0;
52
      OPTION_RESTRICT = 1;
53
      OPTION_CASCADE = 2;
54
      OPTION_SET_NULL = 3;
55
      OPTION_NO_ACTION = 4;
56
      OPTION_DEFAULT = 5;
57
    }
58
59
    required ForeignKeyOption update_option = 6 [ default = OPTION_UNDEF ];
60
    required ForeignKeyOption delete_option = 7 [ default = OPTION_UNDEF ];
352.1.1 by Jay Pipes
New table definition and updated reader and writer test programs
61
  }
62
323 by Brian Aker
Updated proto file for table (not FRM work).
63
  message Field {
352.1.1 by Jay Pipes
New table definition and updated reader and writer test programs
64
65
    enum FieldType {
66
      DOUBLE = 0;
67
      VARCHAR = 1;
896.3.6 by Stewart Smith
Read Fields out of proto instead of FRM.
68
      BLOB = 2;
69
      ENUM = 3;
70
      INTEGER = 4;
71
      BIGINT = 5;
72
      DECIMAL = 6;
73
      DATE = 7;
74
      TIMESTAMP = 9;
75
      DATETIME = 10;
869.1.10 by Stewart Smith
Add some missing things to field storage in proto
76
    }
77
352.1.2 by Jay Pipes
Working reader and writer for table.proto definitions now
78
    message FieldOptions {
584.2.2 by Stewart Smith
Brian's table(_reader|_writer|.proto) fixes
79
      optional string default_value = 1;
869.1.10 by Stewart Smith
Add some missing things to field storage in proto
80
      optional string update_value = 2;
896.3.3 by Stewart Smith
Start generating a record buffer with default values in proto read path instead of FRM write path.
81
      optional bool default_null = 3 [default = false];
896.3.4 by Stewart Smith
Create default_values record from proto instead of reading from FRM. assert if different to FRM.
82
      optional bytes default_bin_value = 4;
1638.3.2 by Stewart Smith
use default_expression and update_expression instead of default_value and update_value in the table proto for NOW()
83
      optional string default_expression = 5;
84
      optional string update_expression = 6;
352.1.2 by Jay Pipes
Working reader and writer for table.proto definitions now
85
    }
86
87
    message FieldConstraints {
1215.1.2 by stewart at flamingspork
[patch 02/17] field NULL | NOT NULL in proto in parser. Only for CREATE TABLE. Change default in proto to reflect default in SQL.
88
      required bool is_nullable = 1 [default = true];
352.1.2 by Jay Pipes
Working reader and writer for table.proto definitions now
89
      optional bool is_unsigned = 2 [default = false];
90
      repeated string expression = 16; /* Reserve 0-15 for frequenty accessed attributes */
91
    }
92
93
    message NumericFieldOptions {
94
      optional bool is_autoincrement = 1 [default = false];
1211.1.1 by Brian Aker
Updating with my change to to DECIMAL from NEWDECIMAL and Stewart's update
95
      optional uint32 scale = 2;
96
      optional uint32 precision = 3;
352.1.2 by Jay Pipes
Working reader and writer for table.proto definitions now
97
    }
98
99
    message StringFieldOptions {
100
      optional bool is_fixed_width = 1 [default = false];
1211.1.1 by Brian Aker
Updating with my change to to DECIMAL from NEWDECIMAL and Stewart's update
101
      optional uint32 length = 2;
584.2.2 by Stewart Smith
Brian's table(_reader|_writer|.proto) fixes
102
      optional uint32 collation_id = 3;
352.1.2 by Jay Pipes
Working reader and writer for table.proto definitions now
103
      optional string collation = 4;
104
    }
105
1396 by Brian Aker
Simple rename.
106
    message EnumerationValues {
896.3.6 by Stewart Smith
Read Fields out of proto instead of FRM.
107
      optional uint32 collation_id = 2;
108
      optional string collation = 3;
1211.1.1 by Brian Aker
Updating with my change to to DECIMAL from NEWDECIMAL and Stewart's update
109
      repeated string field_value = 4;
352.1.2 by Jay Pipes
Working reader and writer for table.proto definitions now
110
    }
111
323 by Brian Aker
Updated proto file for table (not FRM work).
112
    required string name = 1;
113
    required FieldType type = 2;
869.1.10 by Stewart Smith
Add some missing things to field storage in proto
114
    optional FieldOptions options = 4;
115
    optional FieldConstraints constraints = 5;
116
    optional NumericFieldOptions numeric_options = 6;
117
    optional StringFieldOptions string_options = 7;
118
352.1.1 by Jay Pipes
New table definition and updated reader and writer test programs
119
    optional string comment = 16; /* Reserve 0-15 for frequently accessed attributes */
1396 by Brian Aker
Simple rename.
120
    optional EnumerationValues enumeration_values = 17;
352.1.1 by Jay Pipes
New table definition and updated reader and writer test programs
121
  }
122
323 by Brian Aker
Updated proto file for table (not FRM work).
123
  message Index {
352.1.1 by Jay Pipes
New table definition and updated reader and writer test programs
124
125
    enum IndexType {
820.1.15 by Stewart Smith
Read (nearly the whole) index information (key and key parts) out of the proto, not FRM.
126
    /* Kept in sync with enum ha_key_alg if only for stewart's sanity. */
584.2.8 by Stewart Smith
(mostly) revert previous patch that tried to get rid of the UNKNOWN define in item_cmpfunc.h
127
      UNKNOWN_INDEX = 0;
820.1.15 by Stewart Smith
Read (nearly the whole) index information (key and key parts) out of the proto, not FRM.
128
      BTREE = 1;
129
      RTREE = 2;
130
      HASH  = 3;
131
      FULLTEXT = 4;
352.1.2 by Jay Pipes
Working reader and writer for table.proto definitions now
132
    }
133
134
    message IndexPart {
820.1.15 by Stewart Smith
Read (nearly the whole) index information (key and key parts) out of the proto, not FRM.
135
      required uint32 fieldnr = 1;
1308.2.11 by Jay Pipes
* Adds CREATE TABLE as a specific CreateTableStatement message in the
136
      optional uint32 compare_length = 2;
352.1.2 by Jay Pipes
Working reader and writer for table.proto definitions now
137
      optional bool in_reverse_order = 3 [default = false];
352.1.1 by Jay Pipes
New table definition and updated reader and writer test programs
138
    }
139
1537 by Brian Aker
Remove dead options/rename Option and remove the update that we no longer
140
    message Options {
820.1.15 by Stewart Smith
Read (nearly the whole) index information (key and key parts) out of the proto, not FRM.
141
      optional bool pack_key = 1;
142
      optional bool binary_pack_key = 2;
143
      optional bool var_length_key = 3;
144
      optional bool null_part_key = 4;
145
      optional uint32 key_block_size = 5;
146
      optional bool has_partial_segments =6;
147
      optional bool auto_generated_key = 7;
148
    }      
149
323 by Brian Aker
Updated proto file for table (not FRM work).
150
    required string name = 1;
352.1.1 by Jay Pipes
New table definition and updated reader and writer test programs
151
    required bool is_primary = 2;
152
    required bool is_unique = 3;
584.2.8 by Stewart Smith
(mostly) revert previous patch that tried to get rid of the UNKNOWN define in item_cmpfunc.h
153
    required IndexType type = 4 [default = UNKNOWN_INDEX];
820.1.15 by Stewart Smith
Read (nearly the whole) index information (key and key parts) out of the proto, not FRM.
154
    required uint32 key_length = 5;
155
    repeated IndexPart index_part = 6;
1537 by Brian Aker
Remove dead options/rename Option and remove the update that we no longer
156
    optional Options options= 7;
820.1.15 by Stewart Smith
Read (nearly the whole) index information (key and key parts) out of the proto, not FRM.
157
    optional string comment = 8;
323 by Brian Aker
Updated proto file for table (not FRM work).
158
  }
159
352.1.1 by Jay Pipes
New table definition and updated reader and writer test programs
160
  required string name = 1;
1337.2.2 by Stewart Smith
Add Schema to table message. modify alter table to correctly set a schema when running ALTER TABLE. Also update show_table_message test results to reflect the new field.
161
  required string schema = 6;
352.1.1 by Jay Pipes
New table definition and updated reader and writer test programs
162
  required TableType type = 5;
1502.1.31 by Brian Aker
Merge engine options for schema/table.
163
  required Engine engine = 2;
352.1.1 by Jay Pipes
New table definition and updated reader and writer test programs
164
  repeated Field field = 3;
820.1.8 by Stewart Smith
start reading table definition from proto instead of FRM.
165
  repeated Index indexes = 4;
352.1.1 by Jay Pipes
New table definition and updated reader and writer test programs
166
167
  repeated ForeignKeyConstraint fk_constraint = 8;
168
  optional TableOptions options = 9;
1340.1.4 by Brian Aker
A first pass through adding a timestamp to our proto.
169
  required uint64 creation_timestamp= 11 [default = 0];
170
  required uint64 update_timestamp= 12 [default = 0];
1386 by Brian Aker
Adding catalog string.
171
  optional string catalog = 13;
323 by Brian Aker
Updated proto file for table (not FRM work).
172
}
1215.1.1 by stewart at flamingspork
[patch 01/17] horrible hack to have one lonely codepath produce Fields in the table proto
173
174
message AlterTable {
175
  repeated Table.Field added_field = 1;
1273.13.11 by Brian Aker
First pass through tables.
176
}