Messages

Server Messages

AuthenticationOK

Authentication is successful.

AuthenticationSASL

SASL authentication is required.

AuthenticationSASLContinue

SASL authentication challenge.

AuthenticationSASLFinal

SASL authentication final message.

CommandComplete

Successful completion of a command.

CommandDataDescription

Description of command data input and output.

StateDataDescription

Description of state data.

Data

Command result data element.

Dump Header

Initial message of the database backup protocol

Dump Block

Single chunk of database backup data

ErrorResponse

Server error.

LogMessage

Server log message.

ParameterStatus

Server parameter value.

ReadyForCommand

Server is ready for a command.

RestoreReady

Successful response to the Restore message

ServerHandshake

Initial server connection handshake.

ServerKeyData

Opaque token identifying the server connection.

Client Messages

AuthenticationSASLInitialResponse

SASL authentication initial response.

AuthenticationSASLResponse

SASL authentication response.

ClientHandshake

Initial client connection handshake.

Dump

Initiate database backup

Parse

Parse EdgeQL command(s).

Execute

Parse and/or execute a query.

Restore

Initiate database restore

RestoreBlock

Next block of database dump

RestoreEof

End of database dump

Sync

Provide an explicit synchronization point.

Terminate

Terminate the connection.

ErrorResponse

Sent by: server.

Format:

  1. struct ErrorResponse {
  2. // Message type ('E').
  3. uint8 mtype = 0x45;
  4. // Length of message contents in bytes,
  5. // including self.
  6. uint32 message_length;
  7. // Message severity.
  8. uint8<ErrorSeverity> severity;
  9. // Message code.
  10. uint32 error_code;
  11. // Error message.
  12. string message;
  13. // Error attributes.
  14. uint16 num_attributes;
  15. KeyValue attributes[num_attributes];
  16. };
  1. enum ErrorSeverity {
  2. ERROR = 0x78;
  3. FATAL = 0xc8;
  4. PANIC = 0xff;
  5. };

See the list of error codes for all possible error codes.

Known headers:

  • 0x0001 HINT: str – error hint.

  • 0x0002 DETAILS: str – error details.

  • 0x0101 SERVER_TRACEBACK: str – error traceback from server (is only sent in dev mode).

  • 0xFFF1 POSITION_START – byte offset of the start of the error span.

  • 0xFFF2 POSITION_END – byte offset of the end of the error span.

  • 0xFFF3 LINE_START – one-based line number of the start of the error span.

  • 0xFFF4 COLUMN_START – one-based column number of the start of the error span.

  • 0xFFF5 UTF16_COLUMN_START – zero-based column number in UTF-16 encoding of the start of the error span.

  • 0xFFF6 LINE_END – one-based line number of the start of the error span.

  • 0xFFF7 COLUMN_END – one-based column number of the start of the error span.

  • 0xFFF8 UTF16_COLUMN_END – zero-based column number in UTF-16 encoding of the end of the error span.

  • 0xFFF9 CHARACTER_START – zero-based offset of the error span in terms of Unicode code points.

  • 0xFFFA CHARACTER_END – zero-based offset of the end of the error span.

Notes:

  1. Error span is the range of characters (or equivalent bytes) of the original query that compiler points to as the source of the error.

  2. COLUMN_* is defined in terms of width of characters defined by Unicode Standard Annex #11, in other words, the column number in the text if rendered with monospace font, e.g. in a terminal.

  3. UTF16_COLUMN_* is defined as number of UTF-16 code units (i.e. two byte-pairs) that precede target character on the same line.

  4. *_END points to a next character after the last character of the error span.

LogMessage

Sent by: server.

Format:

  1. struct LogMessage {
  2. // Message type ('L').
  3. uint8 mtype = 0x4c;
  4. // Length of message contents in bytes,
  5. // including self.
  6. uint32 message_length;
  7. // Message severity.
  8. uint8<MessageSeverity> severity;
  9. // Message code.
  10. uint32 code;
  11. // Message text.
  12. string text;
  13. // Message annotations.
  14. uint16 num_annotations;
  15. Annotation annotations[num_annotations];
  16. };
  1. enum MessageSeverity {
  2. DEBUG = 0x14;
  3. INFO = 0x28;
  4. NOTICE = 0x3c;
  5. WARNING = 0x50;
  6. };

See the list of error codes for all possible log message codes.

ReadyForCommand

Sent by: server.

Format:

  1. struct ReadyForCommand {
  2. // Message type ('Z').
  3. uint8 mtype = 0x5a;
  4. // Length of message contents in bytes,
  5. // including self.
  6. uint32 message_length;
  7. // A set of annotations.
  8. uint16 num_annotations;
  9. Annotation annotations[num_annotations];
  10. // Transaction state.
  11. uint8<TransactionState> transaction_state;
  12. };
  1. enum TransactionState {
  2. NOT_IN_TRANSACTION = 0x49;
  3. IN_TRANSACTION = 0x54;
  4. IN_FAILED_TRANSACTION = 0x45;
  5. };

RestoreReady

Sent by: server.

Initial Restore message accepted, ready to receive data. See Restore Database Flow.

Format:

  1. struct RestoreReady {
  2. // Message type ('+').
  3. uint8 mtype = 0x2b;
  4. // Length of message contents in bytes,
  5. // including self.
  6. uint32 message_length;
  7. // A set of annotations.
  8. uint16 num_annotations;
  9. Annotation annotations[num_annotations];
  10. // Number of parallel jobs for restore,
  11. // currently always "1"
  12. uint16 jobs;
  13. };

CommandComplete

Sent by: server.

Format:

  1. struct CommandComplete {
  2. // Message type ('C').
  3. uint8 mtype = 0x43;
  4. // Length of message contents in bytes,
  5. // including self.
  6. uint32 message_length;
  7. // A set of annotations.
  8. uint16 num_annotations;
  9. Annotation annotations[num_annotations];
  10. // A bit mask of allowed capabilities.
  11. uint64<Capability> capabilities;
  12. // Command status.
  13. string status;
  14. // State data descriptor ID.
  15. uuid state_typedesc_id;
  16. // Encoded state data.
  17. bytes state_data;
  18. };

Dump

Sent by: client.

Initiates a database backup. See Dump Database Flow.

Format:

  1. struct Dump {
  2. // Message type ('>').
  3. uint8 mtype = 0x3e;
  4. // Length of message contents in bytes,
  5. // including self.
  6. uint32 message_length;
  7. // A set of annotations.
  8. uint16 num_annotations;
  9. Annotation annotations[num_annotations];
  10. };

CommandDataDescription

Sent by: server.

Format:

  1. struct CommandDataDescription {
  2. // Message type ('T').
  3. uint8 mtype = 0x54;
  4. // Length of message contents in bytes,
  5. // including self.
  6. uint32 message_length;
  7. // A set of annotations.
  8. uint16 num_annotations;
  9. Annotation annotations[num_annotations];
  10. // A bit mask of allowed capabilities.
  11. uint64<Capability> capabilities;
  12. // Actual result cardinality.
  13. uint8<Cardinality> result_cardinality;
  14. // Argument data descriptor ID.
  15. uuid input_typedesc_id;
  16. // Argument data descriptor.
  17. bytes input_typedesc;
  18. // Output data descriptor ID.
  19. uuid output_typedesc_id;
  20. // Output data descriptor.
  21. bytes output_typedesc;
  22. };
  1. enum Cardinality {
  2. NO_RESULT = 0x6e;
  3. AT_MOST_ONE = 0x6f;
  4. ONE = 0x41;
  5. MANY = 0x6d;
  6. AT_LEAST_ONE = 0x4d;
  7. };

The format of the input_typedesc and output_typedesc fields is described in the Type descriptors section.

StateDataDescription

Sent by: server.

Format:

  1. struct StateDataDescription {
  2. // Message type ('s').
  3. uint8 mtype = 0x73;
  4. // Length of message contents in bytes,
  5. // including self.
  6. uint32 message_length;
  7. // Updated state data descriptor ID.
  8. uuid typedesc_id;
  9. // State data descriptor.
  10. bytes typedesc;
  11. };

The format of the typedesc fields is described in the Type descriptors section.

Sync

Sent by: client.

Format:

  1. struct Sync {
  2. // Message type ('S').
  3. uint8 mtype = 0x53;
  4. // Length of message contents in bytes,
  5. // including self.
  6. uint32 message_length;
  7. };

Restore

Sent by: client.

Initiate restore to the current database. See Restore Database Flow.

Format:

  1. struct Restore {
  2. // Message type ('<').
  3. uint8 mtype = 0x3c;
  4. // Length of message contents in bytes,
  5. // including self.
  6. uint32 message_length;
  7. // A set of key-value pairs.
  8. uint16 num_attributes;
  9. KeyValue attributes[num_attributes];
  10. // Number of parallel jobs for restore
  11. // (only "1" is supported)
  12. uint16 jobs;
  13. // Original DumpHeader packet data
  14. // excluding mtype and message_length
  15. bytes header_data;
  16. };

RestoreBlock

Sent by: client.

Send dump file data block. See Restore Database Flow.

Format:

  1. struct RestoreBlock {
  2. // Message type ('=').
  3. uint8 mtype = 0x3d;
  4. // Length of message contents in bytes,
  5. // including self.
  6. uint32 message_length;
  7. // Original DumpBlock packet data excluding
  8. // mtype and message_length
  9. bytes block_data;
  10. };

RestoreEof

Sent by: client.

Notify server that dump is fully uploaded. See Restore Database Flow.

Format:

  1. struct RestoreEof {
  2. // Message type ('.').
  3. uint8 mtype = 0x2e;
  4. // Length of message contents in bytes,
  5. // including self.
  6. uint32 message_length;
  7. };

Execute

Sent by: client.

Format:

  1. struct Execute {
  2. // Message type ('O').
  3. uint8 mtype = 0x4f;
  4. // Length of message contents in bytes,
  5. // including self.
  6. uint32 message_length;
  7. // A set of annotations.
  8. uint16 num_annotations;
  9. Annotation annotations[num_annotations];
  10. // A bit mask of allowed capabilities.
  11. uint64<Capability> allowed_capabilities;
  12. // A bit mask of query options.
  13. uint64<CompilationFlag> compilation_flags;
  14. // Implicit LIMIT clause on returned sets.
  15. uint64 implicit_limit;
  16. // Data output format.
  17. uint8<OutputFormat> output_format;
  18. // Expected result cardinality.
  19. uint8<Cardinality> expected_cardinality;
  20. // Command text.
  21. string command_text;
  22. // State data descriptor ID.
  23. uuid state_typedesc_id;
  24. // Encoded state data.
  25. bytes state_data;
  26. // Argument data descriptor ID.
  27. uuid input_typedesc_id;
  28. // Output data descriptor ID.
  29. uuid output_typedesc_id;
  30. // Encoded argument data.
  31. bytes arguments;
  32. };
  1. enum OutputFormat {
  2. BINARY = 0x62;
  3. JSON = 0x6a;
  4. JSON_ELEMENTS = 0x4a;
  5. NONE = 0x6e;
  6. };

Use:

  • BINARY to return data encoded in binary.

  • JSON to return data as single row and single field that contains the resultset as a single JSON array”.

  • JSON_ELEMENTS to return a single JSON string per top-level set element. This can be used to iterate over a large result set efficiently.

  • NONE to prevent the server from returning data, even if the EdgeQL command does.

The data in arguments must be encoded as a tuple value described by a type descriptor identified by input_typedesc_id.

  1. enum Cardinality {
  2. NO_RESULT = 0x6e;
  3. AT_MOST_ONE = 0x6f;
  4. ONE = 0x41;
  5. MANY = 0x6d;
  6. AT_LEAST_ONE = 0x4d;
  7. };

Parse

Sent by: client.

  1. struct Parse {
  2. // Message type ('P').
  3. uint8 mtype = 0x50;
  4. // Length of message contents in bytes,
  5. // including self.
  6. uint32 message_length;
  7. // A set of annotations.
  8. uint16 num_annotations;
  9. Annotation annotations[num_annotations];
  10. // A bit mask of allowed capabilities.
  11. uint64<Capability> allowed_capabilities;
  12. // A bit mask of query options.
  13. uint64<CompilationFlag> compilation_flags;
  14. // Implicit LIMIT clause on returned sets.
  15. uint64 implicit_limit;
  16. // Data output format.
  17. uint8<OutputFormat> output_format;
  18. // Expected result cardinality.
  19. uint8<Cardinality> expected_cardinality;
  20. // Command text.
  21. string command_text;
  22. // State data descriptor ID.
  23. uuid state_typedesc_id;
  24. // Encoded state data.
  25. bytes state_data;
  26. };
  1. enum Capability {
  2. MODIFICATIONS = 0x1;
  3. SESSION_CONFIG = 0x2;
  4. TRANSACTION = 0x4;
  5. DDL = 0x8;
  6. PERSISTENT_CONFIG = 0x10;
  7. ALL = 0xffffffffffffffff;
  8. };

See RFC1004 for more information on capability flags.

  1. enum CompilationFlag {
  2. INJECT_OUTPUT_TYPE_IDS = 0x1;
  3. INJECT_OUTPUT_TYPE_NAMES = 0x2;
  4. INJECT_OUTPUT_OBJECT_IDS = 0x4;
  5. };

Use:

  • 0x0000_0000_0000_0001 (INJECT_OUTPUT_TYPE_IDS) – if set, all returned objects have a __tid__ property set to their type ID (equivalent to having an implicit __tid__ := .__type__.id computed property.)

  • 0x0000_0000_0000_0002 (INJECT_OUTPUT_TYPE_NAMES) – if set all returned objects have a __tname__ property set to their type name (equivalent to having an implicit __tname__ := .__type__.name computed property.) Note that specifying this flag might slow down queries.

  • 0x0000_0000_0000_0004 (INJECT_OUTPUT_OBJECT_IDS) – if set all returned objects have an id property set to their identifier, even if not specified explicitly in the output shape.

  1. enum OutputFormat {
  2. BINARY = 0x62;
  3. JSON = 0x6a;
  4. JSON_ELEMENTS = 0x4a;
  5. NONE = 0x6e;
  6. };

Use:

  • BINARY to return data encoded in binary.

  • JSON to return data as single row and single field that contains the resultset as a single JSON array”.

  • JSON_ELEMENTS to return a single JSON string per top-level set element. This can be used to iterate over a large result set efficiently.

  • NONE to prevent the server from returning data, even if the EdgeQL statement does.

  1. enum Cardinality {
  2. NO_RESULT = 0x6e;
  3. AT_MOST_ONE = 0x6f;
  4. ONE = 0x41;
  5. MANY = 0x6d;
  6. AT_LEAST_ONE = 0x4d;
  7. };

Data

Sent by: server.

Format:

  1. struct Data {
  2. // Message type ('D').
  3. uint8 mtype = 0x44;
  4. // Length of message contents in bytes,
  5. // including self.
  6. uint32 message_length;
  7. // Encoded output data array. The array is
  8. // currently always of size 1.
  9. uint16 num_data;
  10. DataElement data[num_data];
  11. };
  1. struct DataElement {
  2. // Encoded output data.
  3. uint32 num_data;
  4. uint8 data[num_data];
  5. };

The exact encoding of DataElement.data is defined by the query output type descriptor.

Wire formats for the standard scalar types and collections are documented in Data wire formats.

Dump Header

Sent by: server.

Initial message of database backup protocol. See Dump Database Flow.

Format:

  1. struct DumpHeader {
  2. // Message type ('@').
  3. uint8 mtype = 0x40;
  4. // Length of message contents in bytes,
  5. // including self.
  6. uint32 message_length;
  7. // A set of key-value pairs.
  8. uint16 num_attributes;
  9. KeyValue attributes[num_attributes];
  10. // Major version of EdgeDB.
  11. uint16 major_ver;
  12. // Minor version of EdgeDB.
  13. uint16 minor_ver;
  14. // Schema.
  15. string schema_ddl;
  16. // Type identifiers.
  17. uint32 num_types;
  18. DumpTypeInfo types[num_types];
  19. // Object descriptors.
  20. uint32 num_descriptors;
  21. DumpObjectDesc descriptors[num_descriptors];
  22. };
  1. struct DumpTypeInfo {
  2. string type_name;
  3. string type_class;
  4. uuid type_id;
  5. };
  1. struct DumpObjectDesc {
  2. uuid object_id;
  3. bytes description;
  4. uint16 num_dependencies;
  5. uuid dependencies[num_dependencies];
  6. };

Known headers:

  • 101 BLOCK_TYPE – block type, always “I”

  • 102 SERVER_TIME – server time when dump is started as a floating point unix timestamp stringified

  • 103 SERVER_VERSION – full version of server as string

Dump Block

Sent by: server.

The actual protocol data in the backup protocol. See Dump Database Flow.

Format:

  1. struct DumpBlock {
  2. // Message type ('=').
  3. uint8 mtype = 0x3d;
  4. // Length of message contents in bytes,
  5. // including self.
  6. uint32 message_length;
  7. // A set of key-value pairs.
  8. uint16 num_attributes;
  9. KeyValue attributes[num_attributes];
  10. };

Known headers:

  • 101 BLOCK_TYPE – block type, always “D”

  • 110 BLOCK_ID – block identifier (16 bytes of UUID)

  • 111 BLOCK_NUM – integer block index stringified

  • 112 BLOCK_DATA – the actual block data

ServerKeyData

Sent by: server.

Format:

  1. struct ServerKeyData {
  2. // Message type ('K').
  3. uint8 mtype = 0x4b;
  4. // Length of message contents in bytes,
  5. // including self.
  6. uint32 message_length;
  7. // Key data.
  8. uint8 data[32];
  9. };

ParameterStatus

Sent by: server.

Format:

  1. struct ParameterStatus {
  2. // Message type ('S').
  3. uint8 mtype = 0x53;
  4. // Length of message contents in bytes,
  5. // including self.
  6. uint32 message_length;
  7. // Parameter name.
  8. bytes name;
  9. // Parameter value.
  10. bytes value;
  11. };

Known statuses:

  • suggested_pool_concurrency – suggested default size for clients connection pools. Serialized as UTF-8 encoded string.

  • system_config – a set of instance-level configuration settings exposed to clients on connection. Serialized as:

  1. ```
  2. struct ParameterStatus_SystemConfig {
  3. // Type descriptor prefixed with type
  4. // descriptor uuid.
  5. uint32 num_typedesc;
  6. uint8 typedesc[num_typedesc];
  7. // Configuration settings data.
  8. DataElement data[1];
  9. };
  10. ```
  11. Where `DataElement` is defined in the same way as for the [Data](#ref-protocol-msg-data) message:
  12. ```
  13. struct DataElement {
  14. // Encoded output data.
  15. uint32 num_data;
  16. uint8 data[num_data];
  17. };
  18. ```

ClientHandshake

Sent by: client.

Format:

  1. struct ClientHandshake {
  2. // Message type ('V').
  3. uint8 mtype = 0x56;
  4. // Length of message contents in bytes,
  5. // including self.
  6. uint32 message_length;
  7. // Requested protocol major version.
  8. uint16 major_ver;
  9. // Requested protocol minor version.
  10. uint16 minor_ver;
  11. // Connection parameters.
  12. uint16 num_params;
  13. ConnectionParam params[num_params];
  14. // Requested protocol extensions.
  15. uint16 num_extensions;
  16. ProtocolExtension extensions[num_extensions];
  17. };
  1. struct ConnectionParam {
  2. string name;
  3. string value;
  4. };
  1. struct ProtocolExtension {
  2. // Extension name.
  3. string name;
  4. // A set of extension annotaions.
  5. uint16 num_annotations;
  6. Annotation annotations[num_annotations];
  7. };

The ClientHandshake message is the first message sent by the client upon connecting to the server. It is the first phase of protocol negotiation, where the client sends the requested protocol version and extensions. Currently, the only defined major_ver is 1, and minor_ver is 0. No protocol extensions are currently defined. The server always responds with the ServerHandshake.

ServerHandshake

Sent by: server.

Format:

  1. struct ServerHandshake {
  2. // Message type ('v').
  3. uint8 mtype = 0x76;
  4. // Length of message contents in bytes,
  5. // including self.
  6. uint32 message_length;
  7. // maximum supported or client-requested
  8. // protocol major version, whichever is
  9. // greater.
  10. uint16 major_ver;
  11. // maximum supported or client-requested
  12. // protocol minor version, whichever is
  13. // greater.
  14. uint16 minor_ver;
  15. // Supported protocol extensions.
  16. uint16 num_extensions;
  17. ProtocolExtension extensions[num_extensions];
  18. };
  1. struct ProtocolExtension {
  2. // Extension name.
  3. string name;
  4. // A set of extension annotaions.
  5. uint16 num_annotations;
  6. Annotation annotations[num_annotations];
  7. };

The ServerHandshake message is a direct response to the ClientHandshake message and is sent by the server in the case where the server does not support the protocol version or protocol extensions requested by the client. It contains the maximum protocol version supported by the server, considering the version requested by the client. It also contains the intersection of the client-requested and server-supported protocol extensions. Any requested extensions not listed in the Server Handshake message are considered unsupported.

AuthenticationOK

Sent by: server.

Format:

  1. struct AuthenticationOK {
  2. // Message type ('R').
  3. uint8 mtype = 0x52;
  4. // Length of message contents in bytes,
  5. // including self.
  6. uint32 message_length;
  7. // Specifies that this message contains a
  8. // successful authentication indicator.
  9. uint32 auth_status;
  10. };

The AuthenticationOK message is sent by the server once it considers the authentication to be successful.

AuthenticationSASL

Sent by: server.

Format:

  1. struct AuthenticationRequiredSASLMessage {
  2. // Message type ('R').
  3. uint8 mtype = 0x52;
  4. // Length of message contents in bytes,
  5. // including self.
  6. uint32 message_length;
  7. // Specifies that this message contains a
  8. // SASL authentication request.
  9. uint32 auth_status = 0xa;
  10. // A list of supported SASL authentication
  11. // methods.
  12. uint32 num_methods;
  13. string methods[num_methods];
  14. };

The AuthenticationSASL message is sent by the server if it determines that a SASL-based authentication method is required in order to connect using the connection parameters specified in the ClientHandshake. The message contains a list of authentication methods supported by the server in the order preferred by the server.

At the moment, the only SASL authentication method supported by EdgeDB is SCRAM-SHA-256 (RFC 7677).

The client must select an appropriate authentication method from the list returned by the server and send an AuthenticationSASLInitialResponse. One or more server-challenge and client-response message follow. Each server-challenge is sent in an AuthenticationSASLContinue, followed by a response from the client in an AuthenticationSASLResponse message. The particulars of the messages are mechanism specific. Finally, when the authentication exchange is completed successfully, the server sends an AuthenticationSASLFinal, followed immediately by an AuthenticationOK.

AuthenticationSASLContinue

Sent by: server.

Format:

  1. struct AuthenticationSASLContinue {
  2. // Message type ('R').
  3. uint8 mtype = 0x52;
  4. // Length of message contents in bytes,
  5. // including self.
  6. uint32 message_length;
  7. // Specifies that this message contains a
  8. // SASL challenge.
  9. uint32 auth_status = 0xb;
  10. // Mechanism-specific SASL data.
  11. bytes sasl_data;
  12. };

AuthenticationSASLFinal

Sent by: server.

Format:

  1. struct AuthenticationSASLFinal {
  2. // Message type ('R').
  3. uint8 mtype = 0x52;
  4. // Length of message contents in bytes,
  5. // including self.
  6. uint32 message_length;
  7. // Specifies that SASL authentication has
  8. // completed.
  9. uint32 auth_status = 0xc;
  10. bytes sasl_data;
  11. };

AuthenticationSASLInitialResponse

Sent by: client.

Format:

  1. struct AuthenticationSASLInitialResponse {
  2. // Message type ('p').
  3. uint8 mtype = 0x70;
  4. // Length of message contents in bytes,
  5. // including self.
  6. uint32 message_length;
  7. // Name of the SASL authentication
  8. // mechanism that the client selected.
  9. string method;
  10. // Mechanism-specific "Initial Response"
  11. // data.
  12. bytes sasl_data;
  13. };

AuthenticationSASLResponse

Sent by: client.

Format:

  1. struct AuthenticationSASLResponse {
  2. // Message type ('r').
  3. uint8 mtype = 0x72;
  4. // Length of message contents in bytes,
  5. // including self.
  6. uint32 message_length;
  7. // Mechanism-specific response data.
  8. bytes sasl_data;
  9. };

Terminate

Sent by: client.

Format:

  1. struct Terminate {
  2. // Message type ('X').
  3. uint8 mtype = 0x58;
  4. // Length of message contents in bytes,
  5. // including self.
  6. uint32 message_length;
  7. };