Fandom

Drizzle Wiki

Definizione delle tabelle nel Protobuffer

32pagine in
questa wiki
Crea nuova pagina
Discussione0 Condividi

Definizione delle tabelle Modifica

Stiamo cercando di eliminare i file FRM. Dobbiamo definire un sistema di messaggi e allo stesso tempo aggiornare la definizione delle tabelle sezializzate. L'ultima proposta è quella di utilizzare il ProtoBuffer di Google:

http://code.google.com/apis/protocolbuffers/

Il formato è compatto e ha il vantaggio di supportare già il versioning. Inoltre intorno a esso si è formato un ambiente di sviluppo attivo. Sentiti libero di aggiornare questa proposta di formato (nella pagina in inglese, però). Puoi trovare un rapido tutorial qui: http://code.google.com/apis/protocolbuffers/docs/cpptutorial.html

Most Recent Draft Modifica

package drizzle;

message Table {

  enum TableType {
    STANDARD = 0;
    TEMPORARY = 1;
  }

  message StorageEngine {

    message EngineOption {
      enum EngineOptionType {
        BOOL = 0;
        INTEGER = 1;
        STRING = 2;
      }

      required string name = 1;
      required string value = 2;
      required EngineOptionType type = 3;
    }

    required string name = 1;
    repeated EngineOption option = 2;
  }

  message TableOptions {
    optional uint64 auto_increment = 1;
    optional string charset = 2;
    optional string collation = 3;
  }

  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;
      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 {
      required bool is_autoincrement = 1 [default = false];
      optional string default_value = 2;
    }

    message TimestampFieldOptions {
      optional bool auto_updates = 1 [default = false];
    }

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

    message NumericFieldOptions {
      optional int32 length = 1;
      optional int32 scale = 2;
      optional int32 precision = 3;
    }

    message StringFieldOptions {
      required bool is_fixed_width = 1;
      optional int32 length = 2;
      optional string charset = 3; /* Perhaps this can go away soon...*/
      optional string collation = 4;
    }

    message SetFieldOptions {
      required int32 count_elements = 1;
      repeated string value = 2;
    }

    required string name = 1;
    required FieldType type = 2;
    required FieldOptions options = 3;
    required FieldConstraints constraints = 4;
    optional NumericFieldOptions numeric_options = 5;
    optional StringFieldOptions string_options = 6;
    optional string comment = 16; /* Reserve 0-15 for frequently accessed attributes */
    optional SetFieldOptions set_options = 17;
    optional TimestampFieldOptions timestamp_options = 18;
  }

  message Index {

    enum IndexType {
      UNKNOWN = 0;
      HASH = 1;
      BTREE = 2;
      RTREE = 3;
      FULLTEXT = 4;
    }

    message IndexPart {
      required Field field = 1;
      optional int32 compare_length = 2;
      optional bool in_reverse_order = 3 [default = false];
    }

    required string name = 1;
    required bool is_primary = 2;
    required bool is_unique = 3;
    required IndexType type = 4 [default = UNKNOWN];
    repeated IndexPart index_part = 5;
  }

  required string name = 1;
  required TableType type = 5;
  required StorageEngine engine = 2;
  repeated Field field = 3;
  repeated Index index = 4;

  repeated ForeignKeyConstraint fk_constraint = 8;
  optional TableOptions options = 9;
  optional TableStats stats = 10;

  optional string comment = 16;
}

message TableList {
  repeated Table table = 1;
}

Draft 1 Definition Modifica

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;
}

Alternate Definition from Jay Modifica

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;
}

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

Inoltre su Fandom

Wiki casuale