tarantool / tarantool/tarantool
Error on setting callable table as trigger
Nobody has claimed this yet.
- Dominant language
- Lua
- Stars
- 3.7k
- Forks
- 419
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 88
Description
Tarantool version: 1.10.3-6-g5dc6d79
OS version:
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.5 LTS
Release: 16.04
Codename: xenial
Bug description: It is possible to set function as on_replace_trigger, however using callable table is impossible (even though lua code in tarantool seem to allow it).It would be nice if a trigger could hold it's description inside. It would be possible with a table, but not possible with function (without any strange code inside the trigger)
Steps to reproduce:
box.cfg{}
box.schema.create_space('t')
box.space.t:format({ { name = 'id', type = 'number' } })
box.space.t:create_index('primary', { type = 'tree', parts = { 'id' } })
NUMBER = 0
local NUMBER_INC_TABLE = setmetatable({}, { __call = function(self, old, new) NUMBER = NUMBER + 1 end})
local NUMBER_INC_FUNC = function(old, new) NUMBER = NUMBER + 1 end
local ok, err = pcall(function() box.space.t:on_replace(NUMBER_INC_FUNC) end)
if not ok then
error(("%s ERROR on setting function as on_replace_trigger: %s"):format(_TARANTOOL, err))
end
local ok, err = pcall(function() box.space.t:on_replace(NUMBER_INC_TABLE) end)
if not ok then
error(("%s ERROR on setting callable table as on_replace_trigger: %s"):format(_TARANTOOL, err))
end
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the provided Lua reproduction on Tarantool 1.10.3-6-g5dc6d79 and trace the on_replace trigger handling path for callable tables. The fix is complete when the callable table can be registered like the function and the reproduction no longer reports an error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- lua
- Domain
- database
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100