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.

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.

PrepareComplete

Statement preparation complete.

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.

DescribeStatement

Describe a previously prepared statement.

Dump

Initiate database backup

Execute

Execute a prepared statement.

ExecuteScript

Execute an EdgeQL script.

Flush

Force the server to flush its output buffers.

Prepare

Prepare an EdgeQL statement.

Optimistic Execute

Optimistically prepare and 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.

Sent by: server.

Format:

Copy
struct ErrorResponse {
  // Message type ('E').
  uint8           mtype = 0x45;

  // Length of message contents in bytes,
  // including self.
  uint32          message_length;

  // Message severity.
  uint8<ErrorSeverity> severity;

  // Message code.
  uint32          error_code;

  // Error message.
  string          message;

  // Error attributes.
  uint16          num_attributes;
  Header          attributes[num_attributes];
};
Copy
enum ErrorSeverity {
  ERROR           = 0x78;
  FATAL           = 0xc8;
  PANIC           = 0xff;
};

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.

Sent by: server.

Format:

Copy
struct LogMessage {
  // Message type ('L').
  uint8           mtype = 0x4c;

  // Length of message contents in bytes,
  // including self.
  uint32          message_length;

  // Message severity.
  uint8<MessageSeverity> severity;

  // Message code.
  uint32          code;

  // Message text.
  string          text;

  // Message attributes.
  uint16          num_attributes;
  Header          attributes[num_attributes];
};
Copy
enum MessageSeverity {
  DEBUG           = 0x14;
  INFO            = 0x28;
  NOTICE          = 0x3c;
  WARNING         = 0x50;
};

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

Sent by: server.

Format:

Copy
struct ReadyForCommand {
  // Message type ('Z').
  uint8           mtype = 0x5a;

  // Length of message contents in bytes,
  // including self.
  uint32          message_length;

  // A set of message headers.
  uint16          num_headers;
  Header          headers[num_headers];

  // Transaction state.
  uint8<TransactionState> transaction_state;
};
Copy
enum TransactionState {
  NOT_IN_TRANSACTION = 0x49;
  IN_TRANSACTION  = 0x54;
  IN_FAILED_TRANSACTION = 0x45;
};

Sent by: server.

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

Format:

Copy
struct RestoreReady {
  // Message type ('+').
  uint8           mtype = 0x2b;

  // Length of message contents in bytes,
  // including self.
  uint32          message_length;

  // A set of message headers.
  uint16          num_headers;
  Header          headers[num_headers];

  // Number of parallel jobs for restore,
  // currently always "1"
  uint16          jobs;
};

Sent by: server.

Format:

Copy
struct CommandComplete {
  // Message type ('C').
  uint8           mtype = 0x43;

  // Length of message contents in bytes,
  // including self.
  uint32          message_length;

  // A set of message headers.
  uint16          num_headers;
  Header          headers[num_headers];

  // Command status.
  string          status;
};

Known headers:

  • 0x1001 CAPABILITIES: uint64 – capabilities actually used in the query. See RFC1004 for more information.

Extra headers must be ignored.

Sent by: client.

Format:

Copy
struct ExecuteScript {
  // Message type ('Q').
  uint8           mtype = 0x51;

  // Length of message contents in bytes,
  // including self.
  uint32          message_length;

  // A set of message headers.
  uint16          num_headers;
  Header          headers[num_headers];

  // EdgeQL script text to execute.
  string          script;
};

Known headers:

  • 0xFF04 ALLOW_CAPABILITIES: uint64 – optional bitmask of capabilities allowed for this query. See RFC1004 for more information.

Sent by: client.

Copy
struct Prepare {
  // Message type ('P').
  uint8           mtype = 0x50;

  // Length of message contents in bytes,
  // including self.
  uint32          message_length;

  // A set of message headers.
  uint16          num_headers;
  Header          headers[num_headers];

  // Data I/O format.
  uint8<IOFormat> io_format;

  // Expected result cardinality
  uint8<Cardinality> expected_cardinality;

  // Prepared statement name. Currently must
  // be empty.
  bytes           statement_name;

  // Command text.
  string          command;
};
Copy
enum IOFormat {
  BINARY          = 0x62;
  JSON            = 0x6a;
  JSON_ELEMENTS   = 0x4a;
};

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.

Known headers:

  • 0xFF01 IMPLICIT_LIMIT – implicit limit for objects returned. Valid format: decimal number encoded as UTF-8 text. Not set by default.

  • 0xFF02 IMPLICIT_TYPENAMES – if set to “true” all returned objects have a __tname__ property set to their type name (equivalent to having an implicit “__tname__ := .__type__.name” computable.) Note that specifying this header might slow down queries.

  • 0xFF03 IMPLICIT_TYPEIDS – if set to “true” all returned objects have a __tid__ property set to their type ID (equivalent to having an implicit “__tid__ := .__type__.id” computable.)

  • 0xFF04 ALLOW_CAPABILITIES: uint64 – optional bitmask of capabilities allowed for this query. See RFC1004 for more information.

  • 0xFF05 EXPLICIT_OBJECTIDS – If set to “true” returned objects will not have an implicit id property i.e. query shapes will have to explicitly list id properties.

Copy
enum Cardinality {
  NO_RESULT       = 0x6e;
  ONE             = 0x6f;
  MANY            = 0x6d;
};

Sent by: client.

Format:

Copy
struct DescribeStatement {
  // Message type ('D').
  uint8           mtype = 0x44;

  // Length of message contents in bytes,
  // including self.
  uint32          message_length;

  // A set of message headers.
  uint16          num_headers;
  Header          headers[num_headers];

  // Aspect to describe.
  uint8<DescribeAspect> aspect;

  // The name of the statement.
  bytes           statement_name;
};
Copy
enum DescribeAspect {
  DATA_DESCRIPTION = 0x54;
};

Sent by: client.

Initiates a database backup. See Dump Database Flow.

Format:

Copy
struct Dump {
  // Message type ('>').
  uint8           mtype = 0x3e;

  // Length of message contents in bytes,
  // including self.
  uint32          message_length;

  // A set of message headers.
  uint16          num_headers;
  Header          headers[num_headers];
};

Sent by: server.

Format:

Copy
struct CommandDataDescription {
  // Message type ('T').
  uint8           mtype = 0x54;

  // Length of message contents in bytes,
  // including self.
  uint32          message_length;

  // A set of message headers.
  uint16          num_headers;
  Header          headers[num_headers];

  // Actual result cardinality.
  uint8<Cardinality> result_cardinality;

  // Argument data descriptor ID.
  uuid            input_typedesc_id;

  // Argument data descriptor.
  bytes           input_typedesc;

  // Output data descriptor ID.
  uuid            output_typedesc_id;

  // Output data descriptor.
  bytes           output_typedesc;
};
Copy
enum Cardinality {
  NO_RESULT       = 0x6e;
  ONE             = 0x6f;
  MANY            = 0x6d;
};

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

Sent by: client.

Format:

Copy
struct Sync {
  // Message type ('S').
  uint8           mtype = 0x53;

  // Length of message contents in bytes,
  // including self.
  uint32          message_length;
};

Sent by: client.

Format:

Copy
struct Flush {
  // Message type ('H').
  uint8           mtype = 0x48;

  // Length of message contents in bytes,
  // including self.
  uint32          message_length;
};

Sent by: client.

Format:

Copy
struct Execute {
  // Message type ('E').
  uint8           mtype = 0x45;

  // Length of message contents in bytes,
  // including self.
  uint32          message_length;

  // A set of message headers.
  uint16          num_headers;
  Header          headers[num_headers];

  // Prepared statement name.
  bytes           statement_name;

  // Encoded argument data.
  bytes           arguments;
};

Known headers:

  • 0xFF04 ALLOW_CAPABILITIES: uint64 – optional bitmask of capabilities allowed for this query. See RFC1004 for more information.

Sent by: client.

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

Format:

Copy
struct Restore {
  // Message type ('<').
  uint8           mtype = 0x3c;

  // Length of message contents in bytes,
  // including self.
  uint32          message_length;

  // A set of message headers.
  uint16          num_headers;
  Header          headers[num_headers];

  // Number of parallel jobs for restore
  // (only "1" is supported)
  uint16          jobs;

  // Original DumpHeader packet data
  // excluding mtype and message_length
  bytes           header_data;
};

Sent by: client.

Send dump file data block. See Restore Database Flow.

Format:

Copy
struct RestoreBlock {
  // Message type ('=').
  uint8           mtype = 0x3d;

  // Length of message contents in bytes,
  // including self.
  uint32          message_length;

  // Original DumpBlock packet data excluding
  // mtype and message_length
  bytes           block_data;
};

Sent by: client.

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

Format:

Copy
struct RestoreEof {
  // Message type ('.').
  uint8           mtype = 0x2e;

  // Length of message contents in bytes,
  // including self.
  uint32          message_length;
};

Sent by: client.

Format:

Copy
struct OptimisticExecute {
  // Message type ('O').
  uint8           mtype = 0x4f;

  // Length of message contents in bytes,
  // including self.
  uint32          message_length;

  // A set of message headers.
  uint16          num_headers;
  Header          headers[num_headers];

  // Data I/O format.
  uint8<IOFormat> io_format;

  // Expected result cardinality.
  uint8<Cardinality> expected_cardinality;

  // Command text.
  string          command_text;

  // Argument data descriptor ID.
  uuid            input_typedesc_id;

  // Output data descriptor ID.
  uuid            output_typedesc_id;

  // Encoded argument data.
  bytes           arguments;
};

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

Known headers:

  • 0xFF01 IMPLICIT_LIMIT – implicit limit for objects returned. Valid format: decimal number encoded as UTF-8 text. Not set by default.

  • 0xFF02 IMPLICIT_TYPENAMES – if set to “true” all returned objects have a __tname__ property set to their type name (equivalent to having an implicit “__tname__ := .__type__.name” computable.) Note that specifying this header might slow down queries.

  • 0xFF03 IMPLICIT_TYPEIDS – if set to “true” all returned objects have a __tid__ property set to their type ID (equivalent to having an implicit “__tid__ := .__type__.id” computable.)

  • 0xFF04 ALLOW_CAPABILITIES: uint64 – optional bitmask of capabilities allowed for this query. See RFC1004 for more information.

  • 0xFF05 EXPLICIT_OBJECTIDS – If set to “true” returned objects will not have an implicit id property i.e. query shapes will have to explicitly list id properties.

Sent by: server.

Format:

Copy
struct Data {
  // Message type ('D').
  uint8           mtype = 0x44;

  // Length of message contents in bytes,
  // including self.
  uint32          message_length;

  // Encoded output data array. The array is
  // currently always of size 1.
  uint16          num_data;
  DataElement     data[num_data];
};
Copy
struct DataElement {
  // Encoded output data.
  uint32          num_data;
  uint8           data[num_data];
};

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.

Sent by: server.

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

Format:

Copy
struct DumpHeader {
  // Message type ('@').
  uint8           mtype = 0x40;

  // Length of message contents in bytes,
  // including self.
  uint32          message_length;

  // A set of message headers.
  uint16          num_headers;
  Header          headers[num_headers];

  // Major version of EdgeDB.
  uint16          major_ver;

  // Minor version of EdgeDB.
  uint16          minor_ver;

  // Schema.
  string          schema_ddl;

  // Type identifiers.
  uint32          num_types;
  DumpTypeInfo    types[num_types];

  // Object descriptors.
  uint32          num_descriptors;
  DumpObjectDesc  descriptors[num_descriptors];
};
Copy
struct DumpTypeInfo {
  string          type_name;

  string          type_class;

  uuid            type_id;
};
Copy
struct DumpObjectDesc {
  uuid            object_id;

  bytes           description;

  uint16          num_dependencies;
  uuid            dependencies[num_dependencies];
};

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

Sent by: server.

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

Format:

Copy
struct DumpBlock {
  // Message type ('=').
  uint8           mtype = 0x3d;

  // Length of message contents in bytes,
  // including self.
  uint32          message_length;

  // A set of message headers.
  uint16          num_headers;
  Header          headers[num_headers];
};

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

Sent by: server.

Format:

Copy
struct ServerKeyData {
  // Message type ('K').
  uint8           mtype = 0x4b;

  // Length of message contents in bytes,
  // including self.
  uint32          message_length;

  // Key data.
  uint8           data[32];
};

Sent by: server.

Format:

Copy
struct ParameterStatus {
  // Message type ('S').
  uint8           mtype = 0x53;

  // Length of message contents in bytes,
  // including self.
  uint32          message_length;

  // Parameter name.
  bytes           name;

  // Parameter value.
  bytes           value;
};

Sent by: server.

Format:

Copy
struct PrepareComplete {
  // Message type ('1').
  uint8           mtype = 0x31;

  // Length of message contents in bytes,
  // including self.
  uint32          message_length;

  // A set of message headers.
  uint16          num_headers;
  Header          headers[num_headers];

  // Result cardinality.
  uint8<Cardinality> cardinality;

  // Argument data descriptor ID.
  uuid            input_typedesc_id;

  // Result data descriptor ID.
  uuid            output_typedesc_id;
};
Copy
enum Cardinality {
  NO_RESULT       = 0x6e;
  ONE             = 0x6f;
  MANY            = 0x6d;
};

Known headers:

  • 0x1001 CAPABILITIES: uint64 – capabilities needed to execute the query. See RFC1004 for more information.

Extra headers must be ignored.

Sent by: client.

Format:

Copy
struct ClientHandshake {
  // Message type ('V').
  uint8           mtype = 0x56;

  // Length of message contents in bytes,
  // including self.
  uint32          message_length;

  // Requested protocol major version.
  uint16          major_ver;

  // Requested protocol minor version.
  uint16          minor_ver;

  // Connection parameters.
  uint16          num_params;
  ConnectionParam params[num_params];

  // Requested protocol extensions.
  uint16          num_extensions;
  ProtocolExtension extensions[num_extensions];
};
Copy
struct ConnectionParam {
  string          name;

  string          value;
};
Copy
struct ProtocolExtension {
  // Extension name.
  string          name;

  // A set of extension headers.
  uint16          num_headers;
  Header          headers[num_headers];
};

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.

Sent by: server.

Format:

Copy
struct ServerHandshake {
  // Message type ('v').
  uint8           mtype = 0x76;

  // Length of message contents in bytes,
  // including self.
  uint32          message_length;

  // maximum supported or client-requested
  // protocol major version, whichever is
  // greater.
  uint16          major_ver;

  // maximum supported or client-requested
  // protocol minor version, whichever is
  // greater.
  uint16          minor_ver;

  // Supported protocol extensions.
  uint16          num_extensions;
  ProtocolExtension extensions[num_extensions];
};
Copy
struct ProtocolExtension {
  // Extension name.
  string          name;

  // A set of extension headers.
  uint16          num_headers;
  Header          headers[num_headers];
};

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.

Sent by: server.

Format:

Copy
struct AuthenticationOK {
  // Message type ('R').
  uint8           mtype = 0x52;

  // Length of message contents in bytes,
  // including self.
  uint32          message_length;

  // Specifies that this message contains a
  // successful authentication indicator.
  uint32          auth_status;
};

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

Sent by: server.

Format:

Copy
struct AuthenticationRequiredSASLMessage {
  // Message type ('R').
  uint8           mtype = 0x52;

  // Length of message contents in bytes,
  // including self.
  uint32          message_length;

  // Specifies that this message contains a
  // SASL authentication request.
  uint32          auth_status = 0xa;

  // A list of supported SASL authentication
  // methods.
  uint32          num_methods;
  string          methods[num_methods];
};

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.

Sent by: server.

Format:

Copy
struct AuthenticationSASLContinue {
  // Message type ('R').
  uint8           mtype = 0x52;

  // Length of message contents in bytes,
  // including self.
  uint32          message_length;

  // Specifies that this message contains a
  // SASL challenge.
  uint32          auth_status = 0xb;

  // Mechanism-specific SASL data.
  bytes           sasl_data;
};

Sent by: server.

Format:

Copy
struct AuthenticationSASLFinal {
  // Message type ('R').
  uint8           mtype = 0x52;

  // Length of message contents in bytes,
  // including self.
  uint32          message_length;

  // Specifies that SASL authentication has
  // completed.
  uint32          auth_status = 0xc;

  bytes           sasl_data;
};

Sent by: client.

Format:

Copy
struct AuthenticationSASLInitialResponse {
  // Message type ('p').
  uint8           mtype = 0x70;

  // Length of message contents in bytes,
  // including self.
  uint32          message_length;

  // Name of the SASL authentication
  // mechanism that the client selected.
  string          method;

  // Mechanism-specific "Initial Response"
  // data.
  bytes           sasl_data;
};

Sent by: client.

Format:

Copy
struct AuthenticationSASLResponse {
  // Message type ('r').
  uint8           mtype = 0x72;

  // Length of message contents in bytes,
  // including self.
  uint32          message_length;

  // Mechanism-specific response data.
  bytes           sasl_data;
};

Sent by: client.

Format:

Copy
struct Terminate {
  // Message type ('X').
  uint8           mtype = 0x58;

  // Length of message contents in bytes,
  // including self.
  uint32          message_length;
};
Light
Dark
System