Fossil SCM

Update the built-in SQLite to the latest 3.7.0 beta snapshot that includes fixes for large databases in WAL mode.

drh 2010-07-07 14:57 trunk
Commit f0cd78c1a3d084764bcb898877ec54656355c15b
2 files changed +63 -34 +1 -1
+63 -34
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -509,10 +509,17 @@
509509
#else
510510
# define ALWAYS(X) (X)
511511
# define NEVER(X) (X)
512512
#endif
513513
514
+/*
515
+** Return true (non-zero) if the input is a integer that is too large
516
+** to fit in 32-bits. This macro is used inside of various testcase()
517
+** macros to verify that we have tested SQLite for large-file support.
518
+*/
519
+#define IS_BIG_INT(X) (((X)&(i64)0xffffffff)!=0)
520
+
514521
/*
515522
** The macro unlikely() is a hint that surrounds a boolean
516523
** expression that is usually false. Macro likely() surrounds
517524
** a boolean expression that is usually true. GCC is able to
518525
** use these hints to generate better code, sometimes.
@@ -636,11 +643,11 @@
636643
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
637644
** [sqlite_version()] and [sqlite_source_id()].
638645
*/
639646
#define SQLITE_VERSION "3.7.0"
640647
#define SQLITE_VERSION_NUMBER 3007000
641
-#define SQLITE_SOURCE_ID "2010-07-06 20:37:10 5621862b0e2fc945ded51f5926a6b4c9f07d0ab7"
648
+#define SQLITE_SOURCE_ID "2010-07-07 14:45:41 8eefc287265443ec043bdab629597e79c9d22006"
642649
643650
/*
644651
** CAPI3REF: Run-Time Library Version Numbers
645652
** KEYWORDS: sqlite3_version, sqlite3_sourceid
646653
**
@@ -11333,13 +11340,15 @@
1133311340
"OMIT_CAST",
1133411341
#endif
1133511342
#ifdef SQLITE_OMIT_CHECK
1133611343
"OMIT_CHECK",
1133711344
#endif
11338
-#ifdef SQLITE_OMIT_COMPILEOPTION_DIAGS
11339
- "OMIT_COMPILEOPTION_DIAGS",
11340
-#endif
11345
+/* // redundant
11346
+** #ifdef SQLITE_OMIT_COMPILEOPTION_DIAGS
11347
+** "OMIT_COMPILEOPTION_DIAGS",
11348
+** #endif
11349
+*/
1134111350
#ifdef SQLITE_OMIT_COMPLETE
1134211351
"OMIT_COMPLETE",
1134311352
#endif
1134411353
#ifdef SQLITE_OMIT_COMPOUND_SELECT
1134511354
"OMIT_COMPOUND_SELECT",
@@ -11369,13 +11378,10 @@
1136911378
"OMIT_FOREIGN_KEY",
1137011379
#endif
1137111380
#ifdef SQLITE_OMIT_GET_TABLE
1137211381
"OMIT_GET_TABLE",
1137311382
#endif
11374
-#ifdef SQLITE_OMIT_GLOBALRECOVER
11375
- "OMIT_GLOBALRECOVER",
11376
-#endif
1137711383
#ifdef SQLITE_OMIT_INCRBLOB
1137811384
"OMIT_INCRBLOB",
1137911385
#endif
1138011386
#ifdef SQLITE_OMIT_INTEGRITY_CHECK
1138111387
"OMIT_INTEGRITY_CHECK",
@@ -11449,10 +11455,13 @@
1144911455
#ifdef SQLITE_OMIT_VIEW
1145011456
"OMIT_VIEW",
1145111457
#endif
1145211458
#ifdef SQLITE_OMIT_VIRTUALTABLE
1145311459
"OMIT_VIRTUALTABLE",
11460
+#endif
11461
+#ifdef SQLITE_OMIT_WAL
11462
+ "OMIT_WAL",
1145411463
#endif
1145511464
#ifdef SQLITE_OMIT_WSD
1145611465
"OMIT_WSD",
1145711466
#endif
1145811467
#ifdef SQLITE_OMIT_XFER_OPT
@@ -30851,26 +30860,41 @@
3085130860
int flags, /* Type of test to make on this file */
3085230861
int *pResOut /* OUT: Result */
3085330862
){
3085430863
DWORD attr;
3085530864
int rc = 0;
30856
- void *zConverted = convertUtf8Filename(zFilename);
30865
+ void *zConverted;
3085730866
UNUSED_PARAMETER(pVfs);
30867
+
30868
+ SimulateIOError( return SQLITE_IOERR_ACCESS; );
30869
+ zConverted = convertUtf8Filename(zFilename);
3085830870
if( zConverted==0 ){
3085930871
return SQLITE_NOMEM;
3086030872
}
3086130873
if( isNT() ){
3086230874
WIN32_FILE_ATTRIBUTE_DATA sAttrData;
3086330875
memset(&sAttrData, 0, sizeof(sAttrData));
30864
- attr = GetFileAttributesExW((WCHAR*)zConverted,
30865
- GetFileExInfoStandard, &sAttrData);
30866
- /* For an SQLITE_ACCESS_EXISTS query, treat a zero-length file
30867
- ** as if it does not exist.
30868
- */
30869
- if( flags==SQLITE_ACCESS_EXISTS && attr!=INVALID_FILE_ATTRIBUTES
30870
- && sAttrData.nFileSizeHigh==0 && sAttrData.nFileSizeLow==0 ){
30871
- attr = INVALID_FILE_ATTRIBUTES;
30876
+ if( GetFileAttributesExW((WCHAR*)zConverted,
30877
+ GetFileExInfoStandard,
30878
+ &sAttrData) ){
30879
+ /* For an SQLITE_ACCESS_EXISTS query, treat a zero-length file
30880
+ ** as if it does not exist.
30881
+ */
30882
+ if( flags==SQLITE_ACCESS_EXISTS
30883
+ && sAttrData.nFileSizeHigh==0
30884
+ && sAttrData.nFileSizeLow==0 ){
30885
+ attr = INVALID_FILE_ATTRIBUTES;
30886
+ }else{
30887
+ attr = sAttrData.dwFileAttributes;
30888
+ }
30889
+ }else{
30890
+ if( GetLastError()!=ERROR_FILE_NOT_FOUND ){
30891
+ free(zConverted);
30892
+ return SQLITE_IOERR_ACCESS;
30893
+ }else{
30894
+ attr = INVALID_FILE_ATTRIBUTES;
30895
+ }
3087230896
}
3087330897
/* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed.
3087430898
** Since the ASCII version of these Windows API do not exist for WINCE,
3087530899
** it's important to not reference them for WINCE builds.
3087630900
*/
@@ -36924,17 +36948,13 @@
3692436948
**
3692536949
** If everything is successful, SQLITE_OK is returned. If an IO error
3692636950
** occurs, an IO error code is returned. Or, if the EXCLUSIVE lock cannot
3692736951
** be obtained, SQLITE_BUSY is returned.
3692836952
*/
36929
-static int pager_write_pagelist(PgHdr *pList){
36930
- Pager *pPager; /* Pager object */
36953
+static int pager_write_pagelist(Pager *pPager, PgHdr *pList){
3693136954
int rc; /* Return code */
3693236955
36933
- if( NEVER(pList==0) ) return SQLITE_OK;
36934
- pPager = pList->pPager;
36935
-
3693636956
/* At this point there may be either a RESERVED or EXCLUSIVE lock on the
3693736957
** database file. If there is already an EXCLUSIVE lock, the following
3693836958
** call is a no-op.
3693936959
**
3694036960
** Moving the lock from RESERVED to EXCLUSIVE actually involves going
@@ -36947,11 +36967,11 @@
3694736967
** is unchanged and we can rollback without having to playback the
3694836968
** journal into the original database file. Once we transition to
3694936969
** EXCLUSIVE, it means the database file has been changed and any rollback
3695036970
** will require a journal playback.
3695136971
*/
36952
- assert( !pagerUseWal(pList->pPager) );
36972
+ assert( !pagerUseWal(pPager) );
3695336973
assert( pPager->state>=PAGER_RESERVED );
3695436974
rc = pager_wait_on_lock(pPager, EXCLUSIVE_LOCK);
3695536975
3695636976
/* If the file is a temp-file has not yet been opened, open it now. It
3695736977
** is not possible for rc to be other than SQLITE_OK if this branch
@@ -37192,11 +37212,11 @@
3719237212
rc = subjournalPage(pPg);
3719337213
}
3719437214
3719537215
/* Write the contents of the page out to the database file. */
3719637216
if( rc==SQLITE_OK ){
37197
- rc = pager_write_pagelist(pPg);
37217
+ rc = pager_write_pagelist(pPager, pPg);
3719837218
}
3719937219
}
3720037220
3720137221
/* Mark the page as clean. */
3720237222
if( rc==SQLITE_OK ){
@@ -38821,11 +38841,11 @@
3882138841
*/
3882238842
rc = syncJournal(pPager);
3882338843
if( rc!=SQLITE_OK ) goto commit_phase_one_exit;
3882438844
3882538845
/* Write all dirty pages to the database file. */
38826
- rc = pager_write_pagelist(sqlite3PcacheDirtyList(pPager->pPCache));
38846
+ rc = pager_write_pagelist(pPager,sqlite3PcacheDirtyList(pPager->pPCache));
3882738847
if( rc!=SQLITE_OK ){
3882838848
assert( rc!=SQLITE_IOERR_BLOCKED );
3882938849
goto commit_phase_one_exit;
3883038850
}
3883138851
sqlite3PcacheCleanAll(pPager->pPCache);
@@ -40137,11 +40157,11 @@
4013740157
** Return the offset of frame iFrame in the write-ahead log file,
4013840158
** assuming a database page size of szPage bytes. The offset returned
4013940159
** is to the start of the write-ahead log frame-header.
4014040160
*/
4014140161
#define walFrameOffset(iFrame, szPage) ( \
40142
- WAL_HDRSIZE + ((iFrame)-1)*((szPage)+WAL_FRAME_HDRSIZE) \
40162
+ WAL_HDRSIZE + ((iFrame)-1)*(i64)((szPage)+WAL_FRAME_HDRSIZE) \
4014340163
)
4014440164
4014540165
/*
4014640166
** An open write-ahead log file is represented by an instance of the
4014740167
** following object.
@@ -41313,24 +41333,29 @@
4131341333
rc = sqlite3OsSync(pWal->pWalFd, sync_flags);
4131441334
}
4131541335
4131641336
/* Iterate through the contents of the WAL, copying data to the db file. */
4131741337
while( rc==SQLITE_OK && 0==walIteratorNext(pIter, &iDbpage, &iFrame) ){
41338
+ i64 iOffset;
4131841339
assert( walFramePgno(pWal, iFrame)==iDbpage );
4131941340
if( iFrame<=nBackfill || iFrame>mxSafeFrame ) continue;
41320
- rc = sqlite3OsRead(pWal->pWalFd, zBuf, szPage,
41321
- walFrameOffset(iFrame, szPage) + WAL_FRAME_HDRSIZE
41322
- );
41341
+ iOffset = walFrameOffset(iFrame, szPage) + WAL_FRAME_HDRSIZE;
41342
+ /* testcase( IS_BIG_INT(iOffset) ); // requires a 4GiB WAL file */
41343
+ rc = sqlite3OsRead(pWal->pWalFd, zBuf, szPage, iOffset);
4132341344
if( rc!=SQLITE_OK ) break;
41324
- rc = sqlite3OsWrite(pWal->pDbFd, zBuf, szPage, (iDbpage-1)*szPage);
41345
+ iOffset = (iDbpage-1)*(i64)szPage;
41346
+ testcase( IS_BIG_INT(iOffset) );
41347
+ rc = sqlite3OsWrite(pWal->pDbFd, zBuf, szPage, iOffset);
4132541348
if( rc!=SQLITE_OK ) break;
4132641349
}
4132741350
4132841351
/* If work was actually accomplished... */
4132941352
if( rc==SQLITE_OK ){
4133041353
if( mxSafeFrame==walIndexHdr(pWal)->mxFrame ){
41331
- rc = sqlite3OsTruncate(pWal->pDbFd, ((i64)pWal->hdr.nPage*(i64)szPage));
41354
+ i64 szDb = pWal->hdr.nPage*(i64)szPage;
41355
+ testcase( IS_BIG_INT(szDb) );
41356
+ rc = sqlite3OsTruncate(pWal->pDbFd, szDb);
4133241357
if( rc==SQLITE_OK && sync_flags ){
4133341358
rc = sqlite3OsSync(pWal->pDbFd, sync_flags);
4133441359
}
4133541360
}
4133641361
if( rc==SQLITE_OK ){
@@ -41864,10 +41889,11 @@
4186441889
** required page. Read and return data from the log file.
4186541890
*/
4186641891
if( iRead ){
4186741892
i64 iOffset = walFrameOffset(iRead, pWal->hdr.szPage) + WAL_FRAME_HDRSIZE;
4186841893
*pInWal = 1;
41894
+ /* testcase( IS_BIG_INT(iOffset) ); // requires a 4GiB WAL */
4186941895
return sqlite3OsRead(pWal->pWalFd, pOut, nOut, iOffset);
4187041896
}
4187141897
4187241898
*pInWal = 0;
4187341899
return SQLITE_OK;
@@ -42154,12 +42180,12 @@
4215442180
for(p=pList; p; p=p->pDirty){
4215542181
u32 nDbsize; /* Db-size field for frame header */
4215642182
i64 iOffset; /* Write offset in log file */
4215742183
void *pData;
4215842184
42159
-
4216042185
iOffset = walFrameOffset(++iFrame, szPage);
42186
+ /* testcase( IS_BIG_INT(iOffset) ); // requires a 4GiB WAL */
4216142187
4216242188
/* Populate and write the frame header */
4216342189
nDbsize = (isCommit && p->pDirty==0) ? nTruncate : 0;
4216442190
#if defined(SQLITE_HAS_CODEC)
4216542191
if( (pData = sqlite3PagerCodec(p))==0 ) return SQLITE_NOMEM;
@@ -42195,10 +42221,11 @@
4219542221
if( (pData = sqlite3PagerCodec(pLast))==0 ) return SQLITE_NOMEM;
4219642222
#else
4219742223
pData = pLast->pData;
4219842224
#endif
4219942225
walEncodeFrame(pWal, pLast->pgno, nTruncate, pData, aFrame);
42226
+ /* testcase( IS_BIG_INT(iOffset) ); // requires a 4GiB WAL */
4220042227
rc = sqlite3OsWrite(pWal->pWalFd, aFrame, sizeof(aFrame), iOffset);
4220142228
if( rc!=SQLITE_OK ){
4220242229
return rc;
4220342230
}
4220442231
iOffset += WAL_FRAME_HDRSIZE;
@@ -83587,20 +83614,24 @@
8358783614
** PRAGMA [database.]journal_mode =
8358883615
** (delete|persist|off|truncate|memory|wal|off)
8358983616
*/
8359083617
if( sqlite3StrICmp(zLeft,"journal_mode")==0 ){
8359183618
int eMode; /* One of the PAGER_JOURNALMODE_XXX symbols */
83619
+
83620
+ if( sqlite3ReadSchema(pParse) ){
83621
+ goto pragma_out;
83622
+ }
8359283623
8359383624
sqlite3VdbeSetNumCols(v, 1);
8359483625
sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "journal_mode", SQLITE_STATIC);
8359583626
8359683627
if( zRight==0 ){
8359783628
eMode = PAGER_JOURNALMODE_QUERY;
8359883629
}else{
8359983630
const char *zMode;
8360083631
int n = sqlite3Strlen30(zRight);
83601
- for(eMode=0; (zMode = sqlite3JournalModename(eMode)); eMode++){
83632
+ for(eMode=0; (zMode = sqlite3JournalModename(eMode))!=0; eMode++){
8360283633
if( sqlite3StrNICmp(zRight, zMode, n)==0 ) break;
8360383634
}
8360483635
if( !zMode ){
8360583636
eMode = PAGER_JOURNALMODE_QUERY;
8360683637
}
@@ -104129,20 +104160,18 @@
104129104160
sqlite3_mutex_leave(db->mutex);
104130104161
return SQLITE_OK;
104131104162
}
104132104163
#endif /* SQLITE_OMIT_UTF16 */
104133104164
104134
-#ifndef SQLITE_OMIT_GLOBALRECOVER
104135104165
#ifndef SQLITE_OMIT_DEPRECATED
104136104166
/*
104137104167
** This function is now an anachronism. It used to be used to recover from a
104138104168
** malloc() failure, but SQLite now does this automatically.
104139104169
*/
104140104170
SQLITE_API int sqlite3_global_recover(void){
104141104171
return SQLITE_OK;
104142104172
}
104143
-#endif
104144104173
#endif
104145104174
104146104175
/*
104147104176
** Test to see whether or not the database connection is in autocommit
104148104177
** mode. Return TRUE if it is and FALSE if not. Autocommit mode is on
104149104178
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -509,10 +509,17 @@
509 #else
510 # define ALWAYS(X) (X)
511 # define NEVER(X) (X)
512 #endif
513
 
 
 
 
 
 
 
514 /*
515 ** The macro unlikely() is a hint that surrounds a boolean
516 ** expression that is usually false. Macro likely() surrounds
517 ** a boolean expression that is usually true. GCC is able to
518 ** use these hints to generate better code, sometimes.
@@ -636,11 +643,11 @@
636 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
637 ** [sqlite_version()] and [sqlite_source_id()].
638 */
639 #define SQLITE_VERSION "3.7.0"
640 #define SQLITE_VERSION_NUMBER 3007000
641 #define SQLITE_SOURCE_ID "2010-07-06 20:37:10 5621862b0e2fc945ded51f5926a6b4c9f07d0ab7"
642
643 /*
644 ** CAPI3REF: Run-Time Library Version Numbers
645 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
646 **
@@ -11333,13 +11340,15 @@
11333 "OMIT_CAST",
11334 #endif
11335 #ifdef SQLITE_OMIT_CHECK
11336 "OMIT_CHECK",
11337 #endif
11338 #ifdef SQLITE_OMIT_COMPILEOPTION_DIAGS
11339 "OMIT_COMPILEOPTION_DIAGS",
11340 #endif
 
 
11341 #ifdef SQLITE_OMIT_COMPLETE
11342 "OMIT_COMPLETE",
11343 #endif
11344 #ifdef SQLITE_OMIT_COMPOUND_SELECT
11345 "OMIT_COMPOUND_SELECT",
@@ -11369,13 +11378,10 @@
11369 "OMIT_FOREIGN_KEY",
11370 #endif
11371 #ifdef SQLITE_OMIT_GET_TABLE
11372 "OMIT_GET_TABLE",
11373 #endif
11374 #ifdef SQLITE_OMIT_GLOBALRECOVER
11375 "OMIT_GLOBALRECOVER",
11376 #endif
11377 #ifdef SQLITE_OMIT_INCRBLOB
11378 "OMIT_INCRBLOB",
11379 #endif
11380 #ifdef SQLITE_OMIT_INTEGRITY_CHECK
11381 "OMIT_INTEGRITY_CHECK",
@@ -11449,10 +11455,13 @@
11449 #ifdef SQLITE_OMIT_VIEW
11450 "OMIT_VIEW",
11451 #endif
11452 #ifdef SQLITE_OMIT_VIRTUALTABLE
11453 "OMIT_VIRTUALTABLE",
 
 
 
11454 #endif
11455 #ifdef SQLITE_OMIT_WSD
11456 "OMIT_WSD",
11457 #endif
11458 #ifdef SQLITE_OMIT_XFER_OPT
@@ -30851,26 +30860,41 @@
30851 int flags, /* Type of test to make on this file */
30852 int *pResOut /* OUT: Result */
30853 ){
30854 DWORD attr;
30855 int rc = 0;
30856 void *zConverted = convertUtf8Filename(zFilename);
30857 UNUSED_PARAMETER(pVfs);
 
 
 
30858 if( zConverted==0 ){
30859 return SQLITE_NOMEM;
30860 }
30861 if( isNT() ){
30862 WIN32_FILE_ATTRIBUTE_DATA sAttrData;
30863 memset(&sAttrData, 0, sizeof(sAttrData));
30864 attr = GetFileAttributesExW((WCHAR*)zConverted,
30865 GetFileExInfoStandard, &sAttrData);
30866 /* For an SQLITE_ACCESS_EXISTS query, treat a zero-length file
30867 ** as if it does not exist.
30868 */
30869 if( flags==SQLITE_ACCESS_EXISTS && attr!=INVALID_FILE_ATTRIBUTES
30870 && sAttrData.nFileSizeHigh==0 && sAttrData.nFileSizeLow==0 ){
30871 attr = INVALID_FILE_ATTRIBUTES;
 
 
 
 
 
 
 
 
 
 
 
 
30872 }
30873 /* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed.
30874 ** Since the ASCII version of these Windows API do not exist for WINCE,
30875 ** it's important to not reference them for WINCE builds.
30876 */
@@ -36924,17 +36948,13 @@
36924 **
36925 ** If everything is successful, SQLITE_OK is returned. If an IO error
36926 ** occurs, an IO error code is returned. Or, if the EXCLUSIVE lock cannot
36927 ** be obtained, SQLITE_BUSY is returned.
36928 */
36929 static int pager_write_pagelist(PgHdr *pList){
36930 Pager *pPager; /* Pager object */
36931 int rc; /* Return code */
36932
36933 if( NEVER(pList==0) ) return SQLITE_OK;
36934 pPager = pList->pPager;
36935
36936 /* At this point there may be either a RESERVED or EXCLUSIVE lock on the
36937 ** database file. If there is already an EXCLUSIVE lock, the following
36938 ** call is a no-op.
36939 **
36940 ** Moving the lock from RESERVED to EXCLUSIVE actually involves going
@@ -36947,11 +36967,11 @@
36947 ** is unchanged and we can rollback without having to playback the
36948 ** journal into the original database file. Once we transition to
36949 ** EXCLUSIVE, it means the database file has been changed and any rollback
36950 ** will require a journal playback.
36951 */
36952 assert( !pagerUseWal(pList->pPager) );
36953 assert( pPager->state>=PAGER_RESERVED );
36954 rc = pager_wait_on_lock(pPager, EXCLUSIVE_LOCK);
36955
36956 /* If the file is a temp-file has not yet been opened, open it now. It
36957 ** is not possible for rc to be other than SQLITE_OK if this branch
@@ -37192,11 +37212,11 @@
37192 rc = subjournalPage(pPg);
37193 }
37194
37195 /* Write the contents of the page out to the database file. */
37196 if( rc==SQLITE_OK ){
37197 rc = pager_write_pagelist(pPg);
37198 }
37199 }
37200
37201 /* Mark the page as clean. */
37202 if( rc==SQLITE_OK ){
@@ -38821,11 +38841,11 @@
38821 */
38822 rc = syncJournal(pPager);
38823 if( rc!=SQLITE_OK ) goto commit_phase_one_exit;
38824
38825 /* Write all dirty pages to the database file. */
38826 rc = pager_write_pagelist(sqlite3PcacheDirtyList(pPager->pPCache));
38827 if( rc!=SQLITE_OK ){
38828 assert( rc!=SQLITE_IOERR_BLOCKED );
38829 goto commit_phase_one_exit;
38830 }
38831 sqlite3PcacheCleanAll(pPager->pPCache);
@@ -40137,11 +40157,11 @@
40137 ** Return the offset of frame iFrame in the write-ahead log file,
40138 ** assuming a database page size of szPage bytes. The offset returned
40139 ** is to the start of the write-ahead log frame-header.
40140 */
40141 #define walFrameOffset(iFrame, szPage) ( \
40142 WAL_HDRSIZE + ((iFrame)-1)*((szPage)+WAL_FRAME_HDRSIZE) \
40143 )
40144
40145 /*
40146 ** An open write-ahead log file is represented by an instance of the
40147 ** following object.
@@ -41313,24 +41333,29 @@
41313 rc = sqlite3OsSync(pWal->pWalFd, sync_flags);
41314 }
41315
41316 /* Iterate through the contents of the WAL, copying data to the db file. */
41317 while( rc==SQLITE_OK && 0==walIteratorNext(pIter, &iDbpage, &iFrame) ){
 
41318 assert( walFramePgno(pWal, iFrame)==iDbpage );
41319 if( iFrame<=nBackfill || iFrame>mxSafeFrame ) continue;
41320 rc = sqlite3OsRead(pWal->pWalFd, zBuf, szPage,
41321 walFrameOffset(iFrame, szPage) + WAL_FRAME_HDRSIZE
41322 );
41323 if( rc!=SQLITE_OK ) break;
41324 rc = sqlite3OsWrite(pWal->pDbFd, zBuf, szPage, (iDbpage-1)*szPage);
 
 
41325 if( rc!=SQLITE_OK ) break;
41326 }
41327
41328 /* If work was actually accomplished... */
41329 if( rc==SQLITE_OK ){
41330 if( mxSafeFrame==walIndexHdr(pWal)->mxFrame ){
41331 rc = sqlite3OsTruncate(pWal->pDbFd, ((i64)pWal->hdr.nPage*(i64)szPage));
 
 
41332 if( rc==SQLITE_OK && sync_flags ){
41333 rc = sqlite3OsSync(pWal->pDbFd, sync_flags);
41334 }
41335 }
41336 if( rc==SQLITE_OK ){
@@ -41864,10 +41889,11 @@
41864 ** required page. Read and return data from the log file.
41865 */
41866 if( iRead ){
41867 i64 iOffset = walFrameOffset(iRead, pWal->hdr.szPage) + WAL_FRAME_HDRSIZE;
41868 *pInWal = 1;
 
41869 return sqlite3OsRead(pWal->pWalFd, pOut, nOut, iOffset);
41870 }
41871
41872 *pInWal = 0;
41873 return SQLITE_OK;
@@ -42154,12 +42180,12 @@
42154 for(p=pList; p; p=p->pDirty){
42155 u32 nDbsize; /* Db-size field for frame header */
42156 i64 iOffset; /* Write offset in log file */
42157 void *pData;
42158
42159
42160 iOffset = walFrameOffset(++iFrame, szPage);
 
42161
42162 /* Populate and write the frame header */
42163 nDbsize = (isCommit && p->pDirty==0) ? nTruncate : 0;
42164 #if defined(SQLITE_HAS_CODEC)
42165 if( (pData = sqlite3PagerCodec(p))==0 ) return SQLITE_NOMEM;
@@ -42195,10 +42221,11 @@
42195 if( (pData = sqlite3PagerCodec(pLast))==0 ) return SQLITE_NOMEM;
42196 #else
42197 pData = pLast->pData;
42198 #endif
42199 walEncodeFrame(pWal, pLast->pgno, nTruncate, pData, aFrame);
 
42200 rc = sqlite3OsWrite(pWal->pWalFd, aFrame, sizeof(aFrame), iOffset);
42201 if( rc!=SQLITE_OK ){
42202 return rc;
42203 }
42204 iOffset += WAL_FRAME_HDRSIZE;
@@ -83587,20 +83614,24 @@
83587 ** PRAGMA [database.]journal_mode =
83588 ** (delete|persist|off|truncate|memory|wal|off)
83589 */
83590 if( sqlite3StrICmp(zLeft,"journal_mode")==0 ){
83591 int eMode; /* One of the PAGER_JOURNALMODE_XXX symbols */
 
 
 
 
83592
83593 sqlite3VdbeSetNumCols(v, 1);
83594 sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "journal_mode", SQLITE_STATIC);
83595
83596 if( zRight==0 ){
83597 eMode = PAGER_JOURNALMODE_QUERY;
83598 }else{
83599 const char *zMode;
83600 int n = sqlite3Strlen30(zRight);
83601 for(eMode=0; (zMode = sqlite3JournalModename(eMode)); eMode++){
83602 if( sqlite3StrNICmp(zRight, zMode, n)==0 ) break;
83603 }
83604 if( !zMode ){
83605 eMode = PAGER_JOURNALMODE_QUERY;
83606 }
@@ -104129,20 +104160,18 @@
104129 sqlite3_mutex_leave(db->mutex);
104130 return SQLITE_OK;
104131 }
104132 #endif /* SQLITE_OMIT_UTF16 */
104133
104134 #ifndef SQLITE_OMIT_GLOBALRECOVER
104135 #ifndef SQLITE_OMIT_DEPRECATED
104136 /*
104137 ** This function is now an anachronism. It used to be used to recover from a
104138 ** malloc() failure, but SQLite now does this automatically.
104139 */
104140 SQLITE_API int sqlite3_global_recover(void){
104141 return SQLITE_OK;
104142 }
104143 #endif
104144 #endif
104145
104146 /*
104147 ** Test to see whether or not the database connection is in autocommit
104148 ** mode. Return TRUE if it is and FALSE if not. Autocommit mode is on
104149
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -509,10 +509,17 @@
509 #else
510 # define ALWAYS(X) (X)
511 # define NEVER(X) (X)
512 #endif
513
514 /*
515 ** Return true (non-zero) if the input is a integer that is too large
516 ** to fit in 32-bits. This macro is used inside of various testcase()
517 ** macros to verify that we have tested SQLite for large-file support.
518 */
519 #define IS_BIG_INT(X) (((X)&(i64)0xffffffff)!=0)
520
521 /*
522 ** The macro unlikely() is a hint that surrounds a boolean
523 ** expression that is usually false. Macro likely() surrounds
524 ** a boolean expression that is usually true. GCC is able to
525 ** use these hints to generate better code, sometimes.
@@ -636,11 +643,11 @@
643 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
644 ** [sqlite_version()] and [sqlite_source_id()].
645 */
646 #define SQLITE_VERSION "3.7.0"
647 #define SQLITE_VERSION_NUMBER 3007000
648 #define SQLITE_SOURCE_ID "2010-07-07 14:45:41 8eefc287265443ec043bdab629597e79c9d22006"
649
650 /*
651 ** CAPI3REF: Run-Time Library Version Numbers
652 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
653 **
@@ -11333,13 +11340,15 @@
11340 "OMIT_CAST",
11341 #endif
11342 #ifdef SQLITE_OMIT_CHECK
11343 "OMIT_CHECK",
11344 #endif
11345 /* // redundant
11346 ** #ifdef SQLITE_OMIT_COMPILEOPTION_DIAGS
11347 ** "OMIT_COMPILEOPTION_DIAGS",
11348 ** #endif
11349 */
11350 #ifdef SQLITE_OMIT_COMPLETE
11351 "OMIT_COMPLETE",
11352 #endif
11353 #ifdef SQLITE_OMIT_COMPOUND_SELECT
11354 "OMIT_COMPOUND_SELECT",
@@ -11369,13 +11378,10 @@
11378 "OMIT_FOREIGN_KEY",
11379 #endif
11380 #ifdef SQLITE_OMIT_GET_TABLE
11381 "OMIT_GET_TABLE",
11382 #endif
 
 
 
11383 #ifdef SQLITE_OMIT_INCRBLOB
11384 "OMIT_INCRBLOB",
11385 #endif
11386 #ifdef SQLITE_OMIT_INTEGRITY_CHECK
11387 "OMIT_INTEGRITY_CHECK",
@@ -11449,10 +11455,13 @@
11455 #ifdef SQLITE_OMIT_VIEW
11456 "OMIT_VIEW",
11457 #endif
11458 #ifdef SQLITE_OMIT_VIRTUALTABLE
11459 "OMIT_VIRTUALTABLE",
11460 #endif
11461 #ifdef SQLITE_OMIT_WAL
11462 "OMIT_WAL",
11463 #endif
11464 #ifdef SQLITE_OMIT_WSD
11465 "OMIT_WSD",
11466 #endif
11467 #ifdef SQLITE_OMIT_XFER_OPT
@@ -30851,26 +30860,41 @@
30860 int flags, /* Type of test to make on this file */
30861 int *pResOut /* OUT: Result */
30862 ){
30863 DWORD attr;
30864 int rc = 0;
30865 void *zConverted;
30866 UNUSED_PARAMETER(pVfs);
30867
30868 SimulateIOError( return SQLITE_IOERR_ACCESS; );
30869 zConverted = convertUtf8Filename(zFilename);
30870 if( zConverted==0 ){
30871 return SQLITE_NOMEM;
30872 }
30873 if( isNT() ){
30874 WIN32_FILE_ATTRIBUTE_DATA sAttrData;
30875 memset(&sAttrData, 0, sizeof(sAttrData));
30876 if( GetFileAttributesExW((WCHAR*)zConverted,
30877 GetFileExInfoStandard,
30878 &sAttrData) ){
30879 /* For an SQLITE_ACCESS_EXISTS query, treat a zero-length file
30880 ** as if it does not exist.
30881 */
30882 if( flags==SQLITE_ACCESS_EXISTS
30883 && sAttrData.nFileSizeHigh==0
30884 && sAttrData.nFileSizeLow==0 ){
30885 attr = INVALID_FILE_ATTRIBUTES;
30886 }else{
30887 attr = sAttrData.dwFileAttributes;
30888 }
30889 }else{
30890 if( GetLastError()!=ERROR_FILE_NOT_FOUND ){
30891 free(zConverted);
30892 return SQLITE_IOERR_ACCESS;
30893 }else{
30894 attr = INVALID_FILE_ATTRIBUTES;
30895 }
30896 }
30897 /* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed.
30898 ** Since the ASCII version of these Windows API do not exist for WINCE,
30899 ** it's important to not reference them for WINCE builds.
30900 */
@@ -36924,17 +36948,13 @@
36948 **
36949 ** If everything is successful, SQLITE_OK is returned. If an IO error
36950 ** occurs, an IO error code is returned. Or, if the EXCLUSIVE lock cannot
36951 ** be obtained, SQLITE_BUSY is returned.
36952 */
36953 static int pager_write_pagelist(Pager *pPager, PgHdr *pList){
 
36954 int rc; /* Return code */
36955
 
 
 
36956 /* At this point there may be either a RESERVED or EXCLUSIVE lock on the
36957 ** database file. If there is already an EXCLUSIVE lock, the following
36958 ** call is a no-op.
36959 **
36960 ** Moving the lock from RESERVED to EXCLUSIVE actually involves going
@@ -36947,11 +36967,11 @@
36967 ** is unchanged and we can rollback without having to playback the
36968 ** journal into the original database file. Once we transition to
36969 ** EXCLUSIVE, it means the database file has been changed and any rollback
36970 ** will require a journal playback.
36971 */
36972 assert( !pagerUseWal(pPager) );
36973 assert( pPager->state>=PAGER_RESERVED );
36974 rc = pager_wait_on_lock(pPager, EXCLUSIVE_LOCK);
36975
36976 /* If the file is a temp-file has not yet been opened, open it now. It
36977 ** is not possible for rc to be other than SQLITE_OK if this branch
@@ -37192,11 +37212,11 @@
37212 rc = subjournalPage(pPg);
37213 }
37214
37215 /* Write the contents of the page out to the database file. */
37216 if( rc==SQLITE_OK ){
37217 rc = pager_write_pagelist(pPager, pPg);
37218 }
37219 }
37220
37221 /* Mark the page as clean. */
37222 if( rc==SQLITE_OK ){
@@ -38821,11 +38841,11 @@
38841 */
38842 rc = syncJournal(pPager);
38843 if( rc!=SQLITE_OK ) goto commit_phase_one_exit;
38844
38845 /* Write all dirty pages to the database file. */
38846 rc = pager_write_pagelist(pPager,sqlite3PcacheDirtyList(pPager->pPCache));
38847 if( rc!=SQLITE_OK ){
38848 assert( rc!=SQLITE_IOERR_BLOCKED );
38849 goto commit_phase_one_exit;
38850 }
38851 sqlite3PcacheCleanAll(pPager->pPCache);
@@ -40137,11 +40157,11 @@
40157 ** Return the offset of frame iFrame in the write-ahead log file,
40158 ** assuming a database page size of szPage bytes. The offset returned
40159 ** is to the start of the write-ahead log frame-header.
40160 */
40161 #define walFrameOffset(iFrame, szPage) ( \
40162 WAL_HDRSIZE + ((iFrame)-1)*(i64)((szPage)+WAL_FRAME_HDRSIZE) \
40163 )
40164
40165 /*
40166 ** An open write-ahead log file is represented by an instance of the
40167 ** following object.
@@ -41313,24 +41333,29 @@
41333 rc = sqlite3OsSync(pWal->pWalFd, sync_flags);
41334 }
41335
41336 /* Iterate through the contents of the WAL, copying data to the db file. */
41337 while( rc==SQLITE_OK && 0==walIteratorNext(pIter, &iDbpage, &iFrame) ){
41338 i64 iOffset;
41339 assert( walFramePgno(pWal, iFrame)==iDbpage );
41340 if( iFrame<=nBackfill || iFrame>mxSafeFrame ) continue;
41341 iOffset = walFrameOffset(iFrame, szPage) + WAL_FRAME_HDRSIZE;
41342 /* testcase( IS_BIG_INT(iOffset) ); // requires a 4GiB WAL file */
41343 rc = sqlite3OsRead(pWal->pWalFd, zBuf, szPage, iOffset);
41344 if( rc!=SQLITE_OK ) break;
41345 iOffset = (iDbpage-1)*(i64)szPage;
41346 testcase( IS_BIG_INT(iOffset) );
41347 rc = sqlite3OsWrite(pWal->pDbFd, zBuf, szPage, iOffset);
41348 if( rc!=SQLITE_OK ) break;
41349 }
41350
41351 /* If work was actually accomplished... */
41352 if( rc==SQLITE_OK ){
41353 if( mxSafeFrame==walIndexHdr(pWal)->mxFrame ){
41354 i64 szDb = pWal->hdr.nPage*(i64)szPage;
41355 testcase( IS_BIG_INT(szDb) );
41356 rc = sqlite3OsTruncate(pWal->pDbFd, szDb);
41357 if( rc==SQLITE_OK && sync_flags ){
41358 rc = sqlite3OsSync(pWal->pDbFd, sync_flags);
41359 }
41360 }
41361 if( rc==SQLITE_OK ){
@@ -41864,10 +41889,11 @@
41889 ** required page. Read and return data from the log file.
41890 */
41891 if( iRead ){
41892 i64 iOffset = walFrameOffset(iRead, pWal->hdr.szPage) + WAL_FRAME_HDRSIZE;
41893 *pInWal = 1;
41894 /* testcase( IS_BIG_INT(iOffset) ); // requires a 4GiB WAL */
41895 return sqlite3OsRead(pWal->pWalFd, pOut, nOut, iOffset);
41896 }
41897
41898 *pInWal = 0;
41899 return SQLITE_OK;
@@ -42154,12 +42180,12 @@
42180 for(p=pList; p; p=p->pDirty){
42181 u32 nDbsize; /* Db-size field for frame header */
42182 i64 iOffset; /* Write offset in log file */
42183 void *pData;
42184
 
42185 iOffset = walFrameOffset(++iFrame, szPage);
42186 /* testcase( IS_BIG_INT(iOffset) ); // requires a 4GiB WAL */
42187
42188 /* Populate and write the frame header */
42189 nDbsize = (isCommit && p->pDirty==0) ? nTruncate : 0;
42190 #if defined(SQLITE_HAS_CODEC)
42191 if( (pData = sqlite3PagerCodec(p))==0 ) return SQLITE_NOMEM;
@@ -42195,10 +42221,11 @@
42221 if( (pData = sqlite3PagerCodec(pLast))==0 ) return SQLITE_NOMEM;
42222 #else
42223 pData = pLast->pData;
42224 #endif
42225 walEncodeFrame(pWal, pLast->pgno, nTruncate, pData, aFrame);
42226 /* testcase( IS_BIG_INT(iOffset) ); // requires a 4GiB WAL */
42227 rc = sqlite3OsWrite(pWal->pWalFd, aFrame, sizeof(aFrame), iOffset);
42228 if( rc!=SQLITE_OK ){
42229 return rc;
42230 }
42231 iOffset += WAL_FRAME_HDRSIZE;
@@ -83587,20 +83614,24 @@
83614 ** PRAGMA [database.]journal_mode =
83615 ** (delete|persist|off|truncate|memory|wal|off)
83616 */
83617 if( sqlite3StrICmp(zLeft,"journal_mode")==0 ){
83618 int eMode; /* One of the PAGER_JOURNALMODE_XXX symbols */
83619
83620 if( sqlite3ReadSchema(pParse) ){
83621 goto pragma_out;
83622 }
83623
83624 sqlite3VdbeSetNumCols(v, 1);
83625 sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "journal_mode", SQLITE_STATIC);
83626
83627 if( zRight==0 ){
83628 eMode = PAGER_JOURNALMODE_QUERY;
83629 }else{
83630 const char *zMode;
83631 int n = sqlite3Strlen30(zRight);
83632 for(eMode=0; (zMode = sqlite3JournalModename(eMode))!=0; eMode++){
83633 if( sqlite3StrNICmp(zRight, zMode, n)==0 ) break;
83634 }
83635 if( !zMode ){
83636 eMode = PAGER_JOURNALMODE_QUERY;
83637 }
@@ -104129,20 +104160,18 @@
104160 sqlite3_mutex_leave(db->mutex);
104161 return SQLITE_OK;
104162 }
104163 #endif /* SQLITE_OMIT_UTF16 */
104164
 
104165 #ifndef SQLITE_OMIT_DEPRECATED
104166 /*
104167 ** This function is now an anachronism. It used to be used to recover from a
104168 ** malloc() failure, but SQLite now does this automatically.
104169 */
104170 SQLITE_API int sqlite3_global_recover(void){
104171 return SQLITE_OK;
104172 }
 
104173 #endif
104174
104175 /*
104176 ** Test to see whether or not the database connection is in autocommit
104177 ** mode. Return TRUE if it is and FALSE if not. Autocommit mode is on
104178
+1 -1
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -107,11 +107,11 @@
107107
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
108108
** [sqlite_version()] and [sqlite_source_id()].
109109
*/
110110
#define SQLITE_VERSION "3.7.0"
111111
#define SQLITE_VERSION_NUMBER 3007000
112
-#define SQLITE_SOURCE_ID "2010-07-06 20:37:10 5621862b0e2fc945ded51f5926a6b4c9f07d0ab7"
112
+#define SQLITE_SOURCE_ID "2010-07-07 14:45:41 8eefc287265443ec043bdab629597e79c9d22006"
113113
114114
/*
115115
** CAPI3REF: Run-Time Library Version Numbers
116116
** KEYWORDS: sqlite3_version, sqlite3_sourceid
117117
**
118118
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -107,11 +107,11 @@
107 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
108 ** [sqlite_version()] and [sqlite_source_id()].
109 */
110 #define SQLITE_VERSION "3.7.0"
111 #define SQLITE_VERSION_NUMBER 3007000
112 #define SQLITE_SOURCE_ID "2010-07-06 20:37:10 5621862b0e2fc945ded51f5926a6b4c9f07d0ab7"
113
114 /*
115 ** CAPI3REF: Run-Time Library Version Numbers
116 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
117 **
118
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -107,11 +107,11 @@
107 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
108 ** [sqlite_version()] and [sqlite_source_id()].
109 */
110 #define SQLITE_VERSION "3.7.0"
111 #define SQLITE_VERSION_NUMBER 3007000
112 #define SQLITE_SOURCE_ID "2010-07-07 14:45:41 8eefc287265443ec043bdab629597e79c9d22006"
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