Skip to content

Commit

Permalink
storage: fix core_version string in exports
Browse files Browse the repository at this point in the history
exports_deply_funcs() used to log the core version as nil. The problem
is the fact, that table.concat was used for core version string, so the
complied exports always had nil instead of core_version.

table.concat doesn't work with non-array tables, as they have no defined
order. Let's explicitly define __tostring function for version and use
it in order to log core version.

Closes tarantool#465

NO_DOC=bugfix
  • Loading branch information
Serpentian committed Dec 29, 2023
1 parent 5bfe03b commit bdf8601
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
13 changes: 13 additions & 0 deletions test/unit-luatest/storage_exports_test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,16 @@ test_group.test_deploy_privs = function(g)
box.schema.role.drop('two')
end)
end

test_group.test_core_version = function(g)
g.server:exec(function()
local vexports = require('vshard.storage.exports')
local exports = vexports.log[#vexports.log]
exports = vexports.compile(exports)

local version = _TARANTOOL
local pos = version:find('-g')
version = version:sub(1, pos - 1)
ilt.assert_equals(exports.core_version, version)
end)
end
2 changes: 1 addition & 1 deletion vshard/storage/exports.lua
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ local function exports_compile(exports)
end
return {
vshard_version = exports.version,
core_version = table.concat(lvutil.core_version, '.'),
core_version = tostring(lvutil.core_version),
funcs = compiled_funcs,
}
end
Expand Down
11 changes: 11 additions & 0 deletions vshard/version.lua
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,17 @@ local version_mt = {
__le = function(l, r)
return version_cmp(l, r) <= 0
end,
__tostring = function(v)
local str = v.id_major .. '.' .. v.id_middle .. '.' .. v.id_minor
if v.rel_type then
str = str .. '-' .. v.rel_type
if v.rel_num ~= 0 then
str = str .. v.rel_num
end
end
str = str .. '-' .. v.id_commit
return str
end,
}

local function version_new(id_major, id_middle, id_minor, rel_type, rel_num,
Expand Down

0 comments on commit bdf8601

Please sign in to comment.