sql: prohibit creation of FK on unexisting tables
Originally, SQLite allows to create table with foreign keys constraint which refers to yet not created parent table. For instance: CREATE TABLE child(id INT PRIMARY KEY REFERENCES parent); CREATE TABLE parent(id INT PRIMARY KEY); This patch bans such ability since it contradicts SQL ANSI. Moreover, SQLite allows to drop parent table if deletion of all rows wouldn't result in FK constraint violations. This feature has been removed since in such situation child table would become inconsistent. Finally, within current patch ability to create FK constraints on VIEWs is banned as well. Part of #3271
Showing
- src/box/sql/build.c 34 additions, 9 deletionssrc/box/sql/build.c
- src/box/sql/fkey.c 9 additions, 87 deletionssrc/box/sql/fkey.c
- src/box/sql/sqliteInt.h 0 additions, 3 deletionssrc/box/sql/sqliteInt.h
- src/box/sql/vdbe.c 0 additions, 30 deletionssrc/box/sql/vdbe.c
- test/sql-tap/alter.test.lua 2 additions, 2 deletionstest/sql-tap/alter.test.lua
- test/sql-tap/fkey1.test.lua 9 additions, 9 deletionstest/sql-tap/fkey1.test.lua
- test/sql-tap/fkey2.test.lua 22 additions, 68 deletionstest/sql-tap/fkey2.test.lua
- test/sql-tap/fkey3.test.lua 2 additions, 2 deletionstest/sql-tap/fkey3.test.lua
- test/sql-tap/gh-2953-drop-table-with-FK.test.lua 0 additions, 122 deletionstest/sql-tap/gh-2953-drop-table-with-FK.test.lua
- test/sql-tap/table.test.lua 1 addition, 0 deletionstest/sql-tap/table.test.lua
- test/sql-tap/tkt-b1d3a2e531.test.lua 1 addition, 1 deletiontest/sql-tap/tkt-b1d3a2e531.test.lua
Loading
Please register or sign in to comment