Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Fix a problem in btree.c that could cause a crash following an OOM. Also various test script problems. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | two-mappings |
Files: | files | file ages | folders |
SHA1: | e8bcdf938eee2c307c24d60d0295e552 |
User & Date: | dan 2013-03-29 18:52:56 |
Context
2013-03-29
| ||
19:38 | Further fixes for test scripts. check-in: 23ffa4f9 user: dan tags: two-mappings | |
18:52 | Fix a problem in btree.c that could cause a crash following an OOM. Also various test script problems. check-in: e8bcdf93 user: dan tags: two-mappings | |
11:24 | Avoid assuming the page-size is 4096 bytes in os_unix.c. check-in: 3b7ec8d7 user: dan tags: two-mappings | |
Changes
Changes to src/btree.c.
2592 2592 2593 2593 for(pCsr=pBt->pCursor; pCsr && rc==SQLITE_OK; pCsr=pCsr->pNext){ 2594 2594 if( pCsr->iPage>=0 ){ 2595 2595 MemPage *pPg = pCsr->apPage[0]; 2596 2596 if( pPg && pPg->pDbPage->flags & PGHDR_MMAP ){ 2597 2597 MemPage *pNew = 0; 2598 2598 rc = getAndInitPage(pBt, pPg->pgno, &pNew, 0); 2599 - if( rc==SQLITE_OK && pCsr->iPage==0 ){ 2600 - pCsr->info.pCell = pNew->aData + (pCsr->info.pCell - pPg->aData); 2599 + if( rc==SQLITE_OK ){ 2600 + if( pCsr->iPage==0 ){ 2601 + pCsr->info.pCell = pNew->aData + (pCsr->info.pCell - pPg->aData); 2602 + } 2603 + pCsr->apPage[0] = pNew; 2604 + releasePage(pPg); 2601 2605 } 2602 - pCsr->apPage[0] = pNew; 2603 - releasePage(pPg); 2604 - if( rc!=SQLITE_OK ) return rc; 2605 2606 } 2606 2607 } 2607 2608 } 2608 2609 2609 2610 return rc; 2610 2611 } 2611 2612
Changes to src/os_unix.c.
4641 4641 } 4642 4642 #if HAVE_MREMAP 4643 4643 /* If we have an mremap() call, resize the existing mapping. */ 4644 4644 else{ 4645 4645 unixMapping *pMap = &pFd->aMmap[0]; 4646 4646 pNew = osMremap( 4647 4647 pMap->pMapRegion, pMap->mmapOrigsize, nMap, MREMAP_MAYMOVE 4648 - ); 4648 + ); 4649 4649 if( pNew==MAP_FAILED ){ 4650 4650 return SQLITE_IOERR_MMAP; 4651 4651 } 4652 4652 pFd->aMmap[0].pMapRegion = pNew; 4653 4653 pFd->aMmap[0].mmapSize = nMap; 4654 4654 pFd->aMmap[0].mmapOrigsize = nMap; 4655 4655 }
Changes to test/mallocH.test.
58 58 EXPLAIN QUERY PLAN SELECT * FROM abc AS t2 WHERE rowid=1; 59 59 } 60 60 } 61 61 62 62 # Malloc failure during integrity_check pragma. 63 63 # 64 64 do_malloc_test mallocH-5 -sqlprep { 65 + PRAGMA mmap_limit = 0; 65 66 CREATE TABLE t1(a PRIMARY KEY, b UNIQUE); 66 67 CREATE TABLE t2(x,y); 67 68 INSERT INTO t1 VALUES(1,2); 68 69 INSERT INTO t2 SELECT * FROM t1; 69 70 } -sqlbody { 70 71 PRAGMA integrity_check; 71 72 } 72 73 73 74 finish_test
Changes to test/pagerfault.test.
1197 1197 } 1198 1198 } -test { 1199 1199 faultsim_test_result {0 {}} 1200 1200 1201 1201 set contents [db eval {SELECT * FROM t1}] 1202 1202 if {$contents != "1 2"} { error "Bad database contents ($contents)" } 1203 1203 1204 - set sz [file size test.db] 1205 - if {$testrc!=0 && $sz!=1024*3 && $sz!=4096*3} { 1206 - error "Expected file size to be 3072 or 12288 bytes - actual size $sz bytes" 1204 + set nPg [file_page_count test.db] 1205 + set pgsz [file_page_size test.db] 1206 + if {$testrc!=0 && ($nPg!=3 || ($pgsz!=1024 && $pgsz!=4096))} { 1207 + error "File should be 3 pages. Page size 1024 or 4096 bytes. Is $nPg/$pgsz." 1207 1208 } 1208 - if {$testrc==0 && $sz!=4096*3} { 1209 - error "Expected file size to be 12288 bytes - actual size $sz bytes" 1209 + if {$testrc==0 && ($nPg!=3 || $pgsz!=4096)} { 1210 + error "File should be 3 pages. Page size 4096 bytes. Is $nPg/$pgsz." 1210 1211 } 1211 1212 } 1212 1213 1213 1214 do_test pagerfault-27-pre { 1214 1215 faultsim_delete_and_reopen 1215 1216 db func a_string a_string 1216 1217 execsql {
Changes to test/tester.tcl.
1676 1676 } 1677 1677 1678 1678 # Return the number of pages in the database file $zFile, according to 1679 1679 # the database header. 1680 1680 # 1681 1681 proc file_page_count {zFile} { 1682 1682 set nPg [hexio_get_int [hexio_read $zFile 28 4]] 1683 + set pgsz [file_page_size $zFile] 1684 + set filesz [file size $zFile] 1685 + set syspgsz 4096 1686 + 1687 + # Check that the file size is consistent with the database page size, 1688 + # the page count, and the system page size. 1689 + if {($filesz < ($nPg * $pgsz)) 1690 + || ($filesz > (((($nPg * $pgsz)+$syspgsz-1) / $syspgsz) * $syspgsz)) 1691 + } { 1692 + error "file_size=$filesz. page_count=$nPg. page_size=$pgsz." 1693 + } 1694 + 1683 1695 return $nPg 1684 1696 } 1685 1697 1686 1698 # Return the page size of database file $zFile, according to the database 1687 1699 # header. 1688 1700 # 1689 1701 proc file_page_size {zFile} {