sql: display error on FK creation and drop failure
Before insertion to _fk_constraint we must be sure that there is no entry with given <name, child id>. Otherwise, insertion will fail and 'duplicate key' will be shown. Such error message doesn't seem to be informative enough, so lets verify before insertion to _fk_constraint that it doesn't already contain entry with given name. The same is for dropping constraint, but here vice versa: we test that _fk_constraint contains entry with given name and child id. It is worth mentioning that during CREATE TABLE processing schema id changes and check in OP_OpenRead opcode fails (which in turn shows that pointer to space may expire). On the other hand, _fk_constraint space itself remains immutable, so as a temporary workaround lets use flag indicating pointer to system space passed to OP_OpenRead. It makes possible to use pointer to space, even if schema has changed. Closes #3271
Showing
- src/box/errcode.h 2 additions, 0 deletionssrc/box/errcode.h
- src/box/sql/build.c 35 additions, 17 deletionssrc/box/sql/build.c
- src/box/sql/sqliteInt.h 7 additions, 3 deletionssrc/box/sql/sqliteInt.h
- src/box/sql/trigger.c 13 additions, 2 deletionssrc/box/sql/trigger.c
- src/box/sql/vdbe.c 2 additions, 1 deletionsrc/box/sql/vdbe.c
- test/box/misc.result 2 additions, 0 deletionstest/box/misc.result
- test/sql-tap/alter2.test.lua 24 additions, 1 deletiontest/sql-tap/alter2.test.lua
Loading
Please register or sign in to comment