]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Add further tests for the code on this branch.
authordan <dan@noemail.net>
Fri, 10 Nov 2017 17:47:54 +0000 (17:47 +0000)
committerdan <dan@noemail.net>
Fri, 10 Nov 2017 17:47:54 +0000 (17:47 +0000)
FossilOrigin-Name: f8c4e33f4813e0c909064406b5cc17e2d465d8a48a50ede1d356b39479d3d669

manifest
manifest.uuid
test/wherelfault.test [new file with mode: 0644]
test/wherelimit2.test

index 2d902bb312dd135ce66ea9891d0214e52bc45a3f..5bd57a17fd9675ade6ea48b27d7a74c5fb1a423f 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\sa\sproblem\sinvolving\s"DELETE/UPDATE...LIMIT"\sstatements\sthat\suse\san\sINDEXED\nBY\sclause.
-D 2017-11-10T16:14:26.225
+C Add\sfurther\stests\sfor\sthe\scode\son\sthis\sbranch.
+D 2017-11-10T17:47:54.147
 F Makefile.in b142eb20482922153ebc77b261cdfd0a560ed05a81e9f6d9a2b0e8192922a1d2
 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
 F Makefile.msc a55372a22454e742ba7c8f6edf05b83213ec01125166ad7dcee0567e2f7fc81b
@@ -1557,8 +1557,9 @@ F test/whereI.test eab5b226bbc344ac70d7dc09b963a064860ae6d7
 F test/whereJ.test 55a3221706a7ab706293f17cc8f96da563bf0767
 F test/whereK.test f8e3cf26a8513ecc7f514f54df9f0572c046c42b
 F test/wherefault.test 1374c3aa198388925246475f84ad4cd5f9528864
+F test/wherelfault.test 9012e4ef5259058b771606616bd007af5d154e64cc25fa9fd4170f6411db44e3
 F test/wherelimit.test 1dee70c9cc147330156d75e23de88f771e624998b03ae316cb64e1d249f129d8
-F test/wherelimit2.test 85e3fc3e61e100d8da27323c5cb30ed5881013c3b9100bb26ac5fd52d594c79b
+F test/wherelimit2.test be78ba3aa1831c6358fd7d5b9809bfd520f0c2a7d63a295e8f182e140ff137c3
 F test/wild001.test bca33f499866f04c24510d74baf1e578d4e44b1c
 F test/win32heap.test 10fd891266bd00af68671e702317726375e5407561d859be1aa04696f2aeee74
 F test/win32lock.test fbf107c91d8f5512be5a5b87c4c42ab9fdd54972
@@ -1674,7 +1675,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
 F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P 35477a3dcceadf5dade8e036d5a2ce91b9ca83c4b85d309db233bdbcf538b1cc
-R 07fcc16cd40c06e7e9266df3e5decf1a
+P 09f94c2c8199b0d23a45cc062ca9561f9e5ddfcba117100e41889ce199d21bdb
+R 276fb9c7ab900388b15c7da93d892ba2
 U dan
-Z 02c3e7941017d253308184d6859dc937
+Z 620b60e1c2be9813cc742e8964032235
index 03929fbdcf0675cb8b803e127507b7ab1878ca4f..1df45c1eee758061989fbbb25006787b139f3832 100644 (file)
@@ -1 +1 @@
-09f94c2c8199b0d23a45cc062ca9561f9e5ddfcba117100e41889ce199d21bdb
\ No newline at end of file
+f8c4e33f4813e0c909064406b5cc17e2d465d8a48a50ede1d356b39479d3d669
\ No newline at end of file
diff --git a/test/wherelfault.test b/test/wherelfault.test
new file mode 100644 (file)
index 0000000..cfb8c1c
--- /dev/null
@@ -0,0 +1,82 @@
+# 2008 October 6
+#
+# The author disclaims copyright to this source code.  In place of
+# a legal notice, here is a blessing:
+#
+#    May you do good and not evil.
+#    May you find forgiveness for yourself and forgive others.
+#    May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.  The
+# focus of this file is testing fault-injection with the 
+# LIMIT ... OFFSET ... clause of UPDATE and DELETE statements.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/malloc_common.tcl
+set testprefix wherelfault
+
+ifcapable !update_delete_limit {
+  finish_test
+  return
+}
+
+do_execsql_test 1.0 {
+  CREATE TABLE t1(a, b);
+  INSERT INTO t1 VALUES(1, 'f');
+  INSERT INTO t1 VALUES(2, 'e');
+  INSERT INTO t1 VALUES(3, 'd');
+  INSERT INTO t1 VALUES(4, 'c');
+  INSERT INTO t1 VALUES(5, 'b');
+  INSERT INTO t1 VALUES(6, 'a');
+
+  CREATE VIEW v1 AS SELECT a,b FROM t1;
+  CREATE TABLE log(op, a);
+
+  CREATE TRIGGER v1del INSTEAD OF DELETE ON v1 BEGIN
+    INSERT INTO log VALUES('delete', old.a);
+  END;
+
+  CREATE TRIGGER v1upd INSTEAD OF UPDATE ON v1 BEGIN
+    INSERT INTO log VALUES('update', old.a);
+  END;
+}
+
+faultsim_save_and_close
+do_faultsim_test 1.1 -prep {
+  faultsim_restore_and_reopen
+  db eval {SELECT * FROM sqlite_master}
+} -body {
+  execsql { DELETE FROM v1 ORDER BY a LIMIT 3; }
+} -test {
+  faultsim_test_result {0 {}} 
+}
+
+do_faultsim_test 1.2 -prep {
+  faultsim_restore_and_reopen
+  db eval {SELECT * FROM sqlite_master}
+} -body {
+  execsql { UPDATE v1 SET b = 555 ORDER BY a LIMIT 3 }
+} -test {
+  faultsim_test_result {0 {}} 
+}
+
+#-------------------------------------------------------------------------
+sqlite3 db test.db
+do_execsql_test 2.1.0 {
+  CREATE TABLE t2(a, b, c, PRIMARY KEY(a, b)) WITHOUT ROWID;
+}
+faultsim_save_and_close
+
+do_faultsim_test 2.1 -prep {
+  faultsim_restore_and_reopen
+  db eval {SELECT * FROM sqlite_master}
+} -body {
+  execsql { DELETE FROM t2 WHERE c=? ORDER BY a DESC LIMIT 10 }
+} -test {
+  faultsim_test_result {0 {}} 
+}
+
+finish_test
index fbcc14aa5029f7174374ba307ad31695fb42e5dc..43a37958eed87e6bc261400fc9daea1fe201811a 100644 (file)
@@ -239,7 +239,61 @@ do_execsql_test 4.5 {
 #-------------------------------------------------------------------------
 # Test using object names that require quoting.
 #
+do_execsql_test 5.0 {
+  CREATE TABLE "x y"("a b" PRIMARY KEY, "c d") WITHOUT ROWID;
+  CREATE INDEX xycd ON "x y"("c d");
 
+  INSERT INTO "x y" VALUES('a', 'a');
+  INSERT INTO "x y" VALUES('b', 'b');
+  INSERT INTO "x y" VALUES('c', 'c');
+  INSERT INTO "x y" VALUES('d', 'd');
+  INSERT INTO "x y" VALUES('e', 'a');
+  INSERT INTO "x y" VALUES('f', 'b');
+  INSERT INTO "x y" VALUES('g', 'c');
+  INSERT INTO "x y" VALUES('h', 'd');
+}
+
+do_execsql_test 5.1 {
+  BEGIN;
+    DELETE FROM "x y" WHERE "c d"!='e' ORDER BY "c d" LIMIT 2 OFFSET 2;
+    SELECT * FROM "x y" ORDER BY 1;
+  ROLLBACK;
+} {
+  a a c c d d e a g c h d
+}
+
+do_execsql_test 5.2 {
+  BEGIN;
+    UPDATE "x y" SET "c d"='e' WHERE "c d"!='e' ORDER BY "c d" LIMIT 2 OFFSET 2;
+    SELECT * FROM "x y" ORDER BY 1;
+  ROLLBACK;
+} {
+  a a b e c c d d e a f e g c h d
+}
+
+proc log {args} { lappend ::log {*}$args }
+db func log log
+do_execsql_test 5.3 {
+  CREATE VIEW "v w" AS SELECT * FROM "x y";
+  CREATE TRIGGER tr1 INSTEAD OF DELETE ON "v w" BEGIN
+    SELECT log(old."a b", old."c d");
+  END;
+  CREATE TRIGGER tr2 INSTEAD OF UPDATE ON "v w" BEGIN
+    SELECT log(new."a b", new."c d");
+  END;
+}
+
+do_test 5.4 {
+  set ::log {}
+  execsql { DELETE FROM "v w" ORDER BY "a b" LIMIT 3 }
+  set ::log
+} {a a b b c c}
+
+do_test 5.5 {
+  set ::log {}
+  execsql { UPDATE "v w" SET "a b" = "a b" || 'x' ORDER BY "a b" LIMIT 5; }
+  set ::log
+} {ax a bx b cx c dx d ex a}
 
 
 finish_test