~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to docs/protocol.rst

  • Committer: Monty Taylor
  • Date: 2010-09-26 21:24:15 UTC
  • mto: (1796.1.2 build)
  • mto: This revision was merged to the branch mainline in revision 1797.
  • Revision ID: mordred@inaugust.com-20100926212415-5fn3p3q75pgiei7r
Moved protocol doc into the docs.

Show diffs side-by-side

added added

removed removed

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