commit - ee08747291788868ddd5fe5f0571b48c2501b89b
commit + 60cbfbe454c179bf97ebf23b1494e871a4befe1d
blob - 0bdbc2eb76074559383afafa98052ce6c213c4d7
blob + cef101cc511141e92f65dc79f08f202bf769c692
--- src/box/lua/misc.cc
+++ src/box/lua/misc.cc
port_c_dump_lua(struct port *base, struct lua_State *L,
enum port_dump_lua_mode mode)
{
- assert(mode == PORT_DUMP_LUA_MODE_FLAT ||
- mode == PORT_DUMP_LUA_MODE_TABLE);
struct port_c *port = (struct port_c *)base;
if (mode == PORT_DUMP_LUA_MODE_MP_OBJECT) {
port_dump_lua_mp_object_mode_slow(base, L, &fiber()->gc,
blob - eae1fde95c164a32d325c1a048d90b2f4f072576
blob + b0939b1209bc9bcc69833275de4ed19ccbe764c5
--- test/engine-luatest/gh_6436_tuple_constraint_test.lua
+++ test/engine-luatest/gh_6436_tuple_constraint_test.lua
test_lua(cg, {field=0})
test_net(cg, {field=0})
- --[[ Disabled until #6778 is fixed.
--- Test after recovery from xlog.
cg.server:restart()
test_lua(cg, {field=0})
test_net(cg, {field=0})
- --]]
--- Test after recovery from snap.
cg.server:eval('box.snapshot()')
test_lua(cg, {field=0})
test_net(cg, {field=0})
- --[[ Disabled until #6778 is fixed.
--- Test after recovery from xlog.
cg.server:restart()
test_lua(cg, {field=0})
test_net(cg, {field=0})
- --]]
--- Test after recovery from snap.
cg.server:eval('box.snapshot()')
)
t.assert_equals(s:select{}, {{1, 2, 300}, {100, 2, 3}})
+
+ end, {engine})
+end
+
+-- Checks that function that takes raw args can be used as a tuple constraint
+g.test_tuple_constraint_takes_raw = function(cg)
+ local engine = cg.params.engine
+
+ table.insert(cg.cleanup, function()
+ cg.server:exec(function()
+ if box.space.test then box.space.test:drop() end
+ if box.func.tuple_constr1 then box.func.tuple_constr1:drop() end
+ end)
+ end)
+
+ cg.server:exec(function(engine)
+ local constr_tuple_body1 = "function(mp) " ..
+ "local tuple = mp[1] " ..
+ "local name = mp[2] " ..
+ "if name ~= 'tuple_constr1' then error('wrong name!') end " ..
+ "return tuple[1] + tuple[2] < 100 end"
+ local function func_opts(body)
+ return {language = 'LUA', is_deterministic = true, body = body,
+ takes_raw_args = true}
+ end
+ box.schema.func.create('tuple_constr1', func_opts(constr_tuple_body1))
+
+ local fmt = {'id1', 'id2', 'id3'}
+ local s = box.schema.create_space('test', {engine=engine,
+ format=fmt,
+ constraint='tuple_constr1'})
+ s:create_index('pk')
+ box.schema.user.grant('guest', 'read,write', 'space', 'test')
end, {engine})
+
+ -- check accessing from lua
+ local function test_lua(cg, field4)
+ cg.server:exec(function(field4)
+ local s = box.space.test
+
+ t.assert_equals(s:replace{1, 2, 3, field4}, {1, 2, 3, field4})
+ t.assert_error_msg_content_equals(
+ "Check constraint 'tuple_constr1' failed for a tuple",
+ function() s:replace{100, 2, 3, field4} end
+ )
+ t.assert_error_msg_content_equals(
+ "Check constraint 'tuple_constr1' failed for a tuple",
+ function() s:replace{1, 200, 3, field4} end
+ )
+ t.assert_equals(s:select{}, {{1, 2, 3, field4}})
+ end, {field4})
+ end
+
+ -- check accessing from net.box
+ local function test_net(cg, field4)
+ local c = netbox.connect(cg.server.net_box_uri)
+ local s = c.space.test
+ t.assert_equals(s:replace{1, 2, 3, field4}, {1, 2, 3, field4})
+ t.assert_error_msg_content_equals(
+ "Check constraint 'tuple_constr1' failed for a tuple",
+ function() s:replace{100, 2, 3, field4} end)
+ t.assert_error_msg_content_equals(
+ "Check constraint 'tuple_constr1' failed for a tuple",
+ function() s:replace{1, 200, 3, field4} end)
+ t.assert_equals(s:select{}, {{1, 2, 3, field4}})
+ end
+
+ test_lua(cg)
+ test_net(cg)
end