From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 91B132FD09 for ; Thu, 30 May 2019 08:36:07 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id oBnKp_56hrlA for ; Thu, 30 May 2019 08:36:07 -0400 (EDT) Received: from smtpng2.m.smailru.net (smtpng2.m.smailru.net [94.100.179.3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id EA5992FD08 for ; Thu, 30 May 2019 08:36:06 -0400 (EDT) From: Roman Khabibov Subject: [tarantool-patches] [PATCH 2/2] net.box: fetch '_vcollation' sysview into the module Date: Thu, 30 May 2019 15:36:03 +0300 Message-Id: <8580960460ba5013b81e3a327fc94df2377c06da.1559219194.git.roman.habibov@tarantool.org> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-Help: List-Unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-Subscribe: List-Owner: List-post: List-Archive: To: tarantool-patches@freelists.org Cc: v.shpilevoy@tarantool.org Fetch "_vcollation" sysview to show collation name instead collation id. Closes #3941 --- src/box/lua/net_box.lua | 24 ++++++++++++++++++------ test/box/net.box.result | 2 +- test/box/stat_net.result | 4 ++-- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/box/lua/net_box.lua b/src/box/lua/net_box.lua index 0cfb5075d..251ad407a 100644 --- a/src/box/lua/net_box.lua +++ b/src/box/lua/net_box.lua @@ -31,6 +31,7 @@ local decode_greeting = internal.decode_greeting local TIMEOUT_INFINITY = 500 * 365 * 86400 local VSPACE_ID = 281 local VINDEX_ID = 289 +local VCOLLATION_ID = 277 local DEFAULT_CONNECT_TIMEOUT = 10 local IPROTO_STATUS_KEY = 0x00 @@ -735,11 +736,16 @@ local function create_transport(host, port, user, password, callback, end local select1_id = new_request_id() local select2_id = new_request_id() + local select3_id = new_request_id() local response = {} -- fetch everything from space _vspace, 2 = ITER_ALL encode_select(send_buf, select1_id, VSPACE_ID, 0, 2, 0, 0xFFFFFFFF, nil) -- fetch everything from space _vindex, 2 = ITER_ALL encode_select(send_buf, select2_id, VINDEX_ID, 0, 2, 0, 0xFFFFFFFF, nil) + -- fetch everything from space _vcollation, 2 = ITER_ALL + encode_select(send_buf, select3_id, VCOLLATION_ID, 0, 2, 0, 0xFFFFFFFF, + nil) + schema_version = nil -- any schema_version will do provided that -- it is consistent across responses repeat @@ -747,7 +753,7 @@ local function create_transport(host, port, user, password, callback, if err then return error_sm(err, hdr) end dispatch_response_iproto(hdr, body_rpos, body_end) local id = hdr[IPROTO_SYNC_KEY] - if id == select1_id or id == select2_id then + if id == select1_id or id == select2_id or id == select3_id then -- response to a schema query we've submitted local status = hdr[IPROTO_STATUS_KEY] local response_schema_version = hdr[IPROTO_SCHEMA_VERSION_KEY] @@ -766,9 +772,10 @@ local function create_transport(host, port, user, password, callback, body, body_end = decode(body_rpos) response[id] = body[IPROTO_DATA_KEY] end - until response[select1_id] and response[select2_id] - callback('did_fetch_schema', schema_version, - response[select1_id], response[select2_id]) + until response[select1_id] and response[select2_id] and + response[select3_id] + callback('did_fetch_schema', schema_version, response[select1_id], + response[select2_id],response[select3_id]) set_state('active') return iproto_sm(schema_version) end @@ -1190,7 +1197,8 @@ function remote_methods:timeout(timeout) return self end -function remote_methods:_install_schema(schema_version, spaces, indices) +function remote_methods:_install_schema(schema_version, spaces, indices, + collations) local sl, space_mt, index_mt = {}, self._space_mt, self._index_mt for _, space in pairs(spaces) do local name = space[3] @@ -1258,11 +1266,15 @@ function remote_methods:_install_schema(schema_version, spaces, indices) local pkcollationid = index[PARTS][k].collation local pktype = index[PARTS][k][2] or index[PARTS][k].type local pkfield = index[PARTS][k][1] or index[PARTS][k].field + local pkcollation = nil + if pkcollationid ~= nil then + pkcollation = collations[pkcollationid + 1][2] + end local pk = { type = pktype, fieldno = pkfield + 1, - collation_id = pkcollationid, + collation = pkcollation, is_nullable = pknullable } idx.parts[k] = pk diff --git a/test/box/net.box.result b/test/box/net.box.result index d02fed7a3..474297af3 100644 --- a/test/box/net.box.result +++ b/test/box/net.box.result @@ -2910,7 +2910,7 @@ c.space.test.index.sk.parts --- - - type: string is_nullable: false - collation_id: 277 + collation: test fieldno: 1 ... c:close() diff --git a/test/box/stat_net.result b/test/box/stat_net.result index 92f6d581f..9eeada7ec 100644 --- a/test/box/stat_net.result +++ b/test/box/stat_net.result @@ -85,7 +85,7 @@ box.stat.net.CONNECTIONS.total ... box.stat.net.REQUESTS.total --- -- 13 +- 17 ... box.stat.net.CONNECTIONS.current --- @@ -151,7 +151,7 @@ test_run:wait_cond(function() return box.stat.net.REQUESTS.current == 0 end, WAI ... box.stat.net.REQUESTS.total --- -- 15 +- 19 ... -- reset box.stat.reset() -- 2.20.1 (Apple Git-117)