diff --git a/src/box/lua/call.cc b/src/box/lua/call.cc index 2fb66a5af8e815eb79f0655c30bfcb183ed32c0a..8c27328020cdb89423aa144ec6bee1be5a757473 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,24 @@ 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) { free(port->ret); - port->capacity = port->size = 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 +271,21 @@ boxffi_select(struct port *port, uint32_t space_id, uint32_t index_id, request.key = key; request.key_end = key_end; + /* + * A single instance of port_ffi object is used + * for all selects, reset it. + */ + port->size = 0; try { - box_process(&request, port); + box_process(&request, (struct port *) port); return 0; } catch (Exception *e) { + /* + * The tuples will be not blessed and garbage + * collected, unreference them here, to avoid + * a leak. + */ + 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 2562554c52e83c295ecefbf8eddefc34f58af767..f578e6a54c0cb5051161689033c2c5c8f67921f2 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 37a504332901f14f141b91f0d111cbcf0b4827da..0d2336a9d6115d330911ea765a11d2a8cd2dbd7b 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 e1dda8bc6191a52583685d7c25fce312b6092600..adb76c27f0f16ff6bebcfc3d9a2d9603a2d0e526 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 e3d5f9487137d8d108714d13040be45c7ee2d0e4..7511ee82e1124eefaac3caaa7c5446090064b7d7 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, @@ -547,7 +549,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 @@ -562,7 +566,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 *') -- Helper function for nicer error messages -- in some cases when space object is misused @@ -630,7 +633,7 @@ function box.schema.space.bless(space) elseif tuple ~= nil then return box.tuple.bless(tuple) else - return nil + return end end -- iteration @@ -693,17 +696,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 @@ -736,15 +735,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 fec69a110b88df50c25f2178e1f83aabfdddea00..2cce8b212b8ed2f5b02b9449af2f0e5d0d6f8bfc 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 d2b9ddba9c450bf9668f30538d58c094f0fdc4d8..78adccd02e1067294119c4d04840dbb1a9ca7dac 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 666f190a705255bb1b2821b53127bf1faea3b3ee..dd8d50d07919d45c47a17f39472b13ac2df3291a 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 76e6e6541a82e184161cc5cead06d072448a86e7..8b43d22906c70e9f102f73048ddf6c7a652a77ee 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 f1120fcfae7fba0c2d59523c2c8ca281131485be..4988bb424aff02fe372c6052770756796cf72666 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 fb0063f0325d0cb2800100356bcd78af8e0aa1c4..04a55e1862f1fab027c47d45efbdfaf20d091dc8 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 e0af610e1d2a5cbbe36be0a58863168f6a41d16e..fd6d1893162e64fec4d6a446e8f322c72ab10e76 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 9dd70ba901d12eb27a64b7cc9b2684ae788232db..850c0c0c073f1de6d099379ae04dceb040da4f0e 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 fef2ad1c7a15908af1e7c5068166dfae915b4422..dd113ee1608678b9c58e6207576af8814d6d9c48 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 990ca6d34b7c921b430d20511c36a1a609dbfdfb..ebe60c7beeb632bc1f07c4561b03a4d5356a6ce6 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 44ce0acc7cadd555fa304fad7c6d9719612200a4..eabee2a4a30824c4be88aca67ef49a2a5622370d 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 b54176e0e539b6d0eb2aa9d43c5e1e35e23cc26b..c3d0ef87bc8e0d122947f4a1daf4b33b93a66238 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 7c29a93097e44bf30b7238b418eb2ef4d545a165..1023399bbed6b4469e49c4e10470c2dd994393ef 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 9e67cf809494397e1f1f4bf943935534be284063..9a25faf642f7eac87f8273157377bd2f8690327b 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 1a9464261803fce555051a28146e87fd3779860f..8d153249912fbb2d9b0c43fbada913d5462ed368 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 f6fed09ca1684dc6dcd8a5100ef9a8504653ce49..9c4d88a1ba64f94f1c5544a24e81c1ab98f7789c 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 c88ad6d056187d0c7d3a435659611e02631d8892..91a6e01c64c0bf2885b24e78911011b8083d5d99 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()