diff --git a/src/box/lua/box.lua b/src/box/lua/box.lua index ca90a1a69727e343b8604e6dc709263ea51312ff..30265e439ef0977be990bd744ea4b2cdae85b696 100644 --- a/src/box/lua/box.lua +++ b/src/box/lua/box.lua @@ -8,16 +8,22 @@ box.flags = { BOX_RETURN_TUPLE = 0x01, BOX_ADD = 0x02, BOX_REPLACE = 0x04 } -- -- function box.select_limit(space, index, offset, limit, ...) - return box.net.self:select_limit(tonumber(space), tonumber(index), - tonumber(offset), tonumber(limit), ...) + local key_part_count = select('#', ...) + return box.process(17, + box.pack('iiiiiV', + tonumber(space), + tonumber(index), + tonumber(offset), + tonumber(limit), + 1, -- key count + key_part_count, ...)) end - -- -- -- function box.select(space, index, ...) - return box.net.self:select(tonumber(space), tonumber(index), ...) + return box.select_limit(space, index, 0, 4294967295, ...) end -- @@ -26,8 +32,7 @@ end -- starts from the key. -- function box.select_range(sno, ino, limit, ...) - return box.net.self:select_range(tonumber(sno), tonumber(ino), - tonumber(limit), ...) + return box.net.self:select_range(sno, ino, limit, ...) end -- @@ -36,8 +41,7 @@ end -- starts from the key. -- function box.select_reverse_range(sno, ino, limit, ...) - return box.net.self:select_reverse_range(tonumber(sno), tonumber(ino), - tonumber(limit), ...) + return box.net.self:select_reverse_range(sno, ino, limit, ...) end -- @@ -45,25 +49,47 @@ end -- index is always 0. It doesn't accept compound keys -- function box.delete(space, ...) - return box.net.self:delete(tonumber(space), ...) + local key_part_count = select('#', ...) + return box.process(21, + box.pack('iiV', + tonumber(space), + box.flags.BOX_RETURN_TUPLE, -- flags + key_part_count, ...)) end -- insert or replace a tuple function box.replace(space, ...) - return box.net.self:replace(tonumber(space), ...) + local field_count = select('#', ...) + return box.process(13, + box.pack('iiV', + tonumber(space), + box.flags.BOX_RETURN_TUPLE, -- flags + field_count, ...)) end -- insert a tuple (produces an error if the tuple already exists) function box.insert(space, ...) - return box.net.self:insert(tonumber(space), ...) + local field_count = select('#', ...) + return box.process(13, + box.pack('iiV', + tonumber(space), + bit.bor(box.flags.BOX_RETURN_TUPLE, + box.flags.BOX_ADD), -- flags + field_count, ...)) end -- function box.update(space, key, format, ...) - return box.net.self:update(tonumber(space), key, format, ...) + local op_count = select('#', ...)/2 + return box.process(19, + box.pack('iiVi'..format, + tonumber(space), + box.flags.BOX_RETURN_TUPLE, + 1, key, + op_count, + ...)) end - function box.dostring(s, ...) local chunk, message = loadstring(s) if chunk == nil then diff --git a/test/box/lua.result b/test/box/lua.result index 1edd02d6038a19b7bd820f617403bc0d6a921e39..95c8a0e1f0220359a2927acbbe522fede213aea7 100644 --- a/test/box/lua.result +++ b/test/box/lua.result @@ -292,7 +292,7 @@ error: 'No index #1 is defined in space 0' ... lua box.select(0) --- -error: '[string "-- box_net.lua (internal file)..."]:68: box.pack: expected 32-bit int' +error: '[string "-- box.lua (internal file)..."]:13: box.pack: expected 32-bit int' ... call box.replace('0', 'abcd', 'hello', 'world') Found 1 tuple: