box: loose truncate check in case of foreign key
In #7309 a truncation of a space that was referenced by foreign key from some other space was prohibited. It appeared that this solution is too bothering since a user can't truncate a space even if he truncated referring space before that. Fix it by allowing space truncate if referring spaces are empty. Also allow drop of the primary index in the same case with the same reason: logically the index along with all space data is not needed for consistency if there's no referring data. Note that by design space truncate is implemented quite similar to space drop. Both delete all indexes, from secondary to primary. Since this patch allows deletion of the primary index (which is the action that actually deletes all data from the space), this patch changes the result of space drop too: the space remains alive with no indexes, while before this patch it remained alive with no secondary indexes but with present primary. In both cases the behaviour is quite strange and must be fixed in #4348. To make tests pass I had to perform drop in box.atomic manually. Closes #8946 NO_DOC=bugfix (cherry picked from commit 983a7ec2)
Showing
- changelogs/unreleased/gh-8946-foreign-key-disables-truncate.md 4 additions, 0 deletions...elogs/unreleased/gh-8946-foreign-key-disables-truncate.md
- src/box/alter.cc 41 additions, 4 deletionssrc/box/alter.cc
- src/box/space_cache.h 1 addition, 1 deletionsrc/box/space_cache.h
- test/engine-luatest/gh_6436_complex_foreign_key_test.lua 3 additions, 3 deletionstest/engine-luatest/gh_6436_complex_foreign_key_test.lua
- test/engine-luatest/gh_6436_field_foreign_key_test.lua 3 additions, 3 deletionstest/engine-luatest/gh_6436_field_foreign_key_test.lua
- test/engine-luatest/gh_8946_foreign_key_disables_truncate_test.lua 131 additions, 0 deletions...ne-luatest/gh_8946_foreign_key_disables_truncate_test.lua
- test/sql/delete.result 4 additions, 0 deletionstest/sql/delete.result
- test/sql/delete.test.lua 1 addition, 0 deletionstest/sql/delete.test.lua
Loading
Please register or sign in to comment