From: Roman Khabibov <roman.habibov@tarantool.org>
To: tarantool-patches@freelists.org
Cc: vdavydov.dev@gmail.com
Subject: [PATCH 2/2] net.box: fetch '_vcollation' sysview into the module
Date: Fri, 22 Mar 2019 03:27:37 +0300 [thread overview]
Message-ID: <3b347d38e9675d46f9246288bec0239acf977183.1553183293.git.roman.habibov@tarantool.org> (raw)
In-Reply-To: <cover.1553183293.git.roman.habibov@tarantool.org>
In-Reply-To: <cover.1553183293.git.roman.habibov@tarantool.org>
Fetch "_vcollation" sysview to show collation name instead collation id.
Closes #3941
---
src/box/lua/net_box.lua | 19 ++++++++++++++-----
test/box/net.box.result | 2 +-
2 files changed, 15 insertions(+), 6 deletions(-)
diff --git a/src/box/lua/net_box.lua b/src/box/lua/net_box.lua
index b3139a3f5..05960fa90 100644
--- a/src/box/lua/net_box.lua
+++ b/src/box/lua/net_box.lua
@@ -30,6 +30,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
@@ -723,11 +724,15 @@ 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
@@ -735,7 +740,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]
@@ -754,9 +759,9 @@ 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]
+ 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[select1_id], response[select2_id], response[select3_id])
set_state('active')
return iproto_sm(schema_version)
end
@@ -1176,7 +1181,7 @@ 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]
@@ -1244,11 +1249,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 b800531b4..0bcf3b309 100644
--- a/test/box/net.box.result
+++ b/test/box/net.box.result
@@ -2666,7 +2666,7 @@ c.space.test.index.sk.parts
---
- - type: string
is_nullable: false
- collation_id: 4
+ collation: test
fieldno: 1
...
c:close()
--
2.17.2 (Apple Git-113)
next prev parent reply other threads:[~2019-03-22 0:27 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-22 0:27 [PATCH 0/2] add '_vcollation' sysview and fetch it in net.box Roman Khabibov
2019-03-22 0:27 ` [PATCH 1/2] schema: add "_vcollation" sysview Roman Khabibov
2019-03-22 0:27 ` Roman Khabibov [this message]
2019-03-22 8:33 ` [PATCH 0/2] add '_vcollation' sysview and fetch it in net.box Vladimir Davydov
2019-03-22 15:39 ` [tarantool-patches] " Konstantin Osipov
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=3b347d38e9675d46f9246288bec0239acf977183.1553183293.git.roman.habibov@tarantool.org \
--to=roman.habibov@tarantool.org \
--cc=tarantool-patches@freelists.org \
--cc=vdavydov.dev@gmail.com \
--subject='Re: [PATCH 2/2] net.box: fetch '\''_vcollation'\'' sysview into the module' \
/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