[tarantool-patches] Re: [PATCH 1/5] sql: prohibit creation of FK on unexisting tables

n.pettik korablev at tarantool.org
Mon Aug 6 03:27:57 MSK 2018


>>> 1. sql-tap/fkey2.test.lua fails on this commit. Travis fails
>>> as well.
>> Does it really matter?:) Could you forgive me these fails and
>> make me avoid suffering? Anyway, they are completely fixed
>> in second patch, but in scope of current patch they can be only
>> partially repaired. Hence, it would look like I fix in the second patch
>> fixes made in first one..
> 
> It had been failing even on the last commit. So it really mattered.

Really? On my local machine on last commit all test seem to pass..
On Travis also I don’t see failed tests related to FK constraints.

> On the second commit it fails now as well.

These tests are fixed on third commit, not on second.

> Please, make it working. It is not okay, that a non-trivial patch
> breaks tests, that somehow stop failing after some non-linked
> changes.

But okay, I fixed them in current commit:

+++ b/test/sql-tap/fkey2.test.lua
@@ -1,6 +1,6 @@
 #!/usr/bin/env tarantool
 test = require("sqltester")
-test:plan(121)
+test:plan(117)
 
 -- This file implements regression tests for foreign keys.
 
@@ -724,14 +724,11 @@ test:do_catchsql_test(
 test:do_catchsql_test(
     "fkey2-7.2",
     [[
-        DROP TABLE IF EXISTS c;
-        DROP TABLE IF EXISTS p;
-        CREATE VIEW v AS SELECT x AS y FROM c;
-        CREATE TABLE c(x PRIMARY KEY REFERENCES v(y));
-        INSERT INTO c DEFAULT VALUES;
+        CREATE VIEW v AS SELECT b AS y FROM p;
+        CREATE TABLE d(x PRIMARY KEY REFERENCES v(y));
     ]], {
         -- <fkey2-7.2>
-        1, "no such table: C"
+        1, "referenced table can't be view"
         -- </fkey2-7.2>
     })
 
@@ -740,13 +737,14 @@ test:do_catchsql_test(
     [[
         DROP VIEW v;
         DROP TABLE IF EXISTS c;
+        DROP TABLE IF EXISTS p;
         CREATE TABLE p(a COLLATE binary, b PRIMARY KEY);
         CREATE UNIQUE INDEX idx ON p(a COLLATE "unicode_ci");
         CREATE TABLE c(x PRIMARY KEY REFERENCES p(a));
         INSERT INTO c DEFAULT VALUES;
     ]], {
         -- <fkey2-7.3>
-        1, "no such view: V"
+        1, "foreign key mismatch - \"C\" referencing \"P\""
         -- </fkey2-7.3>
     })

@@ -1053,7 +1051,7 @@ test:do_catchsql_test(
         CREATE TABLE t1(a PRIMARY KEY, b REFERENCES nosuchtable);
     ]], {
         -- <fkey2-10.6>
-        1, "foreign key constraint references nonexistent table: NOSUCHTABLE"
+        1, "Space 'NOSUCHTABLE' does not exist"
         -- </fkey2-10.6>
     })
 
@@ -1080,57 +1078,17 @@ test:do_catchsql_test(
         -- </fkey2-10.8>
     })
 

@@ -1083,54 +1081,13 @@ test:do_catchsql_test(
 test:do_execsql_test(
     "fkey2-10.9",
     [[
-        DELETE FROM t2;
+        DROP TABLE t2;
         DROP TABLE t1;
     ]], {
         -- <fkey2-10.9>
         -- </fkey2-10.9>
     })

-test:do_catchsql_test(
-    "fkey2-10.10",
-    [[
-        INSERT INTO t2 VALUES('x');
-    ]], {
-        -- <fkey2-10.10>
-        1, "no such table: T1"
-        -- </fkey2-10.10>
-    })
-
-test:do_execsql_test(
-    "fkey2-10.11",
-    [[
-        CREATE TABLE t1(x PRIMARY KEY);
-        INSERT INTO t1 VALUES('x');
-        INSERT INTO t2 VALUES('x');
-    ]], {
-        -- <fkey2-10.11>
-        -- </fkey2-10.11>
-    })
-
-test:do_catchsql_test(
-    "fkey2-10.12",
-    [[
-        DROP TABLE t1;
-    ]], {
-        -- <fkey2-10.12>
-        1, "FOREIGN KEY constraint failed"
-        -- </fkey2-10.12>
-    })
-
-test:do_execsql_test(
-    "fkey2-10.13",
-    [[
-        DROP TABLE t2;
-        DROP TABLE t1;
-    ]], {
-        -- <fkey2-10.13>
-        -- </fkey2-10.13>
-    })
-
 test:do_execsql_test(
     "fkey2-10.14",
     [[
@@ -1181,7 +1139,7 @@ test:do_execsql_test(
         -- </fkey2-10.17>
     })
 
-test:do_execsql_test(
+test:do_catchsql_test(
     "fkey2-10.18",
     [[
         CREATE TABLE b1(a PRIMARY KEY, b);
@@ -1193,7 +1151,7 @@ test:do_execsql_test(
         -- </fkey2-10.18>
     })
 
-test:do_execsql_test(
+test:do_catchsql_test(
     "fkey2-10.19",
     [[
         CREATE TABLE b3(a PRIMARY KEY, b REFERENCES b2 DEFERRABLE INITIALLY DEFERRED);
@@ -1204,15 +1162,15 @@ test:do_execsql_test(
         -- </fkey2-10.19>
     })
 
-test:do_execsql_test(
+test:do_catchsql_test(
     "fkey2-10.20",
     [[
         DROP VIEW IF EXISTS v;
-        CREATE VIEW v AS SELECT * FROM t1;
-        CREATE TABLE t1(x PRIMARY KEY REFERENCES v);
-        DROP VIEW v;
+        CREATE VIEW v AS SELECT * FROM b1;
+        CREATE TABLE t3(x PRIMARY KEY REFERENCES v);
     ]], {
         -- <fkey2-10.20>
+        1, "referenced table can't be view"
         -- </fkey2-10.20>
     })



More information about the Tarantool-patches mailing list