From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtpng1.m.smailru.net (smtpng1.m.smailru.net [94.100.181.251]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 4600D430D56 for ; Tue, 29 Oct 2019 14:46:20 +0300 (MSK) Received: by smtpng1.m.smailru.net with esmtpa (envelope-from ) id 1iPPx5-0007Fj-KB for tarantool-patches@dev.tarantool.org; Tue, 29 Oct 2019 14:46:19 +0300 From: Maria Date: Tue, 29 Oct 2019 14:46:25 +0300 Message-Id: <20191029114625.14689-1-maria.khaydich@tarantool.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH] Netbox connection and self are interchangable List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: tarantool-patches@dev.tarantool.org Despite what was stated in the documentation netbox.connect was not always equivalent to netbox.self. In particular, they converted tuple to different types - table and cdata respectively. Closes #4513 Issue: https://github.com/tarantool/tarantool/issues/4513 Branch: https://github.com/tarantool/tarantool/tree/eljashm/gh-4513-netbox.self-convert-tuples-to-table-type --- src/box/lua/net_box.lua | 11 ++++++++++- test/box/net.box.result | 24 ++++++++++++++++++++++++ test/box/net.box.test.lua | 11 +++++++++++ 3 files changed, 45 insertions(+), 1 deletion(-) diff --git a/src/box/lua/net_box.lua b/src/box/lua/net_box.lua index 31a8c16b7..31cb9cb12 100644 --- a/src/box/lua/net_box.lua +++ b/src/box/lua/net_box.lua @@ -1518,7 +1518,16 @@ local function handle_eval_result(status, ...) rollback() return box.error(E_PROC_LUA, (...)) end - return ... + if not ... then + return ... + end + local results = {...} + for n, res in pairs(results) do + if type(res) == 'cdata' and ffi.istype('struct tuple', res) then + results[n] = res:totable() + end + end + return unpack(results) end this_module.self = { diff --git a/test/box/net.box.result b/test/box/net.box.result index e3dabf7d9..e0332a5f3 100644 --- a/test/box/net.box.result +++ b/test/box/net.box.result @@ -3930,3 +3930,27 @@ test_run:grep_log('default', '00000040:.*') box.cfg{log_level=log_level} --- ... +-- +-- gh-4513 netbox.connect returns table but netbox.self does not +-- +space = box.schema.space.create('gh4513') +--- +... +box.schema.user.grant('guest','read, write, execute','universe') +--- +... +idx = box.space.gh4513:create_index('primary') +--- +... +box.space.gh4513:insert({1}) +--- +- [1] +... +type(remote.connect(box.cfg.listen):eval("return box.space.gh4513:get({1})")) +--- +- table +... +type(remote.self:eval("return box.space.gh4513:get{1}")) +--- +- table +... diff --git a/test/box/net.box.test.lua b/test/box/net.box.test.lua index 8e65ff470..bcc41c84e 100644 --- a/test/box/net.box.test.lua +++ b/test/box/net.box.test.lua @@ -1583,3 +1583,14 @@ test_run:wait_log('default', '00000030:.*', nil, 10) test_run:grep_log('default', '00000040:.*') box.cfg{log_level=log_level} + +-- +-- gh-4513 netbox.connect returns table but netbox.self does not +-- +space = box.schema.space.create('gh4513') +box.schema.user.grant('guest','read, write, execute','universe') +idx = box.space.gh4513:create_index('primary') +box.space.gh4513:insert({1}) + +type(remote.connect(box.cfg.listen):eval("return box.space.gh4513:get({1})")) +type(remote.self:eval("return box.space.gh4513:get{1}")) -- 2.20.1 (Apple Git-117)