Commit 58eb5c0
committed
psql-srv: Appropriately return EmptyQueryResponse message
When a PostgreSQL client sends an empty query over the wire protocol,
the appropriate response is to send an EmptyQueryResponse message in
reply. This is different from the CommandComplete message, which is the
standard reply for regular queries.
Our usage of our fork of tokio_postgres elides a copy during standard
query processing by directly accessing the CommandComplete message
buffer, which is populated by tokio_postgres when Readyset runs queries
on an upstream PostgreSQL database. Unfortunately, tokio_postgres
returns a CommandComplete message for an empty query run on the
upstream, even though the upstream replied with an EmptyQueryResponse
message. Fortunately, however, we don't have to forward all
CommandComplete messages we process from tokio_postgres back to our
client.
Now, we selectively detect when tokio_postgres produces a
CommandComplete message that is semantically equivalent to an
EmptyQueryResponse, and then we send back an EmptyQueryResponse message
to our client.
This patch brings our behavior a little more into alignment with the
PostgreSQL wire protocol, allowing us to be a little more compatible
with applications that expect to receive an EmptyQueryResponse in reply
to an empty query.
Also add some flushes to related tests, as I experienced some flakiness
there with the stream not being processed before the test functions
exited.
Fixes: REA-5385
Release-Note-Core: Improve PostgreSQL wire protocol compatibility by
appropriately responding to an empty query with an EmptyQueryResponse
message.
Change-Id: Ib24aa57f9f38663946feefee52e6c862d1f9daf3
Reviewed-on: https://gerrit.readyset.name/c/readyset/+/8898
Reviewed-by: Jason Brown <jason.b@readyset.io>
Tested-by: Buildkite CI1 parent 9c0e0b4 commit 58eb5c0
3 files changed
+37
-31
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
| |||
107 | 108 | | |
108 | 109 | | |
109 | 110 | | |
110 | | - | |
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
| |||
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
123 | | - | |
124 | 123 | | |
125 | 124 | | |
126 | 125 | | |
127 | 126 | | |
128 | 127 | | |
129 | 128 | | |
130 | | - | |
131 | 129 | | |
132 | 130 | | |
133 | 131 | | |
134 | 132 | | |
135 | 133 | | |
136 | 134 | | |
137 | | - | |
138 | 135 | | |
139 | 136 | | |
140 | 137 | | |
141 | 138 | | |
142 | 139 | | |
143 | | - | |
144 | 140 | | |
145 | 141 | | |
146 | 142 | | |
147 | 143 | | |
148 | | - | |
149 | 144 | | |
150 | 145 | | |
151 | 146 | | |
152 | 147 | | |
153 | | - | |
154 | 148 | | |
155 | 149 | | |
156 | 150 | | |
| |||
192 | 186 | | |
193 | 187 | | |
194 | 188 | | |
195 | | - | |
196 | 189 | | |
197 | 190 | | |
198 | 191 | | |
199 | 192 | | |
200 | 193 | | |
201 | 194 | | |
202 | | - | |
203 | 195 | | |
204 | 196 | | |
205 | 197 | | |
| |||
229 | 221 | | |
230 | 222 | | |
231 | 223 | | |
232 | | - | |
233 | 224 | | |
234 | 225 | | |
235 | 226 | | |
236 | 227 | | |
237 | | - | |
238 | 228 | | |
239 | 229 | | |
240 | 230 | | |
| |||
246 | 236 | | |
247 | 237 | | |
248 | 238 | | |
249 | | - | |
250 | 239 | | |
251 | 240 | | |
252 | 241 | | |
| |||
261 | 250 | | |
262 | 251 | | |
263 | 252 | | |
264 | | - | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
265 | 257 | | |
266 | 258 | | |
267 | 259 | | |
| |||
354 | 346 | | |
355 | 347 | | |
356 | 348 | | |
357 | | - | |
358 | 349 | | |
359 | 350 | | |
360 | 351 | | |
| |||
365 | 356 | | |
366 | 357 | | |
367 | 358 | | |
368 | | - | |
369 | 359 | | |
370 | 360 | | |
371 | 361 | | |
| |||
375 | 365 | | |
376 | 366 | | |
377 | 367 | | |
378 | | - | |
379 | 368 | | |
380 | 369 | | |
381 | 370 | | |
382 | 371 | | |
383 | | - | |
384 | 372 | | |
385 | 373 | | |
386 | 374 | | |
387 | 375 | | |
388 | 376 | | |
389 | | - | |
390 | 377 | | |
391 | 378 | | |
392 | 379 | | |
| |||
401 | 388 | | |
402 | 389 | | |
403 | 390 | | |
404 | | - | |
405 | 391 | | |
406 | 392 | | |
407 | 393 | | |
| |||
416 | 402 | | |
417 | 403 | | |
418 | 404 | | |
419 | | - | |
420 | 405 | | |
421 | 406 | | |
422 | 407 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
| 59 | + | |
59 | 60 | | |
60 | 61 | | |
61 | 62 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
74 | | - | |
| 74 | + | |
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
| |||
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
116 | 129 | | |
117 | 130 | | |
118 | 131 | | |
| |||
127 | 140 | | |
128 | 141 | | |
129 | 142 | | |
130 | | - | |
| 143 | + | |
131 | 144 | | |
132 | 145 | | |
133 | 146 | | |
| |||
137 | 150 | | |
138 | 151 | | |
139 | 152 | | |
140 | | - | |
| 153 | + | |
141 | 154 | | |
142 | 155 | | |
143 | 156 | | |
| |||
161 | 174 | | |
162 | 175 | | |
163 | 176 | | |
| 177 | + | |
164 | 178 | | |
165 | 179 | | |
166 | 180 | | |
| |||
180 | 194 | | |
181 | 195 | | |
182 | 196 | | |
| 197 | + | |
183 | 198 | | |
184 | 199 | | |
185 | 200 | | |
| |||
197 | 212 | | |
198 | 213 | | |
199 | 214 | | |
| 215 | + | |
200 | 216 | | |
201 | 217 | | |
202 | 218 | | |
| |||
218 | 234 | | |
219 | 235 | | |
220 | 236 | | |
| 237 | + | |
221 | 238 | | |
222 | 239 | | |
223 | 240 | | |
224 | | - | |
| 241 | + | |
225 | 242 | | |
226 | 243 | | |
227 | | - | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
228 | 251 | | |
229 | 252 | | |
230 | 253 | | |
231 | 254 | | |
232 | 255 | | |
233 | 256 | | |
234 | | - | |
235 | | - | |
236 | | - | |
237 | | - | |
238 | | - | |
239 | | - | |
| 257 | + | |
240 | 258 | | |
241 | 259 | | |
242 | 260 | | |
| |||
245 | 263 | | |
246 | 264 | | |
247 | 265 | | |
| 266 | + | |
248 | 267 | | |
249 | 268 | | |
250 | 269 | | |
| |||
326 | 345 | | |
327 | 346 | | |
328 | 347 | | |
| 348 | + | |
329 | 349 | | |
330 | 350 | | |
0 commit comments