native_protocol_v3.html-diff

作成日 差分は期限切れになりません
340 削除
626
176 追加
546
<!DOCTYPE html>
<!DOCTYPE html>
<html>
<html>
<head>
<head>
<title>CQL BINARY PROTOCOL v3</title>
<meta charset="utf-8">
<style>
<title>CQL BINARY PROTOCOL v3</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 v3</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 v3</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 v2</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 v2</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 opcode is defined <a href="#s2.4">Section 2.4</a> and the
opcode values). The list of allowed opcode is defined <a href="#s2.4">Section 2.4</a> and the
details of each corresponding message is described <a href="#s4">Section 4</a>.
details of each corresponding message is described <a href="#s4">Section 4</a>.


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


Note to client implementors: clients library should always assume that the
Note to client implementors: clients library 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 remaining of the frame
document. It will however always be safe to ignore the remaining of the frame
body in such cases. The reason is that this may allow to sometimes extend the
body in such cases. The reason is that this may allow to sometimes extend the
protocol with optional features without needing to change the protocol
protocol with optional features without needing to change the protocol
version.
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 indicate both the direction of the message
<h3 id="s2.1">2.1 version</h3>
<pre> The version is a single byte that indicate both the direction of the message
(request or response) and the version of the protocol in use. The up-most bit
(request or response) and the version of the protocol in use. The up-most bit
of version is used to define the direction of the message: 0 indicates a
of version is used to define the direction of the message: 0 indicates a
request, 1 indicates a responses. This can be useful for protocol analyzers to
request, 1 indicates a responses. This can be useful for protocol analyzers to
distinguish the nature of the packet from the direction which it is moving.
distinguish the nature of the packet from the direction which it is moving.
The rest of that byte is the protocol version (3 for the protocol defined in
The rest of that byte is the protocol version (3 for the protocol defined in
this document). In other words, for this version of the protocol, version will
this document). In other words, for this version of the protocol, version will
have one of:
have one of:
0x03 Request frame for this protocol version
0x03 Request frame for this protocol version
0x83 Response frame for this protocol version
0x83 Response frame for this protocol version


Please note that the while every message ship with the version, only one version
Please note that the while every message ship 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 describe the version 3 of the protocol. For the changes made since
This document describe the version 3 of the protocol. For the changes made since
version 2, see <a href="#s10">Section 10</a>.
version 2, 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 allow to select them):
by the mask that allow to select 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 indicate the client requires
0x02: Tracing flag. For a request frame, this indicate the client requires
tracing of the request. Note that not all requests support tracing.
tracing of the request. Note that not all requests support tracing.
Currently, only QUERY, PREPARE and EXECUTE queries support tracing.
Currently, only QUERY, PREPARE and EXECUTE queries support tracing.
Other requests will simply ignore the tracing flag if set. If a
Other requests will simply ignore the tracing flag if set. If a
request support tracing and the tracing flag was set, the response to
request support tracing and the tracing flag was set, the response to
this request will have the tracing flag set and contain tracing
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 rest of the body will then be the usual body
the frame body. The rest of the body will then be the usual body
corresponding to the response opcode.
corresponding to the response opcode.


The rest of the flags is currently unused and ignored.
The rest of the 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 allow to deal with the asynchronous nature of the protocol. If a client
This allow to deal with 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 id to these 3
respond to REQ_3 (or REQ_2) first. Assigning different stream id to these 3
requests allows the client to distinguish to which request an received answer
requests allows the client to distinguish to which request an received answer
respond to. As there can only be 32768 different simultaneous streams, it is up
respond 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 those
the 32768 maximum possible stream ids if it is simpler for those
implementation.
implementation.
</pre>
</pre>
<h3 id="s2.4">2.4 opcode</h3>
<h3 id="s2.4">2.4 opcode</h3>
<pre> An integer byte that distinguish the actual message:
<pre> An integer byte that distinguish 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 signed integer
[int] A 4 bytes signed integer
[long] A 8 bytes signed integer
[long] A 8 bytes signed 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`.
[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].


</pre>
</pre>
<h2 id="s4">4 Messages</h2>
<h2 id="s4">4 Messages</h2>
<pre></pre>
<pre></pre>
<h3 id="s4.1">4.1 Requests</h3>
<pre> Note that outside of their normal responses (described below), all requests
<h3 id="s4.1">4.1 Requests</h3>
<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
message.
message.


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.


</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 answer with this message. Those
challenges (a bytes token) to which the client answer 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. It is however that client that
AUTH_SUCCESS message after a client AUTH_RESPONSE. It is however that client that
initiate the exchange by sending an initial AUTH_RESPONSE in response to a
initiate the exchange by 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 what STARTUP options are supported. The body of an
<pre> Asks the server to return what 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 there mask:
flags are, given there mask:
0x01: Values. In that case, a [short] &lt;n&gt; followed by &lt;n&gt; [bytes]
0x01: Values. In that case, a [short] &lt;n&gt; followed by &lt;n&gt; [bytes]
values are provided. Those value are used for bound variables in
values are provided. Those value 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. This is optional, and
the marker the value must be bound to. This is optional, and
if not present, values will be bound by position.
if not present, values will be bound by position.
0x02: Skip_metadata. If present, the Result Set returned as a response
0x02: Skip_metadata. If present, the Result Set returned as a response
to that query (if any) will have the NO_METADATA flag (see
to that 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. In that case, &lt;result_page_size&gt; is an [int]
0x04: Page_size. In that case, &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 present, &lt;paging_state&gt; should be present.
0x08: With_paging_state. If present, &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>). If provided, the query will be
in a result set (<a href="#s4.2.5.2">Section 4.2.5.2</a>). If provided, the query will be
executed but starting from a given paging state. This also to
executed but starting from a given paging state. This also to
continue paging on a different node from the one it has been
continue paging on a different node from the one it has been
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 present, &lt;serial_consistency&gt; should be
0x10: With serial consistency. If present, &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
either SERIAL or LOCAL_SERIAL, if not present, it defaults to
either SERIAL or LOCAL_SERIAL, if not present, it defaults to
SERIAL. This option will be ignored for anything else that a
SERIAL. This option will be ignored for anything else that a
conditional update/insert.
conditional update/insert.
0x20: With default timestamp. If present, &lt;timestamp&gt; should be present.
0x20: With default timestamp. If present, &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 discouraged but supported for
in microseconds (negative values are discouraged but supported for
backward compatibility reasons except for the smallest negative
backward compatibility reasons except for the smallest negative
value (-2^63) that is forbidden). If provided, this will
value (-2^63) that is forbidden). If provided, 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 than in QUERY (see <a href="#s4.1.4">Section 4.1.4</a>).
same definition than 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).
statements will be rejected).
- &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 the remainder of the message contains. It is similar
in particular influence the remainder of the message contains. It is similar
to the &lt;flags&gt; from QUERY and EXECUTE methods, except that the 4 rightmost
to the &lt;flags&gt; from QUERY and EXECUTE methods, except that the 4 rightmost
bits must always be 0 as their corresponding option do not make sense for
bits must always be 0 as their corresponding option do not make sense for
Batch. A flag is set if the bit corresponding to its `mask` is set. Supported
Batch. A flag is set if the bit corresponding to its `mask` is set. Supported
flags are, given there mask:
flags are, given there mask:
0x10: With serial consistency. If present, &lt;serial_consistency&gt; should be
0x10: With serial consistency. If present, &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
either SERIAL or LOCAL_SERIAL, if not present, it defaults to
either SERIAL or LOCAL_SERIAL, if not present, it defaults to
SERIAL. This option will be ignored for anything else that a
SERIAL. This option will be ignored for anything else that a
conditional update/insert.
conditional update/insert.
0x20: With default timestamp. If present, &lt;timestamp&gt; should be present.
0x20: With default timestamp. If present, &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. If provided, this will replace the server side assigned
in microseconds. If provided, this will replace the server side assigned
timestamp as default timestamp. Note that a timestamp in the query itself
timestamp as default timestamp. Note that a timestamp in the query itself
will still override this timestamp. This is entirely optional.
will still override this timestamp. This is entirely optional.
0x40: With names for values. If set, then all values for all &lt;query_i&gt; must be
0x40: With names for values. If set, then all values for all &lt;query_i&gt; must be
preceded by a [string] &lt;name_i&gt; that have the same meaning as in QUERY
preceded by a [string] &lt;name_i&gt; that have the same meaning as in QUERY
requests [IMPORTANT NOTE: this feature does not work and should not be
requests [IMPORTANT NOTE: this feature does not work and should not be
used. It is specified in a way that makes it impossible for the server
used. It is specified in a way that makes it impossible for the server
to implement. This will be fixed in a future version of the native
to implement. This will be fixed in a future version of the native
protocol. See <a href="https://issues.apache.org/jira/browse/CASSANDRA-10246">https://issues.apache.org/jira/browse/CASSANDRA-10246</a> for
protocol. See <a href="https://issues.apache.org/jira/browse/CASSANDRA-10246">https://issues.apache.org/jira/browse/CASSANDRA-10246</a> for
more details].
more details].
- &lt;n&gt; is a [short] indicating the number of following queries.
- &lt;n&gt; is a [short] indicating the number of following queries.
- &lt;query_1&gt;...&lt;query_n&gt; are the queries to execute. A &lt;query_i&gt; must be of the
- &lt;query_1&gt;...&lt;query_n&gt; are the queries to execute. A &lt;query_i&gt; must be of the
form:
form:
&lt;kind&gt;&lt;string_or_id&gt;&lt;n&gt;[&lt;name_1&gt;]&lt;value_1&gt;...[&lt;name_n&gt;]&lt;value_n&gt;
&lt;kind&gt;&lt;string_or_id&gt;&lt;n&gt;[&lt;name_1&gt;]&lt;value_1&gt;...[&lt;name_n&gt;]&lt;value_n&gt;
where:
where:
- &lt;kind&gt; is a [byte] indicating whether the following query is a prepared
- &lt;kind&gt; is a [byte] indicating whether the following query is a prepared
one or not. &lt;kind&gt; value must be either 0 or 1.
one or not. &lt;kind&gt; value must be either 0 or 1.
- &lt;string_or_id&gt; depends on the value of &lt;kind&gt;. If &lt;kind&gt; == 0, it should be
- &lt;string_or_id&gt; depends on the value of &lt;kind&gt;. If &lt;kind&gt; ==
a [long string] query string (as in QUERY, the query string might contain
bind markers). Otherwise (that is, if &lt;kind&gt; == 1), it should be a
[short bytes] representing a prepared query ID.
- &lt;n&gt; is a [short] indicating the number (possibly 0) of following values.
- &lt;name_i&gt; is the optional name of the following &lt;value_i&gt;. It must be present
if and only if the 0x40 flag is provided for the batch.
- &lt;value_i&gt; is the [bytes] to use for bound variable i (of bound variable &lt;name_i&gt;
if the 0x40 flag is used).
- &lt;consistency&gt; is the [con