Tarantool development patches archive
 help / color / mirror / Atom feed
* [tarantool-patches] [PATCH 0/2] Add _vcollation and fetch in net.box
@ 2019-05-30 12:36 Roman Khabibov
  2019-05-30 12:36 ` [tarantool-patches] [PATCH 1/2] schema: add "_vcollation" sysview Roman Khabibov
                   ` (3 more replies)
  0 siblings, 4 replies; 15+ messages in thread
From: Roman Khabibov @ 2019-05-30 12:36 UTC (permalink / raw)
  To: tarantool-patches; +Cc: v.shpilevoy

As I understood "readable for all" means that filter for
"_vcollation" must always return "true", because the condition
"User has read access to according system space" is always
met.

Roman Khabibov (2):
  schema: add "_vcollation" sysview
  net.box: fetch '_vcollation' sysview into the module

 src/box/bootstrap.snap             | Bin 4374 -> 4441 bytes
 src/box/lua/net_box.lua            |  24 ++++++--
 src/box/lua/space.cc               |   2 +
 src/box/lua/upgrade.lua            |  25 ++++++++
 src/box/schema_def.h               |   2 +
 src/box/sysview.c                  |  13 ++++
 test/app-tap/tarantoolctl.test.lua |   4 +-
 test/box-py/bootstrap.result       |  13 +++-
 test/box/access_misc.result        |   4 ++
 test/box/access_sysview.result     |  92 ++++++++++++++++++++++++++---
 test/box/access_sysview.test.lua   |  30 ++++++++++
 test/box/alter.result              |   6 +-
 test/box/net.box.result            |   2 +-
 test/box/stat_net.result           |   4 +-
 test/wal_off/alter.result          |   2 +-
 15 files changed, 201 insertions(+), 22 deletions(-)

-- 
2.20.1 (Apple Git-117)

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [tarantool-patches] [PATCH 1/2] schema: add "_vcollation" sysview
  2019-05-30 12:36 [tarantool-patches] [PATCH 0/2] Add _vcollation and fetch in net.box Roman Khabibov
@ 2019-05-30 12:36 ` Roman Khabibov
  2019-06-04 16:31   ` Vladimir Davydov
  2019-05-30 12:36 ` [tarantool-patches] [PATCH 2/2] net.box: fetch '_vcollation' sysview into the module Roman Khabibov
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 15+ messages in thread
From: Roman Khabibov @ 2019-05-30 12:36 UTC (permalink / raw)
  To: tarantool-patches; +Cc: v.shpilevoy

Add "_vcollation" sysview to read it from net.box. This
sysview is always readable, exept when the user doesn't have
"public" role.

Needed for #3941
---
 src/box/bootstrap.snap             | Bin 4374 -> 4441 bytes
 src/box/lua/space.cc               |   2 +
 src/box/lua/upgrade.lua            |  25 ++++++++
 src/box/schema_def.h               |   2 +
 src/box/sysview.c                  |  13 ++++
 test/app-tap/tarantoolctl.test.lua |   4 +-
 test/box-py/bootstrap.result       |  13 +++-
 test/box/access_misc.result        |   4 ++
 test/box/access_sysview.result     |  92 ++++++++++++++++++++++++++---
 test/box/access_sysview.test.lua   |  30 ++++++++++
 test/box/alter.result              |   6 +-
 test/wal_off/alter.result          |   2 +-
 12 files changed, 180 insertions(+), 13 deletions(-)

diff --git a/src/box/bootstrap.snap b/src/box/bootstrap.snap
index 871a93f9856f97636ad55b7f5260e5c6957fef36..4e93a794a0608710a2bb93e96e9031451186bf01 100644
GIT binary patch
literal 4441
zcmV-f5vJ}_PC-x#FfK7O3RY!ub7^mGIv_GGGA=MJGC49WXEkDGHfA<7HZclGZgX^D
zZewLSAZ0UTWj8QoW-T}~Vl^!^G&40VVmLN4EjMOmV>UQqF=I6_VhUD6Y;R+0Iv{&}
z3JTS_3%bn^-T=-7f<eKh0000004TLD{Qyv{h5#CsSRqCbkk~l@3;+xOdU@HTEDz~p
z+BX^(yPn0f4L~;l9QsnGq$X36ku4=DlgO!mdPKbrZ7!#tL!6h=TVNc<ruKgh$s0t8
z1Qr4a0`vj1od+O9S&WOac-O%P7?be;<1rmzoN_?s95)zqjv8=qj^`+516mv>4Q6pN
z5R+@N@^vvz7$;E#lYuB=5JpTd0Hb$bFqrKuxIkwSxAXFa=GDc5EOPOZML5}OOP4Ha
z;gZD)wq!AjX%;P_h@}Eiyplx}Q!7~huX5%8CM*A^OjT%hC}^61DYX6j`^Ijbe-3T`
z-{-F#DilaC!M#(c+#7)e{4P!5S1AI1`GsKV-UpQKl>))NsRIwx{EjB2=65p(YCgo(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p-dAVAr&5G-T#-`cag8Ot5Re#*GG?>4dLFN=m729Yya7)h%h5u*T+C1OEsyl^RY
z9=&k!gVhJ{3ZZ2o!oK=O4aNeNuuO7*e_Ra{TVoQZed}kR*8wQB#FB>4L%p!ia4=$e
zYOuO=uXI%bH>&a%2UGEhi%6AqE-P;j9BOma-w;Ih`Yx@O3_ducSwe8ZIn+vQ2?-3=
z%|9yMPJ!n;klelKR<4>U<6rW-U47{x7*d#zsvrw0JEj}b^1vXuaN4jv$A2^-Zc)<K
zP@MU2;Kleeq#R$<iXQ?{@G39C0{$kmg+I+mNCY}1jz*t=_EuMcmc#XDGvBU41sMlx
z&(6N*l}yPX=uUz4e|kXz)Y#m?IJ~=~7!7Fp3|R~51m>qn^BoGAo*o-+n<;~iD;J7|
zQLrKBBIVi0?L%RO#>v{Vv)k7d4KXYOEKzvjJjy0iFhW+J&3wO~^YE6AxO(yzw(ydk
zxP5vTci75K+-tH!hy7wCv~j)#kA)dcT=i~!v)V9cG5(s%(U4@}&rtx^8Z@h$qsLi+
QJ>-q$w`eZc2h|X*?NOjQ=l}o!

diff --git a/src/box/lua/space.cc b/src/box/lua/space.cc
index 100da0a79..fbfc2a64d 100644
--- a/src/box/lua/space.cc
+++ b/src/box/lua/space.cc
@@ -525,6 +525,8 @@ box_lua_space_init(struct lua_State *L)
 	lua_setfield(L, -2, "FUNC_ID");
 	lua_pushnumber(L, BOX_COLLATION_ID);
 	lua_setfield(L, -2, "COLLATION_ID");
+	lua_pushnumber(L, BOX_VCOLLATION_ID);
+	lua_setfield(L, -2, "VCOLLATION_ID");
 	lua_pushnumber(L, BOX_VFUNC_ID);
 	lua_setfield(L, -2, "VFUNC_ID");
 	lua_pushnumber(L, BOX_PRIV_ID);
diff --git a/src/box/lua/upgrade.lua b/src/box/lua/upgrade.lua
index 89d6e3d52..f2a1be639 100644
--- a/src/box/lua/upgrade.lua
+++ b/src/box/lua/upgrade.lua
@@ -737,6 +737,30 @@ local function upgrade_to_2_1_3()
     end
 end
 
+local function create_vcollation_space()
+    local _collation = box.space._collation
+    local format = _collation:format()
+    create_sysview(box.schema.COLLATION_ID, box.schema.VCOLLATION_ID)
+    box.space[box.schema.VCOLLATION_ID]:format(format)
+end
+
+local function upgrade_to_2_1_4()
+    local _collation = box.space._collation
+    local _index = box.space._index
+
+    -- System space format usually is in order "id, owner, name...".
+    -- The fields "name", "owner" are swapped in "_collation" format,
+    -- due to the field "owner" was added after the "_collation" creation.
+    box.space._index:delete{276, 1}
+    log.info("update index name on _collation")
+    box.space._index:insert{_collation.id, 2, 'name', 'tree', {unique = true},
+                            {{1, 'string'}}}
+    log.info("create index owner on _collation")
+    box.space._index:insert{_collation.id, 1, 'owner', 'tree', {unique = false},
+                            {{2, 'unsigned'}}}
+    create_vcollation_space()
+end
+
 local function get_version()
     local version = box.space._schema:get{'version'}
     if version == nil then
@@ -768,6 +792,7 @@ local function upgrade(options)
         {version = mkversion(2, 1, 1), func = upgrade_to_2_1_1, auto = true},
         {version = mkversion(2, 1, 2), func = upgrade_to_2_1_2, auto = true},
         {version = mkversion(2, 1, 3), func = upgrade_to_2_1_3, auto = true},
+        {version = mkversion(2, 1, 4), func = upgrade_to_2_1_4, auto = true}
     }
 
     for _, handler in ipairs(handlers) do
diff --git a/src/box/schema_def.h b/src/box/schema_def.h
index eeeeb950b..77c004690 100644
--- a/src/box/schema_def.h
+++ b/src/box/schema_def.h
@@ -72,6 +72,8 @@ enum {
 	BOX_SCHEMA_ID = 272,
 	/** Space id of _collation. */
 	BOX_COLLATION_ID = 276,
+	/** Space id of _vcollation. */
+	BOX_VCOLLATION_ID = 277,
 	/** Space id of _space. */
 	BOX_SPACE_ID = 280,
 	/** Space id of _vspace view. */
diff --git a/src/box/sysview.c b/src/box/sysview.c
index 96c5e78ca..0d1259af0 100644
--- a/src/box/sysview.c
+++ b/src/box/sysview.c
@@ -402,6 +402,14 @@ vsequence_filter(struct space *source, struct tuple *tuple)
 	       ((PRIV_WRDA | PRIV_X) & effective);
 }
 
+static bool
+	vcollation_filter(struct space *source, struct tuple *tuple)
+	{
+		(void) source;
+		(void) tuple;
+		return true;
+	}
+
 static struct index *
 sysview_space_create_index(struct space *space, struct index_def *def)
 {
@@ -448,6 +456,11 @@ sysview_space_create_index(struct space *space, struct index_def *def)
 		source_index_id = def->iid;
 		filter = vsequence_filter;
 		break;
+	case BOX_VCOLLATION_ID:
+		source_space_id = BOX_COLLATION_ID;
+		source_index_id = def->iid;
+		filter = vcollation_filter;
+		break;
 	default:
 		diag_set(ClientError, ER_MODIFY_INDEX,
 			 def->name, space_name(space),
diff --git a/test/app-tap/tarantoolctl.test.lua b/test/app-tap/tarantoolctl.test.lua
index c1e1490ca..ac1efa0ba 100755
--- a/test/app-tap/tarantoolctl.test.lua
+++ b/test/app-tap/tarantoolctl.test.lua
@@ -405,8 +405,8 @@ do
             check_ctlcat_xlog(test_i, dir, "--from=3 --to=6 --format=json --show-system --replica 1", "\n", 3)
             check_ctlcat_xlog(test_i, dir, "--from=3 --to=6 --format=json --show-system --replica 1 --replica 2", "\n", 3)
             check_ctlcat_xlog(test_i, dir, "--from=3 --to=6 --format=json --show-system --replica 2", "\n", 0)
-            check_ctlcat_snap(test_i, dir, "--space=280", "---\n", 21)
-            check_ctlcat_snap(test_i, dir, "--space=288", "---\n", 47)
+            check_ctlcat_snap(test_i, dir, "--space=280", "---\n", 22)
+            check_ctlcat_snap(test_i, dir, "--space=288", "---\n", 51)
         end)
     end)
 
diff --git a/test/box-py/bootstrap.result b/test/box-py/bootstrap.result
index 379f6c51f..f37a28c80 100644
--- a/test/box-py/bootstrap.result
+++ b/test/box-py/bootstrap.result
@@ -4,7 +4,7 @@ box.internal.bootstrap()
 box.space._schema:select{}
 ---
 - - ['max_id', 511]
-  - ['version', 2, 1, 3]
+  - ['version', 2, 1, 4]
 ...
 box.space._cluster:select{}
 ---
@@ -21,6 +21,10 @@ box.space._space:select{}
         'name': 'name', 'type': 'string'}, {'name': 'owner', 'type': 'unsigned'},
       {'name': 'type', 'type': 'string'}, {'name': 'locale', 'type': 'string'}, {
         'name': 'opts', 'type': 'map'}]]
+  - [277, 1, '_vcollation', 'sysview', 0, {}, [{'name': 'id', 'type': 'unsigned'},
+      {'name': 'name', 'type': 'string'}, {'name': 'owner', 'type': 'unsigned'}, {
+        'name': 'type', 'type': 'string'}, {'name': 'locale', 'type': 'string'}, {
+        'name': 'opts', 'type': 'map'}]]
   - [280, 1, '_space', 'memtx', 0, {}, [{'name': 'id', 'type': 'unsigned'}, {'name': 'owner',
         'type': 'unsigned'}, {'name': 'name', 'type': 'string'}, {'name': 'engine',
         'type': 'string'}, {'name': 'field_count', 'type': 'unsigned'}, {'name': 'flags',
@@ -83,7 +87,11 @@ box.space._index:select{}
 ---
 - - [272, 0, 'primary', 'tree', {'unique': true}, [[0, 'string']]]
   - [276, 0, 'primary', 'tree', {'unique': true}, [[0, 'unsigned']]]
-  - [276, 1, 'name', 'tree', {'unique': true}, [[1, 'string']]]
+  - [276, 1, 'owner', 'tree', {'unique': false}, [[2, 'unsigned']]]
+  - [276, 2, 'name', 'tree', {'unique': true}, [[1, 'string']]]
+  - [277, 0, 'primary', 'tree', {'unique': true}, [[0, 'unsigned']]]
+  - [277, 1, 'owner', 'tree', {'unique': false}, [[2, 'unsigned']]]
+  - [277, 2, 'name', 'tree', {'unique': true}, [[1, 'string']]]
   - [280, 0, 'primary', 'tree', {'unique': true}, [[0, 'unsigned']]]
   - [280, 1, 'owner', 'tree', {'unique': false}, [[1, 'unsigned']]]
   - [280, 2, 'name', 'tree', {'unique': true}, [[2, 'string']]]
@@ -150,6 +158,7 @@ box.space._priv:select{}
   - [1, 1, 'universe', 0, 4294967295]
   - [1, 2, 'function', 1, 4]
   - [1, 2, 'space', 276, 2]
+  - [1, 2, 'space', 277, 1]
   - [1, 2, 'space', 281, 1]
   - [1, 2, 'space', 286, 1]
   - [1, 2, 'space', 289, 1]
diff --git a/test/box/access_misc.result b/test/box/access_misc.result
index 36ebfae09..2b7ca4f97 100644
--- a/test/box/access_misc.result
+++ b/test/box/access_misc.result
@@ -761,6 +761,10 @@ box.space._space:select()
         'name': 'name', 'type': 'string'}, {'name': 'owner', 'type': 'unsigned'},
       {'name': 'type', 'type': 'string'}, {'name': 'locale', 'type': 'string'}, {
         'name': 'opts', 'type': 'map'}]]
+  - [277, 1, '_vcollation', 'sysview', 0, {}, [{'name': 'id', 'type': 'unsigned'},
+      {'name': 'name', 'type': 'string'}, {'name': 'owner', 'type': 'unsigned'}, {
+        'name': 'type', 'type': 'string'}, {'name': 'locale', 'type': 'string'}, {
+        'name': 'opts', 'type': 'map'}]]
   - [280, 1, '_space', 'memtx', 0, {}, [{'name': 'id', 'type': 'unsigned'}, {'name': 'owner',
         'type': 'unsigned'}, {'name': 'name', 'type': 'string'}, {'name': 'engine',
         'type': 'string'}, {'name': 'field_count', 'type': 'unsigned'}, {'name': 'flags',
diff --git a/test/box/access_sysview.result b/test/box/access_sysview.result
index c6a2b22ed..96976babb 100644
--- a/test/box/access_sysview.result
+++ b/test/box/access_sysview.result
@@ -74,6 +74,10 @@ session.su('guest')
 ---
 - true
 ...
+#box.space._vspace.index[2]:select('_vcollation') ~= 0
+---
+- true
+...
 #box.space._vindex:select(box.space._vspace.id) > 0
 ---
 - true
@@ -94,6 +98,10 @@ session.su('guest')
 ---
 - true
 ...
+#box.space._vindex:select(box.space._vcollation.id) > 0
+---
+- true
+...
 box.session.su('admin')
 ---
 ...
@@ -127,6 +135,10 @@ box.session.su('guest')
 ---
 - error: Read access to space '_vsequence' is denied for user 'guest'
 ...
+#box.space._vcollation:select{}
+---
+- error: Read access to space '_vcollation' is denied for user 'guest'
+...
 box.session.su('admin')
 ---
 ...
@@ -138,11 +150,15 @@ box.session.su('guest')
 ...
 #box.space._vspace:select{}
 ---
-- 8
+- 9
 ...
 #box.space._vindex:select{}
 ---
-- 20
+- 24
+...
+#box.space._vcollation:select{}
+---
+- 277
 ...
 box.session.su('admin')
 ---
@@ -230,11 +246,11 @@ box.session.su('guest')
 ...
 #box.space._vspace:select{}
 ---
-- 22
+- 23
 ...
 #box.space._vindex:select{}
 ---
-- 48
+- 52
 ...
 #box.space._vuser:select{}
 ---
@@ -242,12 +258,16 @@ box.session.su('guest')
 ...
 #box.space._vpriv:select{}
 ---
-- 15
+- 16
 ...
 #box.space._vfunc:select{}
 ---
 - 1
 ...
+#box.space._vcollation:select{}
+---
+- 277
+...
 box.session.su('admin')
 ---
 ...
@@ -262,7 +282,7 @@ box.session.su('guest')
 ...
 #box.space._vindex:select{}
 ---
-- 48
+- 52
 ...
 #box.space._vuser:select{}
 ---
@@ -270,7 +290,7 @@ box.session.su('guest')
 ...
 #box.space._vpriv:select{}
 ---
-- 15
+- 16
 ...
 #box.space._vfunc:select{}
 ---
@@ -280,6 +300,10 @@ box.session.su('guest')
 ---
 - 0
 ...
+#box.space._vcollation:select{}
+---
+- 277
+...
 box.session.su('admin')
 ---
 ...
@@ -631,6 +655,60 @@ seq:drop()
 ---
 ...
 --
+-- _vcollation
+--
+box.session.su('admin')
+---
+...
+box.internal.collation.create('test', 'ICU', 'ru-RU')
+---
+...
+-- Only admin can create collation.
+coll_cnt = #box.space._collation:select{}
+---
+...
+box.schema.user.grant("guest", "read, write, alter, execute", "space", "_collation")
+---
+...
+box.session.su("guest")
+---
+...
+box.internal.collation.create('guest0', 'ICU', 'ru-RU')
+---
+- error: Create access to collation 'guest0' is denied for user 'guest'
+...
+box.space._vcollation:select{0}
+---
+- - [0, 'none', 1, 'BINARY', '', {}]
+...
+#box.space._vcollation:select{} == coll_cnt
+---
+- true
+...
+box.session.su('admin')
+---
+...
+-- _vcollation is readable anyway.
+box.schema.user.revoke("guest", "read", "space", "_collation")
+---
+...
+box.session.su("guest")
+---
+...
+#box.space._vcollation:select{}
+---
+- 278
+...
+session.su('admin')
+---
+...
+box.internal.collation.drop('test')
+---
+...
+box.internal.collation.drop('guest0')
+---
+...
+--
 -- view:alter() tests
 --
 box.space._vspace.index[1]:alter({parts = { 2, 'string' }})
diff --git a/test/box/access_sysview.test.lua b/test/box/access_sysview.test.lua
index c62458407..031df28aa 100644
--- a/test/box/access_sysview.test.lua
+++ b/test/box/access_sysview.test.lua
@@ -31,12 +31,14 @@ session.su('guest')
 #box.space._vspace.index[2]:select('_vuser') ~= 0
 #box.space._vspace.index[2]:select('_vfunc') ~= 0
 #box.space._vspace.index[2]:select('_vpriv') ~= 0
+#box.space._vspace.index[2]:select('_vcollation') ~= 0
 
 #box.space._vindex:select(box.space._vspace.id) > 0
 #box.space._vindex:select(box.space._vindex.id) > 0
 #box.space._vindex:select(box.space._vuser.id) > 0
 #box.space._vindex:select(box.space._vfunc.id) > 0
 #box.space._vindex:select(box.space._vpriv.id) > 0
+#box.space._vindex:select(box.space._vcollation.id) > 0
 
 box.session.su('admin')
 box.schema.user.revoke('guest', 'public')
@@ -48,6 +50,7 @@ box.session.su('guest')
 #box.space._vpriv:select{}
 #box.space._vfunc:select{}
 #box.space._vsequence:select{}
+#box.space._vcollation:select{}
 
 box.session.su('admin')
 box.schema.user.grant('guest', 'public')
@@ -55,6 +58,7 @@ box.session.su('guest')
 
 #box.space._vspace:select{}
 #box.space._vindex:select{}
+#box.space._vcollation:select{}
 
 box.session.su('admin')
 s = box.schema.space.create('test')
@@ -96,6 +100,7 @@ box.session.su('guest')
 #box.space._vuser:select{}
 #box.space._vpriv:select{}
 #box.space._vfunc:select{}
+#box.space._vcollation:select{}
 
 box.session.su('admin')
 box.schema.user.revoke('guest', 'read', 'universe')
@@ -107,6 +112,7 @@ box.session.su('guest')
 #box.space._vpriv:select{}
 #box.space._vfunc:select{}
 #box.space._vsequence:select{}
+#box.space._vcollation:select{}
 
 box.session.su('admin')
 box.schema.user.revoke('guest', 'write', 'universe')
@@ -264,6 +270,30 @@ box.session.su("guest")
 session.su('admin')
 seq:drop()
 
+--
+-- _vcollation
+--
+
+box.session.su('admin')
+box.internal.collation.create('test', 'ICU', 'ru-RU')
+
+-- Only admin can create collation.
+coll_cnt = #box.space._collation:select{}
+box.schema.user.grant("guest", "read, write, alter, execute", "space", "_collation")
+box.session.su("guest")
+box.internal.collation.create('guest0', 'ICU', 'ru-RU')
+box.space._vcollation:select{0}
+#box.space._vcollation:select{} == coll_cnt
+box.session.su('admin')
+
+-- _vcollation is readable anyway.
+box.schema.user.revoke("guest", "read", "space", "_collation")
+box.session.su("guest")
+#box.space._vcollation:select{}
+session.su('admin')
+box.internal.collation.drop('test')
+box.internal.collation.drop('guest0')
+
 --
 -- view:alter() tests
 --
diff --git a/test/box/alter.result b/test/box/alter.result
index c1b1de135..7fb09b4cd 100644
--- a/test/box/alter.result
+++ b/test/box/alter.result
@@ -183,7 +183,11 @@ _index:select{}
 ---
 - - [272, 0, 'primary', 'tree', {'unique': true}, [[0, 'string']]]
   - [276, 0, 'primary', 'tree', {'unique': true}, [[0, 'unsigned']]]
-  - [276, 1, 'name', 'tree', {'unique': true}, [[1, 'string']]]
+  - [276, 1, 'owner', 'tree', {'unique': false}, [[2, 'unsigned']]]
+  - [276, 2, 'name', 'tree', {'unique': true}, [[1, 'string']]]
+  - [277, 0, 'primary', 'tree', {'unique': true}, [[0, 'unsigned']]]
+  - [277, 1, 'owner', 'tree', {'unique': false}, [[2, 'unsigned']]]
+  - [277, 2, 'name', 'tree', {'unique': true}, [[1, 'string']]]
   - [280, 0, 'primary', 'tree', {'unique': true}, [[0, 'unsigned']]]
   - [280, 1, 'owner', 'tree', {'unique': false}, [[1, 'unsigned']]]
   - [280, 2, 'name', 'tree', {'unique': true}, [[2, 'string']]]
diff --git a/test/wal_off/alter.result b/test/wal_off/alter.result
index ee280fcbb..8040efa1a 100644
--- a/test/wal_off/alter.result
+++ b/test/wal_off/alter.result
@@ -28,7 +28,7 @@ end;
 ...
 #spaces;
 ---
-- 65505
+- 65504
 ...
 -- cleanup
 for k, v in pairs(spaces) do
-- 
2.20.1 (Apple Git-117)

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [tarantool-patches] [PATCH 2/2] net.box: fetch '_vcollation' sysview into the module
  2019-05-30 12:36 [tarantool-patches] [PATCH 0/2] Add _vcollation and fetch in net.box Roman Khabibov
  2019-05-30 12:36 ` [tarantool-patches] [PATCH 1/2] schema: add "_vcollation" sysview Roman Khabibov
@ 2019-05-30 12:36 ` Roman Khabibov
  2019-06-04 16:36   ` Vladimir Davydov
  2019-06-03 18:45 ` [tarantool-patches] Re: [PATCH 0/2] Add _vcollation and fetch in net.box Vladislav Shpilevoy
  2019-06-04 15:54 ` [tarantool-patches] " Vladimir Davydov
  3 siblings, 1 reply; 15+ messages in thread
From: Roman Khabibov @ 2019-05-30 12:36 UTC (permalink / raw)
  To: tarantool-patches; +Cc: v.shpilevoy

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)

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [tarantool-patches] Re: [PATCH 0/2] Add _vcollation and fetch in net.box
  2019-05-30 12:36 [tarantool-patches] [PATCH 0/2] Add _vcollation and fetch in net.box Roman Khabibov
  2019-05-30 12:36 ` [tarantool-patches] [PATCH 1/2] schema: add "_vcollation" sysview Roman Khabibov
  2019-05-30 12:36 ` [tarantool-patches] [PATCH 2/2] net.box: fetch '_vcollation' sysview into the module Roman Khabibov
@ 2019-06-03 18:45 ` Vladislav Shpilevoy
  2019-06-04 15:54 ` [tarantool-patches] " Vladimir Davydov
  3 siblings, 0 replies; 15+ messages in thread
From: Vladislav Shpilevoy @ 2019-06-03 18:45 UTC (permalink / raw)
  To: tarantool-patches, Roman Khabibov

Please, provide name of the branch, and issue link.
There are 2 branches on this issue, and I don't know
which one to review.

On 30/05/2019 15:36, Roman Khabibov wrote:
> As I understood "readable for all" means that filter for
> "_vcollation" must always return "true", because the condition
> "User has read access to according system space" is always
> met.
> 
> Roman Khabibov (2):
>   schema: add "_vcollation" sysview
>   net.box: fetch '_vcollation' sysview into the module
> 
>  src/box/bootstrap.snap             | Bin 4374 -> 4441 bytes
>  src/box/lua/net_box.lua            |  24 ++++++--
>  src/box/lua/space.cc               |   2 +
>  src/box/lua/upgrade.lua            |  25 ++++++++
>  src/box/schema_def.h               |   2 +
>  src/box/sysview.c                  |  13 ++++
>  test/app-tap/tarantoolctl.test.lua |   4 +-
>  test/box-py/bootstrap.result       |  13 +++-
>  test/box/access_misc.result        |   4 ++
>  test/box/access_sysview.result     |  92 ++++++++++++++++++++++++++---
>  test/box/access_sysview.test.lua   |  30 ++++++++++
>  test/box/alter.result              |   6 +-
>  test/box/net.box.result            |   2 +-
>  test/box/stat_net.result           |   4 +-
>  test/wal_off/alter.result          |   2 +-
>  15 files changed, 201 insertions(+), 22 deletions(-)
> 

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [tarantool-patches] [PATCH 0/2] Add _vcollation and fetch in net.box
  2019-05-30 12:36 [tarantool-patches] [PATCH 0/2] Add _vcollation and fetch in net.box Roman Khabibov
                   ` (2 preceding siblings ...)
  2019-06-03 18:45 ` [tarantool-patches] Re: [PATCH 0/2] Add _vcollation and fetch in net.box Vladislav Shpilevoy
@ 2019-06-04 15:54 ` Vladimir Davydov
  3 siblings, 0 replies; 15+ messages in thread
From: Vladimir Davydov @ 2019-06-04 15:54 UTC (permalink / raw)
  To: Roman Khabibov; +Cc: tarantool-patches, v.shpilevoy

On Thu, May 30, 2019 at 03:36:01PM +0300, Roman Khabibov wrote:
> As I understood "readable for all" means that filter for
> "_vcollation" must always return "true", because the condition
> "User has read access to according system space" is always
> met.
> 
> Roman Khabibov (2):
>   schema: add "_vcollation" sysview
>   net.box: fetch '_vcollation' sysview into the module

Branch/ticket URLs are missing.

There have been quite a few changes to the master since you submitted
this patch set. Could you please rebase it on top of the latest master
commit?

Also, it looks like this isn't the first version of the patch set.
In future please don't forget to add v2 to subject (--subject-prefix)
and write a very brief change log in the cover letter enumerating
what have changed since the last version.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [tarantool-patches] [PATCH 1/2] schema: add "_vcollation" sysview
  2019-05-30 12:36 ` [tarantool-patches] [PATCH 1/2] schema: add "_vcollation" sysview Roman Khabibov
@ 2019-06-04 16:31   ` Vladimir Davydov
  2019-06-05 17:08     ` [tarantool-patches] " Roman Khabibov
  0 siblings, 1 reply; 15+ messages in thread
From: Vladimir Davydov @ 2019-06-04 16:31 UTC (permalink / raw)
  To: Roman Khabibov; +Cc: tarantool-patches, v.shpilevoy

On Thu, May 30, 2019 at 03:36:02PM +0300, Roman Khabibov wrote:
> diff --git a/src/box/lua/upgrade.lua b/src/box/lua/upgrade.lua
> index 89d6e3d52..f2a1be639 100644
> --- a/src/box/lua/upgrade.lua
> +++ b/src/box/lua/upgrade.lua
> @@ -737,6 +737,30 @@ local function upgrade_to_2_1_3()
>      end
>  end
>  
> +local function create_vcollation_space()
> +    local _collation = box.space._collation
> +    local format = _collation:format()
> +    create_sysview(box.schema.COLLATION_ID, box.schema.VCOLLATION_ID)
> +    box.space[box.schema.VCOLLATION_ID]:format(format)
> +end
> +
> +local function upgrade_to_2_1_4()
> +    local _collation = box.space._collation
> +    local _index = box.space._index
> +
> +    -- System space format usually is in order "id, owner, name...".
> +    -- The fields "name", "owner" are swapped in "_collation" format,
> +    -- due to the field "owner" was added after the "_collation" creation.
> +    box.space._index:delete{276, 1}
> +    log.info("update index name on _collation")
> +    box.space._index:insert{_collation.id, 2, 'name', 'tree', {unique = true},
> +                            {{1, 'string'}}}
> +    log.info("create index owner on _collation")
> +    box.space._index:insert{_collation.id, 1, 'owner', 'tree', {unique = false},
> +                            {{2, 'unsigned'}}}

I don't understand this part. Why do you need to create 'owner' index?
Why do you need to update 'name' index?

> +    create_vcollation_space()
> +end
> +
>  local function get_version()
>      local version = box.space._schema:get{'version'}
>      if version == nil then
> @@ -768,6 +792,7 @@ local function upgrade(options)
>          {version = mkversion(2, 1, 1), func = upgrade_to_2_1_1, auto = true},
>          {version = mkversion(2, 1, 2), func = upgrade_to_2_1_2, auto = true},
>          {version = mkversion(2, 1, 3), func = upgrade_to_2_1_3, auto = true},
> +        {version = mkversion(2, 1, 4), func = upgrade_to_2_1_4, auto = true}

Should be in upgrade_to_2_2_1.

>      }
>  
>      for _, handler in ipairs(handlers) do
> diff --git a/src/box/schema_def.h b/src/box/schema_def.h
> index eeeeb950b..77c004690 100644
> --- a/src/box/schema_def.h
> +++ b/src/box/schema_def.h
> @@ -72,6 +72,8 @@ enum {
>  	BOX_SCHEMA_ID = 272,
>  	/** Space id of _collation. */
>  	BOX_COLLATION_ID = 276,
> +	/** Space id of _vcollation. */
> +	BOX_VCOLLATION_ID = 277,
>  	/** Space id of _space. */
>  	BOX_SPACE_ID = 280,
>  	/** Space id of _vspace view. */
> diff --git a/src/box/sysview.c b/src/box/sysview.c
> index 96c5e78ca..0d1259af0 100644
> --- a/src/box/sysview.c
> +++ b/src/box/sysview.c
> @@ -402,6 +402,14 @@ vsequence_filter(struct space *source, struct tuple *tuple)
>  	       ((PRIV_WRDA | PRIV_X) & effective);
>  }
>  
> +static bool
> +	vcollation_filter(struct space *source, struct tuple *tuple)
> +	{
> +		(void) source;
> +		(void) tuple;
> +		return true;
> +	}
> +

Bad indentation.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [tarantool-patches] [PATCH 2/2] net.box: fetch '_vcollation' sysview into the module
  2019-05-30 12:36 ` [tarantool-patches] [PATCH 2/2] net.box: fetch '_vcollation' sysview into the module Roman Khabibov
@ 2019-06-04 16:36   ` Vladimir Davydov
  2019-06-05 17:08     ` [tarantool-patches] " Roman Khabibov
  0 siblings, 1 reply; 15+ messages in thread
From: Vladimir Davydov @ 2019-06-04 16:36 UTC (permalink / raw)
  To: Roman Khabibov; +Cc: tarantool-patches, v.shpilevoy

On Thu, May 30, 2019 at 03:36:03PM +0300, Roman Khabibov wrote:
> 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(-)

This one looks good to me, but you probably need to write a doc bot
request.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [tarantool-patches] Re: [PATCH 2/2] net.box: fetch '_vcollation' sysview into the module
  2019-06-04 16:36   ` Vladimir Davydov
@ 2019-06-05 17:08     ` Roman Khabibov
  2019-06-05 17:28       ` Vladimir Davydov
  0 siblings, 1 reply; 15+ messages in thread
From: Roman Khabibov @ 2019-06-05 17:08 UTC (permalink / raw)
  To: tarantool-patches; +Cc: Vladimir Davydov


> On Jun 4, 2019, at 7:36 PM, Vladimir Davydov <vdavydov.dev@gmail.com> wrote:
> 
> On Thu, May 30, 2019 at 03:36:03PM +0300, Roman Khabibov wrote:
>> 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(-)
> 
> This one looks good to me, but you probably need to write a doc bot
> request.
> 
What should I write in this request? I understood, that you meant
info about _vcollation existance.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [tarantool-patches] Re: [PATCH 1/2] schema: add "_vcollation" sysview
  2019-06-04 16:31   ` Vladimir Davydov
@ 2019-06-05 17:08     ` Roman Khabibov
  2019-06-05 17:56       ` Vladimir Davydov
  0 siblings, 1 reply; 15+ messages in thread
From: Roman Khabibov @ 2019-06-05 17:08 UTC (permalink / raw)
  To: tarantool-patches; +Cc: Vladimir Davydov

Hi! Thanks for the review.

> On Jun 4, 2019, at 7:31 PM, Vladimir Davydov <vdavydov.dev@gmail.com> wrote:
> 
> On Thu, May 30, 2019 at 03:36:02PM +0300, Roman Khabibov wrote:
>> diff --git a/src/box/lua/upgrade.lua b/src/box/lua/upgrade.lua
>> index 89d6e3d52..f2a1be639 100644
>> --- a/src/box/lua/upgrade.lua
>> +++ b/src/box/lua/upgrade.lua
>> @@ -737,6 +737,30 @@ local function upgrade_to_2_1_3()
>>     end
>> end
>> 
>> +local function create_vcollation_space()
>> +    local _collation = box.space._collation
>> +    local format = _collation:format()
>> +    create_sysview(box.schema.COLLATION_ID, box.schema.VCOLLATION_ID)
>> +    box.space[box.schema.VCOLLATION_ID]:format(format)
>> +end
>> +
>> +local function upgrade_to_2_1_4()
>> +    local _collation = box.space._collation
>> +    local _index = box.space._index
>> +
>> +    -- System space format usually is in order "id, owner, name...".
>> +    -- The fields "name", "owner" are swapped in "_collation" format,
>> +    -- due to the field "owner" was added after the "_collation" creation.
>> +    box.space._index:delete{276, 1}
>> +    log.info("update index name on _collation")
>> +    box.space._index:insert{_collation.id, 2, 'name', 'tree', {unique = true},
>> +                            {{1, 'string'}}}
>> +    log.info("create index owner on _collation")
>> +    box.space._index:insert{_collation.id, 1, 'owner', 'tree', {unique = false},
>> +                            {{2, 'unsigned'}}}
> 
> I don't understand this part. Why do you need to create 'owner' index?
> Why do you need to update 'name' index?
create_sysview() can’t work otherwise.

+
+-- Fit _collation indexes to be suitable forcreate_sysview().
+local function upgrade_collation_to_2_2_2()
+    local _collation = box.space._collation
+    local _index = box.space._index

> 
>> +    create_vcollation_space()
>> +end
>> +
>> local function get_version()
>>     local version = box.space._schema:get{'version'}
>>     if version == nil then
>> @@ -768,6 +792,7 @@ local function upgrade(options)
>>         {version = mkversion(2, 1, 1), func = upgrade_to_2_1_1, auto = true},
>>         {version = mkversion(2, 1, 2), func = upgrade_to_2_1_2, auto = true},
>>         {version = mkversion(2, 1, 3), func = upgrade_to_2_1_3, auto = true},
>> +        {version = mkversion(2, 1, 4), func = upgrade_to_2_1_4, auto = true}
> 
> Should be in upgrade_to_2_2_1.
To 2.2.2 maybe?

+--------------------------------------------------------------------------------
+-- Tarantool 2.2.2
+--------------------------------------------------------------------------------
+
+-- Fit _collation space to be suitable for create_sysview().
+local function upgrade_collation_to_2_2_2()
+    local _collation = box.space._collation
+    local _index = box.space._index
+
+    -- System space format usually is in order "id, owner,
+    -- name...". The fields "name", "owner" are swapped in
+    -- "_collation" format, due to the field "owner" was added
+    -- after the "_collation" creation.
+    box.space._index:delete{276, 1}
+    log.info("update index name on _collation")
+    box.space._index:insert{_collation.id, 2, 'name', 'tree', {unique = true},
+                            {{1, 'string'}}}
+    log.info("create index owner on _collation")
+    box.space._index:insert{_collation.id, 1, 'owner', 'tree', {unique = false},
+                            {{2, 'unsigned'}}}
+end
+
+local function create_vcollation_space()
+    local _collation = box.space._collation
+    local format = _collation:format()
+    create_sysview(box.schema.COLLATION_ID, box.schema.VCOLLATION_ID)
+    box.space[box.schema.VCOLLATION_ID]:format(format)
+end
+
+local function upgrade_to_2_2_2()
+    upgrade_collation_to_2_2_2()
+    create_vcollation_space()
+end
+
 --------------------------------------------------------------------------------
>>     }
>> 
>>     for _, handler in ipairs(handlers) do
>> diff --git a/src/box/schema_def.h b/src/box/schema_def.h
>> index eeeeb950b..77c004690 100644
>> --- a/src/box/schema_def.h
>> +++ b/src/box/schema_def.h
>> @@ -72,6 +72,8 @@ enum {
>> 	BOX_SCHEMA_ID = 272,
>> 	/** Space id of _collation. */
>> 	BOX_COLLATION_ID = 276,
>> +	/** Space id of _vcollation. */
>> +	BOX_VCOLLATION_ID = 277,
>> 	/** Space id of _space. */
>> 	BOX_SPACE_ID = 280,
>> 	/** Space id of _vspace view. */
>> diff --git a/src/box/sysview.c b/src/box/sysview.c
>> index 96c5e78ca..0d1259af0 100644
>> --- a/src/box/sysview.c
>> +++ b/src/box/sysview.c
>> @@ -402,6 +402,14 @@ vsequence_filter(struct space *source, struct tuple *tuple)
>> 	       ((PRIV_WRDA | PRIV_X) & effective);
>> }
>> 
>> +static bool
>> +	vcollation_filter(struct space *source, struct tuple *tuple)
>> +	{
>> +		(void) source;
>> +		(void) tuple;
>> +		return true;
>> +	}
>> +
> 
> Bad indentation.
+static bool
+vcollation_filter(struct space *source, struct tuple *tuple)
+{
+	(void) source;
+	(void) tuple;
+	return true;
+}
+

commit e67cd253a41f5e010c00b5cb38059224850e86c4
Author: Roman Khabibov <roman.habibov@tarantool.org>
Date:   Thu May 16 02:06:39 2019 +0300

    schema: add "_vcollation" sysview
    
    Add "_vcollation" sysview to read it from net.box. This
    sysview is always readable, except when a user doesn't have
    "public" role.
    
    Needed for #3941
    
    @TarantoolBot document
    Title: box.space._vcollation
    
    _vcollation is a system space that represents a virtual view.
    The structure of its tuples is identical to that of _collation.
    Tuples of this sysview is always readable, except when the user
    doesn't have "public" role.

diff --git a/src/box/bootstrap.snap b/src/box/bootstrap.snap
index bb8fbeba1..f01a34670 100644
Binary files a/src/box/bootstrap.snap and b/src/box/bootstrap.snap differ
diff --git a/src/box/lua/space.cc b/src/box/lua/space.cc
index 87adaeb16..5d837eda6 100644
--- a/src/box/lua/space.cc
+++ b/src/box/lua/space.cc
@@ -540,6 +540,8 @@ box_lua_space_init(struct lua_State *L)
 	lua_setfield(L, -2, "FUNC_ID");
 	lua_pushnumber(L, BOX_COLLATION_ID);
 	lua_setfield(L, -2, "COLLATION_ID");
+	lua_pushnumber(L, BOX_VCOLLATION_ID);
+	lua_setfield(L, -2, "VCOLLATION_ID");
 	lua_pushnumber(L, BOX_VFUNC_ID);
 	lua_setfield(L, -2, "VFUNC_ID");
 	lua_pushnumber(L, BOX_PRIV_ID);
diff --git a/src/box/lua/upgrade.lua b/src/box/lua/upgrade.lua
index 070662698..b7fb08014 100644
--- a/src/box/lua/upgrade.lua
+++ b/src/box/lua/upgrade.lua
@@ -778,6 +778,40 @@ local function upgrade_to_2_2_1()
     upgrade_sequence_to_2_2_1()
 end
 
+--------------------------------------------------------------------------------
+-- Tarantool 2.2.2
+--------------------------------------------------------------------------------
+
+-- Fit _collation indexes to be suitable forcreate_sysview().
+local function upgrade_collation_to_2_2_2()
+    local _collation = box.space._collation
+    local _index = box.space._index
+
+    -- System space format usually is in order "id, owner,
+    -- name...". The fields "name", "owner" are swapped in
+    -- "_collation" format, due to the field "owner" was added
+    -- after the "_collation" creation.
+    box.space._index:delete{276, 1}
+    log.info("update index name on _collation")
+    box.space._index:insert{_collation.id, 2, 'name', 'tree', {unique = true},
+                            {{1, 'string'}}}
+    log.info("create index owner on _collation")
+    box.space._index:insert{_collation.id, 1, 'owner', 'tree', {unique = false},
+                            {{2, 'unsigned'}}}
+end
+
+local function create_vcollation_space()
+    local _collation = box.space._collation
+    local format = _collation:format()
+    create_sysview(box.schema.COLLATION_ID, box.schema.VCOLLATION_ID)
+    box.space[box.schema.VCOLLATION_ID]:format(format)
+end
+
+local function upgrade_to_2_2_2()
+    upgrade_collation_to_2_2_2()
+    create_vcollation_space()
+end
+
 --------------------------------------------------------------------------------
 
 local function get_version()
@@ -812,6 +846,7 @@ local function upgrade(options)
         {version = mkversion(2, 1, 2), func = upgrade_to_2_1_2, auto = true},
         {version = mkversion(2, 1, 3), func = upgrade_to_2_1_3, auto = true},
         {version = mkversion(2, 2, 1), func = upgrade_to_2_2_1, auto = true},
+        {version = mkversion(2, 2, 2), func = upgrade_to_2_2_2, auto = true}
     }
 
     for _, handler in ipairs(handlers) do
diff --git a/src/box/schema_def.h b/src/box/schema_def.h
index b817b49f6..e0febb640 100644
--- a/src/box/schema_def.h
+++ b/src/box/schema_def.h
@@ -72,6 +72,8 @@ enum {
 	BOX_SCHEMA_ID = 272,
 	/** Space id of _collation. */
 	BOX_COLLATION_ID = 276,
+	/** Space id of _vcollation. */
+	BOX_VCOLLATION_ID = 277,
 	/** Space id of _space. */
 	BOX_SPACE_ID = 280,
 	/** Space id of _vspace view. */
diff --git a/src/box/sysview.c b/src/box/sysview.c
index 96c5e78ca..46cf1e13f 100644
--- a/src/box/sysview.c
+++ b/src/box/sysview.c
@@ -402,6 +402,14 @@ vsequence_filter(struct space *source, struct tuple *tuple)
 	       ((PRIV_WRDA | PRIV_X) & effective);
 }
 
+static bool
+vcollation_filter(struct space *source, struct tuple *tuple)
+{
+	(void) source;
+	(void) tuple;
+	return true;
+}
+
 static struct index *
 sysview_space_create_index(struct space *space, struct index_def *def)
 {
@@ -448,6 +456,11 @@ sysview_space_create_index(struct space *space, struct index_def *def)
 		source_index_id = def->iid;
 		filter = vsequence_filter;
 		break;
+	case BOX_VCOLLATION_ID:
+		source_space_id = BOX_COLLATION_ID;
+		source_index_id = def->iid;
+		filter = vcollation_filter;
+		break;
 	default:
 		diag_set(ClientError, ER_MODIFY_INDEX,
 			 def->name, space_name(space),
diff --git a/test/app-tap/tarantoolctl.test.lua b/test/app-tap/tarantoolctl.test.lua
index c1e1490ca..ac1efa0ba 100755
--- a/test/app-tap/tarantoolctl.test.lua
+++ b/test/app-tap/tarantoolctl.test.lua
@@ -405,8 +405,8 @@ do
             check_ctlcat_xlog(test_i, dir, "--from=3 --to=6 --format=json --show-system --replica 1", "\n", 3)
             check_ctlcat_xlog(test_i, dir, "--from=3 --to=6 --format=json --show-system --replica 1 --replica 2", "\n", 3)
             check_ctlcat_xlog(test_i, dir, "--from=3 --to=6 --format=json --show-system --replica 2", "\n", 0)
-            check_ctlcat_snap(test_i, dir, "--space=280", "---\n", 21)
-            check_ctlcat_snap(test_i, dir, "--space=288", "---\n", 47)
+            check_ctlcat_snap(test_i, dir, "--space=280", "---\n", 22)
+            check_ctlcat_snap(test_i, dir, "--space=288", "---\n", 51)
         end)
     end)
 
diff --git a/test/box-py/bootstrap.result b/test/box-py/bootstrap.result
index 0684914c0..c8c37eb06 100644
--- a/test/box-py/bootstrap.result
+++ b/test/box-py/bootstrap.result
@@ -4,7 +4,7 @@ box.internal.bootstrap()
 box.space._schema:select{}
 ---
 - - ['max_id', 511]
-  - ['version', 2, 2, 1]
+  - ['version', 2, 2, 2]
 ...
 box.space._cluster:select{}
 ---
@@ -21,6 +21,10 @@ box.space._space:select{}
         'name': 'name', 'type': 'string'}, {'name': 'owner', 'type': 'unsigned'},
       {'name': 'type', 'type': 'string'}, {'name': 'locale', 'type': 'string'}, {
         'name': 'opts', 'type': 'map'}]]
+  - [277, 1, '_vcollation', 'sysview', 0, {}, [{'name': 'id', 'type': 'unsigned'},
+      {'name': 'name', 'type': 'string'}, {'name': 'owner', 'type': 'unsigned'}, {
+        'name': 'type', 'type': 'string'}, {'name': 'locale', 'type': 'string'}, {
+        'name': 'opts', 'type': 'map'}]]
   - [280, 1, '_space', 'memtx', 0, {}, [{'name': 'id', 'type': 'unsigned'}, {'name': 'owner',
         'type': 'unsigned'}, {'name': 'name', 'type': 'string'}, {'name': 'engine',
         'type': 'string'}, {'name': 'field_count', 'type': 'unsigned'}, {'name': 'flags',
@@ -84,7 +88,11 @@ box.space._index:select{}
 ---
 - - [272, 0, 'primary', 'tree', {'unique': true}, [[0, 'string']]]
   - [276, 0, 'primary', 'tree', {'unique': true}, [[0, 'unsigned']]]
-  - [276, 1, 'name', 'tree', {'unique': true}, [[1, 'string']]]
+  - [276, 1, 'owner', 'tree', {'unique': false}, [[2, 'unsigned']]]
+  - [276, 2, 'name', 'tree', {'unique': true}, [[1, 'string']]]
+  - [277, 0, 'primary', 'tree', {'unique': true}, [[0, 'unsigned']]]
+  - [277, 1, 'owner', 'tree', {'unique': false}, [[2, 'unsigned']]]
+  - [277, 2, 'name', 'tree', {'unique': true}, [[1, 'string']]]
   - [280, 0, 'primary', 'tree', {'unique': true}, [[0, 'unsigned']]]
   - [280, 1, 'owner', 'tree', {'unique': false}, [[1, 'unsigned']]]
   - [280, 2, 'name', 'tree', {'unique': true}, [[2, 'string']]]
@@ -151,6 +159,7 @@ box.space._priv:select{}
   - [1, 1, 'universe', 0, 4294967295]
   - [1, 2, 'function', 1, 4]
   - [1, 2, 'space', 276, 2]
+  - [1, 2, 'space', 277, 1]
   - [1, 2, 'space', 281, 1]
   - [1, 2, 'space', 286, 1]
   - [1, 2, 'space', 289, 1]
diff --git a/test/box/access_misc.result b/test/box/access_misc.result
index 24bdd9d63..d5bb8b208 100644
--- a/test/box/access_misc.result
+++ b/test/box/access_misc.result
@@ -761,6 +761,10 @@ box.space._space:select()
         'name': 'name', 'type': 'string'}, {'name': 'owner', 'type': 'unsigned'},
       {'name': 'type', 'type': 'string'}, {'name': 'locale', 'type': 'string'}, {
         'name': 'opts', 'type': 'map'}]]
+  - [277, 1, '_vcollation', 'sysview', 0, {}, [{'name': 'id', 'type': 'unsigned'},
+      {'name': 'name', 'type': 'string'}, {'name': 'owner', 'type': 'unsigned'}, {
+        'name': 'type', 'type': 'string'}, {'name': 'locale', 'type': 'string'}, {
+        'name': 'opts', 'type': 'map'}]]
   - [280, 1, '_space', 'memtx', 0, {}, [{'name': 'id', 'type': 'unsigned'}, {'name': 'owner',
         'type': 'unsigned'}, {'name': 'name', 'type': 'string'}, {'name': 'engine',
         'type': 'string'}, {'name': 'field_count', 'type': 'unsigned'}, {'name': 'flags',
diff --git a/test/box/access_sysview.result b/test/box/access_sysview.result
index c6a2b22ed..96976babb 100644
--- a/test/box/access_sysview.result
+++ b/test/box/access_sysview.result
@@ -74,6 +74,10 @@ session.su('guest')
 ---
 - true
 ...
+#box.space._vspace.index[2]:select('_vcollation') ~= 0
+---
+- true
+...
 #box.space._vindex:select(box.space._vspace.id) > 0
 ---
 - true
@@ -94,6 +98,10 @@ session.su('guest')
 ---
 - true
 ...
+#box.space._vindex:select(box.space._vcollation.id) > 0
+---
+- true
+...
 box.session.su('admin')
 ---
 ...
@@ -127,6 +135,10 @@ box.session.su('guest')
 ---
 - error: Read access to space '_vsequence' is denied for user 'guest'
 ...
+#box.space._vcollation:select{}
+---
+- error: Read access to space '_vcollation' is denied for user 'guest'
+...
 box.session.su('admin')
 ---
 ...
@@ -138,11 +150,15 @@ box.session.su('guest')
 ...
 #box.space._vspace:select{}
 ---
-- 8
+- 9
 ...
 #box.space._vindex:select{}
 ---
-- 20
+- 24
+...
+#box.space._vcollation:select{}
+---
+- 277
 ...
 box.session.su('admin')
 ---
@@ -230,11 +246,11 @@ box.session.su('guest')
 ...
 #box.space._vspace:select{}
 ---
-- 22
+- 23
 ...
 #box.space._vindex:select{}
 ---
-- 48
+- 52
 ...
 #box.space._vuser:select{}
 ---
@@ -242,12 +258,16 @@ box.session.su('guest')
 ...
 #box.space._vpriv:select{}
 ---
-- 15
+- 16
 ...
 #box.space._vfunc:select{}
 ---
 - 1
 ...
+#box.space._vcollation:select{}
+---
+- 277
+...
 box.session.su('admin')
 ---
 ...
@@ -262,7 +282,7 @@ box.session.su('guest')
 ...
 #box.space._vindex:select{}
 ---
-- 48
+- 52
 ...
 #box.space._vuser:select{}
 ---
@@ -270,7 +290,7 @@ box.session.su('guest')
 ...
 #box.space._vpriv:select{}
 ---
-- 15
+- 16
 ...
 #box.space._vfunc:select{}
 ---
@@ -280,6 +300,10 @@ box.session.su('guest')
 ---
 - 0
 ...
+#box.space._vcollation:select{}
+---
+- 277
+...
 box.session.su('admin')
 ---
 ...
@@ -631,6 +655,60 @@ seq:drop()
 ---
 ...
 --
+-- _vcollation
+--
+box.session.su('admin')
+---
+...
+box.internal.collation.create('test', 'ICU', 'ru-RU')
+---
+...
+-- Only admin can create collation.
+coll_cnt = #box.space._collation:select{}
+---
+...
+box.schema.user.grant("guest", "read, write, alter, execute", "space", "_collation")
+---
+...
+box.session.su("guest")
+---
+...
+box.internal.collation.create('guest0', 'ICU', 'ru-RU')
+---
+- error: Create access to collation 'guest0' is denied for user 'guest'
+...
+box.space._vcollation:select{0}
+---
+- - [0, 'none', 1, 'BINARY', '', {}]
+...
+#box.space._vcollation:select{} == coll_cnt
+---
+- true
+...
+box.session.su('admin')
+---
+...
+-- _vcollation is readable anyway.
+box.schema.user.revoke("guest", "read", "space", "_collation")
+---
+...
+box.session.su("guest")
+---
+...
+#box.space._vcollation:select{}
+---
+- 278
+...
+session.su('admin')
+---
+...
+box.internal.collation.drop('test')
+---
+...
+box.internal.collation.drop('guest0')
+---
+...
+--
 -- view:alter() tests
 --
 box.space._vspace.index[1]:alter({parts = { 2, 'string' }})
diff --git a/test/box/access_sysview.test.lua b/test/box/access_sysview.test.lua
index c62458407..031df28aa 100644
--- a/test/box/access_sysview.test.lua
+++ b/test/box/access_sysview.test.lua
@@ -31,12 +31,14 @@ session.su('guest')
 #box.space._vspace.index[2]:select('_vuser') ~= 0
 #box.space._vspace.index[2]:select('_vfunc') ~= 0
 #box.space._vspace.index[2]:select('_vpriv') ~= 0
+#box.space._vspace.index[2]:select('_vcollation') ~= 0
 
 #box.space._vindex:select(box.space._vspace.id) > 0
 #box.space._vindex:select(box.space._vindex.id) > 0
 #box.space._vindex:select(box.space._vuser.id) > 0
 #box.space._vindex:select(box.space._vfunc.id) > 0
 #box.space._vindex:select(box.space._vpriv.id) > 0
+#box.space._vindex:select(box.space._vcollation.id) > 0
 
 box.session.su('admin')
 box.schema.user.revoke('guest', 'public')
@@ -48,6 +50,7 @@ box.session.su('guest')
 #box.space._vpriv:select{}
 #box.space._vfunc:select{}
 #box.space._vsequence:select{}
+#box.space._vcollation:select{}
 
 box.session.su('admin')
 box.schema.user.grant('guest', 'public')
@@ -55,6 +58,7 @@ box.session.su('guest')
 
 #box.space._vspace:select{}
 #box.space._vindex:select{}
+#box.space._vcollation:select{}
 
 box.session.su('admin')
 s = box.schema.space.create('test')
@@ -96,6 +100,7 @@ box.session.su('guest')
 #box.space._vuser:select{}
 #box.space._vpriv:select{}
 #box.space._vfunc:select{}
+#box.space._vcollation:select{}
 
 box.session.su('admin')
 box.schema.user.revoke('guest', 'read', 'universe')
@@ -107,6 +112,7 @@ box.session.su('guest')
 #box.space._vpriv:select{}
 #box.space._vfunc:select{}
 #box.space._vsequence:select{}
+#box.space._vcollation:select{}
 
 box.session.su('admin')
 box.schema.user.revoke('guest', 'write', 'universe')
@@ -264,6 +270,30 @@ box.session.su("guest")
 session.su('admin')
 seq:drop()
 
+--
+-- _vcollation
+--
+
+box.session.su('admin')
+box.internal.collation.create('test', 'ICU', 'ru-RU')
+
+-- Only admin can create collation.
+coll_cnt = #box.space._collation:select{}
+box.schema.user.grant("guest", "read, write, alter, execute", "space", "_collation")
+box.session.su("guest")
+box.internal.collation.create('guest0', 'ICU', 'ru-RU')
+box.space._vcollation:select{0}
+#box.space._vcollation:select{} == coll_cnt
+box.session.su('admin')
+
+-- _vcollation is readable anyway.
+box.schema.user.revoke("guest", "read", "space", "_collation")
+box.session.su("guest")
+#box.space._vcollation:select{}
+session.su('admin')
+box.internal.collation.drop('test')
+box.internal.collation.drop('guest0')
+
 --
 -- view:alter() tests
 --
diff --git a/test/box/alter.result b/test/box/alter.result
index e83c0b7ef..ba1405cf1 100644
--- a/test/box/alter.result
+++ b/test/box/alter.result
@@ -168,7 +168,11 @@ _index:select{}
 ---
 - - [272, 0, 'primary', 'tree', {'unique': true}, [[0, 'string']]]
   - [276, 0, 'primary', 'tree', {'unique': true}, [[0, 'unsigned']]]
-  - [276, 1, 'name', 'tree', {'unique': true}, [[1, 'string']]]
+  - [276, 1, 'owner', 'tree', {'unique': false}, [[2, 'unsigned']]]
+  - [276, 2, 'name', 'tree', {'unique': true}, [[1, 'string']]]
+  - [277, 0, 'primary', 'tree', {'unique': true}, [[0, 'unsigned']]]
+  - [277, 1, 'owner', 'tree', {'unique': false}, [[2, 'unsigned']]]
+  - [277, 2, 'name', 'tree', {'unique': true}, [[1, 'string']]]
   - [280, 0, 'primary', 'tree', {'unique': true}, [[0, 'unsigned']]]
   - [280, 1, 'owner', 'tree', {'unique': false}, [[1, 'unsigned']]]
   - [280, 2, 'name', 'tree', {'unique': true}, [[2, 'string']]]
diff --git a/test/wal_off/alter.result b/test/wal_off/alter.result
index ee280fcbb..8040efa1a 100644
--- a/test/wal_off/alter.result
+++ b/test/wal_off/alter.result
@@ -28,7 +28,7 @@ end;
 ...
 #spaces;
 ---
-- 65505
+- 65504
 ...
 -- cleanup
 for k, v in pairs(spaces) do

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [tarantool-patches] Re: [PATCH 2/2] net.box: fetch '_vcollation' sysview into the module
  2019-06-05 17:08     ` [tarantool-patches] " Roman Khabibov
@ 2019-06-05 17:28       ` Vladimir Davydov
  2019-06-06 15:22         ` Roman Khabibov
  2019-06-06 16:00         ` Roman Khabibov
  0 siblings, 2 replies; 15+ messages in thread
From: Vladimir Davydov @ 2019-06-05 17:28 UTC (permalink / raw)
  To: Roman Khabibov; +Cc: tarantool-patches

On Wed, Jun 05, 2019 at 08:08:39PM +0300, Roman Khabibov wrote:
> 
> > On Jun 4, 2019, at 7:36 PM, Vladimir Davydov <vdavydov.dev@gmail.com> wrote:
> > 
> > On Thu, May 30, 2019 at 03:36:03PM +0300, Roman Khabibov wrote:
> >> 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(-)
> > 
> > This one looks good to me, but you probably need to write a doc bot
> > request.
> > 
> What should I write in this request? I understood, that you meant
> info about _vcollation existance.

Yep, something like this I suppose:

  https://www.tarantool.io/en/doc/2.1/book/box/box_space/#box-space-vspace

BTW we miss _vsequence documentation. Should be added as well.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [tarantool-patches] Re: [PATCH 1/2] schema: add "_vcollation" sysview
  2019-06-05 17:08     ` [tarantool-patches] " Roman Khabibov
@ 2019-06-05 17:56       ` Vladimir Davydov
  2019-06-06 15:18         ` Roman Khabibov
  0 siblings, 1 reply; 15+ messages in thread
From: Vladimir Davydov @ 2019-06-05 17:56 UTC (permalink / raw)
  To: Roman Khabibov; +Cc: tarantool-patches

On Wed, Jun 05, 2019 at 08:08:46PM +0300, Roman Khabibov wrote:
> >> +local function upgrade_to_2_1_4()
> >> +    local _collation = box.space._collation
> >> +    local _index = box.space._index
> >> +
> >> +    -- System space format usually is in order "id, owner, name...".
> >> +    -- The fields "name", "owner" are swapped in "_collation" format,
> >> +    -- due to the field "owner" was added after the "_collation" creation.
> >> +    box.space._index:delete{276, 1}
> >> +    log.info("update index name on _collation")
> >> +    box.space._index:insert{_collation.id, 2, 'name', 'tree', {unique = true},
> >> +                            {{1, 'string'}}}
> >> +    log.info("create index owner on _collation")
> >> +    box.space._index:insert{_collation.id, 1, 'owner', 'tree', {unique = false},
> >> +                            {{2, 'unsigned'}}}
> > 
> > I don't understand this part. Why do you need to create 'owner' index?
> > Why do you need to update 'name' index?
> create_sysview() can’t work otherwise.

I fail to see why is that. Could you please elaborate?

> 
> +
> +-- Fit _collation indexes to be suitable forcreate_sysview().
> +local function upgrade_collation_to_2_2_2()
> +    local _collation = box.space._collation
> +    local _index = box.space._index
> 
> > 
> >> +    create_vcollation_space()
> >> +end
> >> +
> >> local function get_version()
> >>     local version = box.space._schema:get{'version'}
> >>     if version == nil then
> >> @@ -768,6 +792,7 @@ local function upgrade(options)
> >>         {version = mkversion(2, 1, 1), func = upgrade_to_2_1_1, auto = true},
> >>         {version = mkversion(2, 1, 2), func = upgrade_to_2_1_2, auto = true},
> >>         {version = mkversion(2, 1, 3), func = upgrade_to_2_1_3, auto = true},
> >> +        {version = mkversion(2, 1, 4), func = upgrade_to_2_1_4, auto = true}
> > 
> > Should be in upgrade_to_2_2_1.
> To 2.2.2 maybe?

No. The last release was 2.2.0 so the next one will be 2.2.1.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [tarantool-patches] Re: [PATCH 1/2] schema: add "_vcollation" sysview
  2019-06-05 17:56       ` Vladimir Davydov
@ 2019-06-06 15:18         ` Roman Khabibov
  0 siblings, 0 replies; 15+ messages in thread
From: Roman Khabibov @ 2019-06-06 15:18 UTC (permalink / raw)
  To: tarantool-patches; +Cc: Vladimir Davydov



> On Jun 5, 2019, at 8:56 PM, Vladimir Davydov <vdavydov.dev@gmail.com> wrote:
> 
> On Wed, Jun 05, 2019 at 08:08:46PM +0300, Roman Khabibov wrote:
>>>> +local function upgrade_to_2_1_4()
>>>> +    local _collation = box.space._collation
>>>> +    local _index = box.space._index
>>>> +
>>>> +    -- System space format usually is in order "id, owner, name...".
>>>> +    -- The fields "name", "owner" are swapped in "_collation" format,
>>>> +    -- due to the field "owner" was added after the "_collation" creation.
>>>> +    box.space._index:delete{276, 1}
>>>> +    log.info("update index name on _collation")
>>>> +    box.space._index:insert{_collation.id, 2, 'name', 'tree', {unique = true},
>>>> +                            {{1, 'string'}}}
>>>> +    log.info("create index owner on _collation")
>>>> +    box.space._index:insert{_collation.id, 1, 'owner', 'tree', {unique = false},
>>>> +                            {{2, 'unsigned'}}}
>>> 
>>> I don't understand this part. Why do you need to create 'owner' index?
>>> Why do you need to update 'name' index?
>> create_sysview() can’t work otherwise.
> 
> I fail to see why is that. Could you please elaborate
You were right. I actually don’t need it. Removed.
>> 
>> +
>> +-- Fit _collation indexes to be suitable forcreate_sysview().
>> +local function upgrade_collation_to_2_2_2()
>> +    local _collation = box.space._collation
>> +    local _index = box.space._index
>> 
>>> 
>>>> +    create_vcollation_space()
>>>> +end
>>>> +
>>>> local function get_version()
>>>>    local version = box.space._schema:get{'version'}
>>>>    if version == nil then
>>>> @@ -768,6 +792,7 @@ local function upgrade(options)
>>>>        {version = mkversion(2, 1, 1), func = upgrade_to_2_1_1, auto = true},
>>>>        {version = mkversion(2, 1, 2), func = upgrade_to_2_1_2, auto = true},
>>>>        {version = mkversion(2, 1, 3), func = upgrade_to_2_1_3, auto = true},
>>>> +        {version = mkversion(2, 1, 4), func = upgrade_to_2_1_4, auto = true}
>>> 
>>> Should be in upgrade_to_2_2_1.
>> To 2.2.2 maybe?
> 
> No. The last release was 2.2.0 so the next one will be 2.2.1.
Done.

+local function create_vcollation_space()
+    local _collation = box.space._collation
+    local format = _collation:format()
+    create_sysview(box.schema.COLLATION_ID, box.schema.VCOLLATION_ID)
+    box.space[box.schema.VCOLLATION_ID]:format(format)
+end
+
 -- Add sequence field to _space_sequence table
 local function upgrade_sequence_to_2_2_1()
     log.info("add sequence field to space _space_sequence")
@@ -776,6 +783,7 @@ end
 
 local function upgrade_to_2_2_1()
     upgrade_sequence_to_2_2_1()
+    create_vcollation_space()
 end


commit f13d3f0ce8a2d7af8a11ebc1003d1145652a46a3
Author: Roman Khabibov <roman.habibov@tarantool.org>
Date:   Thu May 16 02:06:39 2019 +0300

    schema: add "_vcollation" sysview
    
    Add "_vcollation" sysview to read it from net.box. This
    sysview is always readable, except when a user doesn't have
    "public" role.
    
    Needed for #3941
    
    @TarantoolBot document
    Title: box.space._vcollation
    
    _vcollation is a system space that represents a virtual view.
    The structure of its tuples is identical to that of _collation.
    Tuples of this sysview is always readable, except when the user
    doesn't have "public" role.

diff --git a/src/box/bootstrap.snap b/src/box/bootstrap.snap
index bb8fbeba1..eb9297d7c 100644
Binary files a/src/box/bootstrap.snap and b/src/box/bootstrap.snap differ
diff --git a/src/box/lua/space.cc b/src/box/lua/space.cc
index 87adaeb16..5d837eda6 100644
--- a/src/box/lua/space.cc
+++ b/src/box/lua/space.cc
@@ -540,6 +540,8 @@ box_lua_space_init(struct lua_State *L)
 	lua_setfield(L, -2, "FUNC_ID");
 	lua_pushnumber(L, BOX_COLLATION_ID);
 	lua_setfield(L, -2, "COLLATION_ID");
+	lua_pushnumber(L, BOX_VCOLLATION_ID);
+	lua_setfield(L, -2, "VCOLLATION_ID");
 	lua_pushnumber(L, BOX_VFUNC_ID);
 	lua_setfield(L, -2, "VFUNC_ID");
 	lua_pushnumber(L, BOX_PRIV_ID);
diff --git a/src/box/lua/upgrade.lua b/src/box/lua/upgrade.lua
index 070662698..fe62fb0a9 100644
--- a/src/box/lua/upgrade.lua
+++ b/src/box/lua/upgrade.lua
@@ -749,6 +749,13 @@ end
 -- Tarantool 2.2.1
 --------------------------------------------------------------------------------
 
+local function create_vcollation_space()
+    local _collation = box.space._collation
+    local format = _collation:format()
+    create_sysview(box.schema.COLLATION_ID, box.schema.VCOLLATION_ID)
+    box.space[box.schema.VCOLLATION_ID]:format(format)
+end
+
 -- Add sequence field to _space_sequence table
 local function upgrade_sequence_to_2_2_1()
     log.info("add sequence field to space _space_sequence")
@@ -776,6 +783,7 @@ end
 
 local function upgrade_to_2_2_1()
     upgrade_sequence_to_2_2_1()
+    create_vcollation_space()
 end
 
 --------------------------------------------------------------------------------
@@ -811,7 +819,7 @@ local function upgrade(options)
         {version = mkversion(2, 1, 1), func = upgrade_to_2_1_1, auto = true},
         {version = mkversion(2, 1, 2), func = upgrade_to_2_1_2, auto = true},
         {version = mkversion(2, 1, 3), func = upgrade_to_2_1_3, auto = true},
-        {version = mkversion(2, 2, 1), func = upgrade_to_2_2_1, auto = true},
+        {version = mkversion(2, 2, 1), func = upgrade_to_2_2_1, auto = true}
     }
 
     for _, handler in ipairs(handlers) do
diff --git a/src/box/schema_def.h b/src/box/schema_def.h
index b817b49f6..e0febb640 100644
--- a/src/box/schema_def.h
+++ b/src/box/schema_def.h
@@ -72,6 +72,8 @@ enum {
 	BOX_SCHEMA_ID = 272,
 	/** Space id of _collation. */
 	BOX_COLLATION_ID = 276,
+	/** Space id of _vcollation. */
+	BOX_VCOLLATION_ID = 277,
 	/** Space id of _space. */
 	BOX_SPACE_ID = 280,
 	/** Space id of _vspace view. */
diff --git a/src/box/sysview.c b/src/box/sysview.c
index 96c5e78ca..46cf1e13f 100644
--- a/src/box/sysview.c
+++ b/src/box/sysview.c
@@ -402,6 +402,14 @@ vsequence_filter(struct space *source, struct tuple *tuple)
 	       ((PRIV_WRDA | PRIV_X) & effective);
 }
 
+static bool
+vcollation_filter(struct space *source, struct tuple *tuple)
+{
+	(void) source;
+	(void) tuple;
+	return true;
+}
+
 static struct index *
 sysview_space_create_index(struct space *space, struct index_def *def)
 {
@@ -448,6 +456,11 @@ sysview_space_create_index(struct space *space, struct index_def *def)
 		source_index_id = def->iid;
 		filter = vsequence_filter;
 		break;
+	case BOX_VCOLLATION_ID:
+		source_space_id = BOX_COLLATION_ID;
+		source_index_id = def->iid;
+		filter = vcollation_filter;
+		break;
 	default:
 		diag_set(ClientError, ER_MODIFY_INDEX,
 			 def->name, space_name(space),
diff --git a/test/app-tap/tarantoolctl.test.lua b/test/app-tap/tarantoolctl.test.lua
index c1e1490ca..7a72acda2 100755
--- a/test/app-tap/tarantoolctl.test.lua
+++ b/test/app-tap/tarantoolctl.test.lua
@@ -405,8 +405,8 @@ do
             check_ctlcat_xlog(test_i, dir, "--from=3 --to=6 --format=json --show-system --replica 1", "\n", 3)
             check_ctlcat_xlog(test_i, dir, "--from=3 --to=6 --format=json --show-system --replica 1 --replica 2", "\n", 3)
             check_ctlcat_xlog(test_i, dir, "--from=3 --to=6 --format=json --show-system --replica 2", "\n", 0)
-            check_ctlcat_snap(test_i, dir, "--space=280", "---\n", 21)
-            check_ctlcat_snap(test_i, dir, "--space=288", "---\n", 47)
+            check_ctlcat_snap(test_i, dir, "--space=280", "---\n", 22)
+            check_ctlcat_snap(test_i, dir, "--space=288", "---\n", 49)
         end)
     end)
 
diff --git a/test/box-py/bootstrap.result b/test/box-py/bootstrap.result
index 0684914c0..d2cca9017 100644
--- a/test/box-py/bootstrap.result
+++ b/test/box-py/bootstrap.result
@@ -21,6 +21,10 @@ box.space._space:select{}
         'name': 'name', 'type': 'string'}, {'name': 'owner', 'type': 'unsigned'},
       {'name': 'type', 'type': 'string'}, {'name': 'locale', 'type': 'string'}, {
         'name': 'opts', 'type': 'map'}]]
+  - [277, 1, '_vcollation', 'sysview', 0, {}, [{'name': 'id', 'type': 'unsigned'},
+      {'name': 'name', 'type': 'string'}, {'name': 'owner', 'type': 'unsigned'}, {
+        'name': 'type', 'type': 'string'}, {'name': 'locale', 'type': 'string'}, {
+        'name': 'opts', 'type': 'map'}]]
   - [280, 1, '_space', 'memtx', 0, {}, [{'name': 'id', 'type': 'unsigned'}, {'name': 'owner',
         'type': 'unsigned'}, {'name': 'name', 'type': 'string'}, {'name': 'engine',
         'type': 'string'}, {'name': 'field_count', 'type': 'unsigned'}, {'name': 'flags',
@@ -85,6 +89,8 @@ box.space._index:select{}
 - - [272, 0, 'primary', 'tree', {'unique': true}, [[0, 'string']]]
   - [276, 0, 'primary', 'tree', {'unique': true}, [[0, 'unsigned']]]
   - [276, 1, 'name', 'tree', {'unique': true}, [[1, 'string']]]
+  - [277, 0, 'primary', 'tree', {'unique': true}, [[0, 'unsigned']]]
+  - [277, 1, 'name', 'tree', {'unique': true}, [[1, 'string']]]
   - [280, 0, 'primary', 'tree', {'unique': true}, [[0, 'unsigned']]]
   - [280, 1, 'owner', 'tree', {'unique': false}, [[1, 'unsigned']]]
   - [280, 2, 'name', 'tree', {'unique': true}, [[2, 'string']]]
@@ -151,6 +157,7 @@ box.space._priv:select{}
   - [1, 1, 'universe', 0, 4294967295]
   - [1, 2, 'function', 1, 4]
   - [1, 2, 'space', 276, 2]
+  - [1, 2, 'space', 277, 1]
   - [1, 2, 'space', 281, 1]
   - [1, 2, 'space', 286, 1]
   - [1, 2, 'space', 289, 1]
diff --git a/test/box/access_misc.result b/test/box/access_misc.result
index 24bdd9d63..d5bb8b208 100644
--- a/test/box/access_misc.result
+++ b/test/box/access_misc.result
@@ -761,6 +761,10 @@ box.space._space:select()
         'name': 'name', 'type': 'string'}, {'name': 'owner', 'type': 'unsigned'},
       {'name': 'type', 'type': 'string'}, {'name': 'locale', 'type': 'string'}, {
         'name': 'opts', 'type': 'map'}]]
+  - [277, 1, '_vcollation', 'sysview', 0, {}, [{'name': 'id', 'type': 'unsigned'},
+      {'name': 'name', 'type': 'string'}, {'name': 'owner', 'type': 'unsigned'}, {
+        'name': 'type', 'type': 'string'}, {'name': 'locale', 'type': 'string'}, {
+        'name': 'opts', 'type': 'map'}]]
   - [280, 1, '_space', 'memtx', 0, {}, [{'name': 'id', 'type': 'unsigned'}, {'name': 'owner',
         'type': 'unsigned'}, {'name': 'name', 'type': 'string'}, {'name': 'engine',
         'type': 'string'}, {'name': 'field_count', 'type': 'unsigned'}, {'name': 'flags',
diff --git a/test/box/access_sysview.result b/test/box/access_sysview.result
index c6a2b22ed..4d1f0c779 100644
--- a/test/box/access_sysview.result
+++ b/test/box/access_sysview.result
@@ -74,6 +74,10 @@ session.su('guest')
 ---
 - true
 ...
+#box.space._vspace.index[2]:select('_vcollation') ~= 0
+---
+- true
+...
 #box.space._vindex:select(box.space._vspace.id) > 0
 ---
 - true
@@ -94,6 +98,10 @@ session.su('guest')
 ---
 - true
 ...
+#box.space._vindex:select(box.space._vcollation.id) > 0
+---
+- true
+...
 box.session.su('admin')
 ---
 ...
@@ -127,6 +135,10 @@ box.session.su('guest')
 ---
 - error: Read access to space '_vsequence' is denied for user 'guest'
 ...
+#box.space._vcollation:select{}
+---
+- error: Read access to space '_vcollation' is denied for user 'guest'
+...
 box.session.su('admin')
 ---
 ...
@@ -138,11 +150,15 @@ box.session.su('guest')
 ...
 #box.space._vspace:select{}
 ---
-- 8
+- 9
 ...
 #box.space._vindex:select{}
 ---
-- 20
+- 22
+...
+#box.space._vcollation:select{}
+---
+- 277
 ...
 box.session.su('admin')
 ---
@@ -230,11 +246,11 @@ box.session.su('guest')
 ...
 #box.space._vspace:select{}
 ---
-- 22
+- 23
 ...
 #box.space._vindex:select{}
 ---
-- 48
+- 50
 ...
 #box.space._vuser:select{}
 ---
@@ -242,12 +258,16 @@ box.session.su('guest')
 ...
 #box.space._vpriv:select{}
 ---
-- 15
+- 16
 ...
 #box.space._vfunc:select{}
 ---
 - 1
 ...
+#box.space._vcollation:select{}
+---
+- 277
+...
 box.session.su('admin')
 ---
 ...
@@ -262,7 +282,7 @@ box.session.su('guest')
 ...
 #box.space._vindex:select{}
 ---
-- 48
+- 50
 ...
 #box.space._vuser:select{}
 ---
@@ -270,7 +290,7 @@ box.session.su('guest')
 ...
 #box.space._vpriv:select{}
 ---
-- 15
+- 16
 ...
 #box.space._vfunc:select{}
 ---
@@ -280,6 +300,10 @@ box.session.su('guest')
 ---
 - 0
 ...
+#box.space._vcollation:select{}
+---
+- 277
+...
 box.session.su('admin')
 ---
 ...
@@ -631,6 +655,60 @@ seq:drop()
 ---
 ...
 --
+-- _vcollation
+--
+box.session.su('admin')
+---
+...
+box.internal.collation.create('test', 'ICU', 'ru-RU')
+---
+...
+-- Only admin can create collation.
+coll_cnt = #box.space._collation:select{}
+---
+...
+box.schema.user.grant("guest", "read, write, alter, execute", "space", "_collation")
+---
+...
+box.session.su("guest")
+---
+...
+box.internal.collation.create('guest0', 'ICU', 'ru-RU')
+---
+- error: Create access to collation 'guest0' is denied for user 'guest'
+...
+box.space._vcollation:select{0}
+---
+- - [0, 'none', 1, 'BINARY', '', {}]
+...
+#box.space._vcollation:select{} == coll_cnt
+---
+- true
+...
+box.session.su('admin')
+---
+...
+-- _vcollation is readable anyway.
+box.schema.user.revoke("guest", "read", "space", "_collation")
+---
+...
+box.session.su("guest")
+---
+...
+#box.space._vcollation:select{}
+---
+- 278
+...
+session.su('admin')
+---
+...
+box.internal.collation.drop('test')
+---
+...
+box.internal.collation.drop('guest0')
+---
+...
+--
 -- view:alter() tests
 --
 box.space._vspace.index[1]:alter({parts = { 2, 'string' }})
diff --git a/test/box/access_sysview.test.lua b/test/box/access_sysview.test.lua
index c62458407..031df28aa 100644
--- a/test/box/access_sysview.test.lua
+++ b/test/box/access_sysview.test.lua
@@ -31,12 +31,14 @@ session.su('guest')
 #box.space._vspace.index[2]:select('_vuser') ~= 0
 #box.space._vspace.index[2]:select('_vfunc') ~= 0
 #box.space._vspace.index[2]:select('_vpriv') ~= 0
+#box.space._vspace.index[2]:select('_vcollation') ~= 0
 
 #box.space._vindex:select(box.space._vspace.id) > 0
 #box.space._vindex:select(box.space._vindex.id) > 0
 #box.space._vindex:select(box.space._vuser.id) > 0
 #box.space._vindex:select(box.space._vfunc.id) > 0
 #box.space._vindex:select(box.space._vpriv.id) > 0
+#box.space._vindex:select(box.space._vcollation.id) > 0
 
 box.session.su('admin')
 box.schema.user.revoke('guest', 'public')
@@ -48,6 +50,7 @@ box.session.su('guest')
 #box.space._vpriv:select{}
 #box.space._vfunc:select{}
 #box.space._vsequence:select{}
+#box.space._vcollation:select{}
 
 box.session.su('admin')
 box.schema.user.grant('guest', 'public')
@@ -55,6 +58,7 @@ box.session.su('guest')
 
 #box.space._vspace:select{}
 #box.space._vindex:select{}
+#box.space._vcollation:select{}
 
 box.session.su('admin')
 s = box.schema.space.create('test')
@@ -96,6 +100,7 @@ box.session.su('guest')
 #box.space._vuser:select{}
 #box.space._vpriv:select{}
 #box.space._vfunc:select{}
+#box.space._vcollation:select{}
 
 box.session.su('admin')
 box.schema.user.revoke('guest', 'read', 'universe')
@@ -107,6 +112,7 @@ box.session.su('guest')
 #box.space._vpriv:select{}
 #box.space._vfunc:select{}
 #box.space._vsequence:select{}
+#box.space._vcollation:select{}
 
 box.session.su('admin')
 box.schema.user.revoke('guest', 'write', 'universe')
@@ -264,6 +270,30 @@ box.session.su("guest")
 session.su('admin')
 seq:drop()
 
+--
+-- _vcollation
+--
+
+box.session.su('admin')
+box.internal.collation.create('test', 'ICU', 'ru-RU')
+
+-- Only admin can create collation.
+coll_cnt = #box.space._collation:select{}
+box.schema.user.grant("guest", "read, write, alter, execute", "space", "_collation")
+box.session.su("guest")
+box.internal.collation.create('guest0', 'ICU', 'ru-RU')
+box.space._vcollation:select{0}
+#box.space._vcollation:select{} == coll_cnt
+box.session.su('admin')
+
+-- _vcollation is readable anyway.
+box.schema.user.revoke("guest", "read", "space", "_collation")
+box.session.su("guest")
+#box.space._vcollation:select{}
+session.su('admin')
+box.internal.collation.drop('test')
+box.internal.collation.drop('guest0')
+
 --
 -- view:alter() tests
 --
diff --git a/test/box/alter.result b/test/box/alter.result
index e83c0b7ef..3e9c5e180 100644
--- a/test/box/alter.result
+++ b/test/box/alter.result
@@ -169,6 +169,8 @@ _index:select{}
 - - [272, 0, 'primary', 'tree', {'unique': true}, [[0, 'string']]]
   - [276, 0, 'primary', 'tree', {'unique': true}, [[0, 'unsigned']]]
   - [276, 1, 'name', 'tree', {'unique': true}, [[1, 'string']]]
+  - [277, 0, 'primary', 'tree', {'unique': true}, [[0, 'unsigned']]]
+  - [277, 1, 'name', 'tree', {'unique': true}, [[1, 'string']]]
   - [280, 0, 'primary', 'tree', {'unique': true}, [[0, 'unsigned']]]
   - [280, 1, 'owner', 'tree', {'unique': false}, [[1, 'unsigned']]]
   - [280, 2, 'name', 'tree', {'unique': true}, [[2, 'string']]]
diff --git a/test/wal_off/alter.result b/test/wal_off/alter.result
index ee280fcbb..8040efa1a 100644
--- a/test/wal_off/alter.result
+++ b/test/wal_off/alter.result
@@ -28,7 +28,7 @@ end;
 ...
 #spaces;
 ---
-- 65505
+- 65504
 ...
 -- cleanup
 for k, v in pairs(spaces) do

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [tarantool-patches] Re: [PATCH 2/2] net.box: fetch '_vcollation' sysview into the module
  2019-06-05 17:28       ` Vladimir Davydov
@ 2019-06-06 15:22         ` Roman Khabibov
  2019-06-06 16:00         ` Roman Khabibov
  1 sibling, 0 replies; 15+ messages in thread
From: Roman Khabibov @ 2019-06-06 15:22 UTC (permalink / raw)
  To: tarantool-patches; +Cc: Vladimir Davydov



> On Jun 5, 2019, at 8:28 PM, Vladimir Davydov <vdavydov.dev@gmail.com> wrote:
> 
> On Wed, Jun 05, 2019 at 08:08:39PM +0300, Roman Khabibov wrote:
>> 
>>> On Jun 4, 2019, at 7:36 PM, Vladimir Davydov <vdavydov.dev@gmail.com> wrote:
>>> 
>>> On Thu, May 30, 2019 at 03:36:03PM +0300, Roman Khabibov wrote:
>>>> 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(-)
>>> 
>>> This one looks good to me, but you probably need to write a doc bot
>>> request.
>>> 
>> What should I write in this request? I understood, that you meant
>> info about _vcollation existance.
> 
> Yep, something like this I suppose:
> 
>  https://www.tarantool.io/en/doc/2.1/book/box/box_space/#box-space-vspace
> 
> BTW we miss _vsequence documentation. Should be added as well.
_vfunc too?

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [tarantool-patches] Re: [PATCH 2/2] net.box: fetch '_vcollation' sysview into the module
  2019-06-05 17:28       ` Vladimir Davydov
  2019-06-06 15:22         ` Roman Khabibov
@ 2019-06-06 16:00         ` Roman Khabibov
  2019-06-06 17:00           ` Vladimir Davydov
  1 sibling, 1 reply; 15+ messages in thread
From: Roman Khabibov @ 2019-06-06 16:00 UTC (permalink / raw)
  To: tarantool-patches; +Cc: Vladimir Davydov



> On Jun 5, 2019, at 8:28 PM, Vladimir Davydov <vdavydov.dev@gmail.com> wrote:
> 
> On Wed, Jun 05, 2019 at 08:08:39PM +0300, Roman Khabibov wrote:
>> 
>>> On Jun 4, 2019, at 7:36 PM, Vladimir Davydov <vdavydov.dev@gmail.com> wrote:
>>> 
>>> On Thu, May 30, 2019 at 03:36:03PM +0300, Roman Khabibov wrote:
>>>> 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(-)
>>> 
>>> This one looks good to me, but you probably need to write a doc bot
>>> request.
>>> 
>> What should I write in this request? I understood, that you meant
>> info about _vcollation existance.
> 
> Yep, something like this I suppose:
> 
>  https://www.tarantool.io/en/doc/2.1/book/box/box_space/#box-space-vspace
> 
> BTW we miss _vsequence documentation. Should be added as well.

commit 2faf236c6b45b308ad86fd60f4250fc7af33996d
Author: Roman Khabibov <roman.habibov@tarantool.org>
Date:   Thu May 16 13:15:25 2019 +0300

    net.box: fetch '_vcollation' sysview into the module
    
    Fetch "_vcollation" sysview to show collation name instead collation id.
    
    Closes #3941

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..9c516fff5 100644
--- a/test/box/net.box.result
+++ b/test/box/net.box.result
@@ -2339,14 +2339,14 @@ connected_cnt
 ...
 disconnected_cnt
 ---
-- 1
+- 2
 ...
 conn:close()
 ---
 ...
 disconnected_cnt
 ---
-- 2
+- 3
 ...
 test_run:cmd('stop server connecter')
 ---
@@ -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()

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [tarantool-patches] Re: [PATCH 2/2] net.box: fetch '_vcollation' sysview into the module
  2019-06-06 16:00         ` Roman Khabibov
@ 2019-06-06 17:00           ` Vladimir Davydov
  0 siblings, 0 replies; 15+ messages in thread
From: Vladimir Davydov @ 2019-06-06 17:00 UTC (permalink / raw)
  To: Roman Khabibov; +Cc: tarantool-patches

Pushed both patches to master, thanks!

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2019-06-06 17:00 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-30 12:36 [tarantool-patches] [PATCH 0/2] Add _vcollation and fetch in net.box Roman Khabibov
2019-05-30 12:36 ` [tarantool-patches] [PATCH 1/2] schema: add "_vcollation" sysview Roman Khabibov
2019-06-04 16:31   ` Vladimir Davydov
2019-06-05 17:08     ` [tarantool-patches] " Roman Khabibov
2019-06-05 17:56       ` Vladimir Davydov
2019-06-06 15:18         ` Roman Khabibov
2019-05-30 12:36 ` [tarantool-patches] [PATCH 2/2] net.box: fetch '_vcollation' sysview into the module Roman Khabibov
2019-06-04 16:36   ` Vladimir Davydov
2019-06-05 17:08     ` [tarantool-patches] " Roman Khabibov
2019-06-05 17:28       ` Vladimir Davydov
2019-06-06 15:22         ` Roman Khabibov
2019-06-06 16:00         ` Roman Khabibov
2019-06-06 17:00           ` Vladimir Davydov
2019-06-03 18:45 ` [tarantool-patches] Re: [PATCH 0/2] Add _vcollation and fetch in net.box Vladislav Shpilevoy
2019-06-04 15:54 ` [tarantool-patches] " Vladimir Davydov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox