Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(248)

Unified Diff: third_party/sqlite/src/test/fkey1.test

Issue 1610963002: Import SQLite 3.10.2. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/sqlite/src/test/filectrl.test ('k') | third_party/sqlite/src/test/fkey2.test » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/sqlite/src/test/fkey1.test
diff --git a/third_party/sqlite/src/test/fkey1.test b/third_party/sqlite/src/test/fkey1.test
index 90a4c44409ed94d68188651efe3eabeedc7ce3eb..e10781ac520c9cf8f1889613f82fd2f6e525cb0b 100644
--- a/third_party/sqlite/src/test/fkey1.test
+++ b/third_party/sqlite/src/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
« no previous file with comments | « third_party/sqlite/src/test/filectrl.test ('k') | third_party/sqlite/src/test/fkey2.test » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698