Description
Product: Tarantool
Since: 2.10.0-beta1
Root document: https://www.tarantool.io/en/doc/latest/reference/reference_lua/net_box/
SME: @ alyapunov
Details
Implement begin
, commit
and rollback
methods for stream object
in net.box
, which allows to begin, commit and rollback transaction
accordingly. Now there are multiple ways to begin, commit and rollback
transaction from net.box
: using appropriate stream methods, using 'callor 'eval' methods or using
executemethod with sql transaction syntax. User can mix these methods, for example, start transaction using
stream:begin(), and commit transaction using
stream:call('box.commit')`
or stream:execute('COMMIT').
Simple example of using interactive transactions via iproto from net.box:
stream = conn:new_stream()
space = stream.space.test
space_not_from_stream = conn.space.test
stream:begin()
space:replace({1})
-- return previously inserted tuple, because request
-- belongs to transaction.
space:select({})
-- empty select, because select doesn't belongs to
-- transaction
space_not_from_stream:select({})
stream:call('box.commit')
-- now transaction was commited, so all requests
-- returns tuple.
Different examples of using streams you can find in
gh-5860-implement-streams-in-iproto.test.lua (https://github.com/tarantool/tarantool/blob/master/test/box/net.box_iproto_transactions_over_streams.test.lua)
Requested by @EvgenyMekhanik in tarantool/tarantool@f9ca802.