From 48766847a211f65dbdef1e23dfff94323a09d78b Mon Sep 17 00:00:00 2001 From: Roman Tsisyk <roman@tsisyk.com> Date: Fri, 20 Feb 2015 15:44:48 +0300 Subject: [PATCH] Move tuple_ref() from Lua function tuple_bless() to boxffi_* bindings Other changes: * Fix #708: catch exceptions in boxffi_iterator_next * Optimize index:get() to directly use index:findByKey() instead of box_process() + execute_select() + iterator->init() + iterator->next() --- src/box/lua/call.cc | 22 ++++++++++-- src/box/lua/call.h | 2 +- src/box/lua/index.cc | 46 ++++++++++++++++++++---- src/box/lua/index.h | 3 ++ src/box/lua/schema.lua | 33 +++++++++-------- src/box/lua/tuple.cc | 7 ++-- src/box/lua/tuple.lua | 11 ++---- src/box/tuple.h | 17 --------- src/ffisyms.cc | 3 +- test/big/hash.result | 6 ++-- test/big/hash_multipart.result | 2 +- test/big/lua.result | 6 ++-- test/box/access_bin.result | 2 +- test/box/errinj.result | 5 +-- test/box/errinj.test.lua | 4 +-- test/box/select.result | 12 +++---- test/box/stat.result | 2 +- test/box/tuple.result | 26 +++++++------- test/sophia/transaction.result | 8 ++--- test/sophia/transaction.test.lua | 8 ++--- test/sophia/transaction_multidb.result | 16 ++++----- test/sophia/transaction_multidb.test.lua | 16 ++++----- 22 files changed, 143 insertions(+), 114 deletions(-) diff --git a/src/box/lua/call.cc b/src/box/lua/call.cc index 2fb66a5af8..ee5e3ad8c6 100644 --- a/src/box/lua/call.cc +++ b/src/box/lua/call.cc @@ -224,6 +224,7 @@ port_ffi_add_tuple(struct port *port, struct tuple *tuple) port_ffi->ret = ret; port_ffi->capacity = capacity; } + tuple_ref(tuple); port_ffi->ret[port_ffi->size++] = tuple; } @@ -239,15 +240,28 @@ port_ffi_create(struct port_ffi *port) port->vtab = &port_ffi_vtab; } + +static inline void +port_ffi_clear(struct port_ffi *port) +{ + for (uint32_t i = 0; i < port->size; i++) { + tuple_unref(port->ret[i]); + port->ret[i] = NULL; + } + port->size = 0; +} + void port_ffi_destroy(struct port_ffi *port) { + port_ffi_clear(port); free(port->ret); - port->capacity = port->size = 0; + port->ret = NULL; + port->capacity = 0; } int -boxffi_select(struct port *port, uint32_t space_id, uint32_t index_id, +boxffi_select(struct port_ffi *port, uint32_t space_id, uint32_t index_id, int iterator, uint32_t offset, uint32_t limit, const char *key, const char *key_end) { @@ -261,10 +275,12 @@ boxffi_select(struct port *port, uint32_t space_id, uint32_t index_id, request.key = key; request.key_end = key_end; + port->size = 0; try { - box_process(&request, port); + box_process(&request, (struct port *) port); return 0; } catch (Exception *e) { + port_ffi_clear(port); /* will be hanled by box.error() in Lua */ return -1; } diff --git a/src/box/lua/call.h b/src/box/lua/call.h index 2562554c52..f578e6a54c 100644 --- a/src/box/lua/call.h +++ b/src/box/lua/call.h @@ -60,7 +60,7 @@ void port_ffi_destroy(struct port_ffi *port); int -boxffi_select(struct port *port, uint32_t space_id, uint32_t index_id, +boxffi_select(struct port_ffi *port, uint32_t space_id, uint32_t index_id, int iterator, uint32_t offset, uint32_t limit, const char *key, const char *key_end); diff --git a/src/box/lua/index.cc b/src/box/lua/index.cc index 37a5043329..0d2336a9d6 100644 --- a/src/box/lua/index.cc +++ b/src/box/lua/index.cc @@ -32,6 +32,7 @@ #include "box/space.h" #include "box/schema.h" #include "box/user_def.h" +#include "box/tuple.h" #include "box/lua/tuple.h" #include "fiber.h" @@ -70,7 +71,31 @@ struct tuple * boxffi_index_random(uint32_t space_id, uint32_t index_id, uint32_t rnd) { try { - return check_index(space_id, index_id)->random(rnd); + Index *index = check_index(space_id, index_id); + struct tuple *tuple = index->random(rnd); + if (tuple == NULL) + return NULL; + tuple_ref(tuple); /* must not throw in this case */ + return tuple; + } catch (Exception *) { + return (struct tuple *) -1; /* handled by box.error() in Lua */ + } +} + +struct tuple * +boxffi_index_get(uint32_t space_id, uint32_t index_id, const char *key) +{ + try { + Index *index = check_index(space_id, index_id); + if (!index->key_def->is_unique) + tnt_raise(ClientError, ER_MORE_THAN_ONE_TUPLE); + uint32_t part_count = key ? mp_decode_array(&key) : 0; + primary_key_validate(index->key_def, key, part_count); + struct tuple *tuple = index->findByKey(key, part_count); + if (tuple == NULL) + return NULL; + tuple_ref(tuple); /* must not throw in this case */ + return tuple; } catch (Exception *) { return (struct tuple *) -1; /* handled by box.error() in Lua */ } @@ -120,20 +145,27 @@ boxffi_index_iterator(uint32_t space_id, uint32_t index_id, int type, struct tuple* boxffi_iterator_next(struct iterator *itr) { - if (itr->sc_version != sc_version) { - try { + try { + if (itr->sc_version != sc_version) { Index *index = check_index(itr->space_id, itr->index_id); if (index != itr->index) return NULL; if (index->sc_version > itr->sc_version) return NULL; itr->sc_version = sc_version; - } catch (Exception *) { - /* space or index does not exist, nothing to fetch */ - return NULL; } + } catch (Exception *) { + return NULL; /* invalidate iterator */ + } + try { + struct tuple *tuple = itr->next(itr); + if (tuple == NULL) + return NULL; + tuple_ref(tuple); /* must not throw in this case */ + return tuple; + } catch (Exception *) { + return (struct tuple *) -1; /* handled by box.error() in Lua */ } - return itr->next(itr); } /* }}} */ diff --git a/src/box/lua/index.h b/src/box/lua/index.h index e1dda8bc61..adb76c27f0 100644 --- a/src/box/lua/index.h +++ b/src/box/lua/index.h @@ -48,6 +48,9 @@ boxffi_index_len(uint32_t space_id, uint32_t index_id); struct tuple * boxffi_index_random(uint32_t space_id, uint32_t index_id, uint32_t rnd); +struct tuple * +boxffi_index_get(uint32_t space_id, uint32_t index_id, const char *key); + struct iterator * boxffi_index_iterator(uint32_t space_id, uint32_t index_id, int type, const char *key); diff --git a/src/box/lua/schema.lua b/src/box/lua/schema.lua index 410379e8b5..83aff4bc31 100644 --- a/src/box/lua/schema.lua +++ b/src/box/lua/schema.lua @@ -26,6 +26,8 @@ ffi.cdef[[ boxffi_index_memsize(uint32_t space_id, uint32_t index_id); struct tuple * boxffi_index_random(uint32_t space_id, uint32_t index_id, uint32_t rnd); + struct tuple * + boxffi_index_get(uint32_t space_id, uint32_t index_id, const char *key); struct iterator * boxffi_index_iterator(uint32_t space_id, uint32_t index_id, int type, const char *key); @@ -47,7 +49,7 @@ ffi.cdef[[ port_ffi_destroy(struct port_ffi *port); int - boxffi_select(struct port *port, uint32_t space_id, uint32_t index_id, + boxffi_select(struct port_ffi *port, uint32_t space_id, uint32_t index_id, int iterator, uint32_t offset, uint32_t limit, const char *key, const char *key_end); void password_prepare(const char *password, int len, @@ -544,7 +546,9 @@ local iterator_gen = function(param, state) end -- next() modifies state in-place local tuple = builtin.boxffi_iterator_next(state) - if tuple ~= nil then + if tuple == ffi.cast('void *', -1) then + return box.error() -- error + elseif tuple ~= nil then return state, box.tuple.bless(tuple) -- new state, value else return nil @@ -559,7 +563,6 @@ end local port = ffi.new('struct port_ffi') builtin.port_ffi_create(port) ffi.gc(port, builtin.port_ffi_destroy) -local port_t = ffi.typeof('struct port *') function box.schema.space.bless(space) local index_mt = {} @@ -614,7 +617,7 @@ function box.schema.space.bless(space) elseif tuple ~= nil then return box.tuple.bless(tuple) else - return nil + return end end -- iteration @@ -677,17 +680,13 @@ function box.schema.space.bless(space) index_mt.get = function(index, key) local key, key_end = msgpackffi.encode_tuple(key) - port.size = 0; - if builtin.boxffi_select(ffi.cast(port_t, port), index.space_id, - index.id, box.index.EQ, 0, 2, key, key_end) ~=0 then - return box.error() - end - if port.size == 0 then - return - elseif port.size == 1 then - return box.tuple.bless(port.ret[0]) + local tuple = builtin.boxffi_index_get(index.space_id, index.id, key) + if tuple == ffi.cast('void *', -1) then + return box.error() -- error + elseif tuple ~= nil then + return box.tuple.bless(tuple) else - box.error(box.error.MORE_THAN_ONE_TUPLE) + return end end @@ -720,15 +719,15 @@ function box.schema.space.bless(space) end end - port.size = 0; - if builtin.boxffi_select(ffi.cast(port_t, port), index.space_id, + if builtin.boxffi_select(port, index.space_id, index.id, iterator, offset, limit, key, key_end) ~=0 then return box.error() end local ret = {} for i=0,port.size - 1,1 do - table.insert(ret, box.tuple.bless(port.ret[i])) + -- tuple.bless must never fail + ret[i + 1] = box.tuple.bless(port.ret[i]) end return ret end diff --git a/src/box/lua/tuple.cc b/src/box/lua/tuple.cc index fec69a110b..2cce8b212b 100644 --- a/src/box/lua/tuple.cc +++ b/src/box/lua/tuple.cc @@ -365,9 +365,10 @@ boxffi_tuple_update(struct tuple *tuple, const char *expr, const char *expr_end) { RegionGuard region_guard(&fiber()->gc); try { - return tuple_update(tuple_format_ber, - region_alloc_cb, &fiber()->gc, - tuple, expr, expr_end, 1); + struct tuple *new_tuple = tuple_update(tuple_format_ber, + region_alloc_cb, &fiber()->gc, tuple, expr, expr_end, 1); + tuple_ref(new_tuple); /* must not throw in this case */ + return new_tuple; } catch (ClientError *e) { return NULL; } diff --git a/src/box/lua/tuple.lua b/src/box/lua/tuple.lua index d2b9ddba9c..78adccd02e 100644 --- a/src/box/lua/tuple.lua +++ b/src/box/lua/tuple.lua @@ -16,8 +16,6 @@ struct tuple char data[0]; } __attribute__((packed)); -int -tuple_ref_nothrow(struct tuple *tuple); void tuple_unref(struct tuple *tuple); uint32_t @@ -56,13 +54,8 @@ local tuple_gc = function(tuple) end local tuple_bless = function(tuple) - -- tuple_ref(..) may throw to prevent reference counter to overflow, - -- which is not allowed in ffi call, so we'll use nothrow version - if (builtin.tuple_ref_nothrow(tuple) ~= 0) then - box.error(); - end - local tuple2 = ffi.gc(ffi.cast(const_struct_tuple_ref_t, tuple), tuple_gc) - return tuple2 + -- must never fail: + return ffi.gc(ffi.cast(const_struct_tuple_ref_t, tuple), tuple_gc) end local tuple_iterator_t = ffi.typeof('struct tuple_iterator') diff --git a/src/box/tuple.h b/src/box/tuple.h index 666f190a70..dd8d50d079 100644 --- a/src/box/tuple.h +++ b/src/box/tuple.h @@ -208,23 +208,6 @@ tuple_ref(struct tuple *tuple) tuple->refs++; } -/** - * Increment tuple reference counter. - * Returns -1 if overflow detected, 0 otherwise - * - * @pre tuple->refs + count >= 0 - */ -extern "C" inline int -tuple_ref_nothrow(struct tuple *tuple) -{ - try { - tuple_ref(tuple); - } catch (Exception *e) { - return -1; - } - return 0; -} - /** * Decrement tuple reference counter. If it has reached zero, free the tuple. * diff --git a/src/ffisyms.cc b/src/ffisyms.cc index 76e6e6541a..8b43d22906 100644 --- a/src/ffisyms.cc +++ b/src/ffisyms.cc @@ -30,13 +30,14 @@ void *ffi_symbols[] = { (void *) tuple_rewind, (void *) tuple_seek, (void *) tuple_next, - (void *) tuple_ref_nothrow, (void *) tuple_unref, (void *) boxffi_index_len, (void *) boxffi_index_memsize, (void *) boxffi_index_random, + (void *) boxffi_index_get, (void *) boxffi_index_iterator, (void *) boxffi_tuple_update, + (void *) boxffi_iterator_next, (void *) port_ffi_create, (void *) port_ffi_destroy, (void *) boxffi_select, diff --git a/test/big/hash.result b/test/big/hash.result index f1120fcfae..4988bb424a 100644 --- a/test/big/hash.result +++ b/test/big/hash.result @@ -89,7 +89,7 @@ hash.index['primary']:get{'invalid key'} ... hash.index['primary']:get{1, 2} --- -- error: Invalid key part count (expected [0..1], got 2) +- error: Invalid key part count in an exact match (expected 1, got 2) ... ------------------------------------------------------------------------------- -- 32-bit hash delete fields test @@ -262,7 +262,7 @@ hash.index['primary']:get{'invalid key'} ... hash.index['primary']:get{'00000001', '00000002'} --- -- error: Invalid key part count (expected [0..1], got 2) +- error: Invalid key part count in an exact match (expected 1, got 2) ... ------------------------------------------------------------------------------- -- 64-bit hash delete fields test @@ -415,7 +415,7 @@ hash.index['primary']:get{'key 5'} -- select by invalid keys hash.index['primary']:get{'key 1', 'key 2'} --- -- error: Invalid key part count (expected [0..1], got 2) +- error: Invalid key part count in an exact match (expected 1, got 2) ... ------------------------------------------------------------------------------- -- String hash delete fields test diff --git a/test/big/hash_multipart.result b/test/big/hash_multipart.result index fb0063f032..04a55e1862 100644 --- a/test/big/hash_multipart.result +++ b/test/big/hash_multipart.result @@ -89,7 +89,7 @@ hash.index['primary']:get{1, 'foo'} -- primary index select with extra part hash.index['primary']:get{1, 'foo', 0, 0} --- -- error: Invalid key part count (expected [0..3], got 4) +- error: Invalid key part count in an exact match (expected 3, got 4) ... -- primary index select with wrong type hash.index['primary']:get{1, 'foo', 'baz'} diff --git a/test/big/lua.result b/test/big/lua.result index e0af610e1d..fd6d189316 100644 --- a/test/big/lua.result +++ b/test/big/lua.result @@ -32,7 +32,7 @@ space.index['minmax']:get{'new', 'world'} -- https://bugs.launchpad.net/tarantool/+bug/904208 space.index['minmax']:get{'new', 'world', 'order'} --- -- error: Invalid key part count (expected [0..2], got 3) +- error: Invalid key part count in an exact match (expected 2, got 3) ... space:delete{'brave'} --- @@ -47,7 +47,7 @@ space:insert{'item 1', 'alabama', 'song'} ... space.index['minmax']:get{'alabama'} --- -- ['item 1', 'alabama', 'song'] +- error: Invalid key part count in an exact match (expected 2, got 1) ... space:insert{'item 2', 'california', 'dreaming '} --- @@ -734,7 +734,7 @@ t:find(2, '2') ... t:find(89, '2') --- -- error: '[string "-- tuple.lua (internal file)..."]:91: error: invalid key to ''next''' +- error: '[string "-- tuple.lua (internal file)..."]:84: error: invalid key to ''next''' ... t:findall(4, '3') --- diff --git a/test/box/access_bin.result b/test/box/access_bin.result index 9dd70ba901..850c0c0c07 100644 --- a/test/box/access_bin.result +++ b/test/box/access_bin.result @@ -183,7 +183,7 @@ test:drop() -- box.space._priv:get{1} --- -- [1, 1, 'universe', 0, 7] +- error: Invalid key part count in an exact match (expected 3, got 1) ... u = box.space._user:get{1} --- diff --git a/test/box/errinj.result b/test/box/errinj.result index e709a74502..d9df2ada28 100644 --- a/test/box/errinj.result +++ b/test/box/errinj.result @@ -26,14 +26,15 @@ errinj.set("some-injection") -- check error --- - 'error: can''t find error injection ''some-injection''' ... -space:get{222444} +space:select{222444} --- +- [] ... errinj.set("ERRINJ_TESTING", true) --- - ok ... -space:get{222444} +space:select{222444} --- - error: Error injection 'ERRINJ_TESTING' ... diff --git a/test/box/errinj.test.lua b/test/box/errinj.test.lua index 990ca6d34b..ebe60c7bee 100644 --- a/test/box/errinj.test.lua +++ b/test/box/errinj.test.lua @@ -6,9 +6,9 @@ index = space:create_index('primary', { type = 'hash' }) errinj.info() errinj.set("some-injection", true) errinj.set("some-injection") -- check error -space:get{222444} +space:select{222444} errinj.set("ERRINJ_TESTING", true) -space:get{222444} +space:select{222444} errinj.set("ERRINJ_TESTING", false) -- Check how well we handle a failed log write diff --git a/test/box/select.result b/test/box/select.result index 44ce0acc7c..eabee2a4a3 100644 --- a/test/box/select.result +++ b/test/box/select.result @@ -15,15 +15,15 @@ for i = 1, 20 do s:insert({ i, 1, 2, 3 }) end -------------------------------------------------------------------------------- s.index[0]:get() --- -- error: More than one tuple found by get() +- error: Invalid key part count in an exact match (expected 1, got 0) ... s.index[0]:get({}) --- -- error: More than one tuple found by get() +- error: Invalid key part count in an exact match (expected 1, got 0) ... s.index[0]:get(nil) --- -- error: More than one tuple found by get() +- error: Invalid key part count in an exact match (expected 1, got 0) ... s.index[0]:get(1) --- @@ -35,7 +35,7 @@ s.index[0]:get({1}) ... s.index[0]:get({1, 2}) --- -- error: Invalid key part count (expected [0..1], got 2) +- error: Invalid key part count in an exact match (expected 1, got 2) ... s.index[0]:get(0) --- @@ -53,11 +53,11 @@ s.index[0]:get({"0"}) ... s.index[1]:get(1) --- -- error: More than one tuple found by get() +- error: Invalid key part count in an exact match (expected 2, got 1) ... s.index[1]:get({1}) --- -- error: More than one tuple found by get() +- error: Invalid key part count in an exact match (expected 2, got 1) ... s.index[1]:get({1, 2}) --- diff --git a/test/box/stat.result b/test/box/stat.result index b54176e0e5..c3d0ef87bc 100644 --- a/test/box/stat.result +++ b/test/box/stat.result @@ -50,7 +50,7 @@ box.stat.REPLACE.total ... box.stat.SELECT.total --- -- 2 +- 1 ... --# stop server default --# start server default diff --git a/test/box/tuple.result b/test/box/tuple.result index 7c29a93097..1023399bbe 100644 --- a/test/box/tuple.result +++ b/test/box/tuple.result @@ -305,12 +305,12 @@ t:unpack(2, 1) ... t:totable(0) --- -- error: '[string "-- tuple.lua (internal file)..."]:123: tuple.totable: invalid second +- error: '[string "-- tuple.lua (internal file)..."]:116: tuple.totable: invalid second argument' ... t:totable(1, 0) --- -- error: '[string "-- tuple.lua (internal file)..."]:132: tuple.totable: invalid third +- error: '[string "-- tuple.lua (internal file)..."]:125: tuple.totable: invalid third argument' ... -- @@ -435,15 +435,15 @@ t:next(3) ... t:next(4) --- -- error: '[string "-- tuple.lua (internal file)..."]:91: error: invalid key to ''next''' +- error: '[string "-- tuple.lua (internal file)..."]:84: error: invalid key to ''next''' ... t:next(-1) --- -- error: '[string "-- tuple.lua (internal file)..."]:91: error: invalid key to ''next''' +- error: '[string "-- tuple.lua (internal file)..."]:84: error: invalid key to ''next''' ... t:next("fdsaf") --- -- error: '[string "-- tuple.lua (internal file)..."]:74: error: invalid key to ''next''' +- error: '[string "-- tuple.lua (internal file)..."]:67: error: invalid key to ''next''' ... box.tuple.new({'x', 'y', 'z'}):next() --- @@ -455,7 +455,7 @@ t=space:insert{1953719668} ... t:next(1684234849) --- -- error: '[string "-- tuple.lua (internal file)..."]:91: error: invalid key to ''next''' +- error: '[string "-- tuple.lua (internal file)..."]:84: error: invalid key to ''next''' ... t:next(1) --- @@ -611,7 +611,7 @@ r = {} ... for _state, val in t:pairs(10) do table.insert(r, val) end --- -- error: '[string "-- tuple.lua (internal file)..."]:91: error: invalid key to ''next''' +- error: '[string "-- tuple.lua (internal file)..."]:84: error: invalid key to ''next''' ... r --- @@ -697,19 +697,19 @@ t:findall(1, 'xxxxx') ... t:find(100, 'a') --- -- error: '[string "-- tuple.lua (internal file)..."]:91: error: invalid key to ''next''' +- error: '[string "-- tuple.lua (internal file)..."]:84: error: invalid key to ''next''' ... t:findall(100, 'a') --- -- error: '[string "-- tuple.lua (internal file)..."]:91: error: invalid key to ''next''' +- error: '[string "-- tuple.lua (internal file)..."]:84: error: invalid key to ''next''' ... t:find(100, 'xxxxx') --- -- error: '[string "-- tuple.lua (internal file)..."]:91: error: invalid key to ''next''' +- error: '[string "-- tuple.lua (internal file)..."]:84: error: invalid key to ''next''' ... t:findall(100, 'xxxxx') --- -- error: '[string "-- tuple.lua (internal file)..."]:91: error: invalid key to ''next''' +- error: '[string "-- tuple.lua (internal file)..."]:84: error: invalid key to ''next''' ... --- -- Lua type coercion @@ -803,12 +803,12 @@ t = box.tuple.new({'a', 'b', 'c', 'd', 'e'}) ... t:update() --- -- error: '[string "-- tuple.lua (internal file)..."]:172: Usage: tuple:update({ { +- error: '[string "-- tuple.lua (internal file)..."]:165: Usage: tuple:update({ { op, field, arg}+ })' ... t:update(10) --- -- error: '[string "-- tuple.lua (internal file)..."]:172: Usage: tuple:update({ { +- error: '[string "-- tuple.lua (internal file)..."]:165: Usage: tuple:update({ { op, field, arg}+ })' ... t:update({}) diff --git a/test/sophia/transaction.result b/test/sophia/transaction.result index 9e67cf8094..9a25faf642 100644 --- a/test/sophia/transaction.result +++ b/test/sophia/transaction.result @@ -14,7 +14,7 @@ for key = 1, 10 do space:insert({key}) end t = {} --- ... -for key = 1, 10 do table.insert(t, space:get({key})) end +for key = 1, 10 do table.insert(t, space:select({key})[1]) end --- ... t @@ -36,7 +36,7 @@ box.rollback() t = {} --- ... -for key = 1, 10 do assert(space:get({key}) == nil) end +for key = 1, 10 do assert(#space:select({key}) == 0) end --- ... t @@ -62,7 +62,7 @@ box.commit() t = {} --- ... -for key = 1, 10 do table.insert(t, space:get({key})) end +for key = 1, 10 do table.insert(t, space:select({key})[1]) end --- ... t @@ -91,7 +91,7 @@ box.commit() t = {} --- ... -for key = 1, 10 do assert(space:get({key}) == nil) end +for key = 1, 10 do assert(#space:select({key}) == 0) end --- ... t diff --git a/test/sophia/transaction.test.lua b/test/sophia/transaction.test.lua index 1a94642618..8d15324991 100644 --- a/test/sophia/transaction.test.lua +++ b/test/sophia/transaction.test.lua @@ -7,12 +7,12 @@ index = space:create_index('primary', { type = 'tree', parts = {1, 'num'} }) box.begin() for key = 1, 10 do space:insert({key}) end t = {} -for key = 1, 10 do table.insert(t, space:get({key})) end +for key = 1, 10 do table.insert(t, space:select({key})[1]) end t box.rollback() t = {} -for key = 1, 10 do assert(space:get({key}) == nil) end +for key = 1, 10 do assert(#space:select({key}) == 0) end t -- begin/commit insert @@ -23,7 +23,7 @@ for key = 1, 10 do space:insert({key}) end t = {} box.commit() t = {} -for key = 1, 10 do table.insert(t, space:get({key})) end +for key = 1, 10 do table.insert(t, space:select({key})[1]) end t -- begin/commit delete @@ -33,7 +33,7 @@ for key = 1, 10 do space:delete({key}) end box.commit() t = {} -for key = 1, 10 do assert(space:get({key}) == nil) end +for key = 1, 10 do assert(#space:select({key}) == 0) end t space:drop() diff --git a/test/sophia/transaction_multidb.result b/test/sophia/transaction_multidb.result index f6fed09ca1..9c4d88a1ba 100644 --- a/test/sophia/transaction_multidb.result +++ b/test/sophia/transaction_multidb.result @@ -20,7 +20,7 @@ for key = 1, 10 do a:insert({key}) end t = {} --- ... -for key = 1, 10 do table.insert(t, a:get({key})) end +for key = 1, 10 do table.insert(t, a:select({key})[1]) end --- ... t @@ -42,7 +42,7 @@ for key = 1, 10 do b:insert({key}) end t = {} --- ... -for key = 1, 10 do table.insert(t, b:get({key})) end +for key = 1, 10 do table.insert(t, b:select({key})[1]) end --- ... t @@ -64,14 +64,14 @@ box.rollback() t = {} --- ... -for key = 1, 10 do assert(a:get({key}) == nil) end +for key = 1, 10 do assert(#a:select({key}) == 0) end --- ... t --- - [] ... -for key = 1, 10 do assert(b:get({key}) == nil) end +for key = 1, 10 do assert(#b:select({key}) == 0) end --- ... t @@ -103,7 +103,7 @@ box.commit() t = {} --- ... -for key = 1, 10 do table.insert(t, a:get({key})) end +for key = 1, 10 do table.insert(t, a:select({key})[1]) end --- ... t @@ -122,7 +122,7 @@ t t = {} --- ... -for key = 1, 10 do table.insert(t, b:get({key})) end +for key = 1, 10 do table.insert(t, b:select({key})[1]) end --- ... t @@ -154,14 +154,14 @@ box.commit() t = {} --- ... -for key = 1, 10 do assert(a:get({key}) == nil) end +for key = 1, 10 do assert(#a:select({key}) == 0) end --- ... t --- - [] ... -for key = 1, 10 do assert(b:get({key}) == nil) end +for key = 1, 10 do assert(#b:select({key}) == 0) end --- ... t diff --git a/test/sophia/transaction_multidb.test.lua b/test/sophia/transaction_multidb.test.lua index c88ad6d056..91a6e01c64 100644 --- a/test/sophia/transaction_multidb.test.lua +++ b/test/sophia/transaction_multidb.test.lua @@ -10,18 +10,18 @@ index = b:create_index('primary', { type = 'tree', parts = {1, 'num'} }) box.begin() for key = 1, 10 do a:insert({key}) end t = {} -for key = 1, 10 do table.insert(t, a:get({key})) end +for key = 1, 10 do table.insert(t, a:select({key})[1]) end t for key = 1, 10 do b:insert({key}) end t = {} -for key = 1, 10 do table.insert(t, b:get({key})) end +for key = 1, 10 do table.insert(t, b:select({key})[1]) end t box.rollback() t = {} -for key = 1, 10 do assert(a:get({key}) == nil) end +for key = 1, 10 do assert(#a:select({key}) == 0) end t -for key = 1, 10 do assert(b:get({key}) == nil) end +for key = 1, 10 do assert(#b:select({key}) == 0) end t -- begin/commit insert @@ -35,10 +35,10 @@ t = {} box.commit() t = {} -for key = 1, 10 do table.insert(t, a:get({key})) end +for key = 1, 10 do table.insert(t, a:select({key})[1]) end t t = {} -for key = 1, 10 do table.insert(t, b:get({key})) end +for key = 1, 10 do table.insert(t, b:select({key})[1]) end t -- begin/commit delete @@ -49,9 +49,9 @@ for key = 1, 10 do b:delete({key}) end box.commit() t = {} -for key = 1, 10 do assert(a:get({key}) == nil) end +for key = 1, 10 do assert(#a:select({key}) == 0) end t -for key = 1, 10 do assert(b:get({key}) == nil) end +for key = 1, 10 do assert(#b:select({key}) == 0) end t a:drop() -- GitLab