native_protocol_v4.html-diff

建立於 差異永不過期
340 刪除
625
176 新增
545
<!DOCTYPE html>
<!DOCTYPE html>
<html>
<html>
<head>
<head>
<title>CQL BINARY PROTOCOL v4</title>
<meta charset="utf-8">
<style>
<title>CQL BINARY PROTOCOL v4</title>
nav ol {
<style>
margin: 0;
nav ol { margin: 0; padding: 0; padding-left: 1em; }
padding: 0;
nav li { list-style: none; }
padding-left: 1em;
nav.top ul { margin: 0; padding: 0; background: #eee; color: black; }
}
nav.top ul li { display: inline-block; }
nav li {
</style>
list-style: none;
}
nav.top ul {
margin: 0;
padding: 0;
background: #eee;
color: black;
}
nav.top ul li {
display: inline-block;
}
</style>
</head>
</head>
<body>
<body>

<!-- -->
<h1>CQL BINARY PROTOCOL v4</h1>
<!-- Licensed to the Apache Software Foundation (ASF) under one -->
<h2>Table of Contents</h2>
<!-- or more contributor license agreements. See the NOTICE file -->
<nav>
<!-- distributed with this work for additional information -->
<ol>
<!-- regarding copyright ownership. The ASF licenses this file -->
<!-- to you under the Apache License, Version 2.0 (the -->
<li id="toc1">1
<!-- &quot;License&quot;); you may not use this file except in compliance -->
<a href="#s1">Overview</a>
<!-- with the License. You may obtain a copy of the License at -->
<!-- -->
</li>
<!-- http://www.apache.org/licenses/LICENSE-2.0 -->
<!-- -->
<li id="toc2">2
<!-- Unless required by applicable law or agreed to in writing, software -->
<a href="#s2">Frame header</a>
<!-- distributed under the License is distributed on an &quot;AS IS&quot; BASIS, -->
<!-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -->
<ol>
<!-- See the License for the specific language governing permissions and -->
<!-- limitations under the License. -->
<li id="toc2.1">2.1
<!-- -->
<h1>CQL BINARY PROTOCOL v4</h1>
<h2>Table of Contents</h2>
<nav>
<ol>
<li id="toc1">
1
<a href="#s1">Overview</a>
</li>
<li id="toc2">
2
<a href="#s2">Frame header</a>
<ol>
<li id="toc2.1">
2.1
<a href="#s2.1">version</a>
<a href="#s2.1">version</a>
</li>
</li>
<li id="toc2.2">
2.2
<li id="toc2.2">2.2
<a href="#s2.2">flags</a>
<a href="#s2.2">flags</a>
</li>
</li>
<li id="toc2.3">
2.3
<li id="toc2.3">2.3
<a href="#s2.3">stream</a>
<a href="#s2.3">stream</a>
</li>
</li>
<li id="toc2.4">
2.4
<li id="toc2.4">2.4
<a href="#s2.4">opcode</a>
<a href="#s2.4">opcode</a>
</li>
</li>
<li id="toc2.5">
2.5
<li id="toc2.5">2.5
<a href="#s2.5">length</a>
<a href="#s2.5">length</a>
</li>
</li>
</ol>
</li>

<li id="toc3">
</ol>
3
<a href="#s3">Notations</a>
</li>
</li>
<li id="toc4">
<li id="toc3">3
4
<a href="#s3">Notations</a>
<a href="#s4">Messages</a>
<ol>
</li>
<li id="toc4.1">
4.1
<li id="toc4">4
<a href="#s4">Messages</a>
<ol>
<li id="toc4.1">4.1
<a href="#s4.1">Requests</a>
<a href="#s4.1">Requests</a>
<ol>
<ol>
<li id="toc4.1.1">
<li id="toc4.1.1">4.1.1
4.1.1
<a href="#s4.1.1">STARTUP</a>
<a href="#s4.1.1">STARTUP</a>
</li>
</li>
<li id="toc4.1.2">
4.1.2
<li id="toc4.1.2">4.1.2
<a href="#s4.1.2">AUTH_RESPONSE</a>
<a href="#s4.1.2">AUTH_RESPONSE</a>
</li>
<li id="toc4.1.3">
</li>
4.1.3
<a href="#s4.1.3">OPTIONS</a>
<li id="toc4.1.3">4.1.3
</li>
<a href="#s4.1.3">OPTIONS</a>
<li id="toc4.1.4">
4.1.4
</li>
<a href="#s4.1.4">QUERY</a>
</li>
<li id="toc4.1.4">4.1.4
<li id="toc4.1.5">
<a href="#s4.1.4">QUERY</a>
4.1.5
<a href="#s4.1.5">PREPARE</a>
</li>
</li>
<li id="toc4.1.6">
<li id="toc4.1.5">4.1.5
4.1.6
<a href="#s4.1.5">PREPARE</a>
<a href="#s4.1.6">EXECUTE</a>
</li>
</li>
<li id="toc4.1.7">
4.1.7
<li id="toc4.1.6">4.1.6
<a href="#s4.1.7">BATCH</a>
<a href="#s4.1.6">EXECUTE</a>
</li>
<li id="toc4.1.8">
</li>
4.1.8
<a href="#s4.1.8">REGISTER</a>
<li id="toc4.1.7">4.1.7
</li>
<a href="#s4.1.7">BATCH</a>
</li>
<li id="toc4.1.8">4.1.8
<a href="#s4.1.8">REGISTER</a>
</li>

</ol>
</ol>
</li>
</li>
<li id="toc4.2">
4.2
<li id="toc4.2">4.2
<a href="#s4.2">Responses</a>
<a href="#s4.2">Responses</a>
<ol>
<li id="toc4.2.1">4.2.1
<a href="#s4.2.1">ERROR</a>
</li>
<li id="toc4.2.2">4.2.2
<a href="#s4.2.2">READY</a>
</li>
<li id="toc4.2.3">4.2.3
<a href="#s4.2.3">AUTHENTICATE</a>
</li>
<li id="toc4.2.4">4.2.4
<a href="#s4.2.4">SUPPORTED</a>
</li>
<li id="toc4.2.5">4.2.5
<a href="#s4.2.5">RESULT</a>
<ol>
<ol>
<li id="toc4.2.1">
<li id="toc4.2.5.1">4.2.5.1
4.2.1
<a href="#s4.2.5.1">Void</a>
<a href="#s4.2.1">ERROR</a>
</li>
</li>
<li id="toc4.2.2">
4.2.2
<li id="toc4.2.5.2">4.2.5.2
<a href="#s4.2.2">READY</a>
<a href="#s4.2.5.2">Rows</a>
</li>
<li id="toc4.2.3">
</li>
4.2.3
<a href="#s4.2.3">AUTHENTICATE</a>
<li id="toc4.2.5.3">4.2.5.3
</li>
<a href="#s4.2.5.3">Set_keyspace</a>
<li id="toc4.2.4">
4.2.4
</li>
<a href="#s4.2.4">SUPPORTED</a>
</li>
<li id="toc4.2.5.4">4.2.5.4
<li id="toc4.2.5">
<a href="#s4.2.5.4">Prepared</a>
4.2.5
<a href="#s4.2.5">RESULT</a>
</li>
<ol>
<li id="toc4.2.5.1">
<li id="toc4.2.5.5">4.2.5.5
4.2.5.1
<a href="#s4.2.5.5">Schema_change</a>
<a href="#s4.2.5.1">Void</a>
</li>
</li>
<li id="toc4.2.5.2">
4.2.5.2

<a href="#s4.2.5.2">Rows</a>
</ol>
</li>
<li id="toc4.2.5.3">
</li>
4.2.5.3
<a href="#s4.2.5.3">Set_keyspace</a>
<li id="toc4.2.6">4.2.6
</li>
<a href="#s4.2.6">EVENT</a>
<li id="toc4.2.5.4">
4.2.5.4
</li>
<a href="#s4.2.5.4">Prepared</a>
</li>
<li id="toc4.2.7">4.2.7
<li id="toc4.2.5.5">
<a href="#s4.2.7">AUTH_CHALLENGE</a>
4.2.5.5
<a href="#s4.2.5.5">Schema_change</a>
</li>
</li>
</ol>
<li id="toc4.2.8">4.2.8
</li>
<a href="#s4.2.8">AUTH_SUCCESS</a>
<li id="toc4.2.6">
4.2.6
</li>
<a href="#s4.2.6">EVENT</a>
</li>

<li id="toc4.2.7">
</ol>
4.2.7
<a href="#s4.2.7">AUTH_CHALLENGE</a>
</li>
</li>
<li id="toc4.2.8">

4.2.8
</ol>
<a href="#s4.2.8">AUTH_SUCCESS</a>
</li>
</li>
<li id="toc5">5
<a href="#s5">Compression</a>
</li>
<li id="toc6">6
<a href="#s6">Data Type Serialization Formats</a>
</li>
<li id="toc7">7
<a href="#s7">User Defined Type Serialization</a>
</li>
<li id="toc8">8
<a href="#s8">Result paging</a>
</li>
<li id="toc9">9
<a href="#s9">Error codes</a>
</li>
<li id="toc10">10
<a href="#s10">Changes from v3</a>
</li>

</ol>
</ol>
</nav>
</li>
</ol>
<h2 id="s"> </h2>
</li>
<pre></pre>
<li id="toc5">
5
<h2 id="s1">1 Overview</h2>
<a href="#s5">Compression</a>
<pre> The CQL binary protocol is a frame based protocol. Frames are defined as:
</li>
<li id="toc6">
6
<a href="#s6">Data Type Serialization Formats</a>
</li>
<li id="toc7">
7
<a href="#s7">User Defined Type Serialization</a>
</li>
<li id="toc8">
8
<a href="#s8">Result paging</a>
</li>
<li id="toc9">
9
<a href="#s9">Error codes</a>
</li>
<li id="toc10">
10
<a href="#s10">Changes from v3</a>
</li>
</ol>
</nav>
<h2 id="s1">1 Overview</h2>
<pre> The CQL binary protocol is a frame based protocol. Frames are defined as:


0 8 16 24 32 40
0 8 16 24 32 40
+---------+---------+---------+---------+---------+
+---------+---------+---------+---------+---------+
| version | flags | stream | opcode |
| version | flags | stream | opcode |
+---------+---------+---------+---------+---------+
+---------+---------+---------+---------+---------+
| length |
| length |
+---------+---------+---------+---------+
+---------+---------+---------+---------+
| |
| |
. ... body ... .
. ... body ... .
. .
. .
. .
. .
+----------------------------------------
+----------------------------------------


The protocol is big-endian (network byte order).
The protocol is big-endian (network byte order).


Each frame contains a fixed size header (9 bytes) followed by a variable size
Each frame contains a fixed size header (9 bytes) followed by a variable size
body. The header is described in <a href="#s2">Section 2</a>. The content of the body depends
body. The header is described in <a href="#s2">Section 2</a>. The content of the body depends
on the header opcode value (the body can in particular be empty for some
on the header opcode value (the body can in particular be empty for some
opcode values). The list of allowed opcodes is defined in <a href="#s2.4">Section 2.4</a> and the
opcode values). The list of allowed opcodes is defined in <a href="#s2.4">Section 2.4</a> and the
details of each corresponding message are described <a href="#s4">Section 4</a>.
details of each corresponding message are described <a href="#s4">Section 4</a>.


The protocol distinguishes two types of frames: requests and responses. Requests
The protocol distinguishes two types of frames: requests and responses. Requests
are those frames sent by the client to the server. Responses are those frames sent
are those frames sent by the client to the server. Responses are those frames sent
by the server to the client. Note, however, that the protocol supports server pushes
by the server to the client. Note, however, that the protocol supports server pushes
(events) so a response does not necessarily come right after a client request.
(events) so a response does not necessarily come right after a client request.


Note to client implementors: client libraries should always assume that the
Note to client implementors: client libraries should always assume that the
body of a given frame may contain more data than what is described in this
body of a given frame may contain more data than what is described in this
document. It will however always be safe to ignore the remainder of the frame
document. It will however always be safe to ignore the remainder of the frame
body in such cases. The reason is that this may enable extending the protocol
body in such cases. The reason is that this may enable extending the protocol
with optional features without needing to change the protocol version.
with optional features without needing to change the protocol version.




</pre>
</pre>
<h2 id="s2">2 Frame header</h2>
<h2 id="s2">2 Frame header</h2>
<pre></pre>
<pre></pre>
<h3 id="s2.1">2.1 version</h3>
<pre> The version is a single byte that indicates both the direction of the message
<h3 id="s2.1">2.1 version</h3>
<pre> The version is a single byte that indicates both the direction of the message
(request or response) and the version of the protocol in use. The most
(request or response) and the version of the protocol in use. The most
significant bit of version is used to define the direction of the message:
significant bit of version is used to define the direction of the message:
0 indicates a request, 1 indicates a response. This can be useful for protocol
0 indicates a request, 1 indicates a response. This can be useful for protocol
analyzers to distinguish the nature of the packet from the direction in which
analyzers to distinguish the nature of the packet from the direction in which
it is moving. The rest of that byte is the protocol version (4 for the protocol
it is moving. The rest of that byte is the protocol version (4 for the protocol
defined in this document). In other words, for this version of the protocol,
defined in this document). In other words, for this version of the protocol,
version will be one of:
version will be one of:
0x04 Request frame for this protocol version
0x04 Request frame for this protocol version
0x84 Response frame for this protocol version
0x84 Response frame for this protocol version


Please note that while every message ships with the version, only one version
Please note that while every message ships with the version, only one version
of messages is accepted on a given connection. In other words, the first message
of messages is accepted on a given connection. In other words, the first message
exchanged (STARTUP) sets the version for the connection for the lifetime of this
exchanged (STARTUP) sets the version for the connection for the lifetime of this
connection.
connection.


This document describes version 4 of the protocol. For the changes made since
This document describes version 4 of the protocol. For the changes made since
version 3, see <a href="#s10">Section 10</a>.
version 3, see <a href="#s10">Section 10</a>.


</pre>
</pre>
<h3 id="s2.2">2.2 flags</h3>
<h3 id="s2.2">2.2 flags</h3>
<pre> Flags applying to this frame. The flags have the following meaning (described
<pre> Flags applying to this frame. The flags have the following meaning (described
by the mask that allows selecting them):
by the mask that allows selecting them):
0x01: Compression flag. If set, the frame body is compressed. The actual
0x01: Compression flag. If set, the frame body is compressed. The actual
compression to use should have been set up beforehand through the
compression to use should have been set up beforehand through the
Startup message (which thus cannot be compressed; <a href="#s4.1.1">Section 4.1.1</a>).
Startup message (which thus cannot be compressed; <a href="#s4.1.1">Section 4.1.1</a>).
0x02: Tracing flag. For a request frame, this indicates the client requires
0x02: Tracing flag. For a request frame, this indicates the client requires
tracing of the request. Note that only QUERY, PREPARE and EXECUTE queries
tracing of the request. Note that only QUERY, PREPARE and EXECUTE queries
support tracing. Other requests will simply ignore the tracing flag if
support tracing. Other requests will simply ignore the tracing flag if
set. If a request supports tracing and the tracing flag is set, the response
set. If a request supports tracing and the tracing flag is set, the response
to this request will have the tracing flag set and contain tracing
to this request will have the tracing flag set and contain tracing
information.
information.
If a response frame has the tracing flag set, its body contains
If a response frame has the tracing flag set, its body contains
a tracing ID. The tracing ID is a [uuid] and is the first thing in
a tracing ID. The tracing ID is a [uuid] and is the first thing in
the frame body.
the frame body.
0x04: Custom payload flag. For a request or response frame, this indicates
0x04: Custom payload flag. For a request or response frame, this indicates
that a generic key-value custom payload for a custom QueryHandler
that a generic key-value custom payload for a custom QueryHandler
implementation is present in the frame. Such a custom payload is simply
implementation is present in the frame. Such a custom payload is simply
ignored by the default QueryHandler implementation.
ignored by the default QueryHandler implementation.
Currently, only QUERY, PREPARE, EXECUTE and BATCH requests support
Currently, only QUERY, PREPARE, EXECUTE and BATCH requests support
payload.
payload.
Type of custom payload is [bytes map] (see below). If either or both
Type of custom payload is [bytes map] (see below). If either or both
of the tracing and warning flags are set, the custom payload will follow
of the tracing and warning flags are set, the custom payload will follow
those indicated elements in the frame body. If neither are set, the custom
those indicated elements in the frame body. If neither are set, the custom
payload will be the first value in the frame body.
payload will be the first value in the frame body.
0x08: Warning flag. The response contains warnings which were generated by the
0x08: Warning flag. The response contains warnings which were generated by the
server to go along with this response.
server to go along with this response.
If a response frame has the warning flag set, its body will contain the
If a response frame has the warning flag set, its body will contain the
text of the warnings. The warnings are a [string list] and will be the
text of the warnings. The warnings are a [string list] and will be the
first value in the frame body if the tracing flag is not set, or directly
first value in the frame body if the tracing flag is not set, or directly
after the tracing ID if it is.
after the tracing ID if it is.


The rest of flags is currently unused and ignored.
The rest of flags is currently unused and ignored.
</pre>
</pre>
<h3 id="s2.3">2.3 stream</h3>
<h3 id="s2.3">2.3 stream</h3>
<pre> A frame has a stream id (a [short] value). When sending request messages, this
<pre> A frame has a stream id (a [short] value). When sending request messages, this
stream id must be set by the client to a non-negative value (negative stream id
stream id must be set by the client to a non-negative value (negative stream id
are reserved for streams initiated by the server; currently all EVENT messages
are reserved for streams initiated by the server; currently all EVENT messages
(<a href="#s4.2.6">section 4.2.6</a>) have a streamId of -1). If a client sends a request message
(<a href="#s4.2.6">section 4.2.6</a>) have a streamId of -1). If a client sends a request message
with the stream id X, it is guaranteed that the stream id of the response to
with the stream id X, it is guaranteed that the stream id of the response to
that message will be X.
that message will be X.


This helps to enable the asynchronous nature of the protocol. If a client
This helps to enable the asynchronous nature of the protocol. If a client
sends multiple messages simultaneously (without waiting for responses), there
sends multiple messages simultaneously (without waiting for responses), there
is no guarantee on the order of the responses. For instance, if the client
is no guarantee on the order of the responses. For instance, if the client
writes REQ_1, REQ_2, REQ_3 on the wire (in that order), the server might
writes REQ_1, REQ_2, REQ_3 on the wire (in that order), the server might
respond to REQ_3 (or REQ_2) first. Assigning different stream ids to these 3
respond to REQ_3 (or REQ_2) first. Assigning different stream ids to these 3
requests allows the client to distinguish to which request a received answer
requests allows the client to distinguish to which request a received answer
responds to. As there can only be 32768 different simultaneous streams, it is up
responds to. As there can only be 32768 different simultaneous streams, it is up
to the client to reuse stream id.
to the client to reuse stream id.


Note that clients are free to use the protocol synchronously (i.e. wait for
Note that clients are free to use the protocol synchronously (i.e. wait for
the response to REQ_N before sending REQ_N+1). In that case, the stream id
the response to REQ_N before sending REQ_N+1). In that case, the stream id
can be safely set to 0. Clients should also feel free to use only a subset of
can be safely set to 0. Clients should also feel free to use only a subset of
the 32768 maximum possible stream ids if it is simpler for its implementation.
the 32768 maximum possible stream ids if it is simpler for its implementation.
</pre>
</pre>
<h3 id="s2.4">2.4 opcode</h3>
<h3 id="s2.4">2.4 opcode</h3>
<pre> An integer byte that distinguishes the actual message:
<pre> An integer byte that distinguishes the actual message:
0x00 ERROR
0x00 ERROR
0x01 STARTUP
0x01 STARTUP
0x02 READY
0x02 READY
0x03 AUTHENTICATE
0x03 AUTHENTICATE
0x05 OPTIONS
0x05 OPTIONS
0x06 SUPPORTED
0x06 SUPPORTED
0x07 QUERY
0x07 QUERY
0x08 RESULT
0x08 RESULT
0x09 PREPARE
0x09 PREPARE
0x0A EXECUTE
0x0A EXECUTE
0x0B REGISTER
0x0B REGISTER
0x0C EVENT
0x0C EVENT
0x0D BATCH
0x0D BATCH
0x0E AUTH_CHALLENGE
0x0E AUTH_CHALLENGE
0x0F AUTH_RESPONSE
0x0F AUTH_RESPONSE
0x10 AUTH_SUCCESS
0x10 AUTH_SUCCESS


Messages are described in <a href="#s4">Section 4</a>.
Messages are described in <a href="#s4">Section 4</a>.


(Note that there is no 0x04 message in this version of the protocol)
(Note that there is no 0x04 message in this version of the protocol)


</pre>
</pre>
<h3 id="s2.5">2.5 length</h3>
<h3 id="s2.5">2.5 length</h3>
<pre> A 4 byte integer representing the length of the body of the frame (note:
<pre> A 4 byte integer representing the length of the body of the frame (note:
currently a frame is limited to 256MB in length).
currently a frame is limited to 256MB in length).


</pre>
</pre>
<h2 id="s3">3 Notations</h2>
<h2 id="s3">3 Notations</h2>
<pre> To describe the layout of the frame body for the messages in <a href="#s4">Section 4</a>, we
<pre> To describe the layout of the frame body for the messages in <a href="#s4">Section 4</a>, we
define the following:
define the following:


[int] A 4 bytes integer
[int] A 4 bytes integer
[long] A 8 bytes integer
[long] A 8 bytes integer
[short] A 2 bytes unsigned integer
[short] A 2 bytes unsigned integer
[string] A [short] n, followed by n bytes representing an UTF-8
[string] A [short] n, followed by n bytes representing an UTF-8
string.
string.
[long string] An [int] n, followed by n bytes representing an UTF-8 string.
[long string] An [int] n, followed by n bytes representing an UTF-8 string.
[uuid] A 16 bytes long uuid.
[uuid] A 16 bytes long uuid.
[string list] A [short] n, followed by n [string].
[string list] A [short] n, followed by n [string].
[bytes] A [int] n, followed by n bytes if n &gt;= 0. If n &lt; 0,
[bytes] A [int] n, followed by n bytes if n &gt;= 0. If n &lt; 0,
no byte should follow and the value represented is `null`.
no byte should follow and the value represented is `null`.
[value] A [int] n, followed by n bytes if n &gt;= 0.
[value] A [int] n, followed by n bytes if n &gt;= 0.
If n == -1 no byte should follow and the value represented is `null`.
If n == -1 no byte should follow and the value represented is `null`.
If n == -2 no byte should follow and the value represented is
If n == -2 no byte should follow and the value represented is
`not set` not resulting in any change to the existing value.
`not set` not resulting in any change to the existing value.
n &lt; -2 is an invalid value and results in an error.
n &lt; -2 is an invalid value and results in an error.
[short bytes] A [short] n, followed by n bytes if n &gt;= 0.
[short bytes] A [short] n, followed by n bytes if n &gt;= 0.


[option] A pair of &lt;id&gt;&lt;value&gt; where &lt;id&gt; is a [short] representing
[option] A pair of &lt;id&gt;&lt;value&gt; where &lt;id&gt; is a [short] representing
the option id and &lt;value&gt; depends on that option (and can be
the option id and &lt;value&gt; depends on that option (and can be
of size 0). The supported id (and the corresponding &lt;value&gt;)
of size 0). The supported id (and the corresponding &lt;value&gt;)
will be described when this is used.
will be described when this is used.
[option list] A [short] n, followed by n [option].
[option list] A [short] n, followed by n [option].
[inet] An address (ip and port) to a node. It consists of one
[inet] An address (ip and port) to a node. It consists of one
[byte] n, that represents the address size, followed by n
[byte] n, that represents the address size, followed by n
[byte] representing the IP address (in practice n can only be
[byte] representing the IP address (in practice n can only be
either 4 (IPv4) or 16 (IPv6)), following by one [int]
either 4 (IPv4) or 16 (IPv6)), following by one [int]
representing the port.
representing the port.
[consistency] A consistency level specification. This is a [short]
[consistency] A consistency level specification. This is a [short]
representing a consistency level with the following
representing a consistency level with the following
correspondence:
correspondence:
0x0000 ANY
0x0000 ANY
0x0001 ONE
0x0001 ONE
0x0002 TWO
0x0002 TWO
0x0003 THREE
0x0003 THREE
0x0004 QUORUM
0x0004 QUORUM
0x0005 ALL
0x0005 ALL
0x0006 LOCAL_QUORUM
0x0006 LOCAL_QUORUM
0x0007 EACH_QUORUM
0x0007 EACH_QUORUM
0x0008 SERIAL
0x0008 SERIAL
0x0009 LOCAL_SERIAL
0x0009 LOCAL_SERIAL
0x000A LOCAL_ONE
0x000A LOCAL_ONE


[string map] A [short] n, followed by n pair &lt;k&gt;&lt;v&gt; where &lt;k&gt; and &lt;v&gt;
[string map] A [short] n, followed by n pair &lt;k&gt;&lt;v&gt; where &lt;k&gt; and &lt;v&gt;
are [string].
are [string].
[string multimap] A [short] n, followed by n pair &lt;k&gt;&lt;v&gt; where &lt;k&gt; is a
[string multimap] A [short] n, followed by n pair &lt;k&gt;&lt;v&gt; where &lt;k&gt; is a
[string] and &lt;v&gt; is a [string list].
[string] and &lt;v&gt; is a [string list].
[bytes map] A [short] n, followed by n pair &lt;k&gt;&lt;v&gt; where &lt;k&gt; is a
[bytes map] A [short] n, followed by n pair &lt;k&gt;&lt;v&gt; where &lt;k&gt; is a
[string] and &lt;v&gt; is a [bytes].
[string] and &lt;v&gt; is a [bytes].


</pre>
</pre>
<h2 id="s4">4 Messages</h2>
<h2 id="s4">4 Messages</h2>
<pre> Dependant on the flags specified in the header, the layout of the message body must be:
<pre> Dependant on the flags specified in the header, the layout of the message body must be:
[&lt;tracing_id&gt;][&lt;warnings&gt;][&lt;custom_payload&gt;]&lt;message&gt;
[&lt;tracing_id&gt;][&lt;warnings&gt;][&lt;custom_payload&gt;]&lt;message&gt;
where:
where:
- &lt;tracing_id&gt; is a UUID tracing ID, present if this is a request message and the Tracing flag is set.
- &lt;tracing_id&gt; is a UUID tracing ID, present if this is a request message and the Tracing flag is set.
- &lt;warnings&gt; is a string list of warnings (if this is a request message and the Warning flag is set.
- &lt;warnings&gt; is a string list of warnings (if this is a request message and the Warning flag is set.
- &lt;custom_payload&gt; is bytes map for the serialised custom payload present if this is one of the message types
- &lt;custom_payload&gt; is bytes map for the serialised custom payload present if this is one of the message types
which support custom payloads (QUERY, PREPARE, EXECUTE and BATCH) and the Custom payload flag is set.
which support custom payloads (QUERY, PREPARE, EXECUTE and BATCH) and the Custom payload flag is set.
- &lt;message&gt; as defined below through sections <a href="#s4">4</a> and <a href="#s5">5</a>.
- &lt;message&gt; as defined below through sections <a href="#s4">4</a> and <a href="#s5">5</a>.
</pre>
</pre>
<h3 id="s4.1">4.1 Requests</h3>
<h3 id="s4.1">4.1 Requests</h3>
<pre> Note that outside of their normal responses (described below), all requests
<pre> Note that outside of their normal responses (described below), all requests
can get an ERROR message (<a href="#s4.2.1">Section 4.2.1</a>) as response.
can get an ERROR message (<a href="#s4.2.1">Section 4.2.1</a>) as response.
</pre>
</pre>
<h4 id="s4.1.1">4.1.1 STARTUP</h4>
<h4 id="s4.1.1">4.1.1 STARTUP</h4>
<pre> Initialize the connection. The server will respond by either a READY message
<pre> Initialize the connection. The server will respond by either a READY message
(in which case the connection is ready for queries) or an AUTHENTICATE message
(in which case the connection is ready for queries) or an AUTHENTICATE message
(in which case credentials will need to be provided using AUTH_RESPONSE).
(in which case credentials will need to be provided using AUTH_RESPONSE).


This must be the first message of the connection, except for OPTIONS that can
This must be the first message of the connection, except for OPTIONS that can
be sent before to find out the options supported by the server. Once the
be sent before to find out the options supported by the server. Once the
connection has been initialized, a client should not send any more STARTUP
connection has been initialized, a client should not send any more STARTUP
messages.
messages.


The body is a [string map] of options. Possible options are:
The body is a [string map] of options. Possible options are:
- &#34;CQL_VERSION&#34;: the version of CQL to use. This option is mandatory and
- &#34;CQL_VERSION&#34;: the version of CQL to use. This option is mandatory and
currently the only version supported is &#34;3.0.0&#34;. Note that this is
currently the only version supported is &#34;3.0.0&#34;. Note that this is
different from the protocol version.
different from the protocol version.
- &#34;COMPRESSION&#34;: the compression algorithm to use for frames (See <a href="#s5">section 5</a>).
- &#34;COMPRESSION&#34;: the compression algorithm to use for frames (See <a href="#s5">section 5</a>).
This is optional; if not specified no compression will be used.
This is optional; if not specified no compression will be used.
- &#34;NO_COMPACT&#34;: whether or not connection has to be established in compatibility
- &#34;NO_COMPACT&#34;: whether or not connection has to be established in compatibility
mode. This mode will make all Thrift and Compact Tables to be exposed as if
mode. This mode will make all Thrift and Compact Tables to be exposed as if
they were CQL Tables. This is optional; if not specified, the option will
they were CQL Tables. This is optional; if not specified, the option will
not be used.
not be used.
- &#34;THROW_ON_OVERLOAD&#34;: In case of server overloaded with too many requests, by default the server puts
- &#34;THROW_ON_OVERLOAD&#34;: In case of server overloaded with too many requests, by default the server puts
back pressure on the client connection. Instead, the server can send an OverloadedException error message back to
back pressure on the client connection. Instead, the server can send an OverloadedException error message back to
the client if this option is set to true.
the client if this option is set to true.


</pre>
</pre>
<h4 id="s4.1.2">4.1.2 AUTH_RESPONSE</h4>
<h4 id="s4.1.2">4.1.2 AUTH_RESPONSE</h4>
<pre> Answers a server authentication challenge.
<pre> Answers a server authentication challenge.


Authentication in the protocol is SASL based. The server sends authentication
Authentication in the protocol is SASL based. The server sends authentication
challenges (a bytes token) to which the client answers with this message. Those
challenges (a bytes token) to which the client answers with this message. Those
exchanges continue until the server accepts the authentication by sending a
exchanges continue until the server accepts the authentication by sending a
AUTH_SUCCESS message after a client AUTH_RESPONSE. Note that the exchange
AUTH_SUCCESS message after a client AUTH_RESPONSE. Note that the exchange
begins with the client sending an initial AUTH_RESPONSE in response to a
begins with the client sending an initial AUTH_RESPONSE in response to a
server AUTHENTICATE request.
server AUTHENTICATE request.


The body of this message is a single [bytes] token. The details of what this
The body of this message is a single [bytes] token. The details of what this
token contains (and when it can be null/empty, if ever) depends on the actual
token contains (and when it can be null/empty, if ever) depends on the actual
authenticator used.
authenticator used.


The response to a AUTH_RESPONSE is either a follow-up AUTH_CHALLENGE message,
The response to a AUTH_RESPONSE is either a follow-up AUTH_CHALLENGE message,
an AUTH_SUCCESS message or an ERROR message.
an AUTH_SUCCESS message or an ERROR message.


</pre>
</pre>
<h4 id="s4.1.3">4.1.3 OPTIONS</h4>
<h4 id="s4.1.3">4.1.3 OPTIONS</h4>
<pre> Asks the server to return which STARTUP options are supported. The body of an
<pre> Asks the server to return which STARTUP options are supported. The body of an
OPTIONS message should be empty and the server will respond with a SUPPORTED
OPTIONS message should be empty and the server will respond with a SUPPORTED
message.
message.


</pre>
</pre>
<h4 id="s4.1.4">4.1.4 QUERY</h4>
<h4 id="s4.1.4">4.1.4 QUERY</h4>
<pre> Performs a CQL query. The body of the message must be:
<pre> Performs a CQL query. The body of the message must be:
&lt;query&gt;&lt;query_parameters&gt;
&lt;query&gt;&lt;query_parameters&gt;
where &lt;query&gt; is a [long string] representing the query and
where &lt;query&gt; is a [long string] representing the query and
&lt;query_parameters&gt; must be
&lt;query_parameters&gt; must be
&lt;consistency&gt;&lt;flags&gt;[&lt;n&gt;[name_1]&lt;value_1&gt;...[name_n]&lt;value_n&gt;][&lt;result_page_size&gt;][&lt;paging_state&gt;][&lt;serial_consistency&gt;][&lt;timestamp&gt;]
&lt;consistency&gt;&lt;flags&gt;[&lt;n&gt;[name_1]&lt;value_1&gt;...[name_n]&lt;value_n&gt;][&lt;result_page_size&gt;][&lt;paging_state&gt;][&lt;serial_consistency&gt;][&lt;timestamp&gt;]
where:
where:
- &lt;consistency&gt; is the [consistency] level for the operation.
- &lt;consistency&gt; is the [consistency] level for the operation.
- &lt;flags&gt; is a [byte] whose bits define the options for this query and
- &lt;flags&gt; is a [byte] whose bits define the options for this query and
in particular influence what the remainder of the message contains.
in particular influence what the remainder of the message contains.
A flag is set if the bit corresponding to its `mask` is set. Supported
A flag is set if the bit corresponding to its `mask` is set. Supported
flags are, given their mask:
flags are, given their mask:
0x01: Values. If set, a [short] &lt;n&gt; followed by &lt;n&gt; [value]
0x01: Values. If set, a [short] &lt;n&gt; followed by &lt;n&gt; [value]
values are provided. Those values are used for bound variables in
values are provided. Those values are used for bound variables in
the query. Optionally, if the 0x40 flag is present, each value
the query. Optionally, if the 0x40 flag is present, each value
will be preceded by a [string] name, representing the name of
will be preceded by a [string] name, representing the name of
the marker the value must be bound to.
the marker the value must be bound to.
0x02: Skip_metadata. If set, the Result Set returned as a response
0x02: Skip_metadata. If set, the Result Set returned as a response
to the query (if any) will have the NO_METADATA flag (see
to the query (if any) will have the NO_METADATA flag (see
<a href="#s4.2.5.2">Section 4.2.5.2</a>).
<a href="#s4.2.5.2">Section 4.2.5.2</a>).
0x04: Page_size. If set, &lt;result_page_size&gt; is an [int]
0x04: Page_size. If set, &lt;result_page_size&gt; is an [int]
controlling the desired page size of the result (in CQL3 rows).
controlling the desired page size of the result (in CQL3 rows).
See the section on paging (<a href="#s8">Section 8</a>) for more details.
See the section on paging (<a href="#s8">Section 8</a>) for more details.
0x08: With_paging_state. If set, &lt;paging_state&gt; should be present.
0x08: With_paging_state. If set, &lt;paging_state&gt; should be present.
&lt;paging_state&gt; is a [bytes] value that should have been returned
&lt;paging_state&gt; is a [bytes] value that should have been returned
in a result set (<a href="#s4.2.5.2">Section 4.2.5.2</a>). The query will be
in a result set (<a href="#s4.2.5.2">Section 4.2.5.2</a>). The query will be
executed but starting from a given paging state. This is also to
executed but starting from a given paging state. This is also to
continue paging on a different node than the one where it
continue paging on a different node than the one where it
started (See <a href="#s8">Section 8</a> for more details).
started (See <a href="#s8">Section 8</a> for more details).
0x10: With serial consistency. If set, &lt;serial_consistency&gt; should be
0x10: With serial consistency. If set, &lt;serial_consistency&gt; should be
present. &lt;serial_consistency&gt; is the [consistency] level for the
present. &lt;serial_consistency&gt; is the [consistency] level for the
serial phase of conditional updates. Consistency can be
serial phase of conditional updates. Consistency can be
SERIAL or LOCAL_SERIAL, if not present, it defaults to
SERIAL or LOCAL_SERIAL, if not present, it defaults to
SERIAL. This option will be ignored for anything else other than a
SERIAL. This option will be ignored for anything else other than a
conditional update/insert.
conditional update/insert.
0x20: With default timestamp. If set, &lt;timestamp&gt; should be present.
0x20: With default timestamp. If set, &lt;timestamp&gt; should be present.
&lt;timestamp&gt; is a [long] representing the default timestamp for the query
&lt;timestamp&gt; is a [long] representing the default timestamp for the query
in microseconds (negative values are forbidden). This will
in microseconds (negative values are forbidden). This will
replace the server side assigned timestamp as default timestamp.
replace the server side assigned timestamp as default timestamp.
Note that a timestamp in the query itself will still override
Note that a timestamp in the query itself will still override
this timestamp. This is entirely optional.
this timestamp. This is entirely optional.
0x40: With names for values. This only makes sense if the 0x01 flag is set and
0x40: With names for values. This only makes sense if the 0x01 flag is set and
is ignored otherwise. If present, the values from the 0x01 flag will
is ignored otherwise. If present, the values from the 0x01 flag will
be preceded by a name (see above). Note that this is only useful for
be preceded by a name (see above). Note that this is only useful for
QUERY requests where named bind markers are used; for EXECUTE statements,
QUERY requests where named bind markers are used; for EXECUTE statements,
since the names for the expected values was returned during preparation,
since the names for the expected values was returned during preparation,
a client can always provide values in the right order without any names
a client can always provide values in the right order without any names
and using this flag, while supported, is almost surely inefficient.
and using this flag, while supported, is almost surely inefficient.


Note that the consistency is ignored by some queries (USE, CREATE, ALTER,
Note that the consistency is ignored by some queries (USE, CREATE, ALTER,
TRUNCATE, ...).
TRUNCATE, ...).


The server will respond to a QUERY message with a RESULT message, the content
The server will respond to a QUERY message with a RESULT message, the content
of which depends on the query.
of which depends on the query.


</pre>
</pre>
<h4 id="s4.1.5">4.1.5 PREPARE</h4>
<h4 id="s4.1.5">4.1.5 PREPARE</h4>
<pre> Prepare a query for later execution (through EXECUTE). The body consists of
<pre> Prepare a query for later execution (through EXECUTE). The body consists of
the CQL query to prepare as a [long string].
the CQL query to prepare as a [long string].


The server will respond with a RESULT message with a `prepared` kind (0x0004,
The server will respond with a RESULT message with a `prepared` kind (0x0004,
see <a href="#s4.2.5">Section 4.2.5</a>).
see <a href="#s4.2.5">Section 4.2.5</a>).


</pre>
</pre>
<h4 id="s4.1.6">4.1.6 EXECUTE</h4>
<h4 id="s4.1.6">4.1.6 EXECUTE</h4>
<pre> Executes a prepared query. The body of the message must be:
<pre> Executes a prepared query. The body of the message must be:
&lt;id&gt;&lt;query_parameters&gt;
&lt;id&gt;&lt;query_parameters&gt;
where &lt;id&gt; is the prepared query ID. It&#39;s the [short bytes] returned as a
where &lt;id&gt; is the prepared query ID. It&#39;s the [short bytes] returned as a
response to a PREPARE message. As for &lt;query_parameters&gt;, it has the exact
response to a PREPARE message. As for &lt;query_parameters&gt;, it has the exact
same definition as in QUERY (see <a href="#s4.1.4">Section 4.1.4</a>).
same definition as in QUERY (see <a href="#s4.1.4">Section 4.1.4</a>).


The response from the server will be a RESULT message.
The response from the server will be a RESULT message.


</pre>
</pre>
<h4 id="s4.1.7">4.1.7 BATCH</h4>
<h4 id="s4.1.7">4.1.7 BATCH</h4>
<pre> Allows executing a list of queries (prepared or not) as a batch (note that
<pre> Allows executing a list of queries (prepared or not) as a batch (note that
only DML statements are accepted in a batch). The body of the message must
only DML statements are accepted in a batch). The body of the message must
be:
be:
&lt;type&gt;&lt;n&gt;&lt;query_1&gt;...&lt;query_n&gt;&lt;consistency&gt;&lt;flags&gt;[&lt;serial_consistency&gt;][&lt;timestamp&gt;]
&lt;type&gt;&lt;n&gt;&lt;query_1&gt;...&lt;query_n&gt;&lt;consistency&gt;&lt;flags&gt;[&lt;serial_consistency&gt;][&lt;timestamp&gt;]
where:
where:
- &lt;type&gt; is a [byte] indicating the type of batch to use:
- &lt;type&gt; is a [byte] indicating the type of batch to use:
- If &lt;type&gt; == 0, the batch will be &#34;logged&#34;. This is equivalent to a
- If &lt;type&gt; == 0, the batch will be &#34;logged&#34;. This is equivalent to a
normal CQL3 batch statement.
normal CQL3 batch statement.
- If &lt;type&gt; == 1, the batch will be &#34;unlogged&#34;.
- If &lt;type&gt; == 1, the batch will be &#34;unlogged&#34;.
- If &lt;type&gt; == 2, the batch will be a &#34;counter&#34; batch (and non-counter
- If &lt;type&gt; == 2, the batch will be a &#34;counter&#34; batch (and non-counter
statements will be rejected).
- &lt;flags&gt; is a [byte] whose bits define the options for this query and
in particular influence what the remainder of the message contains. It is similar
to the &lt;flags&gt; from QUERY and EXECUTE methods, except that the 4 rightmost
bits must always be 0 as their corresponding options do not make sense for
Batch. A flag is set if the bit corresponding to its `mask` is set. Supported
flags are, given their mask:
0x10: With serial consistency. If set, &lt;serial_consistency&gt; should be
present. &lt;serial_consistency&gt; is the [consistency] level for the