Skip to content
Snippets Groups Projects
Verified Commit aa4111ad authored by Georgy Moshkin's avatar Georgy Moshkin :speech_balloon: Committed by Denis Smirnov
Browse files

fix: support for compat.c_func_iproto_multireturn = 'new'

parent 2ba636c2
No related branches found
No related tags found
1 merge request!1414sbroad import
......@@ -247,7 +247,8 @@ _G.dql_on_some = function(uuid_to_args, is_readonly, waiting_timeout, vtable_max
if err ~= nil then
error(err)
end
result = res[1][1][1]
-- TODO: explain where this `[1][1]` comes from
result = helper.unwrap_execute_result(res[1][1])
else
local err, err_uuid
local opts = { map_timeout = waiting_timeout, ref_timeout = waiting_timeout }
......@@ -320,10 +321,12 @@ _G.dml_on_some = function(tbl_rs_ir, is_readonly, waiting_timeout)
error(err)
end
-- TODO: explain where this `[1][1]` comes from
local next_result = helper.unwrap_execute_result(res[1][1])
if result == nil then
result = res[1][1][1]
result = next_result
else
result.row_count = result.row_count + res[1][1][1].row_count
result.row_count = result.row_count + next_result.row_count
end
end
......@@ -369,10 +372,12 @@ _G.dml_on_all = function(required, optional, is_readonly, waiting_timeout)
error(err)
end
-- TODO: explain where this `[1][1]` comes from
local next_result = helper.unwrap_execute_result(res[1][1])
if result == nil then
result = res[1][1][1]
result = next_result
else
result.row_count = result.row_count + res[1][1][1].row_count
result.row_count = result.row_count + next_result.row_count
end
end
......
local compat = require('compat')
local compat_mt = compat ~= nil and getmetatable(compat) or nil
-- Make table read-only
local function protect(tbl)
return setmetatable({}, {
......@@ -64,10 +67,32 @@ local function dql_error(err, rs_uuid)
error(err)
end
local function unwrap_execute_result(result)
if compat_mt == nil then
return result[1]
end
-- We want to just call `compat.c_func_iproto_multireturn:is_new()`,
-- but it throws an exception when the option is unknown.
local ok, opt = pcall(compat_mt.__index, compat, 'c_func_iproto_multireturn')
if ok and opt:is_new() then
-- On older versions of tarantool there was a bug which made all FFI
-- stored procedures' wrap their return values into an additional
-- msgpack array (they call it "multireturn", but you couldn't put
-- multiple values in there, it was hard-coded to be 1 element). But
-- thankfully it was fixed and now we get to rewrite all of our code...
-- Yay!
-- See https://github.com/tarantool/tarantool/issues/4799
return result
else
return result[1]
end
end
return {
module_name = module_name,
vtable_limit_exceeded = vtable_limit_exceeded,
dql_error = dql_error,
format_result = format_result,
unwrap_execute_result = unwrap_execute_result,
constants = constants
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment