From: Leonid Vasiliev <lvasiliev@tarantool.org> To: v.shpilevoy@tarantool.org, alexander.turenko@tarantool.org Cc: tarantool-patches@dev.tarantool.org Subject: [Tarantool-patches] [PATCH V6 09/10] iproto: rename IPROTO_ERROR and IPROTO_ERROR_STACK Date: Mon, 20 Apr 2020 01:25:11 +0300 [thread overview] Message-ID: <75b76072b2801ab49d6643d2ef4915549ad9cfc5.1587334824.git.lvasiliev@tarantool.org> (raw) In-Reply-To: <cover.1587334824.git.lvasiliev@tarantool.org> In-Reply-To: <cover.1587334824.git.lvasiliev@tarantool.org> From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org> IPROTO_ERROR in fact is not an error. It is an error message. Secondly, this key is deprecated in favor of IPROTO_ERROR_STACK, which contains all attributes of the whole error stack. It uses MP_ERROR MessagePack extenstion for that. So IPROTO_ERROR is renamed to IPROTO_ERROR_24 (similar to how old call was renamed to IPROTO_CALL_16). IPROTO_ERROR_STACK becomes new IPROTO_ERROR. Follow up #4398 --- src/box/iproto_constants.h | 4 ++-- src/box/lua/net_box.lua | 25 +++++++++++++------------ src/box/xrow.c | 10 +++++----- test/box/iproto.result | 8 ++++---- test/box/iproto.test.lua | 6 +++--- 5 files changed, 27 insertions(+), 26 deletions(-) diff --git a/src/box/iproto_constants.h b/src/box/iproto_constants.h index b57d565..f8eee0f 100644 --- a/src/box/iproto_constants.h +++ b/src/box/iproto_constants.h @@ -101,7 +101,7 @@ enum iproto_key { /* Leave a gap between request keys and response keys */ IPROTO_DATA = 0x30, - IPROTO_ERROR = 0x31, + IPROTO_ERROR_24 = 0x31, /** * IPROTO_METADATA: [ * { IPROTO_FIELD_NAME: name }, @@ -126,7 +126,7 @@ enum iproto_key { /* Leave a gap between SQL keys and additional request keys */ IPROTO_REPLICA_ANON = 0x50, IPROTO_ID_FILTER = 0x51, - IPROTO_ERROR_STACK = 0x52, + IPROTO_ERROR = 0x52, IPROTO_KEY_MAX }; diff --git a/src/box/lua/net_box.lua b/src/box/lua/net_box.lua index 1e55eaa..1b2b6ac 100644 --- a/src/box/lua/net_box.lua +++ b/src/box/lua/net_box.lua @@ -44,8 +44,8 @@ local IPROTO_SQL_INFO_KEY = 0x42 local SQL_INFO_ROW_COUNT_KEY = 0 local IPROTO_FIELD_NAME_KEY = 0 local IPROTO_DATA_KEY = 0x30 -local IPROTO_ERROR_KEY = 0x31 -local IPROTO_ERROR_STACK = 0x52 +local IPROTO_ERROR_24 = 0x31 +local IPROTO_ERROR = 0x52 local IPROTO_GREETING_SIZE = 128 local IPROTO_CHUNK_KEY = 128 local IPROTO_OK_KEY = 0 @@ -150,7 +150,7 @@ local method_decoder = { push = decode_push, } -local function decode_error_stack(raw_data) +local function decode_error(raw_data) local ptr = buffer_reg.acucp ptr[0] = raw_data local err = ffi.C.error_unpack_unsafe(ptr) @@ -170,8 +170,8 @@ local function decode_error_stack(raw_data) end local response_decoder = { - [IPROTO_ERROR_KEY] = decode, - [IPROTO_ERROR_STACK] = decode_error_stack, + [IPROTO_ERROR_24] = decode, + [IPROTO_ERROR] = decode_error, } local function next_id(id) return band(id + 1, 0x7FFFFFFF) end @@ -614,15 +614,16 @@ local function create_transport(host, port, user, password, callback, end assert(body_end == body_rpos, "invalid xrow length") request.errno = band(status, IPROTO_ERRNO_MASK) - -- IPROTO_ERROR_STACK comprises error encoded with - -- IPROTO_ERROR_KEY, so we may ignore content of that key. - if body[IPROTO_ERROR_STACK] ~= nil then - request.response = body[IPROTO_ERROR_STACK] + -- IPROTO_ERROR comprises error encoded with + -- IPROTO_ERROR_24, so we may ignore content of that + -- key. + if body[IPROTO_ERROR] ~= nil then + request.response = body[IPROTO_ERROR] assert(type(request.response) == 'cdata') else request.response = box.error.new({ code = request.errno, - reason = body[IPROTO_ERROR_KEY] + reason = body[IPROTO_ERROR_24] }) end request.cond:broadcast() @@ -800,7 +801,7 @@ local function create_transport(host, port, user, password, callback, if hdr[IPROTO_STATUS_KEY] ~= 0 then local body body, body_end = decode(body_rpos) - return error_sm(E_NO_CONNECTION, body[IPROTO_ERROR_KEY]) + return error_sm(E_NO_CONNECTION, body[IPROTO_ERROR_24]) end set_state('fetch_schema') return iproto_schema_sm(hdr[IPROTO_SCHEMA_VERSION_KEY]) @@ -845,7 +846,7 @@ local function create_transport(host, port, user, password, callback, if status ~= 0 then local body body, body_end = decode(body_rpos) - return error_sm(E_NO_CONNECTION, body[IPROTO_ERROR_KEY]) + return error_sm(E_NO_CONNECTION, body[IPROTO_ERROR_24]) end if schema_version == nil then schema_version = response_schema_version diff --git a/src/box/xrow.c b/src/box/xrow.c index 06c6afb..1b3f3f9 100644 --- a/src/box/xrow.c +++ b/src/box/xrow.c @@ -379,7 +379,7 @@ iproto_header_encode(char *out, uint32_t type, uint64_t sync, struct PACKED iproto_body_bin { uint8_t m_body; /* MP_MAP */ - uint8_t k_data; /* IPROTO_DATA or IPROTO_ERROR */ + uint8_t k_data; /* IPROTO_DATA or errors */ uint8_t m_data; /* MP_STR or MP_ARRAY */ uint32_t v_data_len; /* string length of array size */ }; @@ -496,9 +496,9 @@ static void mpstream_iproto_encode_error(struct mpstream *stream, const struct error *error) { mpstream_encode_map(stream, 2); - mpstream_encode_uint(stream, IPROTO_ERROR); + mpstream_encode_uint(stream, IPROTO_ERROR_24); mpstream_encode_str(stream, error->errmsg); - mpstream_encode_uint(stream, IPROTO_ERROR_STACK); + mpstream_encode_uint(stream, IPROTO_ERROR); error_to_mpstream_noext(error, stream); } @@ -1109,7 +1109,7 @@ xrow_decode_error(struct xrow_header *row) continue; } uint8_t key = mp_decode_uint(&pos); - if (key == IPROTO_ERROR && mp_typeof(*pos) == MP_STR) { + if (key == IPROTO_ERROR_24 && mp_typeof(*pos) == MP_STR) { /* * Obsolete way of sending error responses. * To be deprecated but still should be supported @@ -1119,7 +1119,7 @@ xrow_decode_error(struct xrow_header *row) const char *str = mp_decode_str(&pos, &len); snprintf(error, sizeof(error), "%.*s", len, str); box_error_set(__FILE__, __LINE__, code, error); - } else if (key == IPROTO_ERROR_STACK) { + } else if (key == IPROTO_ERROR) { struct error *e = error_unpack_unsafe(&pos); if (e == NULL) goto error; diff --git a/test/box/iproto.result b/test/box/iproto.result index e4fe684..4b648d3 100644 --- a/test/box/iproto.result +++ b/test/box/iproto.result @@ -25,10 +25,10 @@ IPROTO_FUNCTION_NAME = 0x22 IPROTO_TUPLE = 0x21 --- ... -IPROTO_ERROR = 0x31 +IPROTO_ERROR_24 = 0x31 --- ... -IPROTO_ERROR_STACK = 0x52 +IPROTO_ERROR = 0x52 --- ... IPROTO_ERROR_CODE = 0x01 @@ -92,11 +92,11 @@ sock:close() ... -- Both keys (obsolete and stack ones) are present in response. -- -assert(response.body[IPROTO_ERROR_STACK] ~= nil) +assert(response.body[IPROTO_ERROR] ~= nil) --- - true ... -assert(response.body[IPROTO_ERROR] ~= nil) +assert(response.body[IPROTO_ERROR_24] ~= nil) --- - true ... diff --git a/test/box/iproto.test.lua b/test/box/iproto.test.lua index ec715e9..4af39cc 100644 --- a/test/box/iproto.test.lua +++ b/test/box/iproto.test.lua @@ -9,8 +9,8 @@ IPROTO_SYNC = 0x01 IPROTO_CALL = 0x0A IPROTO_FUNCTION_NAME = 0x22 IPROTO_TUPLE = 0x21 -IPROTO_ERROR = 0x31 -IPROTO_ERROR_STACK = 0x52 +IPROTO_ERROR_24 = 0x31 +IPROTO_ERROR = 0x52 IPROTO_ERROR_CODE = 0x01 IPROTO_ERROR_MESSAGE = 0x02 @@ -49,7 +49,7 @@ sock:close() -- Both keys (obsolete and stack ones) are present in response. -- -assert(response.body[IPROTO_ERROR_STACK] ~= nil) assert(response.body[IPROTO_ERROR] ~= nil) +assert(response.body[IPROTO_ERROR_24] ~= nil) box.schema.user.revoke('guest', 'read,write,execute', 'universe') -- 2.7.4
next prev parent reply other threads:[~2020-04-19 22:25 UTC|newest] Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-04-19 22:25 [Tarantool-patches] [PATCH V6 00/10] Extending error functionality Leonid Vasiliev 2020-04-19 22:25 ` [Tarantool-patches] [PATCH V6 01/10] error: add custom error type Leonid Vasiliev 2020-04-19 22:25 ` [Tarantool-patches] [PATCH V6 02/10] session: add offset to SQL session settings array Leonid Vasiliev 2020-04-19 22:25 ` [Tarantool-patches] [PATCH V6 03/10] error: add session setting for error type marshaling Leonid Vasiliev 2020-04-19 22:25 ` [Tarantool-patches] [PATCH V6 04/10] error: update constructors of some errors Leonid Vasiliev 2020-04-19 22:25 ` [Tarantool-patches] [PATCH V6 05/10] box: move Lua MP_EXT decoder from tuple.c Leonid Vasiliev 2020-04-19 22:25 ` [Tarantool-patches] [PATCH V6 06/10] error: add error MsgPack encoding Leonid Vasiliev 2020-04-19 22:25 ` [Tarantool-patches] [PATCH V6 07/10] error: export error_unref() function Leonid Vasiliev 2020-04-19 22:25 ` [Tarantool-patches] [PATCH V6 08/10] error: make iproto errors reuse mp_error module Leonid Vasiliev 2020-04-19 22:25 ` Leonid Vasiliev [this message] 2020-04-19 22:25 ` [Tarantool-patches] [PATCH V6 10/10] error: fix iproto error stack overlapped by old error Leonid Vasiliev 2020-04-20 0:26 ` [Tarantool-patches] [PATCH V6 00/10] Extending error functionality Vladislav Shpilevoy 2020-04-20 8:05 ` lvasiliev 2020-04-20 8:05 ` Kirill Yukhin 2020-04-21 19:03 ` Konstantin Osipov 2020-04-22 16:17 ` lvasiliev 2020-04-22 17:23 ` Konstantin Osipov 2020-04-20 8:30 ` Kirill Yukhin
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=75b76072b2801ab49d6643d2ef4915549ad9cfc5.1587334824.git.lvasiliev@tarantool.org \ --to=lvasiliev@tarantool.org \ --cc=alexander.turenko@tarantool.org \ --cc=tarantool-patches@dev.tarantool.org \ --cc=v.shpilevoy@tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH V6 09/10] iproto: rename IPROTO_ERROR and IPROTO_ERROR_STACK' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox