sql: Support per-statement transactions
Introduce dedicated opcode OP_TTRansaction, which is responsible for initiation of Tarantool transaction. This opcode is only emitted if statement is generated directly by parser. That means that changes like insertions into system tables are not covered by Tarantool's transations. Tarantool's transaction is committed or rolled back during exectuin of `Halt` opcode. `CloseAllCursors` function was splitted into two: in order Tarantool's WAL to work need to preserve allocated memory until commit to WAL. Call this deallocation after Tarantool's commit. In future this will be re-worked since transaction can be either in statement or generic, and not all Halts should commit. Also, fix a bug: memory area passed to WAL were re-used. WAL itself doesn't do memcpy, so this state of affairs was lead to unpredictable errors during save/restore. Use region_alloc to reserve memory area for WAL in tarantoolSqlite3Insert and tarantoolSqlite3Delete. Closes #2599
Showing
- src/box/sql.c 12 additions, 6 deletionssrc/box/sql.c
- src/box/sql/build.c 3 additions, 0 deletionssrc/box/sql/build.c
- src/box/sql/delete.c 5 additions, 0 deletionssrc/box/sql/delete.c
- src/box/sql/opcodes.c 64 additions, 63 deletionssrc/box/sql/opcodes.c
- src/box/sql/opcodes.h 72 additions, 71 deletionssrc/box/sql/opcodes.h
- src/box/sql/parse.c 229 additions, 221 deletionssrc/box/sql/parse.c
- src/box/sql/parse.y 12 additions, 0 deletionssrc/box/sql/parse.y
- src/box/sql/sqliteInt.h 4 additions, 0 deletionssrc/box/sql/sqliteInt.h
- src/box/sql/trigger.c 8 additions, 7 deletionssrc/box/sql/trigger.c
- src/box/sql/vdbe.c 15 additions, 0 deletionssrc/box/sql/vdbe.c
- src/box/sql/vdbeaux.c 33 additions, 7 deletionssrc/box/sql/vdbeaux.c
- test/sql-tap/gh2259-in-stmt-trans.test.lua 84 additions, 0 deletionstest/sql-tap/gh2259-in-stmt-trans.test.lua
- test/sql/persistency.result 36 additions, 0 deletionstest/sql/persistency.result
- test/sql/persistency.test.lua 7 additions, 0 deletionstest/sql/persistency.test.lua
Loading
Please register or sign in to comment