From: dan Date: Fri, 20 Feb 2026 16:58:45 +0000 (+0000) Subject: Further tests for the new code in btree.c on this branch. X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=eb27374ff1a0609c80e4cb95544bd838d16fb7fe;p=thirdparty%2Fsqlite.git Further tests for the new code in btree.c on this branch. FossilOrigin-Name: 9202cd04f74ae69bb82c6574c2259d270ae35c9476cccc2e20f3c1f9c8a6c995 --- diff --git a/manifest b/manifest index 019779e780..c9e205f292 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improve\shandling\sof\slogical\sconflict\sdetection\sfor\sexact\slookups\son\sindexes. -D 2026-02-20T11:45:30.269 +C Further\stests\sfor\sthe\snew\scode\sin\sbtree.c\son\sthis\sbranch. +D 2026-02-20T16:58:45.446 F .fossil-settings/binary-glob 61195414528fb3ea9693577e1980230d78a1f8b0a54c78cf1b9b24d0a409ed6a x F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea @@ -997,7 +997,7 @@ F test/columncount.test 6fe99c2f35738b0129357a1cf3fa483f76140f4cd8a89014c88c33c8 F test/commitstatus.test d5a871506ce5944a29afb7e65ce47ca7f76cadc1d09775022830258fdd6168a1 F test/concfault.test 500f17c3fcfe7705114422bcc6ddd3c740001a43 F test/concfault2.test 5bf2df9d087b4dfde3311131d829f46c1369703023be3526c63b35d153492299 -F test/concfault3.test 6269970e57193aa0c0bdff543fdd8d8f07ebae26b82b4d59f89ccf6a4c2ef807 +F test/concfault3.test 8ef095eefd8180bb8d9e5eaacae0924f37b3ce53296cd6a2272aab9df42086aa F test/concurrent.test fb624ddac9b008f347685911f90b6b5a022fd0a3f884c0ffef8056bc440e5d76 F test/concurrent2.test 847cd11edc82229a95e1eaf88b55c974430b0f669cefd67a453d274e3480981c F test/concurrent3.test 82923fc2ea7321144b4448f98ea38aa316ddceef9020a392c5f6dea536506434 @@ -1007,10 +1007,10 @@ F test/concurrent6.test a7860e9ca13bb5fb76bcf41c5524fbfa9c37e6e258ecf84ffb5748a2 F test/concurrent7.test b96fa5c4cfdf8d5c0bc66b6934214500bad0260884a736f054ccc76e81aae85d F test/concurrent8.test b93937e74a8efb8b84f2fea7595b53418c5f29777bbe9cbdb5dc219b3dd72a7d F test/concurrent9.test 4b59e327c524d09c992f94b5cc7202cfed124ecbb85823c30308b5e1c7e16dca -F test/concurrentA.test 561ff9bb3de8a51e4ee35df040832c90a052ab1ce2f210bbeb61d584b7f73b72 +F test/concurrentA.test 2272fecbf128ac5a8d7b0c9cfe732c4935a5a1b915e237c93ef8dce39f7df670 F test/concurrentB.test b85e8adc4c1acf9b1cc0e8c2012348dc116d4ce032bb699d039f10de9b4cca71 -F test/concurrentC.test 61c7a6ebf318873327a8d885c84f45b4ce6fe01a576da0974accdef2e1da6809 -F test/concurrentD.test 5b6ba6a4485443944f33fc19862e6014186f714d4a2bf0194975e5f017848b5a +F test/concurrentC.test d5d4b9ce51a2d1b6fa5f652b24b077dc615085c0cdba302317f727923846ad10 +F test/concurrentD.test ded9c6e975af21652717afb87c8632395610372bc276d1efa701af05233f0c69 F test/conflict.test 3307ffdf988e04b01c4e942d8aa369a977f085bf629f43a627c9a77f39d65926 F test/conflict2.test 5557909ce683b1073982f5d1b61dfb1d41e369533bfdaf003180c5bc87282dd1 F test/conflict3.test 81865d9599609aca394fb3b9cd5f561d4729ea5b176bece3644f6ecb540f88ac @@ -2238,8 +2238,8 @@ F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee F tool/warnings.sh d924598cf2f55a4ecbc2aeb055c10bd5f48114793e7ba25f9585435da29e7e98 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f F tool/winmain.c 00c8fb88e365c9017db14c73d3c78af62194d9644feaf60e220ab0f411f3604c -P fd89345e120615d944eb3542cfb98ea5e74e57985f339e0f239630ddde88e4e0 -R 7fa1fb2b7c26bf959ebf55d72d44e396 +P 5fe1e2bb8e2049c33e29fa852bebfc151adf2ea4a05971b58ca7f6963c74bcea +R 9e48e63cc9ae39b6143f273626e4fe0e U dan -Z 2c16de123cf47b7e3e9d760a6d9576c2 +Z 50ea9f4a1b2820f61ff1e25001651907 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 37984c6f63..c4005bafb4 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5fe1e2bb8e2049c33e29fa852bebfc151adf2ea4a05971b58ca7f6963c74bcea +9202cd04f74ae69bb82c6574c2259d270ae35c9476cccc2e20f3c1f9c8a6c995 diff --git a/test/concfault3.test b/test/concfault3.test index 43102a038b..476bc194b6 100644 --- a/test/concfault3.test +++ b/test/concfault3.test @@ -31,6 +31,8 @@ do_execsql_test 1.0 { (4, 'four'), (5, 'five'), (6, 'six'); } {wal2} +faultsim_save_and_close + set res [list \ 2 read 2 4 \ 2 read 7 7 \ @@ -158,6 +160,41 @@ do_faultsim_test 1.5 -prep { catchsql { ROLLBACK } } +do_faultsim_test 1.6 -prep { + sqlite3 db test.db + execsql { + SELECT * FROM t1; + BEGIN CONCURRENT; + } +} -body { + execsql { DELETE FROM t1 WHERE b='five' } + execsql { SELECT * FROM sqlite_concurrent; } +} -test { + faultsim_test_result [list 0 $::res] [list 0 {}] \ + {1 {unable to open a temporary database file for storing temporary tables}} + catchsql { ROLLBACK } +} + +do_faultsim_test 1.7 -prep { + faultsim_restore_and_reopen + sqlite3 db2 test.db + execsql { + BEGIN CONCURRENT; + INSERT INTO t1 VALUES(0, 'zero'); + DELETE FROM t1 WHERE a=4; + } + execsql { + BEGIN CONCURRENT; + INSERT INTO t1 VALUES(7, 'seven'); + COMMIT; + } db2 +} -body { + execsql COMMIT +} -test { + faultsim_test_result [list 0 {}] \ + {1 {unable to open a temporary database file for storing temporary tables}} + catchsql ROLLBACK +} finish_test diff --git a/test/concurrentA.test b/test/concurrentA.test index e52b135ef7..d0ee3542cd 100644 --- a/test/concurrentA.test +++ b/test/concurrentA.test @@ -523,6 +523,36 @@ foreach {tn sql reads sorted} { 3 read (NULL)+ ()+ } + 24 { + SELECT * FROM x1 WHERE b=20; + SELECT * FROM x1 WHERE (b, c) = (20, 20); + } { + 3 read (20)- (20)+ + 3 read (20,20)- (20,20)+ + } { + 3 read (20)- (20)+ + } + + 25 { + SELECT * FROM x1 WHERE b=20; + SELECT * FROM x1 WHERE (b, c) BETWEEN (20, 20) AND (30, 10); + } { + 3 read (20)- (20)+ + 3 read (20,20)- (30,20,10,64) + } { + 3 read (20)- (30,20,10,64) + } + + 26 { + SELECT * FROM x1 WHERE b=20; + SELECT * FROM x1 WHERE (b, c) BETWEEN (10, 30) AND (20, 20); + } { + 3 read (20)- (20)+ + 3 read (10,30)- (20,30,10,46) + } { + 3 read (10,30)- (20)+ + } + } { execsql { BEGIN CONCURRENT } execsql $sql diff --git a/test/concurrentC.test b/test/concurrentC.test index 40cb6fc475..839a7b1a33 100644 --- a/test/concurrentC.test +++ b/test/concurrentC.test @@ -305,7 +305,75 @@ do_test 7.1 { execsql COMMIT db2 } {} +#------------------------------------------------------------------------- +# Check that deleting a record added by the same transaction causes +# no problems. +# +reset_db +do_execsql_test 8.0 { + PRAGMA journal_mode = wal2; + CREATE TABLE t1(x INTEGER PRIMARY KEY, y); + CREATE TABLE t2(x INTEGER PRIMARY KEY, y) WITHOUT ROWID; +} {wal2} +sqlite3 db2 test.db +do_test 8.1 { + execsql { + BEGIN CONCURRENT; + INSERT INTO t1 VALUES(1, 'one'); + INSERT INTO t1 VALUES(3, 'three'); + INSERT INTO t1 VALUES(5, 'five'); + DELETE FROM t1 WHERE x=3; + + INSERT INTO t2 VALUES(1, 'one'); + INSERT INTO t2 VALUES(3, 'three'); + INSERT INTO t2 VALUES(5, 'five'); + DELETE FROM t2 WHERE x=3; + } + execsql { + BEGIN CONCURRENT; + INSERT INTO t1 VALUES(7, 'seven'); + COMMIT; + } db2 + execsql COMMIT; +} {} + +do_execsql_test 8.2 { + SELECT * FROM t1; + SELECT * FROM t2; +} {1 one 5 five 7 seven 1 one 5 five} + +do_test 8.3 { + execsql { + BEGIN CONCURRENT; + INSERT INTO t1 VALUES(9, 'nine'); + DELETE FROM t2 WHERE x=1; + } + execsql { + BEGIN CONCURRENT; + INSERT INTO t1 VALUES(10, 'ten'); + COMMIT; + INSERT INTO t1 VALUES(8, 'eight'); + } db2 + catchsql COMMIT; +} {1 {database is locked}} +execsql ROLLBACK + +do_test 8.4 { + execsql { + BEGIN CONCURRENT; + INSERT INTO t1 VALUES(-1, 'minus one'); + } + execsql { + BEGIN CONCURRENT; + INSERT INTO t2 VALUES(-1, 'negative one'); + COMMIT; + BEGIN CONCURRENT; + INSERT INTO t1 VALUES(-2, 'minustwo'); + COMMIT; + } db2 + execsql COMMIT; +} {} #--------------------------------------------------------------- # @@ -424,6 +492,58 @@ do_test 9.4 { } } {1 {database is locked}} +#------------------------------------------------------------------------- +# +reset_db +do_execsql_test 11.0 { + PRAGMA journal_mode = wal2; + PRAGMA journal_size_limit = 8192; + PRAGMA wal_autocheckpoint = 0; + CREATE TABLE t1(a INTEGER PRIMARY KEY, b); + CREATE TABLE t2(a INTEGER PRIMARY KEY, b); + INSERT INTO t1 VALUES(1, 1); + INSERT INTO t2 VALUES(1, 1); + INSERT INTO t1 VALUES(2, 2); + INSERT INTO t2 VALUES(2, 2); + INSERT INTO t1 VALUES(3, 3); + INSERT INTO t2 VALUES(3, 3); +} {wal2 8192 0} + +do_test 11.1 { + list [file size test.db-wal] [file size test.db-wal2] +} {8416 2128} + +do_execsql_test 11.2 { + PRAGMA wal_checkpoint; + BEGIN CONCURRENT; + INSERT INTO t2 VALUES(5, 5); +} {0 10 8} + +sqlite3 db2 test.db + +do_test 11.3 { + execsql { + PRAGMA journal_size_limit = 8192; + BEGIN CONCURRENT; INSERT INTO t1 VALUES(4, 4); COMMIT; + BEGIN CONCURRENT; INSERT INTO t1 VALUES(5, 5); COMMIT; + BEGIN CONCURRENT; INSERT INTO t1 VALUES(6, 6); COMMIT; + BEGIN CONCURRENT; INSERT INTO t1 VALUES(7, 7); COMMIT; + BEGIN CONCURRENT; INSERT INTO t1 VALUES(8, 8); COMMIT; + BEGIN CONCURRENT; INSERT INTO t1 VALUES(9, 9); COMMIT; + BEGIN CONCURRENT; INSERT INTO t1 VALUES(10, 10); COMMIT; + BEGIN CONCURRENT; INSERT INTO t1 VALUES(11, 11); COMMIT; + BEGIN CONCURRENT; INSERT INTO t2 VALUES(4, 4); COMMIT; + } db2 + +} {} + +do_test 11.1 { + list [file size test.db-wal] [file size test.db-wal2] +} {8416 2128} + +do_execsql_test 11.5 COMMIT + + finish_test diff --git a/test/concurrentD.test b/test/concurrentD.test index 5c3e053de4..169a3e363c 100644 --- a/test/concurrentD.test +++ b/test/concurrentD.test @@ -62,11 +62,11 @@ foreach hdl $DBLIST { for {set i 0} {$i < 2000} {incr i} { foreach hdl $DBLIST { + if {$i==1000} { + $hdl eval "PRAGMA journal_size_limit=8192;" + } $hdl eval "BEGIN CONCURRENT" $hdl eval $T - if {$i==6} { - execsql_pp { SELECT * FROM sqlite_concurrent } $hdl - } } set tag "" @@ -77,6 +77,9 @@ for {set i 0} {$i < 2000} {incr i} { } else { append tag C } + if {$i>1000 && ($i % 5)==0} { + $hdl eval "PRAGMA wal_checkpoint" + } } do_execsql_test 1.1.$i.$tag { @@ -91,6 +94,73 @@ foreach hdl $DBLIST { $hdl close } +#------------------------------------------------------------------------- +reset_db +do_execsql_test 2.0 { + PRAGMA journal_mode = wal2; + PRAGMA journal_size_limit = 8192; + CREATE TABLE t1(a INTEGER PRIMARY KEY, b UNIQUE); + CREATE TABLE t2(a INTEGER PRIMARY KEY, b UNIQUE); + CREATE TABLE t3(a INTEGER PRIMARY KEY, b UNIQUE); +} {wal2 8192} + +do_test 2.1.1 { expr [file size test.db-wal2]>1000 } {0} +do_execsql_test 10.1.2 { + INSERT INTO t1 VALUES(0, 'xyz'); + PRAGMA wal_checkpoint; +} {0 11 9} + +do_test 2.1.3 { expr [file size test.db-wal]>1000 } {1} +do_test 2.1.4 { expr [file size test.db-wal2]>1000 } {1} + +sqlite3 db1 test.db +sqlite3 db2 test.db +sqlite3 db3 test.db + +db1 eval "PRAGMA journal_size_limit=8192;" +db2 eval "PRAGMA journal_size_limit=8192;" +db3 eval "PRAGMA journal_size_limit=8192;" + +proc random {} { + expr int(rand()*(2*1024*1024*1024*1024)) +} +db func random random +db1 func random random +db2 func random random +db3 func random random + +for {set i 0} {$i < 1000} {incr i} { + do_test 2.2.$i { + execsql { + BEGIN CONCURRENT; + INSERT INTO t3 VALUES( random(), randomblob(100) ); + } + execsql { + BEGIN CONCURRENT; + INSERT INTO t1 VALUES( random(), randomblob(100) ); + COMMIT; + PRAGMA wal_checkpoint; + } db1 + execsql { + BEGIN CONCURRENT; + INSERT INTO t2 VALUES( random(), randomblob(100) ); + COMMIT; + PRAGMA wal_checkpoint; + } db2 + execsql { + BEGIN CONCURRENT; + INSERT INTO t3 VALUES( random(), randomblob(100) ); + COMMIT; + PRAGMA wal_checkpoint; + } db3 + execsql COMMIT + } {} +} + +db1 close +db2 close +db3 close + finish_test