1
.. Drizzle Client & Protocol Library
2
# Drizzle Client & Protocol Library
4
# Copyright (C) 2008 Eric Day (eday@oddments.org)
7
# Use and distribution licensed under the BSD license. See
8
# the COPYING file in this directory for full text.
3
.. Copyright (C) 2008 Eric Day (eday@oddments.org)
4
.. All rights reserved.
6
.. Use and distribution licensed under the BSD license. See
7
.. the COPYING.BSD file in the root source directory for full text.
11
STATUS: This is currently a proposed draft as of November 29, 2008
12
`This is currently a proposed draft as of November 29, 2008`
14
16
The Drizzle protocol works over TCP, UDP, and Unix Domain Sockets
15
17
(UDS, also known as IPC sockets), although there are limitations when
127
129
to be aborted gracefully (without having to close the connection)
128
130
in the event of an error.
130
+-------------------------------------------------------------------------+
132
+-------------------------------------------------------------------------+
134
+-----+----------------+----------------+---------------------------------+
135
| 0 | Magic | Protocol | Command ID |
136
+-----+----------------+----------------+---------------------------------+
138
+-----+---------------------------------+---------------------------------+
139
| 32 | Command / Result Code | Client ID Length |
140
+-----+---------------------------------+---------------------------------+
142
+-----+---------------------------------+---------------------------------+
143
| 64 | Client ID (optional, variable length) |
144
+-----+---------------------------------+---------------------------------+
146
+-----+---------------------------------+---------------------------------+
147
| 64+ | Chunk Length and Value Pairs (optional, variable length) |
148
+-----+---------------------------------+---------------------------------+
150
+-----+---------------------------------+---------------------------------+
151
+ 64+ | Chunk Length = 0 | |
152
+-----+---------------------------------+---------------------------------+
154
+-----+---------------------------------+---------------------------------+
156
+-----+---------------------------------+---------------------------------+
132
|----------------------------- 32 Bits -----------------------------|
134
|----------------|----------------|---------------------------------|
135
0 | Magic | Protocol | Command ID |
136
|----------------|----------------|---------------------------------|
137
32 | Command / Result Code | Client ID Length |
138
|---------------------------------|---------------------------------|
139
64 | Client ID (optional, variable length) |
140
|---------------------------------|---------------------------------|
141
64+ | Chunk Length and Value Pairs (optional, variable length) |
142
|---------------------------------|---------------------------------|
143
64+ | Chunk Length = 0 |
144
|---------------------------------|---------------------------------|
146
|-------------------------------------------------------------------|
158
148
The first part of a packet is:
171
161
2-byte Command/result code. For commands, this may be:
174
The entire packet is simply echoed back to the caller.
176
Set protocol options.
180
Same as QUERY, but hints that this is a read-only
181
query. This is only useful for routers/proxies who may want
182
to redirect the request to a read slave.
163
1 ECHO - The entire packet is simply echoed back to the caller.
164
2 SET - Set protocol options.
165
3 QUERY - Execute query.
166
4 QUERY_RO - Same as QUERY, but hints that this is a read-only
167
query. This is only useful for routers/proxies who may want
168
to redirect the request to a read slave.
184
170
Result codes may be:
187
Single packet success response. No data associated
188
with the result besides parameters.
190
Single packet error response.
192
Start of a multi-packet result set.
194
Mark the end of a series of data packets. This is
195
useful so a low level router or proxy can know when a
196
response is complete without inspecting the contents of
172
1 OK - Single packet success response. No data associated
173
with the result besides parameters.
174
2 ERROR - Single packet error response.
175
3 DATA - Start of a multi-packet result set.
176
3 DATA_END - Mark the end of a series of data packets. This is
177
useful so a low level router or proxy can know when a
178
response is complete without inspecting the contents of
199
181
2-byte Client ID length.
200
X-byte Client ID (length is value of client ID length).
201
The client ID is there for the client and routers/proxies to use. The server
202
treats this as opaque data, and will only preserve it to send
203
in responses. This can be used as a sharding key, to keep
204
state information in a proxy, or any other use.
182
X-byte Client ID (length is value of client ID length). The client ID is
183
there for the client and routers/proxies to use. The server
184
treats this as opaque data, and will only preserve it to send
185
in responses. This can be used as a sharding key, to keep
186
state information in a proxy, or any other use.
206
188
Next, zero or more chunks are given, terminated by a chunk length of
207
189
0. Each chunk consist of a length and then that amount of data.