diff --git a/src/box/iproto_constants.h b/src/box/iproto_constants.h index b57d565277829a66281423ab038461078cda745d..f8eee0f3f82ddb74c07d1c37eeb1379c071aa1b7 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 1bb7681ac724c7a0ad06332d7092dbe9e3fc3d3f..9560bfdd483d3952021958e9cbc550ce01447505 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 @@ -151,7 +151,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) @@ -171,8 +171,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 @@ -615,15 +615,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() @@ -801,7 +802,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]) @@ -853,7 +854,7 @@ local function create_transport(host, port, user, password, callback, end 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 06c6afb036a0ef59073f426b117df085fdd4942b..1b3f3f9d152203a56e5e911a944dbc28fc490f35 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 e4fe684cc42332dfdcd423882c1bd4ebed0913e5..4b648d345e6d600fde279e190bb182b50bdb746a 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 ec715e918fadd7c81f51687cb8e913aa7819bab1..4af39cc5fa1035831e68963e80dc121b79ffeeef 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')