net.box: add interactive transaction support in net.box
Implement `begin`, `commit` and `rollback` methods for stream object in `net.box`, which allows to begin, commit and rollback transaction accordingly. Closes #5860 @TarantoolBot document Title: add interactive transaction support in net.box 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 'call` or 'eval' methods or using `execute` method 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: ```lua 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
Showing
- changelogs/unreleased/gh-5860-implement-streams-in-iproto.md 26 additions, 0 deletionschangelogs/unreleased/gh-5860-implement-streams-in-iproto.md
- src/box/lua/net_box.c 48 additions, 1 deletionsrc/box/lua/net_box.c
- src/box/lua/net_box.lua 34 additions, 1 deletionsrc/box/lua/net_box.lua
- test/box/net.box_iproto_transactions_over_streams.result 3009 additions, 0 deletionstest/box/net.box_iproto_transactions_over_streams.result
- test/box/net.box_iproto_transactions_over_streams.test.lua 1238 additions, 0 deletionstest/box/net.box_iproto_transactions_over_streams.test.lua
- test/box/suite.ini 1 addition, 1 deletiontest/box/suite.ini
Loading
Please register or sign in to comment