Fossil SCM

Update SQLite to the 3.8.8.2 release

jan.nijtmans 2015-01-30 15:57 trunk
Commit 703ec175b960e73c69bd037726abe93cb2edda16
2 files changed +109 -116 +2 -2
+109 -116
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1,8 +1,8 @@
11
/******************************************************************************
22
** This file is an amalgamation of many separate C source files from SQLite
3
-** version 3.8.8.1. By combining all the individual C code files into this
3
+** version 3.8.8.2. By combining all the individual C code files into this
44
** single large file, the entire code can be compiled as a single translation
55
** unit. This allows many compilers to do optimizations that would not be
66
** possible if the files were compiled separately. Performance improvements
77
** of 5% or more are commonly seen when SQLite is compiled as a single
88
** translation unit.
@@ -276,13 +276,13 @@
276276
**
277277
** See also: [sqlite3_libversion()],
278278
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
279279
** [sqlite_version()] and [sqlite_source_id()].
280280
*/
281
-#define SQLITE_VERSION "3.8.8.1"
281
+#define SQLITE_VERSION "3.8.8.2"
282282
#define SQLITE_VERSION_NUMBER 3008008
283
-#define SQLITE_SOURCE_ID "2015-01-20 16:51:25 f73337e3e289915a76ca96e7a05a1a8d4e890d55"
283
+#define SQLITE_SOURCE_ID "2015-01-30 14:30:45 7757fc721220e136620a89c9d28247f28bbbc098"
284284
285285
/*
286286
** CAPI3REF: Run-Time Library Version Numbers
287287
** KEYWORDS: sqlite3_version, sqlite3_sourceid
288288
**
@@ -19870,21 +19870,10 @@
1987019870
# define SQLITE_WIN32_VOLATILE
1987119871
#else
1987219872
# define SQLITE_WIN32_VOLATILE volatile
1987319873
#endif
1987419874
19875
-/*
19876
-** For some Windows sub-platforms, the _beginthreadex() / _endthreadex()
19877
-** functions are not available (e.g. those not using MSVC, Cygwin, etc).
19878
-*/
19879
-#if SQLITE_OS_WIN && !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && \
19880
- SQLITE_THREADSAFE>0 && !defined(__CYGWIN__)
19881
-# define SQLITE_OS_WIN_THREADS 1
19882
-#else
19883
-# define SQLITE_OS_WIN_THREADS 0
19884
-#endif
19885
-
1988619875
#endif /* _OS_WIN_H_ */
1988719876
1988819877
/************** End of os_win.h **********************************************/
1988919878
/************** Continuing where we left off in mutex_w32.c ******************/
1989019879
#endif
@@ -22444,11 +22433,11 @@
2244422433
#endif /* SQLITE_OS_UNIX && defined(SQLITE_MUTEX_PTHREADS) */
2244522434
/******************************** End Unix Pthreads *************************/
2244622435
2244722436
2244822437
/********************************* Win32 Threads ****************************/
22449
-#if SQLITE_OS_WIN_THREADS
22438
+#if SQLITE_OS_WIN && !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && SQLITE_THREADSAFE>0
2245022439
2245122440
#define SQLITE_THREADS_IMPLEMENTED 1 /* Prevent the single-thread code below */
2245222441
#include <process.h>
2245322442
2245422443
/* A running thread */
@@ -22537,11 +22526,11 @@
2253722526
if( rc==WAIT_OBJECT_0 ) *ppOut = p->pResult;
2253822527
sqlite3_free(p);
2253922528
return (rc==WAIT_OBJECT_0) ? SQLITE_OK : SQLITE_ERROR;
2254022529
}
2254122530
22542
-#endif /* SQLITE_OS_WIN_THREADS */
22531
+#endif /* SQLITE_OS_WIN && !SQLITE_OS_WINCE && !SQLITE_OS_WINRT */
2254322532
/******************************** End Win32 Threads *************************/
2254422533
2254522534
2254622535
/********************************* Single-Threaded **************************/
2254722536
#ifndef SQLITE_THREADS_IMPLEMENTED
@@ -50206,11 +50195,11 @@
5020650195
int (*xBusy)(void*), /* Function to call when busy */
5020750196
void *pBusyArg, /* Context argument for xBusyHandler */
5020850197
int sync_flags, /* Flags for OsSync() (or 0) */
5020950198
u8 *zBuf /* Temporary buffer to use */
5021050199
){
50211
- int rc; /* Return code */
50200
+ int rc = SQLITE_OK; /* Return code */
5021250201
int szPage; /* Database page-size */
5021350202
WalIterator *pIter = 0; /* Wal iterator context */
5021450203
u32 iDbpage = 0; /* Next database page to write */
5021550204
u32 iFrame = 0; /* Wal frame containing data for iDbpage */
5021650205
u32 mxSafeFrame; /* Max frame that can be backfilled */
@@ -50220,108 +50209,111 @@
5022050209
5022150210
szPage = walPagesize(pWal);
5022250211
testcase( szPage<=32768 );
5022350212
testcase( szPage>=65536 );
5022450213
pInfo = walCkptInfo(pWal);
50225
- if( pInfo->nBackfill>=pWal->hdr.mxFrame ) return SQLITE_OK;
50226
-
50227
- /* Allocate the iterator */
50228
- rc = walIteratorInit(pWal, &pIter);
50229
- if( rc!=SQLITE_OK ){
50230
- return rc;
50231
- }
50232
- assert( pIter );
50233
-
50234
- /* EVIDENCE-OF: R-62920-47450 The busy-handler callback is never invoked
50235
- ** in the SQLITE_CHECKPOINT_PASSIVE mode. */
50236
- assert( eMode!=SQLITE_CHECKPOINT_PASSIVE || xBusy==0 );
50237
-
50238
- /* Compute in mxSafeFrame the index of the last frame of the WAL that is
50239
- ** safe to write into the database. Frames beyond mxSafeFrame might
50240
- ** overwrite database pages that are in use by active readers and thus
50241
- ** cannot be backfilled from the WAL.
50242
- */
50243
- mxSafeFrame = pWal->hdr.mxFrame;
50244
- mxPage = pWal->hdr.nPage;
50245
- for(i=1; i<WAL_NREADER; i++){
50246
- u32 y = pInfo->aReadMark[i];
50247
- if( mxSafeFrame>y ){
50248
- assert( y<=pWal->hdr.mxFrame );
50249
- rc = walBusyLock(pWal, xBusy, pBusyArg, WAL_READ_LOCK(i), 1);
50250
- if( rc==SQLITE_OK ){
50251
- pInfo->aReadMark[i] = (i==1 ? mxSafeFrame : READMARK_NOT_USED);
50252
- walUnlockExclusive(pWal, WAL_READ_LOCK(i), 1);
50253
- }else if( rc==SQLITE_BUSY ){
50254
- mxSafeFrame = y;
50255
- xBusy = 0;
50256
- }else{
50257
- goto walcheckpoint_out;
50258
- }
50259
- }
50260
- }
50261
-
50262
- if( pInfo->nBackfill<mxSafeFrame
50263
- && (rc = walBusyLock(pWal, xBusy, pBusyArg, WAL_READ_LOCK(0), 1))==SQLITE_OK
50264
- ){
50265
- i64 nSize; /* Current size of database file */
50266
- u32 nBackfill = pInfo->nBackfill;
50267
-
50268
- /* Sync the WAL to disk */
50269
- if( sync_flags ){
50270
- rc = sqlite3OsSync(pWal->pWalFd, sync_flags);
50271
- }
50272
-
50273
- /* If the database may grow as a result of this checkpoint, hint
50274
- ** about the eventual size of the db file to the VFS layer.
50275
- */
50276
- if( rc==SQLITE_OK ){
50277
- i64 nReq = ((i64)mxPage * szPage);
50278
- rc = sqlite3OsFileSize(pWal->pDbFd, &nSize);
50279
- if( rc==SQLITE_OK && nSize<nReq ){
50280
- sqlite3OsFileControlHint(pWal->pDbFd, SQLITE_FCNTL_SIZE_HINT, &nReq);
50281
- }
50282
- }
50283
-
50284
-
50285
- /* Iterate through the contents of the WAL, copying data to the db file. */
50286
- while( rc==SQLITE_OK && 0==walIteratorNext(pIter, &iDbpage, &iFrame) ){
50287
- i64 iOffset;
50288
- assert( walFramePgno(pWal, iFrame)==iDbpage );
50289
- if( iFrame<=nBackfill || iFrame>mxSafeFrame || iDbpage>mxPage ) continue;
50290
- iOffset = walFrameOffset(iFrame, szPage) + WAL_FRAME_HDRSIZE;
50291
- /* testcase( IS_BIG_INT(iOffset) ); // requires a 4GiB WAL file */
50292
- rc = sqlite3OsRead(pWal->pWalFd, zBuf, szPage, iOffset);
50293
- if( rc!=SQLITE_OK ) break;
50294
- iOffset = (iDbpage-1)*(i64)szPage;
50295
- testcase( IS_BIG_INT(iOffset) );
50296
- rc = sqlite3OsWrite(pWal->pDbFd, zBuf, szPage, iOffset);
50297
- if( rc!=SQLITE_OK ) break;
50298
- }
50299
-
50300
- /* If work was actually accomplished... */
50301
- if( rc==SQLITE_OK ){
50302
- if( mxSafeFrame==walIndexHdr(pWal)->mxFrame ){
50303
- i64 szDb = pWal->hdr.nPage*(i64)szPage;
50304
- testcase( IS_BIG_INT(szDb) );
50305
- rc = sqlite3OsTruncate(pWal->pDbFd, szDb);
50306
- if( rc==SQLITE_OK && sync_flags ){
50307
- rc = sqlite3OsSync(pWal->pDbFd, sync_flags);
50308
- }
50309
- }
50310
- if( rc==SQLITE_OK ){
50311
- pInfo->nBackfill = mxSafeFrame;
50312
- }
50313
- }
50314
-
50315
- /* Release the reader lock held while backfilling */
50316
- walUnlockExclusive(pWal, WAL_READ_LOCK(0), 1);
50317
- }
50318
-
50319
- if( rc==SQLITE_BUSY ){
50320
- /* Reset the return code so as not to report a checkpoint failure
50321
- ** just because there are active readers. */
50322
- rc = SQLITE_OK;
50214
+ if( pInfo->nBackfill<pWal->hdr.mxFrame ){
50215
+
50216
+ /* Allocate the iterator */
50217
+ rc = walIteratorInit(pWal, &pIter);
50218
+ if( rc!=SQLITE_OK ){
50219
+ return rc;
50220
+ }
50221
+ assert( pIter );
50222
+
50223
+ /* EVIDENCE-OF: R-62920-47450 The busy-handler callback is never invoked
50224
+ ** in the SQLITE_CHECKPOINT_PASSIVE mode. */
50225
+ assert( eMode!=SQLITE_CHECKPOINT_PASSIVE || xBusy==0 );
50226
+
50227
+ /* Compute in mxSafeFrame the index of the last frame of the WAL that is
50228
+ ** safe to write into the database. Frames beyond mxSafeFrame might
50229
+ ** overwrite database pages that are in use by active readers and thus
50230
+ ** cannot be backfilled from the WAL.
50231
+ */
50232
+ mxSafeFrame = pWal->hdr.mxFrame;
50233
+ mxPage = pWal->hdr.nPage;
50234
+ for(i=1; i<WAL_NREADER; i++){
50235
+ u32 y = pInfo->aReadMark[i];
50236
+ if( mxSafeFrame>y ){
50237
+ assert( y<=pWal->hdr.mxFrame );
50238
+ rc = walBusyLock(pWal, xBusy, pBusyArg, WAL_READ_LOCK(i), 1);
50239
+ if( rc==SQLITE_OK ){
50240
+ pInfo->aReadMark[i] = (i==1 ? mxSafeFrame : READMARK_NOT_USED);
50241
+ walUnlockExclusive(pWal, WAL_READ_LOCK(i), 1);
50242
+ }else if( rc==SQLITE_BUSY ){
50243
+ mxSafeFrame = y;
50244
+ xBusy = 0;
50245
+ }else{
50246
+ goto walcheckpoint_out;
50247
+ }
50248
+ }
50249
+ }
50250
+
50251
+ if( pInfo->nBackfill<mxSafeFrame
50252
+ && (rc = walBusyLock(pWal, xBusy, pBusyArg, WAL_READ_LOCK(0),1))==SQLITE_OK
50253
+ ){
50254
+ i64 nSize; /* Current size of database file */
50255
+ u32 nBackfill = pInfo->nBackfill;
50256
+
50257
+ /* Sync the WAL to disk */
50258
+ if( sync_flags ){
50259
+ rc = sqlite3OsSync(pWal->pWalFd, sync_flags);
50260
+ }
50261
+
50262
+ /* If the database may grow as a result of this checkpoint, hint
50263
+ ** about the eventual size of the db file to the VFS layer.
50264
+ */
50265
+ if( rc==SQLITE_OK ){
50266
+ i64 nReq = ((i64)mxPage * szPage);
50267
+ rc = sqlite3OsFileSize(pWal->pDbFd, &nSize);
50268
+ if( rc==SQLITE_OK && nSize<nReq ){
50269
+ sqlite3OsFileControlHint(pWal->pDbFd, SQLITE_FCNTL_SIZE_HINT, &nReq);
50270
+ }
50271
+ }
50272
+
50273
+
50274
+ /* Iterate through the contents of the WAL, copying data to the db file */
50275
+ while( rc==SQLITE_OK && 0==walIteratorNext(pIter, &iDbpage, &iFrame) ){
50276
+ i64 iOffset;
50277
+ assert( walFramePgno(pWal, iFrame)==iDbpage );
50278
+ if( iFrame<=nBackfill || iFrame>mxSafeFrame || iDbpage>mxPage ){
50279
+ continue;
50280
+ }
50281
+ iOffset = walFrameOffset(iFrame, szPage) + WAL_FRAME_HDRSIZE;
50282
+ /* testcase( IS_BIG_INT(iOffset) ); // requires a 4GiB WAL file */
50283
+ rc = sqlite3OsRead(pWal->pWalFd, zBuf, szPage, iOffset);
50284
+ if( rc!=SQLITE_OK ) break;
50285
+ iOffset = (iDbpage-1)*(i64)szPage;
50286
+ testcase( IS_BIG_INT(iOffset) );
50287
+ rc = sqlite3OsWrite(pWal->pDbFd, zBuf, szPage, iOffset);
50288
+ if( rc!=SQLITE_OK ) break;
50289
+ }
50290
+
50291
+ /* If work was actually accomplished... */
50292
+ if( rc==SQLITE_OK ){
50293
+ if( mxSafeFrame==walIndexHdr(pWal)->mxFrame ){
50294
+ i64 szDb = pWal->hdr.nPage*(i64)szPage;
50295
+ testcase( IS_BIG_INT(szDb) );
50296
+ rc = sqlite3OsTruncate(pWal->pDbFd, szDb);
50297
+ if( rc==SQLITE_OK && sync_flags ){
50298
+ rc = sqlite3OsSync(pWal->pDbFd, sync_flags);
50299
+ }
50300
+ }
50301
+ if( rc==SQLITE_OK ){
50302
+ pInfo->nBackfill = mxSafeFrame;
50303
+ }
50304
+ }
50305
+
50306
+ /* Release the reader lock held while backfilling */
50307
+ walUnlockExclusive(pWal, WAL_READ_LOCK(0), 1);
50308
+ }
50309
+
50310
+ if( rc==SQLITE_BUSY ){
50311
+ /* Reset the return code so as not to report a checkpoint failure
50312
+ ** just because there are active readers. */
50313
+ rc = SQLITE_OK;
50314
+ }
5032350315
}
5032450316
5032550317
/* If this is an SQLITE_CHECKPOINT_RESTART or TRUNCATE operation, and the
5032650318
** entire wal file has been copied into the database file, then block
5032750319
** until all readers have finished using the wal file. This ensures that
@@ -50332,11 +50324,11 @@
5033250324
if( pInfo->nBackfill<pWal->hdr.mxFrame ){
5033350325
rc = SQLITE_BUSY;
5033450326
}else if( eMode>=SQLITE_CHECKPOINT_RESTART ){
5033550327
u32 salt1;
5033650328
sqlite3_randomness(4, &salt1);
50337
- assert( mxSafeFrame==pWal->hdr.mxFrame );
50329
+ assert( pInfo->nBackfill==pWal->hdr.mxFrame );
5033850330
rc = walBusyLock(pWal, xBusy, pBusyArg, WAL_READ_LOCK(1), WAL_NREADER-1);
5033950331
if( rc==SQLITE_OK ){
5034050332
if( eMode==SQLITE_CHECKPOINT_TRUNCATE ){
5034150333
/* IMPLEMENTATION-OF: R-44699-57140 This mode works the same way as
5034250334
** SQLITE_CHECKPOINT_RESTART with the addition that it also
@@ -128378,10 +128370,11 @@
128378128370
}
128379128371
if( iDb<0 ){
128380128372
rc = SQLITE_ERROR;
128381128373
sqlite3ErrorWithMsg(db, SQLITE_ERROR, "unknown database: %s", zDb);
128382128374
}else{
128375
+ db->busyHandler.nBusy = 0;
128383128376
rc = sqlite3Checkpoint(db, iDb, eMode, pnLog, pnCkpt);
128384128377
sqlite3Error(db, rc);
128385128378
}
128386128379
rc = sqlite3ApiExit(db, rc);
128387128380
sqlite3_mutex_leave(db->mutex);
128388128381
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1,8 +1,8 @@
1 /******************************************************************************
2 ** This file is an amalgamation of many separate C source files from SQLite
3 ** version 3.8.8.1. By combining all the individual C code files into this
4 ** single large file, the entire code can be compiled as a single translation
5 ** unit. This allows many compilers to do optimizations that would not be
6 ** possible if the files were compiled separately. Performance improvements
7 ** of 5% or more are commonly seen when SQLite is compiled as a single
8 ** translation unit.
@@ -276,13 +276,13 @@
276 **
277 ** See also: [sqlite3_libversion()],
278 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
279 ** [sqlite_version()] and [sqlite_source_id()].
280 */
281 #define SQLITE_VERSION "3.8.8.1"
282 #define SQLITE_VERSION_NUMBER 3008008
283 #define SQLITE_SOURCE_ID "2015-01-20 16:51:25 f73337e3e289915a76ca96e7a05a1a8d4e890d55"
284
285 /*
286 ** CAPI3REF: Run-Time Library Version Numbers
287 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
288 **
@@ -19870,21 +19870,10 @@
19870 # define SQLITE_WIN32_VOLATILE
19871 #else
19872 # define SQLITE_WIN32_VOLATILE volatile
19873 #endif
19874
19875 /*
19876 ** For some Windows sub-platforms, the _beginthreadex() / _endthreadex()
19877 ** functions are not available (e.g. those not using MSVC, Cygwin, etc).
19878 */
19879 #if SQLITE_OS_WIN && !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && \
19880 SQLITE_THREADSAFE>0 && !defined(__CYGWIN__)
19881 # define SQLITE_OS_WIN_THREADS 1
19882 #else
19883 # define SQLITE_OS_WIN_THREADS 0
19884 #endif
19885
19886 #endif /* _OS_WIN_H_ */
19887
19888 /************** End of os_win.h **********************************************/
19889 /************** Continuing where we left off in mutex_w32.c ******************/
19890 #endif
@@ -22444,11 +22433,11 @@
22444 #endif /* SQLITE_OS_UNIX && defined(SQLITE_MUTEX_PTHREADS) */
22445 /******************************** End Unix Pthreads *************************/
22446
22447
22448 /********************************* Win32 Threads ****************************/
22449 #if SQLITE_OS_WIN_THREADS
22450
22451 #define SQLITE_THREADS_IMPLEMENTED 1 /* Prevent the single-thread code below */
22452 #include <process.h>
22453
22454 /* A running thread */
@@ -22537,11 +22526,11 @@
22537 if( rc==WAIT_OBJECT_0 ) *ppOut = p->pResult;
22538 sqlite3_free(p);
22539 return (rc==WAIT_OBJECT_0) ? SQLITE_OK : SQLITE_ERROR;
22540 }
22541
22542 #endif /* SQLITE_OS_WIN_THREADS */
22543 /******************************** End Win32 Threads *************************/
22544
22545
22546 /********************************* Single-Threaded **************************/
22547 #ifndef SQLITE_THREADS_IMPLEMENTED
@@ -50206,11 +50195,11 @@
50206 int (*xBusy)(void*), /* Function to call when busy */
50207 void *pBusyArg, /* Context argument for xBusyHandler */
50208 int sync_flags, /* Flags for OsSync() (or 0) */
50209 u8 *zBuf /* Temporary buffer to use */
50210 ){
50211 int rc; /* Return code */
50212 int szPage; /* Database page-size */
50213 WalIterator *pIter = 0; /* Wal iterator context */
50214 u32 iDbpage = 0; /* Next database page to write */
50215 u32 iFrame = 0; /* Wal frame containing data for iDbpage */
50216 u32 mxSafeFrame; /* Max frame that can be backfilled */
@@ -50220,108 +50209,111 @@
50220
50221 szPage = walPagesize(pWal);
50222 testcase( szPage<=32768 );
50223 testcase( szPage>=65536 );
50224 pInfo = walCkptInfo(pWal);
50225 if( pInfo->nBackfill>=pWal->hdr.mxFrame ) return SQLITE_OK;
50226
50227 /* Allocate the iterator */
50228 rc = walIteratorInit(pWal, &pIter);
50229 if( rc!=SQLITE_OK ){
50230 return rc;
50231 }
50232 assert( pIter );
50233
50234 /* EVIDENCE-OF: R-62920-47450 The busy-handler callback is never invoked
50235 ** in the SQLITE_CHECKPOINT_PASSIVE mode. */
50236 assert( eMode!=SQLITE_CHECKPOINT_PASSIVE || xBusy==0 );
50237
50238 /* Compute in mxSafeFrame the index of the last frame of the WAL that is
50239 ** safe to write into the database. Frames beyond mxSafeFrame might
50240 ** overwrite database pages that are in use by active readers and thus
50241 ** cannot be backfilled from the WAL.
50242 */
50243 mxSafeFrame = pWal->hdr.mxFrame;
50244 mxPage = pWal->hdr.nPage;
50245 for(i=1; i<WAL_NREADER; i++){
50246 u32 y = pInfo->aReadMark[i];
50247 if( mxSafeFrame>y ){
50248 assert( y<=pWal->hdr.mxFrame );
50249 rc = walBusyLock(pWal, xBusy, pBusyArg, WAL_READ_LOCK(i), 1);
50250 if( rc==SQLITE_OK ){
50251 pInfo->aReadMark[i] = (i==1 ? mxSafeFrame : READMARK_NOT_USED);
50252 walUnlockExclusive(pWal, WAL_READ_LOCK(i), 1);
50253 }else if( rc==SQLITE_BUSY ){
50254 mxSafeFrame = y;
50255 xBusy = 0;
50256 }else{
50257 goto walcheckpoint_out;
50258 }
50259 }
50260 }
50261
50262 if( pInfo->nBackfill<mxSafeFrame
50263 && (rc = walBusyLock(pWal, xBusy, pBusyArg, WAL_READ_LOCK(0), 1))==SQLITE_OK
50264 ){
50265 i64 nSize; /* Current size of database file */
50266 u32 nBackfill = pInfo->nBackfill;
50267
50268 /* Sync the WAL to disk */
50269 if( sync_flags ){
50270 rc = sqlite3OsSync(pWal->pWalFd, sync_flags);
50271 }
50272
50273 /* If the database may grow as a result of this checkpoint, hint
50274 ** about the eventual size of the db file to the VFS layer.
50275 */
50276 if( rc==SQLITE_OK ){
50277 i64 nReq = ((i64)mxPage * szPage);
50278 rc = sqlite3OsFileSize(pWal->pDbFd, &nSize);
50279 if( rc==SQLITE_OK && nSize<nReq ){
50280 sqlite3OsFileControlHint(pWal->pDbFd, SQLITE_FCNTL_SIZE_HINT, &nReq);
50281 }
50282 }
50283
50284
50285 /* Iterate through the contents of the WAL, copying data to the db file. */
50286 while( rc==SQLITE_OK && 0==walIteratorNext(pIter, &iDbpage, &iFrame) ){
50287 i64 iOffset;
50288 assert( walFramePgno(pWal, iFrame)==iDbpage );
50289 if( iFrame<=nBackfill || iFrame>mxSafeFrame || iDbpage>mxPage ) continue;
50290 iOffset = walFrameOffset(iFrame, szPage) + WAL_FRAME_HDRSIZE;
50291 /* testcase( IS_BIG_INT(iOffset) ); // requires a 4GiB WAL file */
50292 rc = sqlite3OsRead(pWal->pWalFd, zBuf, szPage, iOffset);
50293 if( rc!=SQLITE_OK ) break;
50294 iOffset = (iDbpage-1)*(i64)szPage;
50295 testcase( IS_BIG_INT(iOffset) );
50296 rc = sqlite3OsWrite(pWal->pDbFd, zBuf, szPage, iOffset);
50297 if( rc!=SQLITE_OK ) break;
50298 }
50299
50300 /* If work was actually accomplished... */
50301 if( rc==SQLITE_OK ){
50302 if( mxSafeFrame==walIndexHdr(pWal)->mxFrame ){
50303 i64 szDb = pWal->hdr.nPage*(i64)szPage;
50304 testcase( IS_BIG_INT(szDb) );
50305 rc = sqlite3OsTruncate(pWal->pDbFd, szDb);
50306 if( rc==SQLITE_OK && sync_flags ){
50307 rc = sqlite3OsSync(pWal->pDbFd, sync_flags);
50308 }
50309 }
50310 if( rc==SQLITE_OK ){
50311 pInfo->nBackfill = mxSafeFrame;
50312 }
50313 }
50314
50315 /* Release the reader lock held while backfilling */
50316 walUnlockExclusive(pWal, WAL_READ_LOCK(0), 1);
50317 }
50318
50319 if( rc==SQLITE_BUSY ){
50320 /* Reset the return code so as not to report a checkpoint failure
50321 ** just because there are active readers. */
50322 rc = SQLITE_OK;
 
 
 
50323 }
50324
50325 /* If this is an SQLITE_CHECKPOINT_RESTART or TRUNCATE operation, and the
50326 ** entire wal file has been copied into the database file, then block
50327 ** until all readers have finished using the wal file. This ensures that
@@ -50332,11 +50324,11 @@
50332 if( pInfo->nBackfill<pWal->hdr.mxFrame ){
50333 rc = SQLITE_BUSY;
50334 }else if( eMode>=SQLITE_CHECKPOINT_RESTART ){
50335 u32 salt1;
50336 sqlite3_randomness(4, &salt1);
50337 assert( mxSafeFrame==pWal->hdr.mxFrame );
50338 rc = walBusyLock(pWal, xBusy, pBusyArg, WAL_READ_LOCK(1), WAL_NREADER-1);
50339 if( rc==SQLITE_OK ){
50340 if( eMode==SQLITE_CHECKPOINT_TRUNCATE ){
50341 /* IMPLEMENTATION-OF: R-44699-57140 This mode works the same way as
50342 ** SQLITE_CHECKPOINT_RESTART with the addition that it also
@@ -128378,10 +128370,11 @@
128378 }
128379 if( iDb<0 ){
128380 rc = SQLITE_ERROR;
128381 sqlite3ErrorWithMsg(db, SQLITE_ERROR, "unknown database: %s", zDb);
128382 }else{
 
128383 rc = sqlite3Checkpoint(db, iDb, eMode, pnLog, pnCkpt);
128384 sqlite3Error(db, rc);
128385 }
128386 rc = sqlite3ApiExit(db, rc);
128387 sqlite3_mutex_leave(db->mutex);
128388
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1,8 +1,8 @@
1 /******************************************************************************
2 ** This file is an amalgamation of many separate C source files from SQLite
3 ** version 3.8.8.2. By combining all the individual C code files into this
4 ** single large file, the entire code can be compiled as a single translation
5 ** unit. This allows many compilers to do optimizations that would not be
6 ** possible if the files were compiled separately. Performance improvements
7 ** of 5% or more are commonly seen when SQLite is compiled as a single
8 ** translation unit.
@@ -276,13 +276,13 @@
276 **
277 ** See also: [sqlite3_libversion()],
278 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
279 ** [sqlite_version()] and [sqlite_source_id()].
280 */
281 #define SQLITE_VERSION "3.8.8.2"
282 #define SQLITE_VERSION_NUMBER 3008008
283 #define SQLITE_SOURCE_ID "2015-01-30 14:30:45 7757fc721220e136620a89c9d28247f28bbbc098"
284
285 /*
286 ** CAPI3REF: Run-Time Library Version Numbers
287 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
288 **
@@ -19870,21 +19870,10 @@
19870 # define SQLITE_WIN32_VOLATILE
19871 #else
19872 # define SQLITE_WIN32_VOLATILE volatile
19873 #endif
19874
 
 
 
 
 
 
 
 
 
 
 
19875 #endif /* _OS_WIN_H_ */
19876
19877 /************** End of os_win.h **********************************************/
19878 /************** Continuing where we left off in mutex_w32.c ******************/
19879 #endif
@@ -22444,11 +22433,11 @@
22433 #endif /* SQLITE_OS_UNIX && defined(SQLITE_MUTEX_PTHREADS) */
22434 /******************************** End Unix Pthreads *************************/
22435
22436
22437 /********************************* Win32 Threads ****************************/
22438 #if SQLITE_OS_WIN && !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && SQLITE_THREADSAFE>0
22439
22440 #define SQLITE_THREADS_IMPLEMENTED 1 /* Prevent the single-thread code below */
22441 #include <process.h>
22442
22443 /* A running thread */
@@ -22537,11 +22526,11 @@
22526 if( rc==WAIT_OBJECT_0 ) *ppOut = p->pResult;
22527 sqlite3_free(p);
22528 return (rc==WAIT_OBJECT_0) ? SQLITE_OK : SQLITE_ERROR;
22529 }
22530
22531 #endif /* SQLITE_OS_WIN && !SQLITE_OS_WINCE && !SQLITE_OS_WINRT */
22532 /******************************** End Win32 Threads *************************/
22533
22534
22535 /********************************* Single-Threaded **************************/
22536 #ifndef SQLITE_THREADS_IMPLEMENTED
@@ -50206,11 +50195,11 @@
50195 int (*xBusy)(void*), /* Function to call when busy */
50196 void *pBusyArg, /* Context argument for xBusyHandler */
50197 int sync_flags, /* Flags for OsSync() (or 0) */
50198 u8 *zBuf /* Temporary buffer to use */
50199 ){
50200 int rc = SQLITE_OK; /* Return code */
50201 int szPage; /* Database page-size */
50202 WalIterator *pIter = 0; /* Wal iterator context */
50203 u32 iDbpage = 0; /* Next database page to write */
50204 u32 iFrame = 0; /* Wal frame containing data for iDbpage */
50205 u32 mxSafeFrame; /* Max frame that can be backfilled */
@@ -50220,108 +50209,111 @@
50209
50210 szPage = walPagesize(pWal);
50211 testcase( szPage<=32768 );
50212 testcase( szPage>=65536 );
50213 pInfo = walCkptInfo(pWal);
50214 if( pInfo->nBackfill<pWal->hdr.mxFrame ){
50215
50216 /* Allocate the iterator */
50217 rc = walIteratorInit(pWal, &pIter);
50218 if( rc!=SQLITE_OK ){
50219 return rc;
50220 }
50221 assert( pIter );
50222
50223 /* EVIDENCE-OF: R-62920-47450 The busy-handler callback is never invoked
50224 ** in the SQLITE_CHECKPOINT_PASSIVE mode. */
50225 assert( eMode!=SQLITE_CHECKPOINT_PASSIVE || xBusy==0 );
50226
50227 /* Compute in mxSafeFrame the index of the last frame of the WAL that is
50228 ** safe to write into the database. Frames beyond mxSafeFrame might
50229 ** overwrite database pages that are in use by active readers and thus
50230 ** cannot be backfilled from the WAL.
50231 */
50232 mxSafeFrame = pWal->hdr.mxFrame;
50233 mxPage = pWal->hdr.nPage;
50234 for(i=1; i<WAL_NREADER; i++){
50235 u32 y = pInfo->aReadMark[i];
50236 if( mxSafeFrame>y ){
50237 assert( y<=pWal->hdr.mxFrame );
50238 rc = walBusyLock(pWal, xBusy, pBusyArg, WAL_READ_LOCK(i), 1);
50239 if( rc==SQLITE_OK ){
50240 pInfo->aReadMark[i] = (i==1 ? mxSafeFrame : READMARK_NOT_USED);
50241 walUnlockExclusive(pWal, WAL_READ_LOCK(i), 1);
50242 }else if( rc==SQLITE_BUSY ){
50243 mxSafeFrame = y;
50244 xBusy = 0;
50245 }else{
50246 goto walcheckpoint_out;
50247 }
50248 }
50249 }
50250
50251 if( pInfo->nBackfill<mxSafeFrame
50252 && (rc = walBusyLock(pWal, xBusy, pBusyArg, WAL_READ_LOCK(0),1))==SQLITE_OK
50253 ){
50254 i64 nSize; /* Current size of database file */
50255 u32 nBackfill = pInfo->nBackfill;
50256
50257 /* Sync the WAL to disk */
50258 if( sync_flags ){
50259 rc = sqlite3OsSync(pWal->pWalFd, sync_flags);
50260 }
50261
50262 /* If the database may grow as a result of this checkpoint, hint
50263 ** about the eventual size of the db file to the VFS layer.
50264 */
50265 if( rc==SQLITE_OK ){
50266 i64 nReq = ((i64)mxPage * szPage);
50267 rc = sqlite3OsFileSize(pWal->pDbFd, &nSize);
50268 if( rc==SQLITE_OK && nSize<nReq ){
50269 sqlite3OsFileControlHint(pWal->pDbFd, SQLITE_FCNTL_SIZE_HINT, &nReq);
50270 }
50271 }
50272
50273
50274 /* Iterate through the contents of the WAL, copying data to the db file */
50275 while( rc==SQLITE_OK && 0==walIteratorNext(pIter, &iDbpage, &iFrame) ){
50276 i64 iOffset;
50277 assert( walFramePgno(pWal, iFrame)==iDbpage );
50278 if( iFrame<=nBackfill || iFrame>mxSafeFrame || iDbpage>mxPage ){
50279 continue;
50280 }
50281 iOffset = walFrameOffset(iFrame, szPage) + WAL_FRAME_HDRSIZE;
50282 /* testcase( IS_BIG_INT(iOffset) ); // requires a 4GiB WAL file */
50283 rc = sqlite3OsRead(pWal->pWalFd, zBuf, szPage, iOffset);
50284 if( rc!=SQLITE_OK ) break;
50285 iOffset = (iDbpage-1)*(i64)szPage;
50286 testcase( IS_BIG_INT(iOffset) );
50287 rc = sqlite3OsWrite(pWal->pDbFd, zBuf, szPage, iOffset);
50288 if( rc!=SQLITE_OK ) break;
50289 }
50290
50291 /* If work was actually accomplished... */
50292 if( rc==SQLITE_OK ){
50293 if( mxSafeFrame==walIndexHdr(pWal)->mxFrame ){
50294 i64 szDb = pWal->hdr.nPage*(i64)szPage;
50295 testcase( IS_BIG_INT(szDb) );
50296 rc = sqlite3OsTruncate(pWal->pDbFd, szDb);
50297 if( rc==SQLITE_OK && sync_flags ){
50298 rc = sqlite3OsSync(pWal->pDbFd, sync_flags);
50299 }
50300 }
50301 if( rc==SQLITE_OK ){
50302 pInfo->nBackfill = mxSafeFrame;
50303 }
50304 }
50305
50306 /* Release the reader lock held while backfilling */
50307 walUnlockExclusive(pWal, WAL_READ_LOCK(0), 1);
50308 }
50309
50310 if( rc==SQLITE_BUSY ){
50311 /* Reset the return code so as not to report a checkpoint failure
50312 ** just because there are active readers. */
50313 rc = SQLITE_OK;
50314 }
50315 }
50316
50317 /* If this is an SQLITE_CHECKPOINT_RESTART or TRUNCATE operation, and the
50318 ** entire wal file has been copied into the database file, then block
50319 ** until all readers have finished using the wal file. This ensures that
@@ -50332,11 +50324,11 @@
50324 if( pInfo->nBackfill<pWal->hdr.mxFrame ){
50325 rc = SQLITE_BUSY;
50326 }else if( eMode>=SQLITE_CHECKPOINT_RESTART ){
50327 u32 salt1;
50328 sqlite3_randomness(4, &salt1);
50329 assert( pInfo->nBackfill==pWal->hdr.mxFrame );
50330 rc = walBusyLock(pWal, xBusy, pBusyArg, WAL_READ_LOCK(1), WAL_NREADER-1);
50331 if( rc==SQLITE_OK ){
50332 if( eMode==SQLITE_CHECKPOINT_TRUNCATE ){
50333 /* IMPLEMENTATION-OF: R-44699-57140 This mode works the same way as
50334 ** SQLITE_CHECKPOINT_RESTART with the addition that it also
@@ -128378,10 +128370,11 @@
128370 }
128371 if( iDb<0 ){
128372 rc = SQLITE_ERROR;
128373 sqlite3ErrorWithMsg(db, SQLITE_ERROR, "unknown database: %s", zDb);
128374 }else{
128375 db->busyHandler.nBusy = 0;
128376 rc = sqlite3Checkpoint(db, iDb, eMode, pnLog, pnCkpt);
128377 sqlite3Error(db, rc);
128378 }
128379 rc = sqlite3ApiExit(db, rc);
128380 sqlite3_mutex_leave(db->mutex);
128381
+2 -2
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -105,13 +105,13 @@
105105
**
106106
** See also: [sqlite3_libversion()],
107107
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
108108
** [sqlite_version()] and [sqlite_source_id()].
109109
*/
110
-#define SQLITE_VERSION "3.8.8.1"
110
+#define SQLITE_VERSION "3.8.8.2"
111111
#define SQLITE_VERSION_NUMBER 3008008
112
-#define SQLITE_SOURCE_ID "2015-01-20 16:51:25 f73337e3e289915a76ca96e7a05a1a8d4e890d55"
112
+#define SQLITE_SOURCE_ID "2015-01-30 14:30:45 7757fc721220e136620a89c9d28247f28bbbc098"
113113
114114
/*
115115
** CAPI3REF: Run-Time Library Version Numbers
116116
** KEYWORDS: sqlite3_version, sqlite3_sourceid
117117
**
118118
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -105,13 +105,13 @@
105 **
106 ** See also: [sqlite3_libversion()],
107 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
108 ** [sqlite_version()] and [sqlite_source_id()].
109 */
110 #define SQLITE_VERSION "3.8.8.1"
111 #define SQLITE_VERSION_NUMBER 3008008
112 #define SQLITE_SOURCE_ID "2015-01-20 16:51:25 f73337e3e289915a76ca96e7a05a1a8d4e890d55"
113
114 /*
115 ** CAPI3REF: Run-Time Library Version Numbers
116 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
117 **
118
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -105,13 +105,13 @@
105 **
106 ** See also: [sqlite3_libversion()],
107 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
108 ** [sqlite_version()] and [sqlite_source_id()].
109 */
110 #define SQLITE_VERSION "3.8.8.2"
111 #define SQLITE_VERSION_NUMBER 3008008
112 #define SQLITE_SOURCE_ID "2015-01-30 14:30:45 7757fc721220e136620a89c9d28247f28bbbc098"
113
114 /*
115 ** CAPI3REF: Run-Time Library Version Numbers
116 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
117 **
118

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button