]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Add tests to this branch. Fix a problem with temporary databases in auto-vacuum mode.
authordan <dan@noemail.net>
Wed, 6 Apr 2016 15:39:03 +0000 (15:39 +0000)
committerdan <dan@noemail.net>
Wed, 6 Apr 2016 15:39:03 +0000 (15:39 +0000)
FossilOrigin-Name: afe9bd9b4b5dc98dccf1bced80567515ab5c0117

manifest
manifest.uuid
src/pager.c
test/temptable2.test

index 261df5d6bf482c9acc2ae3449136ec6f160aecca..0084c64a0fd0fe24e96e32a532ba1ce8ea3a8809 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Defer\sopening\sthe\sfile\sused\sfor\sthe\stemp\sdatabase\s(where\sCREATE\sTEMP\sTABLE\stables\sare\sstored)\suntil\sthe\sdatabase\sis\stoo\slarge\sto\sreside\sentirely\swithin\sthe\scache.\sThere\sare\slikely\sstill\sproblems\son\sthis\sbranch.
-D 2016-04-05T21:07:58.179
+C Add\stests\sto\sthis\sbranch.\sFix\sa\sproblem\swith\stemporary\sdatabases\sin\sauto-vacuum\smode.
+D 2016-04-06T15:39:03.038
 F Makefile.in eba680121821b8a60940a81454316f47a341487a
 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
 F Makefile.msc 1f123a0757f6f04f0341accb46457e116817159a
@@ -362,7 +362,7 @@ F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa
 F src/os_unix.c b1ccb273771f41dbdbe0ba7c1ad63c38ad5972ec
 F src/os_win.c b3ba9573d8d893e70a6a8015bbee572ecf7ffbef
 F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca
-F src/pager.c 123dbae47bf27915a4b567915ff8dcc27cfcd369
+F src/pager.c 685f3cc08d045f64d20133144fb9a437914ea4c7
 F src/pager.h e1d38a2f14849e219df0f91f8323504d134c8a56
 F src/parse.y 5ea8c81c5c41b27887f41b4a7e1c58470d7d3821
 F src/pcache.c e9c00846d3dcdaa75b288c6f16238c2fe2177823
@@ -1110,7 +1110,7 @@ F test/tableopts.test dba698ba97251017b7c80d738c198d39ab747930
 F test/tclsqlite.test e1306001a0ca92250b691ea6d3cecaca5b6342aa
 F test/tempdb.test bd92eba8f20e16a9136e434e20b280794de3cdb6
 F test/temptable.test d2c9b87a54147161bcd1822e30c1d1cd891e5b30
-F test/temptable2.test f3b198e386f6494082c87accc8780cdf84b36e6d
+F test/temptable2.test c16f96e996bf6f587a4df4199c62cf0ac9a1c0ea
 F test/temptrigger.test 8ec228b0db5d7ebc4ee9b458fc28cb9e7873f5e1
 F test/tester.tcl 7b740ee852c55e1e72b6ebe5044acee7aa4e5553
 F test/thread001.test 9f22fd3525a307ff42a326b6bc7b0465be1745a5
@@ -1483,10 +1483,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 fb555c3c2af7f5e62ff839658f4fba7b645d3a68
-R f511e5baaeaad693345498b91b98e90f
-T *branch * tempfiles-lazy-open
-T *sym-tempfiles-lazy-open *
-T -sym-trunk *
+P be5a549eba6cf8e29cb6b9824fd6d0db9d03ca7f
+R 71d9b48ce9c812093890a1f227fcf740
 U dan
-Z 505ba6148fb8f2c79237e86b07655c1c
+Z 749bb77cf880284a6ac38e76d6c94ae0
index 0e8a9ef13012ba144422b0eee822e95c47424aa3..f61492cdc3822b922006e5419cd184919f8f6820 100644 (file)
@@ -1 +1 @@
-be5a549eba6cf8e29cb6b9824fd6d0db9d03ca7f
\ No newline at end of file
+afe9bd9b4b5dc98dccf1bced80567515ab5c0117
\ No newline at end of file
index 45f54ef30d04088f5a2b9126b1f6c93fcb09d9ff..3d8df3cdbb5d435724da0785b250459d33a47d13 100644 (file)
@@ -6815,7 +6815,7 @@ int sqlite3PagerMovepage(Pager *pPager, DbPage *pPg, Pgno pgno, int isCommit){
   /* In order to be able to rollback, an in-memory database must journal
   ** the page we are moving from.
   */
-  if( MEMDB ){
+  if( pPager->tempFile ){
     rc = sqlite3PagerWrite(pPg);
     if( rc ) return rc;
   }
@@ -6855,7 +6855,7 @@ int sqlite3PagerMovepage(Pager *pPager, DbPage *pPg, Pgno pgno, int isCommit){
   ** the journal needs to be sync()ed before database page pPg->pgno 
   ** can be written to. The caller has already promised not to write to it.
   */
-  if( (pPg->flags&PGHDR_NEED_SYNC) && !isCommit && pPager->tempFile==0 ){
+  if( (pPg->flags&PGHDR_NEED_SYNC) && !isCommit /* && pPager->tempFile==0 */ ){
     needSyncPgno = pPg->pgno;
     assert( pPager->journalMode==PAGER_JOURNALMODE_OFF ||
             pageInJournal(pPager, pPg) || pPg->pgno>pPager->dbOrigSize );
@@ -6872,7 +6872,7 @@ int sqlite3PagerMovepage(Pager *pPager, DbPage *pPg, Pgno pgno, int isCommit){
   assert( !pPgOld || pPgOld->nRef==1 );
   if( pPgOld ){
     pPg->flags |= (pPgOld->flags&PGHDR_NEED_SYNC);
-    if( MEMDB ){
+    if( pPager->tempFile ){
       /* Do not discard pages from an in-memory database since we might
       ** need to rollback later.  Just move the page out of the way. */
       sqlite3PcacheMove(pPgOld, pPager->dbSize+1);
@@ -6889,7 +6889,7 @@ int sqlite3PagerMovepage(Pager *pPager, DbPage *pPg, Pgno pgno, int isCommit){
   ** to exist, in case the transaction needs to roll back.  Use pPgOld
   ** as the original page since it has already been allocated.
   */
-  if( MEMDB ){
+  if( pPager->tempFile ){
     assert( pPgOld );
     sqlite3PcacheMove(pPgOld, origPgno);
     sqlite3PagerUnrefNotNull(pPgOld);
index daeb206a2968177f57fcc0194aa701021bc264c6..e702410f68093def77ca7b2aaba141c41dd05b88 100644 (file)
@@ -153,5 +153,63 @@ do_execsql_test 5.1.3 {
 
 do_execsql_test 5.1.4 { PRAGMA temp.integrity_check } {ok}
 
+#-------------------------------------------------------------------------
+# Test this:
+#
+#   1. Page is DIRTY at the start of a transaction.
+#   2. Page is written out as part of the transaction.
+#   3. Page is then read back in.
+#   4. Transaction is rolled back. Is the page now clean or dirty?
+#
+# This actually does work. Step 4 marks the page as clean. But it also
+# writes to the database file itself. So marking it clean is correct - 
+# the page does match the contents of the db file.
+#
+reset_db
+
+do_execsql_test 6.1 {
+  PRAGMA main.cache_size = 10;
+  PRAGMA temp.cache_size = 10;
+
+  CREATE TEMP TABLE t1(x);
+  INSERT INTO t1 VALUES('one');
+
+  CREATE TEMP TABLE t2(a, b);
+  CREATE INDEX i2 ON t2(a, b);
+  WITH x(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM x WHERE i<500 )
+  INSERT INTO t2 SELECT randomblob(100), randomblob(100) FROM x;
+}
+
+do_execsql_test 6.2 {
+  UPDATE t1 SET x='two';             -- step 1
+  BEGIN;
+    UPDATE t2 SET a=randomblob(100); -- step 2
+    SELECT * FROM t1;                -- step 3
+  ROLLBACK;                          -- step 4
+
+  SELECT count(*) FROM t2;
+  SELECT * FROM t1;
+} {two 500 two}
+
+#-------------------------------------------------------------------------
+
+reset_db
+sqlite3 db ""
+do_execsql_test 7.1 {
+  PRAGMA auto_vacuum=INCREMENTAL;
+  CREATE TABLE t1(x);
+  INSERT INTO t1 VALUES(zeroblob(900));
+  INSERT INTO t1 VALUES(zeroblob(900));
+  INSERT INTO t1 SELECT x FROM t1;
+  INSERT INTO t1 SELECT x FROM t1;
+  INSERT INTO t1 SELECT x FROM t1;
+  INSERT INTO t1 SELECT x FROM t1;
+  BEGIN;
+  DELETE FROM t1 WHERE rowid%2;
+  PRAGMA incremental_vacuum(4);
+  ROLLBACK;
+  PRAGMA integrity_check;
+} {ok}
+
 finish_test