box: drop the sequence field check from the _index.on_replace
Sequences can only be attached to integer fields of a space. The corresponding check is done in both schema.lua and alter.cc. The problem is that in order to make the index alter transactional, we have to perform the `_index` space tuple replace before the existed sequence is unattached from the space (because the index alter may be yielding). And the check existing in the alter.cc won't allow us to do that in some cases. Since the check already exists in `box.schema.index.alter`, it's decided to drop it from the `_index` `on_replace` trigger. The downside of the solution is that uncareful manual altering the index can silently put the space into an inconsistent condition: the next insert into the space can either fail or silently succeed whereas it's not supposed operation for the space. Example: ```lua box.cfg{} s = box.schema.space.create('s') pk = s:create_index('pk', {parts = {{1, 'unsigned'}}, sequence = true}) -- Manual altering the index without dropping the sequence. box.space._index:update({s.id, pk.id}, {{'=', 6, {{0, 'string'}}}}) -- This will fail: passed integer (from sequence) in string field. s:insert({box.NULL}) -- Manual altering the index without dropping the sequence again. box.space._index:update({s.id, pk.id}, {{'=', 6, {{0, 'scalar'}}}}) -- This will succeed: passed integer (from sequence) in scalar field. -- Though it shouldn't have been done at all: one should not pass -- NULL in the field which is indexed by the primary key. s:insert({box.NULL}) ``` NO_DOC=no visible changes NO_TEST=no visible changes NO_CHANGELOG=no visible changes
Loading
Please register or sign in to comment