Skip to content

Commit

Permalink
storage: fix local_call not finding C stored procedures
Browse files Browse the repository at this point in the history
Currently, if function was created as C stored procedure with
box.schema.func.create, all types of router.call and router.map_callrw
cannot find it and return `Procedure 'name' is not defined` error.
This is cased by the fact that both of these function use local_call,
which invokes net_box.self.call, which doesn't currently work with
C stored procedures due to the bug.

Let's use box.func, where it's possible instead of net_box.self.call
in local_call.

Closes tarantool#436

NO_DOC=bugfix
NO_TEST=<already tested>
  • Loading branch information
Serpentian committed Sep 18, 2023
1 parent b3c27b3 commit 8e4d403
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
4 changes: 4 additions & 0 deletions example/storage.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ require('strict').on()
local fio = require('fio')
local NAME = fio.basename(arg[0], '.lua')
local fiber = require('fiber')
local multlib = require('multlib')

-- Check if we are running under test-run
if os.getenv('ADMIN') then
Expand Down Expand Up @@ -53,6 +54,9 @@ box.once("testapp:schema:1", function()
account:create_index('bucket_id', {parts = {'bucket_id'}, unique = false})
box.snapshot()

box.schema.func.create('multlib.mult50', {language = 'C'})
box.schema.role.grant('public', 'execute', 'function', 'multlib.mult50')

box.schema.func.create('customer_lookup')
box.schema.role.grant('public', 'execute', 'function', 'customer_lookup')
box.schema.func.create('customer_add')
Expand Down
11 changes: 10 additions & 1 deletion vshard/storage/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,16 @@ end
-- exceptions are not allowed.
--
local function local_call(func_name, args)
return pcall(netbox_self_call, netbox_self, func_name, args)
-- box.func was introduced only in Tarantool 2.2. net_box.self.call
-- doesn't work with C stored procedures up to Tarantool 3.0.0-alpha3.
-- If function wasn't created with box.schema.func interface, then it's
-- not in box.func and we should still use net_box.self.call.
if box.func == nil or box.func[func_name] == nil then
return pcall(netbox_self_call, netbox_self, func_name, args)
end

local func = box.func[func_name]
return pcall(func.call, func, args)
end

--
Expand Down

0 comments on commit 8e4d403

Please sign in to comment.