| Index: third_party/sqlite/sqlite-src-3100200/test/fkey1.test
|
| diff --git a/third_party/sqlite/src/test/fkey1.test b/third_party/sqlite/sqlite-src-3100200/test/fkey1.test
|
| similarity index 55%
|
| copy from third_party/sqlite/src/test/fkey1.test
|
| copy to third_party/sqlite/sqlite-src-3100200/test/fkey1.test
|
| index 90a4c44409ed94d68188651efe3eabeedc7ce3eb..e10781ac520c9cf8f1889613f82fd2f6e525cb0b 100644
|
| --- a/third_party/sqlite/src/test/fkey1.test
|
| +++ b/third_party/sqlite/sqlite-src-3100200/test/fkey1.test
|
| @@ -121,4 +121,68 @@ do_test fkey1-3.5 {
|
| sqlite3_db_status db DBSTATUS_DEFERRED_FKS 0
|
| } {0 0 0}
|
|
|
| +# Stress the dequoting logic. The first test is not so bad.
|
| +do_execsql_test fkey1-4.0 {
|
| + PRAGMA foreign_keys=ON;
|
| + CREATE TABLE "xx1"("xx2" TEXT PRIMARY KEY, "xx3" TEXT);
|
| + INSERT INTO "xx1"("xx2","xx3") VALUES('abc','def');
|
| + CREATE TABLE "xx4"("xx5" TEXT REFERENCES "xx1" ON DELETE CASCADE);
|
| + INSERT INTO "xx4"("xx5") VALUES('abc');
|
| + INSERT INTO "xx1"("xx2","xx3") VALUES('uvw','xyz');
|
| + SELECT 1, "xx5" FROM "xx4";
|
| + DELETE FROM "xx1";
|
| + SELECT 2, "xx5" FROM "xx4";
|
| +} {1 abc}
|
| +
|
| +# This case is identical to the previous except the "xx" in each name
|
| +# is changed to a single escaped double-quote character.
|
| +do_execsql_test fkey1-4.1 {
|
| + PRAGMA foreign_keys=ON;
|
| + CREATE TABLE """1"("""2" TEXT PRIMARY KEY, """3" TEXT);
|
| + INSERT INTO """1"("""2","""3") VALUES('abc','def');
|
| + CREATE TABLE """4"("""5" TEXT REFERENCES """1" ON DELETE CASCADE);
|
| + INSERT INTO """4"("""5") VALUES('abc');
|
| + INSERT INTO """1"("""2","""3") VALUES('uvw','xyz');
|
| + SELECT 1, """5" FROM """4";
|
| + DELETE FROM """1";
|
| + SELECT 2, """5" FROM """4";
|
| +} {1 abc}
|
| +do_execsql_test fkey1-4.2 {
|
| + PRAGMA table_info="""1";
|
| +} {0 {"2} TEXT 0 {} 1 1 {"3} TEXT 0 {} 0}
|
| +
|
| +#-------------------------------------------------------------------------
|
| +#
|
| +do_execsql_test fkey1-5.1 {
|
| + CREATE TABLE t11(
|
| + x INTEGER PRIMARY KEY,
|
| + parent REFERENCES t11 ON DELETE CASCADE
|
| + );
|
| + INSERT INTO t11 VALUES (1, NULL), (2, 1), (3, 2);
|
| +} {}
|
| +
|
| +# The REPLACE part of this statement deletes the row (2, 1). Then the
|
| +# DELETE CASCADE caused by deleting that row removes the (3, 2) row. Which
|
| +# would have been the parent of the new row being inserted. Causing an
|
| +# FK violation.
|
| +#
|
| +do_catchsql_test fkey1-5.2 {
|
| + INSERT OR REPLACE INTO t11 VALUES (2, 3);
|
| +} {1 {FOREIGN KEY constraint failed}}
|
| +
|
| +# A similar test to the above.
|
| +do_execsql_test fkey1-5.3 {
|
| + CREATE TABLE Foo (
|
| + Id INTEGER PRIMARY KEY,
|
| + ParentId INTEGER REFERENCES Foo(Id) ON DELETE CASCADE, C1
|
| + );
|
| + INSERT OR REPLACE INTO Foo(Id, ParentId, C1) VALUES (1, null, 'A');
|
| + INSERT OR REPLACE INTO Foo(Id, ParentId, C1) VALUES (2, 1, 'A-2-1');
|
| + INSERT OR REPLACE INTO Foo(Id, ParentId, C1) VALUES (3, 2, 'A-3-2');
|
| + INSERT OR REPLACE INTO Foo(Id, ParentId, C1) VALUES (4, 3, 'A-4-3');
|
| +}
|
| +do_catchsql_test fkey1-5.4 {
|
| + INSERT OR REPLACE INTO Foo(Id, ParentId, C1) VALUES (2, 3, 'A-2-3');
|
| +} {1 {FOREIGN KEY constraint failed}}
|
| +
|
| finish_test
|
|
|