Skip to content
Snippets Groups Projects
Commit 1f7e7aa2 authored by Chris Sosnin's avatar Chris Sosnin Committed by Nikita Pettik
Browse files

iproto: add an empty body to the unprepare response


Absence of the body in the unprepare response forces users to perform
additional checks to avoid errors. Adding an empty body fixes this problem.

Closes #4769

Reviewed-by: default avatarVladislav Shpilevoy <v.shpilevoy@tarantool.org>
Reviewed-by: default avatarNikita Pettik <korablev@tarantool.org>
parent 05cdeb59
No related branches found
No related tags found
No related merge requests found
......@@ -1780,21 +1780,24 @@ tx_process_sql(struct cmsg *m)
* become out of date during yield.
*/
out = msg->connection->tx.p_obuf;
if (is_unprepare) {
if (iproto_reply_ok(out, msg->header.sync, schema_version) != 0)
goto error;
iproto_wpos_create(&msg->wpos, out);
return;
}
struct obuf_svp header_svp;
/* Prepare memory for the iproto header. */
if (iproto_prepare_header(out, &header_svp, IPROTO_HEADER_LEN) != 0) {
port_destroy(&port);
goto error;
}
/* Nothing to dump in case of UNPREPARE request. */
if (!is_unprepare) {
if (port_dump_msgpack(&port, out) != 0) {
port_destroy(&port);
obuf_rollback_to_svp(out, &header_svp);
goto error;
}
if (port_dump_msgpack(&port, out) != 0) {
port_destroy(&port);
obuf_rollback_to_svp(out, &header_svp);
goto error;
}
port_destroy(&port);
iproto_reply_sql(out, &header_svp, msg->header.sync, schema_version);
iproto_wpos_create(&msg->wpos, out);
return;
......
-- test-run result file version 2
net_box = require('net.box')
| ---
| ...
msgpack = require('msgpack')
| ---
| ...
urilib = require('uri')
| ---
| ...
IPROTO_REQUEST_TYPE = 0x00
| ---
| ...
IPROTO_PREPARE = 13
| ---
| ...
IPROTO_SQL_TEXT = 0x40
| ---
| ...
IPROTO_STMT_ID = 0x43
| ---
| ...
box.schema.user.grant('guest', 'read, write, execute', 'universe')
| ---
| ...
uri = urilib.parse(box.cfg.listen)
| ---
| ...
socket = net_box.establish_connection(uri.host, uri.service)
| ---
| ...
header = { [IPROTO_REQUEST_TYPE] = IPROTO_PREPARE }
| ---
| ...
body = { [IPROTO_SQL_TEXT] = 'SELECT 1' }
| ---
| ...
response = iproto_request(socket, header, body)
| ---
| ...
body = { [IPROTO_STMT_ID] = response['body'][IPROTO_STMT_ID] }
| ---
| ...
-- Decoding of the response will fail if there's no body.
response = iproto_request(socket, header, body)
| ---
| ...
response.body
| ---
| - {}
| ...
box.schema.user.revoke('guest', 'read, write, execute', 'universe')
| ---
| ...
socket:close()
| ---
| - true
| ...
net_box = require('net.box')
msgpack = require('msgpack')
urilib = require('uri')
IPROTO_REQUEST_TYPE = 0x00
IPROTO_PREPARE = 13
IPROTO_SQL_TEXT = 0x40
IPROTO_STMT_ID = 0x43
box.schema.user.grant('guest', 'read, write, execute', 'universe')
uri = urilib.parse(box.cfg.listen)
socket = net_box.establish_connection(uri.host, uri.service)
header = { [IPROTO_REQUEST_TYPE] = IPROTO_PREPARE }
body = { [IPROTO_SQL_TEXT] = 'SELECT 1' }
response = iproto_request(socket, header, body)
body = { [IPROTO_STMT_ID] = response['body'][IPROTO_STMT_ID] }
-- Decoding of the response will fail if there's no body.
response = iproto_request(socket, header, body)
response.body
box.schema.user.revoke('guest', 'read, write, execute', 'universe')
socket:close()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment