1
0
Fork 0
mirror of https://github.com/DBD-SQLite/DBD-SQLite synced 2025-06-07 22:28:47 -04:00

updated SQLite to 3.8.8.2

This commit is contained in:
Kenichi Ishigaki 2015-02-08 18:09:42 +09:00
parent 76d1702937
commit f537ab8ab9
2 changed files with 99 additions and 95 deletions

190
sqlite3.c
View file

@ -1,6 +1,6 @@
/****************************************************************************** /******************************************************************************
** This file is an amalgamation of many separate C source files from SQLite ** This file is an amalgamation of many separate C source files from SQLite
** version 3.8.8.1. By combining all the individual C code files into this ** version 3.8.8.2. By combining all the individual C code files into this
** single large file, the entire code can be compiled as a single translation ** single large file, the entire code can be compiled as a single translation
** unit. This allows many compilers to do optimizations that would not be ** unit. This allows many compilers to do optimizations that would not be
** possible if the files were compiled separately. Performance improvements ** possible if the files were compiled separately. Performance improvements
@ -278,9 +278,9 @@ extern "C" {
** [sqlite3_libversion_number()], [sqlite3_sourceid()], ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
** [sqlite_version()] and [sqlite_source_id()]. ** [sqlite_version()] and [sqlite_source_id()].
*/ */
#define SQLITE_VERSION "3.8.8.1" #define SQLITE_VERSION "3.8.8.2"
#define SQLITE_VERSION_NUMBER 3008008 #define SQLITE_VERSION_NUMBER 3008008
#define SQLITE_SOURCE_ID "2015-01-20 16:51:25 f73337e3e289915a76ca96e7a05a1a8d4e890d55" #define SQLITE_SOURCE_ID "2015-01-30 14:30:45 7757fc721220e136620a89c9d28247f28bbbc098"
/* /*
** CAPI3REF: Run-Time Library Version Numbers ** CAPI3REF: Run-Time Library Version Numbers
@ -50197,7 +50197,7 @@ static int walCheckpoint(
int sync_flags, /* Flags for OsSync() (or 0) */ int sync_flags, /* Flags for OsSync() (or 0) */
u8 *zBuf /* Temporary buffer to use */ u8 *zBuf /* Temporary buffer to use */
){ ){
int rc; /* Return code */ int rc = SQLITE_OK; /* Return code */
int szPage; /* Database page-size */ int szPage; /* Database page-size */
WalIterator *pIter = 0; /* Wal iterator context */ WalIterator *pIter = 0; /* Wal iterator context */
u32 iDbpage = 0; /* Next database page to write */ u32 iDbpage = 0; /* Next database page to write */
@ -50211,104 +50211,107 @@ static int walCheckpoint(
testcase( szPage<=32768 ); testcase( szPage<=32768 );
testcase( szPage>=65536 ); testcase( szPage>=65536 );
pInfo = walCkptInfo(pWal); pInfo = walCkptInfo(pWal);
if( pInfo->nBackfill>=pWal->hdr.mxFrame ) return SQLITE_OK; if( pInfo->nBackfill<pWal->hdr.mxFrame ){
/* Allocate the iterator */ /* Allocate the iterator */
rc = walIteratorInit(pWal, &pIter); rc = walIteratorInit(pWal, &pIter);
if( rc!=SQLITE_OK ){ if( rc!=SQLITE_OK ){
return rc; return rc;
}
assert( pIter );
/* EVIDENCE-OF: R-62920-47450 The busy-handler callback is never invoked
** in the SQLITE_CHECKPOINT_PASSIVE mode. */
assert( eMode!=SQLITE_CHECKPOINT_PASSIVE || xBusy==0 );
/* Compute in mxSafeFrame the index of the last frame of the WAL that is
** safe to write into the database. Frames beyond mxSafeFrame might
** overwrite database pages that are in use by active readers and thus
** cannot be backfilled from the WAL.
*/
mxSafeFrame = pWal->hdr.mxFrame;
mxPage = pWal->hdr.nPage;
for(i=1; i<WAL_NREADER; i++){
u32 y = pInfo->aReadMark[i];
if( mxSafeFrame>y ){
assert( y<=pWal->hdr.mxFrame );
rc = walBusyLock(pWal, xBusy, pBusyArg, WAL_READ_LOCK(i), 1);
if( rc==SQLITE_OK ){
pInfo->aReadMark[i] = (i==1 ? mxSafeFrame : READMARK_NOT_USED);
walUnlockExclusive(pWal, WAL_READ_LOCK(i), 1);
}else if( rc==SQLITE_BUSY ){
mxSafeFrame = y;
xBusy = 0;
}else{
goto walcheckpoint_out;
}
} }
} assert( pIter );
if( pInfo->nBackfill<mxSafeFrame /* EVIDENCE-OF: R-62920-47450 The busy-handler callback is never invoked
&& (rc = walBusyLock(pWal, xBusy, pBusyArg, WAL_READ_LOCK(0), 1))==SQLITE_OK ** in the SQLITE_CHECKPOINT_PASSIVE mode. */
){ assert( eMode!=SQLITE_CHECKPOINT_PASSIVE || xBusy==0 );
i64 nSize; /* Current size of database file */
u32 nBackfill = pInfo->nBackfill;
/* Sync the WAL to disk */ /* Compute in mxSafeFrame the index of the last frame of the WAL that is
if( sync_flags ){ ** safe to write into the database. Frames beyond mxSafeFrame might
rc = sqlite3OsSync(pWal->pWalFd, sync_flags); ** overwrite database pages that are in use by active readers and thus
} ** cannot be backfilled from the WAL.
/* If the database may grow as a result of this checkpoint, hint
** about the eventual size of the db file to the VFS layer.
*/ */
if( rc==SQLITE_OK ){ mxSafeFrame = pWal->hdr.mxFrame;
i64 nReq = ((i64)mxPage * szPage); mxPage = pWal->hdr.nPage;
rc = sqlite3OsFileSize(pWal->pDbFd, &nSize); for(i=1; i<WAL_NREADER; i++){
if( rc==SQLITE_OK && nSize<nReq ){ u32 y = pInfo->aReadMark[i];
sqlite3OsFileControlHint(pWal->pDbFd, SQLITE_FCNTL_SIZE_HINT, &nReq); if( mxSafeFrame>y ){
} assert( y<=pWal->hdr.mxFrame );
} rc = walBusyLock(pWal, xBusy, pBusyArg, WAL_READ_LOCK(i), 1);
if( rc==SQLITE_OK ){
pInfo->aReadMark[i] = (i==1 ? mxSafeFrame : READMARK_NOT_USED);
/* Iterate through the contents of the WAL, copying data to the db file. */ walUnlockExclusive(pWal, WAL_READ_LOCK(i), 1);
while( rc==SQLITE_OK && 0==walIteratorNext(pIter, &iDbpage, &iFrame) ){ }else if( rc==SQLITE_BUSY ){
i64 iOffset; mxSafeFrame = y;
assert( walFramePgno(pWal, iFrame)==iDbpage ); xBusy = 0;
if( iFrame<=nBackfill || iFrame>mxSafeFrame || iDbpage>mxPage ) continue; }else{
iOffset = walFrameOffset(iFrame, szPage) + WAL_FRAME_HDRSIZE; goto walcheckpoint_out;
/* testcase( IS_BIG_INT(iOffset) ); // requires a 4GiB WAL file */
rc = sqlite3OsRead(pWal->pWalFd, zBuf, szPage, iOffset);
if( rc!=SQLITE_OK ) break;
iOffset = (iDbpage-1)*(i64)szPage;
testcase( IS_BIG_INT(iOffset) );
rc = sqlite3OsWrite(pWal->pDbFd, zBuf, szPage, iOffset);
if( rc!=SQLITE_OK ) break;
}
/* If work was actually accomplished... */
if( rc==SQLITE_OK ){
if( mxSafeFrame==walIndexHdr(pWal)->mxFrame ){
i64 szDb = pWal->hdr.nPage*(i64)szPage;
testcase( IS_BIG_INT(szDb) );
rc = sqlite3OsTruncate(pWal->pDbFd, szDb);
if( rc==SQLITE_OK && sync_flags ){
rc = sqlite3OsSync(pWal->pDbFd, sync_flags);
} }
} }
if( rc==SQLITE_OK ){
pInfo->nBackfill = mxSafeFrame;
}
} }
/* Release the reader lock held while backfilling */ if( pInfo->nBackfill<mxSafeFrame
walUnlockExclusive(pWal, WAL_READ_LOCK(0), 1); && (rc = walBusyLock(pWal, xBusy, pBusyArg, WAL_READ_LOCK(0),1))==SQLITE_OK
} ){
i64 nSize; /* Current size of database file */
u32 nBackfill = pInfo->nBackfill;
if( rc==SQLITE_BUSY ){ /* Sync the WAL to disk */
/* Reset the return code so as not to report a checkpoint failure if( sync_flags ){
** just because there are active readers. */ rc = sqlite3OsSync(pWal->pWalFd, sync_flags);
rc = SQLITE_OK; }
/* If the database may grow as a result of this checkpoint, hint
** about the eventual size of the db file to the VFS layer.
*/
if( rc==SQLITE_OK ){
i64 nReq = ((i64)mxPage * szPage);
rc = sqlite3OsFileSize(pWal->pDbFd, &nSize);
if( rc==SQLITE_OK && nSize<nReq ){
sqlite3OsFileControlHint(pWal->pDbFd, SQLITE_FCNTL_SIZE_HINT, &nReq);
}
}
/* Iterate through the contents of the WAL, copying data to the db file */
while( rc==SQLITE_OK && 0==walIteratorNext(pIter, &iDbpage, &iFrame) ){
i64 iOffset;
assert( walFramePgno(pWal, iFrame)==iDbpage );
if( iFrame<=nBackfill || iFrame>mxSafeFrame || iDbpage>mxPage ){
continue;
}
iOffset = walFrameOffset(iFrame, szPage) + WAL_FRAME_HDRSIZE;
/* testcase( IS_BIG_INT(iOffset) ); // requires a 4GiB WAL file */
rc = sqlite3OsRead(pWal->pWalFd, zBuf, szPage, iOffset);
if( rc!=SQLITE_OK ) break;
iOffset = (iDbpage-1)*(i64)szPage;
testcase( IS_BIG_INT(iOffset) );
rc = sqlite3OsWrite(pWal->pDbFd, zBuf, szPage, iOffset);
if( rc!=SQLITE_OK ) break;
}
/* If work was actually accomplished... */
if( rc==SQLITE_OK ){
if( mxSafeFrame==walIndexHdr(pWal)->mxFrame ){
i64 szDb = pWal->hdr.nPage*(i64)szPage;
testcase( IS_BIG_INT(szDb) );
rc = sqlite3OsTruncate(pWal->pDbFd, szDb);
if( rc==SQLITE_OK && sync_flags ){
rc = sqlite3OsSync(pWal->pDbFd, sync_flags);
}
}
if( rc==SQLITE_OK ){
pInfo->nBackfill = mxSafeFrame;
}
}
/* Release the reader lock held while backfilling */
walUnlockExclusive(pWal, WAL_READ_LOCK(0), 1);
}
if( rc==SQLITE_BUSY ){
/* Reset the return code so as not to report a checkpoint failure
** just because there are active readers. */
rc = SQLITE_OK;
}
} }
/* If this is an SQLITE_CHECKPOINT_RESTART or TRUNCATE operation, and the /* If this is an SQLITE_CHECKPOINT_RESTART or TRUNCATE operation, and the
@ -50323,7 +50326,7 @@ static int walCheckpoint(
}else if( eMode>=SQLITE_CHECKPOINT_RESTART ){ }else if( eMode>=SQLITE_CHECKPOINT_RESTART ){
u32 salt1; u32 salt1;
sqlite3_randomness(4, &salt1); sqlite3_randomness(4, &salt1);
assert( mxSafeFrame==pWal->hdr.mxFrame ); assert( pInfo->nBackfill==pWal->hdr.mxFrame );
rc = walBusyLock(pWal, xBusy, pBusyArg, WAL_READ_LOCK(1), WAL_NREADER-1); rc = walBusyLock(pWal, xBusy, pBusyArg, WAL_READ_LOCK(1), WAL_NREADER-1);
if( rc==SQLITE_OK ){ if( rc==SQLITE_OK ){
if( eMode==SQLITE_CHECKPOINT_TRUNCATE ){ if( eMode==SQLITE_CHECKPOINT_TRUNCATE ){
@ -128369,6 +128372,7 @@ SQLITE_API int sqlite3_wal_checkpoint_v2(
rc = SQLITE_ERROR; rc = SQLITE_ERROR;
sqlite3ErrorWithMsg(db, SQLITE_ERROR, "unknown database: %s", zDb); sqlite3ErrorWithMsg(db, SQLITE_ERROR, "unknown database: %s", zDb);
}else{ }else{
db->busyHandler.nBusy = 0;
rc = sqlite3Checkpoint(db, iDb, eMode, pnLog, pnCkpt); rc = sqlite3Checkpoint(db, iDb, eMode, pnLog, pnCkpt);
sqlite3Error(db, rc); sqlite3Error(db, rc);
} }

View file

@ -107,9 +107,9 @@ extern "C" {
** [sqlite3_libversion_number()], [sqlite3_sourceid()], ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
** [sqlite_version()] and [sqlite_source_id()]. ** [sqlite_version()] and [sqlite_source_id()].
*/ */
#define SQLITE_VERSION "3.8.8.1" #define SQLITE_VERSION "3.8.8.2"
#define SQLITE_VERSION_NUMBER 3008008 #define SQLITE_VERSION_NUMBER 3008008
#define SQLITE_SOURCE_ID "2015-01-20 16:51:25 f73337e3e289915a76ca96e7a05a1a8d4e890d55" #define SQLITE_SOURCE_ID "2015-01-30 14:30:45 7757fc721220e136620a89c9d28247f28bbbc098"
/* /*
** CAPI3REF: Run-Time Library Version Numbers ** CAPI3REF: Run-Time Library Version Numbers