Contents |
In the process of eliminating the need for FRM we have to define a message system and at the same time upgrade the serialized table definition. The current proposal is to use Google's Proto Buffer work:
http://code.google.com/apis/protocolbuffers/
The format is compact and has the advantage of having versioning built in. It also has an active developer environment that has formed around it. Please feel free to update the current proposed format. You can find a quick tutorial on it here: http://code.google.com/apis/protocolbuffers/docs/cpptutorial.html
package drizzled.message;
option optimize_for = SPEED;
message Table {
enum TableType {
STANDARD = 0;
TEMPORARY = 1;
INTERNAL = 2;
FUNCTION = 3;
}
message StorageEngine {
message EngineOption {
enum EngineOptionType {
BOOL = 0;
INTEGER = 1;
STRING = 2;
}
required string option_name = 1;
required string option_value = 2;
required EngineOptionType option_type = 3;
}
required string name = 1;
repeated EngineOption option = 2;
}
message TableOptions {
optional uint64 auto_increment = 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 key_block_size = 12;
optional uint32 block_size = 13;
optional string comment = 14;
optional bool pack_keys = 15;
optional bool pack_record = 16;
optional bool checksum = 17;
optional bool page_checksum = 18;
optional bool delay_key_write = 19;
enum RowType {
ROW_TYPE_DEFAULT = 0;
ROW_TYPE_FIXED = 1;
ROW_TYPE_DYNAMIC = 2;
ROW_TYPE_COMPRESSED = 3;
ROW_TYPE_REDUNDANT = 4;
ROW_TYPE_COMPACT = 5;
ROW_TYPE_PAGE = 6;
}
optional RowType row_type = 20;
}
message TableStats {
optional uint32 avg_row_length = 1;
optional uint64 max_rows = 2;
optional uint32 min_rows = 3;
}
message ForeignKeyConstraint {
required string name = 1;
required Field dependent = 2;
required Field parent = 3;
/** @TODO Finish this off... */
}
message Field {
enum FieldType {
DOUBLE = 0;
VARCHAR = 1;
BLOB = 2;
ENUM = 3;
INTEGER = 4;
BIGINT = 5;
DECIMAL = 6;
DATE = 7;
TIMESTAMP = 9;
DATETIME = 10;
}
enum FieldFormatType {
DefaultFormat= 0;
FixedFormat= 1;
DynamicFormat= 2;
}
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;
}
message TimestampFieldOptions {
optional bool auto_updates = 1 [default = false];
}
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 FieldFormatType format = 3;
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;
optional TimestampFieldOptions timestamp_options = 18;
}
message Index {
enum IndexType {
/* Kept in sync with enum ha_key_alg if only for stewart's 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];
optional uint32 key_type = 101; /* THIS MUST DIE. Along with pack_flag*/
}
message IndexOptions {
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 IndexOptions options= 7;
optional string comment = 8;
}
required string name = 1;
required string schema = 6;
required TableType type = 5;
required StorageEngine engine = 2;
repeated Field field = 3;
repeated Index indexes = 4;
repeated ForeignKeyConstraint fk_constraint = 8;
optional TableOptions options = 9;
optional TableStats stats = 10;
required uint64 creation_timestamp= 11 [default = 0];
required uint64 update_timestamp= 12 [default = 0];
optional string catalog = 13;
}
message AlterTable {
repeated Table.Field added_field = 1;
}
package drizzle;
message Table {
required string name = 1;
required string engine = 2;
enum FieldType {
DOUBLE = 0;
VARCHAR = 1;
TEXT = 2;
BLOB = 3;
ENUM = 4;
SET = 5;
TINYINT = 6;
SMALLINT = 7;
INTEGER = 8;
BIGINT = 9;
DECIMAL = 10;
VARBINARY = 11;
DATE = 12;
TIME = 13;
TIMESTAMP = 14;
DATETIME = 15;
}
message Field {
required string name = 1;
optional FieldType type = 2 [default = VARCHAR];
optional string collation = 3;
optional string comment = 4;
optional bool column_format = 5; /* Fixed is true */
optional bool auto_increment = 6;
optional bool is_unsigned = 9;
optional string custom_name = 10;
optional bool is_nullable = 11;
optional int32 scale = 12;
optional int32 precision = 13;
optional int32 characterset = 14;
optional int32 length = 15;
optional string default = 16;
repeated string values = 17;
}
message KeyPart {
required string name = 1;
optional int32 length = 2;
}
enum IndexType {
ORDERED = 0;
HASH = 1;
}
message Index {
required string name = 1;
repeated KeyPart key = 2;
optional bool unique = 3;
optional string comment = 4;
optional int32 key_block_size = 5;
optional IndexType type = 6;
}
repeated Field field = 4;
repeated Index index = ?;
optional string primary = 5;
optional int32 auto_increment = 6;
optional int32 avg_row_length = 7;
optional string character_set = 8;
optional bool checksum = 9;
optional string collation = 10;
optional string comment = 11;
optional string connection = 12;
optional string data_directory = 13;
optional string index_directory = 14;
optional bool delay_key_write = 15;
optional int32 max_rows = 17;
optional int32 min_rows = 18;
optional bool pack_keys = 19;
optional string row_format = 20;
}
message TableList {
repeated Table table = 1;
}
package drizzle;
message TableOptions {
}
message Table {
required string name = 1;
required string engine = 2;
enum FieldType {
DOUBLE = 0;
VARCHAR = 1;
TEXT = 2;
BLOB = 3;
ENUM = 4;
SET = 5;
TINYINT = 6;
SMALLINT = 7;
INTEGER = 8;
BIGINT = 9;
DECIMAL = 10;
VARBINARY = 11;
DATE = 12;
TIME = 13;
TIMESTAMP = 14;
DATETIME = 15;
}
message FieldOptions {
optional bool is_primary_key = 0 [default = false];
optional bool is_autoincrement = 1 [default = false];
optional bool is_key = 2 [default = false];
optional bool is_variable_width = 3;
optional string default_value = 4;
optional bool on_update = 16; /* Reserve 0 - 15 for most common */
}
message FieldConstraints {
optional bool is_unique = 0 [default = false];
optional bool is_unsigned = 1 [default = false];
optional bool is_nullable = 2 [default = false];
optional string expression = 16; /* Reserve 0 - 15 for most common */
}
message NumericOptions {
optional int32 scale = 0;
optional int32 precision = 1;
}
message StringOptions {
optional int32 length = 0;
optional string character_set = 1; /* Perhaps this can go away */
optional string collation = 2;
}
message Field {
required string name = 0;
required FieldType type = 1;
required FieldOptions = 2;
required FieldConstraints = 3;
optional NumericOptions numeric_options = 4;
optional StringOptions string_options = 5;
optional string custom_name = 6; /* What is this for? */
repeated string values = 7; /* Is this for ENUM and SET only? If so, move it out... */
optional string comment = 16; /* Reserve 0 - 15 for most common */
}
message KeyPart {
required string name = 1;
optional int32 length = 2;
}
enum IndexType {
ORDERED = 0; /* What is an "unordered" index?! */
HASH = 1;
}
message Index {
required string name = 1;
repeated KeyPart key = 2;
optional bool is_unique = 3;
optional int32 key_block_size = 5; /* This is MyISAM only, no? ...move it out. */
optional IndexType type = 6;
optional string comment = 16; /* Reserve 0 - 15 for most common */
}
repeated Field field = 4;
repeated Index index = ?;
/* The below are a hodge podge of engine-specific stuff and random attributes...they need cleaning up */
optional string primary = 5;
optional int32 auto_increment = 6;
optional int32 avg_row_length = 7;
optional string character_set = 8;
optional bool checksum = 9;
optional string collation = 10;
optional string connection = 12;
optional string data_directory = 13;
optional string index_directory = 14;
optional bool delay_key_write = 15;
optional int32 max_rows = 17;
optional int32 min_rows = 18;
optional bool pack_keys = 19;
optional string row_format = 20;
optional string comment = 16; /* Reserve 0 - 15 for most common */
}
message TableList {
repeated Table tables = 1;
}