Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Add tests to this branch. Fix a problem with temporary databases in auto-vacuum mode. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | tempfiles-lazy-open |
Files: | files | file ages | folders |
SHA1: |
afe9bd9b4b5dc98dccf1bced80567515 |
User & Date: | dan 2016-04-06 15:39:03.038 |
Context
2016-04-06
| ||
16:27 | Fix a problem in test script lock.test. Fix minor issues in pager.c. (check-in: 84de8813c3 user: dan tags: tempfiles-lazy-open) | |
15:39 | Add tests to this branch. Fix a problem with temporary databases in auto-vacuum mode. (check-in: afe9bd9b4b user: dan tags: tempfiles-lazy-open) | |
2016-04-05
| ||
21:07 | Defer opening the file used for the temp database (where CREATE TEMP TABLE tables are stored) until the database is too large to reside entirely within the cache. There are likely still problems on this branch. (check-in: be5a549eba user: dan tags: tempfiles-lazy-open) | |
Changes
Changes to src/pager.c.
︙ | ︙ | |||
6811 6812 6813 6814 6815 6816 6817 | || pPager->eState==PAGER_WRITER_DBMOD ); assert( assert_pager_state(pPager) ); /* In order to be able to rollback, an in-memory database must journal ** the page we are moving from. */ | | | 6811 6812 6813 6814 6815 6816 6817 6818 6819 6820 6821 6822 6823 6824 6825 | || pPager->eState==PAGER_WRITER_DBMOD ); assert( assert_pager_state(pPager) ); /* In order to be able to rollback, an in-memory database must journal ** the page we are moving from. */ if( pPager->tempFile ){ rc = sqlite3PagerWrite(pPg); if( rc ) return rc; } /* If the page being moved is dirty and has not been saved by the latest ** savepoint, then save the current contents of the page into the ** sub-journal now. This is required to handle the following scenario: |
︙ | ︙ | |||
6851 6852 6853 6854 6855 6856 6857 | /* If the journal needs to be sync()ed before page pPg->pgno can ** be written to, store pPg->pgno in local variable needSyncPgno. ** ** If the isCommit flag is set, there is no need to remember that ** 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. */ | | | | | 6851 6852 6853 6854 6855 6856 6857 6858 6859 6860 6861 6862 6863 6864 6865 6866 6867 6868 6869 6870 6871 6872 6873 6874 6875 6876 6877 6878 6879 6880 6881 6882 6883 6884 6885 6886 6887 6888 6889 6890 6891 6892 6893 6894 6895 6896 6897 6898 6899 | /* If the journal needs to be sync()ed before page pPg->pgno can ** be written to, store pPg->pgno in local variable needSyncPgno. ** ** If the isCommit flag is set, there is no need to remember that ** 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 */ ){ needSyncPgno = pPg->pgno; assert( pPager->journalMode==PAGER_JOURNALMODE_OFF || pageInJournal(pPager, pPg) || pPg->pgno>pPager->dbOrigSize ); assert( pPg->flags&PGHDR_DIRTY ); } /* If the cache contains a page with page-number pgno, remove it ** from its hash chain. Also, if the PGHDR_NEED_SYNC flag was set for ** page pgno before the 'move' operation, it needs to be retained ** for the page moved there. */ pPg->flags &= ~PGHDR_NEED_SYNC; pPgOld = sqlite3PagerLookup(pPager, pgno); assert( !pPgOld || pPgOld->nRef==1 ); if( pPgOld ){ pPg->flags |= (pPgOld->flags&PGHDR_NEED_SYNC); 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); }else{ sqlite3PcacheDrop(pPgOld); } } origPgno = pPg->pgno; sqlite3PcacheMove(pPg, pgno); sqlite3PcacheMakeDirty(pPg); /* For an in-memory database, make sure the original page continues ** to exist, in case the transaction needs to roll back. Use pPgOld ** as the original page since it has already been allocated. */ if( pPager->tempFile ){ assert( pPgOld ); sqlite3PcacheMove(pPgOld, origPgno); sqlite3PagerUnrefNotNull(pPgOld); } if( needSyncPgno ){ /* If needSyncPgno is non-zero, then the journal file needs to be |
︙ | ︙ |
Changes to test/temptable2.test.
︙ | ︙ | |||
148 149 150 151 152 153 154 155 156 157 | do_execsql_test 5.1.3 { UPDATE t2 SET a=randomblob(100); SELECT * FROM t1; } {1 2} do_execsql_test 5.1.4 { PRAGMA temp.integrity_check } {ok} finish_test | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 | do_execsql_test 5.1.3 { UPDATE t2 SET a=randomblob(100); SELECT * FROM t1; } {1 2} 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 |