- Messages
- ErrorResponse
- LogMessage
- ReadyForCommand
- RestoreReady
- CommandComplete
- ExecuteScript
- Prepare
- DescribeStatement
- Dump
- CommandDataDescription
- Sync
- Flush
- Execute
- Restore
- RestoreBlock
- RestoreEof
- Optimistic Execute
- Data
- Dump Header
- Dump Block
- ServerKeyData
- ParameterStatus
- PrepareComplete
- ClientHandshake
- ServerHandshake
- AuthenticationOK
- AuthenticationSASL
- AuthenticationSASLContinue
- AuthenticationSASLFinal
- AuthenticationSASLInitialResponse
- AuthenticationSASLResponse
- Terminate
Messages
Server Messages | |
Authentication is successful. | |
SASL authentication is required. | |
SASL authentication challenge. | |
SASL authentication final message. | |
Successful completion of a command. | |
Description of command data input and output. | |
Command result data element. | |
Initial message of the database backup protocol | |
Single chunk of database backup data | |
Server error. | |
Server log message. | |
Server parameter value. | |
Statement preparation complete. | |
Server is ready for a command. | |
Successful response to the Restore message | |
Initial server connection handshake. | |
Opaque token identifying the server connection. | |
Client Messages | |
SASL authentication initial response. | |
SASL authentication response. | |
Initial client connection handshake. | |
Describe a previously prepared statement. | |
Initiate database backup | |
Execute a prepared statement. | |
Execute an EdgeQL script. | |
Force the server to flush its output buffers. | |
Prepare an EdgeQL statement. | |
Optimistically prepare and execute a query. | |
Initiate database restore | |
Next block of database dump | |
End of database dump | |
Provide an explicit synchronization point. | |
Terminate the connection. |
ErrorResponse
Sent by: server.
Format:
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];
};
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:
Error span is the range of characters (or equivalent bytes) of the original query that compiler points to as the source of the error.
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.UTF16_COLUMN_*
is defined as number of UTF-16 code units (i.e. two byte-pairs) that precede target character on the same line.*_END
points to a next character after the last character of the error span.
LogMessage
Sent by: server.
Format:
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];
};
enum MessageSeverity {
DEBUG = 0x14;
INFO = 0x28;
NOTICE = 0x3c;
WARNING = 0x50;
};
See the list of error codes for all possible log message codes.
ReadyForCommand
Sent by: server.
Format:
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;
};
enum TransactionState {
NOT_IN_TRANSACTION = 0x49;
IN_TRANSACTION = 0x54;
IN_FAILED_TRANSACTION = 0x45;
};
RestoreReady
Sent by: server.
Initial Restore message accepted, ready to receive data. See Restore Database Flow.
Format:
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;
};
CommandComplete
Sent by: server.
Format:
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.
ExecuteScript
Sent by: client.
Format:
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.
Prepare
Sent by: client.
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;
};
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” computed property.) 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” computed property.)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 implicitid
property i.e. query shapes will have to explicitly list id properties.
enum Cardinality {
NO_RESULT = 0x6e;
AT_MOST_ONE = 0x6f;
ONE = 0x41;
MANY = 0x6d;
AT_LEAST_ONE = 0x4d;
};
DescribeStatement
Sent by: client.
Format:
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;
};
enum DescribeAspect {
DATA_DESCRIPTION = 0x54;
};
Dump
Sent by: client.
Initiates a database backup. See Dump Database Flow.
Format:
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];
};
CommandDataDescription
Sent by: server.
Format:
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;
};
enum Cardinality {
NO_RESULT = 0x6e;
AT_MOST_ONE = 0x6f;
ONE = 0x41;
MANY = 0x6d;
AT_LEAST_ONE = 0x4d;
};
The format of the input_typedesc and output_typedesc fields is described in the Type descriptors section.
Sync
Sent by: client.
Format:
struct Sync {
// Message type ('S').
uint8 mtype = 0x53;
// Length of message contents in bytes,
// including self.
uint32 message_length;
};
Flush
Sent by: client.
Format:
struct Flush {
// Message type ('H').
uint8 mtype = 0x48;
// Length of message contents in bytes,
// including self.
uint32 message_length;
};
Execute
Sent by: client.
Format:
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.
Restore
Sent by: client.
Initiate restore to the current database. See Restore Database Flow.
Format:
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;
};
RestoreBlock
Sent by: client.
Send dump file data block. See Restore Database Flow.
Format:
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;
};
RestoreEof
Sent by: client.
Notify server that dump is fully uploaded. See Restore Database Flow.
Format:
struct RestoreEof {
// Message type ('.').
uint8 mtype = 0x2e;
// Length of message contents in bytes,
// including self.
uint32 message_length;
};
Optimistic Execute
Sent by: client.
Format:
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” computed property.) 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” computed property.)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 implicitid
property i.e. query shapes will have to explicitly list id properties.
Data
Sent by: server.
Format:
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];
};
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.
Dump Header
Sent by: server.
Initial message of database backup protocol. See Dump Database Flow.
Format:
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];
};
struct DumpTypeInfo {
string type_name;
string type_class;
uuid type_id;
};
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 stringified103
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:
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 stringified112
BLOCK_DATA
– the actual block data
ServerKeyData
Sent by: server.
Format:
struct ServerKeyData {
// Message type ('K').
uint8 mtype = 0x4b;
// Length of message contents in bytes,
// including self.
uint32 message_length;
// Key data.
uint8 data[32];
};
ParameterStatus
Sent by: server.
Format:
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;
};
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:
```
struct ParameterStatus_SystemConfig {
// Type descriptor prefixed with type
// descriptor uuid.
uint32 num_typedesc;
uint8 typedesc[num_typedesc];
// Configuration settings data.
DataElement data[1];
};
```
Where `DataElement` is defined in the same way as for the [Data](#ref-protocol-msg-data) message:
```
struct DataElement {
// Encoded output data.
uint32 num_data;
uint8 data[num_data];
};
```
PrepareComplete
Sent by: server.
Format:
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;
};
enum Cardinality {
NO_RESULT = 0x6e;
AT_MOST_ONE = 0x6f;
ONE = 0x41;
MANY = 0x6d;
AT_LEAST_ONE = 0x4d;
};
Known headers:
- 0x1001
CAPABILITIES
:uint64
– capabilities needed to execute the query. See RFC1004 for more information.
Extra headers must be ignored.
ClientHandshake
Sent by: client.
Format:
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];
};
struct ConnectionParam {
string name;
string value;
};
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.
ServerHandshake
Sent by: server.
Format:
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];
};
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.
AuthenticationOK
Sent by: server.
Format:
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.
AuthenticationSASL
Sent by: server.
Format:
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.
AuthenticationSASLContinue
Sent by: server.
Format:
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;
};
AuthenticationSASLFinal
Sent by: server.
Format:
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;
};
AuthenticationSASLInitialResponse
Sent by: client.
Format:
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;
};
AuthenticationSASLResponse
Sent by: client.
Format:
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;
};
Terminate
Sent by: client.
Format:
struct Terminate {
// Message type ('X').
uint8 mtype = 0x58;
// Length of message contents in bytes,
// including self.
uint32 message_length;
};