schema: allow to set sequence for any index part, not just the first
Closes #4009 @TarantoolBot document Title: Sequence can now be set for an index part other than the first Initially one could attach a sequence (aka autoincrement) only to the first index part. Now it's possible to attach a sequence to any primary index part. The part still must be integer though. Syntax: ``` box.schema.space.create('test') box.space.test:create_index('primary', { parts = {{1, 'string'}, {2, 'unsigned'}, {3, 'unsigned'}}, sequence = true, sequence_part = 2 }) box.space.test:insert{'a', box.null, 1} -- inserts {'a', 1, 1} ``` Note, `sequence_part` option is 1-base. If `sequence_part` is omitted, 1 is used, which assures backward compatibility with the original behavior. One can also attach a sequence to another index part using `index.alter` (the code below continues the example above): ``` box.space.test.index.primary:alter{sequence_part = 3} box.space.test:insert{'a', 1, box.null, 'x'} -- inserts {'a', 1, 2, 'x'} ```
Showing
- src/box/alter.cc 22 additions, 5 deletionssrc/box/alter.cc
- src/box/bootstrap.snap 0 additions, 0 deletionssrc/box/bootstrap.snap
- src/box/lua/schema.lua 51 additions, 17 deletionssrc/box/lua/schema.lua
- src/box/lua/space.cc 7 additions, 0 deletionssrc/box/lua/space.cc
- src/box/lua/upgrade.lua 34 additions, 1 deletionsrc/box/lua/upgrade.lua
- src/box/request.c 1 addition, 1 deletionsrc/box/request.c
- src/box/schema_def.h 1 addition, 0 deletionssrc/box/schema_def.h
- src/box/space.h 5 additions, 0 deletionssrc/box/space.h
- src/box/sql/build.c 6 additions, 1 deletionsrc/box/sql/build.c
- src/box/sql/insert.c 1 addition, 1 deletionsrc/box/sql/insert.c
- test/box-py/bootstrap.result 3 additions, 2 deletionstest/box-py/bootstrap.result
- test/box/access_misc.result 2 additions, 1 deletiontest/box/access_misc.result
- test/box/sequence.result 135 additions, 6 deletionstest/box/sequence.result
- test/box/sequence.test.lua 44 additions, 6 deletionstest/box/sequence.test.lua
Loading
Please register or sign in to comment