Index: src/btree.c ================================================================== --- src/btree.c +++ src/btree.c @@ -3977,11 +3977,11 @@ && pBt->pPage1->aData[19]==0x01 /* (5) */ ){ u8 aSave[4]; u8 *aWrite = &pBuf[-4]; memcpy(aSave, aWrite, 4); - rc = sqlite3OsRead(fd, aWrite, a+4, pBt->pageSize * (nextPage-1)); + rc = sqlite3OsRead(fd, aWrite, a+4, (i64)pBt->pageSize*(nextPage-1)); nextPage = get4byte(aWrite); memcpy(aWrite, aSave, 4); }else #endif Index: src/pager.c ================================================================== --- src/pager.c +++ src/pager.c @@ -3277,17 +3277,17 @@ ** previously rolled back out of the main journal (and are hence in pDone) ** will be skipped. Out-of-range pages are also skipped. */ if( pSavepoint ){ u32 ii; /* Loop counter */ - i64 offset = pSavepoint->iSubRec*(4+pPager->pageSize); + i64 offset = (i64)pSavepoint->iSubRec*(4+pPager->pageSize); if( pagerUseWal(pPager) ){ rc = sqlite3WalSavepointUndo(pPager->pWal, pSavepoint->aWalData); } for(ii=pSavepoint->iSubRec; rc==SQLITE_OK && iinSubRec; ii++){ - assert( offset==ii*(4+pPager->pageSize) ); + assert( offset==(i64)ii*(4+pPager->pageSize) ); rc = pager_playback_one_page(pPager, &offset, pDone, 0, 1); } assert( rc!=SQLITE_DONE ); } @@ -4135,11 +4135,11 @@ /* If the sub-journal was opened successfully (or was already open), ** write the journal record into the file. */ if( rc==SQLITE_OK ){ void *pData = pPg->pData; - i64 offset = pPager->nSubRec*(4+pPager->pageSize); + i64 offset = (i64)pPager->nSubRec*(4+pPager->pageSize); char *pData2; CODEC2(pPager, pData, pPg->pgno, 7, return SQLITE_NOMEM, pData2); PAGERTRACE(("STMT-JOURNAL %d page %d\n", PAGERID(pPager), pPg->pgno)); rc = write32bits(pPager->sjfd, offset, pPg->pgno); Index: src/test_journal.c ================================================================== --- src/test_journal.c +++ src/test_journal.c @@ -389,11 +389,11 @@ } iTrunk = decodeUint32(&aData[32]); while( rc==SQLITE_OK && iTrunk>0 ){ u32 nLeaf; u32 iLeaf; - sqlite3_int64 iOff = (iTrunk-1)*pMain->nPagesize; + sqlite3_int64 iOff = (i64)(iTrunk-1)*pMain->nPagesize; rc = sqlite3OsRead(p, aData, pMain->nPagesize, iOff); nLeaf = decodeUint32(&aData[4]); for(iLeaf=0; rc==SQLITE_OK && iLeafpWritable, pgno); Index: src/test_stat.c ================================================================== --- src/test_stat.c +++ src/test_stat.c @@ -367,11 +367,11 @@ sqlite3_file *fd; sqlite3_int64 x[2]; /* The default page size and offset */ pCsr->szPage = sqlite3BtreeGetPageSize(pBt); - pCsr->iOffset = pCsr->szPage * (pCsr->iPageno - 1); + pCsr->iOffset = (i64)pCsr->szPage * (pCsr->iPageno - 1); /* If connected to a ZIPVFS backend, override the page size and ** offset with actual values obtained from ZIPVFS. */ fd = sqlite3PagerFile(pPager); ADDED test/bigfile2.test Index: test/bigfile2.test ================================================================== --- /dev/null +++ test/bigfile2.test @@ -0,0 +1,59 @@ +# 2011 December 20 +# +# 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 script testing the ability of SQLite to handle database +# files larger than 4GB. +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl +set testprefix bigfile2 + +# Create a small database. +# +do_execsql_test 1.1 { + CREATE TABLE t1(a, b); + INSERT INTO t1 VALUES(1, 2); +} + +# Pad the file out to 4GB in size. Then clear the file-size field in the +# db header. This will cause SQLite to assume that the first 4GB of pages +# are actually in use and new pages will be appended to the file. +# +db close +if {[catch {fake_big_file 4096 [pwd]/test.db} msg]} { + puts "**** Unable to create a file larger than 4096 MB. *****" + finish_test + return +} +hexio_write test.db 28 00000000 + +do_test 1.2 { + file size test.db +} [expr 14 + 4096 * (1<<20)] + +# Now insert a large row. The overflow pages will be located past the 4GB +# boundary. Then, after opening and closing the database, test that the row +# can be read back in. +# +set str [string repeat k 30000] +do_test 1.3 { + sqlite3 db test.db + execsql { INSERT INTO t1 VALUES(3, $str) } + db close + sqlite3 db test.db + db one { SELECT b FROM t1 WHERE a = 3 } +} $str + +db close +file delete test.db + +finish_test Index: test/unixexcl.test ================================================================== --- test/unixexcl.test +++ test/unixexcl.test @@ -77,7 +77,51 @@ } {hello world} do_test unixexcl-2.$tn.4 { csql2 { SELECT * FROM t1 } } {0 {hello world}} } + +do_multiclient_test tn { + do_test unixexcl-3.$tn.1 { + code1 { db close; sqlite3 db test.db -vfs unix-excl } + code2 { db2 close; sqlite3 db2 test.db -vfs unix-excl } + sql1 { + PRAGMA journal_mode = WAL; + CREATE TABLE t1(a, b); + INSERT INTO t1 VALUES(1, 2); + } + } {wal} + + if {$tn==1} { + do_test unixexcl-3.$tn.1.multiproc { + csql2 { SELECT * FROM t1; } + } {1 {database is locked}} + } else { + do_test unixexcl-3.$tn.1.singleproc { + sql2 { SELECT * FROM t1; } + } {1 2} + + do_test unixexcl-3.$tn.2 { + sql2 { + BEGIN; + SELECT * FROM t1; + } + } {1 2} + do_test unixexcl-3.$tn.3 { + sql1 { PRAGMA wal_checkpoint; INSERT INTO t1 VALUES(3, 4); } + } {0 5 5} + do_test unixexcl-3.$tn.4 { + sql2 { SELECT * FROM t1; } + } {1 2} + do_test unixexcl-3.$tn.5 { + sql1 { SELECT * FROM t1; } + } {1 2 3 4} + do_test unixexcl-3.$tn.6 { + sql2 { COMMIT; SELECT * FROM t1; } + } {1 2 3 4} + do_test unixexcl-3.$tn.7 { + sql1 { PRAGMA wal_checkpoint; } + } {0 7 7} + } +} finish_test