Fossil SCM

Update the built-in fossil to the latest development version.

drh 2010-07-08 17:57 trunk
Commit 1e6ded985600c8aba675b9de560cb5defc24052e
2 files changed +90 -68 +1 -1
+90 -68
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -643,11 +643,11 @@
643643
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
644644
** [sqlite_version()] and [sqlite_source_id()].
645645
*/
646646
#define SQLITE_VERSION "3.7.0"
647647
#define SQLITE_VERSION_NUMBER 3007000
648
-#define SQLITE_SOURCE_ID "2010-07-07 14:45:41 8eefc287265443ec043bdab629597e79c9d22006"
648
+#define SQLITE_SOURCE_ID "2010-07-08 17:40:38 e396184cd3bdb96e29ac33af5d1f631cac553341"
649649
650650
/*
651651
** CAPI3REF: Run-Time Library Version Numbers
652652
** KEYWORDS: sqlite3_version, sqlite3_sourceid
653653
**
@@ -8572,11 +8572,10 @@
85728572
int errMask; /* & result codes with this before returning */
85738573
u8 autoCommit; /* The auto-commit flag. */
85748574
u8 temp_store; /* 1: file 2: memory 0: default */
85758575
u8 mallocFailed; /* True if we have seen a malloc failure */
85768576
u8 dfltLockMode; /* Default locking-mode for attached dbs */
8577
- u8 dfltJournalMode; /* Default journal mode for attached dbs */
85788577
signed char nextAutovac; /* Autovac setting after VACUUM if >=0 */
85798578
u8 suppressErr; /* Do not issue error messages if true */
85808579
int nextPagesize; /* Pagesize after VACUUM if >0 */
85818580
int nTable; /* Number of tables in the database */
85828581
CollSeq *pDfltColl; /* The default collating sequence (BINARY) */
@@ -29420,10 +29419,11 @@
2942029419
assert( id!=0 );
2942129420
assert( pFile->pShm==0 );
2942229421
OSTRACE(("CLOSE %d\n", pFile->h));
2942329422
do{
2942429423
rc = CloseHandle(pFile->h);
29424
+ /* SimulateIOError( rc=0; cnt=MX_CLOSE_ATTEMPT; ); */
2942529425
}while( rc==0 && ++cnt < MX_CLOSE_ATTEMPT && (Sleep(100), 1) );
2942629426
#if SQLITE_OS_WINCE
2942729427
#define WINCE_DELETION_ATTEMPTS 3
2942829428
winceDestroyLock(pFile);
2942929429
if( pFile->zDeleteOnClose ){
@@ -29577,31 +29577,44 @@
2957729577
2957829578
/*
2957929579
** Make sure all writes to a particular file are committed to disk.
2958029580
*/
2958129581
static int winSync(sqlite3_file *id, int flags){
29582
-#ifndef SQLITE_NO_SYNC
29582
+#if !defined(NDEBUG) || !defined(SQLITE_NO_SYNC) || defined(SQLITE_DEBUG)
2958329583
winFile *pFile = (winFile*)id;
29584
-
29585
- assert( id!=0 );
29586
- OSTRACE(("SYNC %d lock=%d\n", pFile->h, pFile->locktype));
2958729584
#else
2958829585
UNUSED_PARAMETER(id);
2958929586
#endif
29587
+
29588
+ assert( pFile );
29589
+ /* Check that one of SQLITE_SYNC_NORMAL or FULL was passed */
29590
+ assert((flags&0x0F)==SQLITE_SYNC_NORMAL
29591
+ || (flags&0x0F)==SQLITE_SYNC_FULL
29592
+ );
29593
+
29594
+ OSTRACE(("SYNC %d lock=%d\n", pFile->h, pFile->locktype));
29595
+
2959029596
#ifndef SQLITE_TEST
2959129597
UNUSED_PARAMETER(flags);
2959229598
#else
2959329599
if( flags & SQLITE_SYNC_FULL ){
2959429600
sqlite3_fullsync_count++;
2959529601
}
2959629602
sqlite3_sync_count++;
2959729603
#endif
29604
+
29605
+ /* Unix cannot, but some systems may return SQLITE_FULL from here. This
29606
+ ** line is to test that doing so does not cause any problems.
29607
+ */
29608
+ SimulateDiskfullError( return SQLITE_FULL );
29609
+ SimulateIOError( return SQLITE_IOERR; );
29610
+
2959829611
/* If we compiled with the SQLITE_NO_SYNC flag, then syncing is a
2959929612
** no-op
2960029613
*/
2960129614
#ifdef SQLITE_NO_SYNC
29602
- return SQLITE_OK;
29615
+ return SQLITE_OK;
2960329616
#else
2960429617
if( FlushFileBuffers(pFile->h) ){
2960529618
return SQLITE_OK;
2960629619
}else{
2960729620
pFile->lastErrno = GetLastError();
@@ -29840,10 +29853,12 @@
2984029853
*/
2984129854
static int winCheckReservedLock(sqlite3_file *id, int *pResOut){
2984229855
int rc;
2984329856
winFile *pFile = (winFile*)id;
2984429857
29858
+ SimulateIOError( return SQLITE_IOERR_CHECKRESERVEDLOCK; );
29859
+
2984529860
assert( id!=0 );
2984629861
if( pFile->locktype>=RESERVED_LOCK ){
2984729862
rc = 1;
2984829863
OSTRACE(("TEST WR-LOCK %d %d (local)\n", pFile->h, rc));
2984929864
}else{
@@ -29912,11 +29927,13 @@
2991229927
*(int*)pArg = (int)((winFile*)id)->lastErrno;
2991329928
return SQLITE_OK;
2991429929
}
2991529930
case SQLITE_FCNTL_SIZE_HINT: {
2991629931
sqlite3_int64 sz = *(sqlite3_int64*)pArg;
29932
+ SimulateIOErrorBenign(1);
2991729933
winTruncate(id, sz);
29934
+ SimulateIOErrorBenign(0);
2991829935
return SQLITE_OK;
2991929936
}
2992029937
}
2992129938
return SQLITE_ERROR;
2992229939
}
@@ -30123,14 +30140,20 @@
3012330140
if( p->mutex ) sqlite3_mutex_free(p->mutex);
3012430141
for(i=0; i<p->nRegion; i++){
3012530142
UnmapViewOfFile(p->aRegion[i].pMap);
3012630143
CloseHandle(p->aRegion[i].hMap);
3012730144
}
30128
- if( p->hFile.h != INVALID_HANDLE_VALUE ) {
30145
+ if( p->hFile.h != INVALID_HANDLE_VALUE ){
30146
+ SimulateIOErrorBenign(1);
3012930147
winClose((sqlite3_file *)&p->hFile);
30148
+ SimulateIOErrorBenign(0);
3013030149
}
30131
- if( deleteFlag ) winDelete(pVfs, p->zFilename, 0);
30150
+ if( deleteFlag ){
30151
+ SimulateIOErrorBenign(1);
30152
+ winDelete(pVfs, p->zFilename, 0);
30153
+ SimulateIOErrorBenign(0);
30154
+ }
3013230155
*pp = p->pNext;
3013330156
sqlite3_free(p->aRegion);
3013430157
sqlite3_free(p);
3013530158
}else{
3013630159
pp = &p->pNext;
@@ -30528,10 +30551,17 @@
3052830551
"abcdefghijklmnopqrstuvwxyz"
3052930552
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
3053030553
"0123456789";
3053130554
size_t i, j;
3053230555
char zTempPath[MAX_PATH+1];
30556
+
30557
+ /* It's odd to simulate an io-error here, but really this is just
30558
+ ** using the io-error infrastructure to test that SQLite handles this
30559
+ ** function failing.
30560
+ */
30561
+ SimulateIOError( return SQLITE_IOERR );
30562
+
3053330563
if( sqlite3_temp_directory ){
3053430564
sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", sqlite3_temp_directory);
3053530565
}else if( isNT() ){
3053630566
char *zMulti;
3053730567
WCHAR zWidePath[MAX_PATH];
@@ -30559,20 +30589,30 @@
3055930589
}else{
3056030590
return SQLITE_NOMEM;
3056130591
}
3056230592
#endif
3056330593
}
30594
+
30595
+ /* Check that the output buffer is large enough for the temporary file
30596
+ ** name. If it is not, return SQLITE_ERROR.
30597
+ */
30598
+ if( (sqlite3Strlen30(zTempPath) + sqlite3Strlen30(SQLITE_TEMP_FILE_PREFIX) + 17) >= nBuf ){
30599
+ return SQLITE_ERROR;
30600
+ }
30601
+
3056430602
for(i=sqlite3Strlen30(zTempPath); i>0 && zTempPath[i-1]=='\\'; i--){}
3056530603
zTempPath[i] = 0;
30566
- sqlite3_snprintf(nBuf-30, zBuf,
30604
+
30605
+ sqlite3_snprintf(nBuf-17, zBuf,
3056730606
"%s\\"SQLITE_TEMP_FILE_PREFIX, zTempPath);
3056830607
j = sqlite3Strlen30(zBuf);
30569
- sqlite3_randomness(20, &zBuf[j]);
30570
- for(i=0; i<20; i++, j++){
30608
+ sqlite3_randomness(15, &zBuf[j]);
30609
+ for(i=0; i<15; i++, j++){
3057130610
zBuf[j] = (char)zChars[ ((unsigned char)zBuf[j])%(sizeof(zChars)-1) ];
3057230611
}
3057330612
zBuf[j] = 0;
30613
+
3057430614
OSTRACE(("TEMP FILENAME: %s\n", zBuf));
3057530615
return SQLITE_OK;
3057630616
}
3057730617
3057830618
/*
@@ -30812,17 +30852,19 @@
3081230852
int syncDir /* Not used on win32 */
3081330853
){
3081430854
int cnt = 0;
3081530855
DWORD rc;
3081630856
DWORD error = 0;
30817
- void *zConverted = convertUtf8Filename(zFilename);
30857
+ void *zConverted;
3081830858
UNUSED_PARAMETER(pVfs);
3081930859
UNUSED_PARAMETER(syncDir);
30860
+
30861
+ SimulateIOError(return SQLITE_IOERR_DELETE);
30862
+ zConverted = convertUtf8Filename(zFilename);
3082030863
if( zConverted==0 ){
3082130864
return SQLITE_NOMEM;
3082230865
}
30823
- SimulateIOError(return SQLITE_IOERR_DELETE);
3082430866
if( isNT() ){
3082530867
do{
3082630868
DeleteFileW(zConverted);
3082730869
}while( ( ((rc = GetFileAttributesW(zConverted)) != INVALID_FILE_ATTRIBUTES)
3082830870
|| ((error = GetLastError()) == ERROR_ACCESS_DENIED))
@@ -30931,16 +30973,18 @@
3093130973
int nFull, /* Size of output buffer in bytes */
3093230974
char *zFull /* Output buffer */
3093330975
){
3093430976
3093530977
#if defined(__CYGWIN__)
30978
+ SimulateIOError( return SQLITE_ERROR );
3093630979
UNUSED_PARAMETER(nFull);
3093730980
cygwin_conv_to_full_win32_path(zRelative, zFull);
3093830981
return SQLITE_OK;
3093930982
#endif
3094030983
3094130984
#if SQLITE_OS_WINCE
30985
+ SimulateIOError( return SQLITE_ERROR );
3094230986
UNUSED_PARAMETER(nFull);
3094330987
/* WinCE has no concept of a relative pathname, or so I am told. */
3094430988
sqlite3_snprintf(pVfs->mxPathname, zFull, "%s", zRelative);
3094530989
return SQLITE_OK;
3094630990
#endif
@@ -30947,10 +30991,17 @@
3094730991
3094830992
#if !SQLITE_OS_WINCE && !defined(__CYGWIN__)
3094930993
int nByte;
3095030994
void *zConverted;
3095130995
char *zOut;
30996
+
30997
+ /* It's odd to simulate an io-error here, but really this is just
30998
+ ** using the io-error infrastructure to test that SQLite handles this
30999
+ ** function failing. This function could fail if, for example, the
31000
+ ** current working directory has been unlinked.
31001
+ */
31002
+ SimulateIOError( return SQLITE_ERROR );
3095231003
UNUSED_PARAMETER(nFull);
3095331004
zConverted = convertUtf8Filename(zRelative);
3095431005
if( isNT() ){
3095531006
WCHAR *zTemp;
3095631007
nByte = GetFullPathNameW((WCHAR*)zConverted, 0, 0, 0) + 3;
@@ -31014,11 +31065,13 @@
3101431065
/*
3101531066
** We need to get the full path name of the file
3101631067
** to get the drive letter to look up the sector
3101731068
** size.
3101831069
*/
31070
+ SimulateIOErrorBenign(1);
3101931071
rc = winFullPathname(pVfs, zRelative, MAX_PATH, zFullpath);
31072
+ SimulateIOErrorBenign(0);
3102031073
if( rc == SQLITE_OK )
3102131074
{
3102231075
void *zConverted = convertUtf8Filename(zFullpath);
3102331076
if( zConverted ){
3102431077
if( isNT() ){
@@ -36166,10 +36219,11 @@
3616636219
3616736220
/* Set the database size back to the value it was before the savepoint
3616836221
** being reverted was opened.
3616936222
*/
3617036223
pPager->dbSize = pSavepoint ? pSavepoint->nOrig : pPager->dbOrigSize;
36224
+ pPager->changeCountDone = pPager->tempFile;
3617136225
3617236226
if( !pSavepoint && pagerUseWal(pPager) ){
3617336227
return pagerRollbackWal(pPager);
3617436228
}
3617536229
@@ -36983,11 +37037,12 @@
3698337037
}
3698437038
3698537039
/* Before the first write, give the VFS a hint of what the final
3698637040
** file size will be.
3698737041
*/
36988
- if( pPager->dbSize > (pPager->dbOrigSize+1) && isOpen(pPager->fd) ){
37042
+ assert( rc!=SQLITE_OK || isOpen(pPager->fd) );
37043
+ if( rc==SQLITE_OK && pPager->dbSize>(pPager->dbOrigSize+1) ){
3698937044
sqlite3_int64 szFile = pPager->pageSize * (sqlite3_int64)pPager->dbSize;
3699037045
sqlite3OsFileControl(pPager->fd, SQLITE_FCNTL_SIZE_HINT, &szFile);
3699137046
}
3699237047
3699337048
while( rc==SQLITE_OK && pList ){
@@ -40983,11 +41038,10 @@
4098341038
4098441039
pRet->pVfs = pVfs;
4098541040
pRet->pWalFd = (sqlite3_file *)&pRet[1];
4098641041
pRet->pDbFd = pDbFd;
4098741042
pRet->readLock = -1;
40988
- sqlite3_randomness(8, &pRet->hdr.aSalt);
4098941043
pRet->zWalName = zWalName;
4099041044
rc = sqlite3OsShmOpen(pDbFd);
4099141045
4099241046
/* Open file handle on the write-ahead log file. */
4099341047
if( rc==SQLITE_OK ){
@@ -42156,10 +42210,11 @@
4215642210
4215742211
sqlite3Put4byte(&aWalHdr[0], (WAL_MAGIC | SQLITE_BIGENDIAN));
4215842212
sqlite3Put4byte(&aWalHdr[4], WAL_MAX_VERSION);
4215942213
sqlite3Put4byte(&aWalHdr[8], szPage);
4216042214
sqlite3Put4byte(&aWalHdr[12], pWal->nCkpt);
42215
+ sqlite3_randomness(8, pWal->hdr.aSalt);
4216142216
memcpy(&aWalHdr[16], pWal->hdr.aSalt, 8);
4216242217
walChecksumBytes(1, aWalHdr, WAL_HDRSIZE-2*4, 0, aCksum);
4216342218
sqlite3Put4byte(&aWalHdr[24], aCksum[0]);
4216442219
sqlite3Put4byte(&aWalHdr[28], aCksum[1]);
4216542220
@@ -63531,15 +63586,10 @@
6353163586
** operation. No IO is required.
6353263587
**
6353363588
** If changing into or out of WAL mode the procedure is more complicated.
6353463589
**
6353563590
** Write a string containing the final journal-mode to register P2.
63536
-**
63537
-** If an attempt to change in to or out of WAL mode fails because another
63538
-** connection also has the same database open, then an SQLITE_BUSY error
63539
-** is raised if P5==0, or of P5!=0 the journal mode changed is skipped
63540
-** without signaling the error.
6354163591
*/
6354263592
case OP_JournalMode: { /* out2-prerelease */
6354363593
#if 0 /* local variables moved into u.cd */
6354463594
Btree *pBt; /* Btree to change journal mode of */
6354563595
Pager *pPager; /* Pager associated with pBt */
@@ -63635,11 +63685,10 @@
6363563685
}
6363663686
}
6363763687
#endif /* ifndef SQLITE_OMIT_WAL */
6363863688
6363963689
if( rc ){
63640
- if( rc==SQLITE_BUSY && pOp->p5!=0 ) rc = SQLITE_OK;
6364163690
u.cd.eNew = u.cd.eOld;
6364263691
}
6364363692
u.cd.eNew = sqlite3PagerSetJournalMode(u.cd.pPager, u.cd.eNew);
6364463693
6364563694
pOut = &aMem[pOp->p2];
@@ -71860,12 +71909,10 @@
7186071909
"attached databases must use the same text encoding as main database");
7186171910
rc = SQLITE_ERROR;
7186271911
}
7186371912
pPager = sqlite3BtreePager(aNew->pBt);
7186471913
sqlite3PagerLockingMode(pPager, db->dfltLockMode);
71865
- /* journal_mode set by the OP_JournalMode opcode that will following
71866
- ** the OP_Function opcode that invoked this function. */
7186771914
sqlite3BtreeSecureDelete(aNew->pBt,
7186871915
sqlite3BtreeSecureDelete(db->aDb[0].pBt,-1) );
7186971916
}
7187071917
aNew->safety_level = 3;
7187171918
aNew->zName = sqlite3DbStrDup(db, zName);
@@ -72057,21 +72104,10 @@
7205772104
sqlite3VdbeAddOp3(v, OP_Function, 0, regArgs+3-pFunc->nArg, regArgs+3);
7205872105
assert( pFunc->nArg==-1 || (pFunc->nArg&0xff)==pFunc->nArg );
7205972106
sqlite3VdbeChangeP5(v, (u8)(pFunc->nArg));
7206072107
sqlite3VdbeChangeP4(v, -1, (char *)pFunc, P4_FUNCDEF);
7206172108
72062
- if( type==SQLITE_ATTACH ){
72063
- /* On an attach, also set the journal mode. Note that
72064
- ** sqlite3VdbeUsesBtree() is not call here since the iDb index
72065
- ** will be out of range prior to the new database being attached.
72066
- ** The OP_JournalMode opcode will all sqlite3VdbeUsesBtree() for us.
72067
- */
72068
- sqlite3VdbeAddOp3(v, OP_JournalMode, db->nDb, regArgs+3,
72069
- db->dfltJournalMode);
72070
- sqlite3VdbeChangeP5(v, 1);
72071
- }
72072
-
7207372109
/* Code an OP_Expire. For an ATTACH statement, set P1 to true (expire this
7207472110
** statement only). For DETACH, set it to false (expire all existing
7207572111
** statements).
7207672112
*/
7207772113
sqlite3VdbeAddOp1(v, OP_Expire, (type==SQLITE_ATTACH));
@@ -75944,11 +75980,10 @@
7594475980
assert( db->aDb[1].pSchema );
7594575981
if( SQLITE_NOMEM==sqlite3BtreeSetPageSize(pBt, db->nextPagesize, -1, 0) ){
7594675982
db->mallocFailed = 1;
7594775983
return 1;
7594875984
}
75949
- sqlite3PagerSetJournalMode(sqlite3BtreePager(pBt), db->dfltJournalMode);
7595075985
}
7595175986
return 0;
7595275987
}
7595375988
7595475989
/*
@@ -83613,62 +83648,49 @@
8361383648
** PRAGMA [database.]journal_mode
8361483649
** PRAGMA [database.]journal_mode =
8361583650
** (delete|persist|off|truncate|memory|wal|off)
8361683651
*/
8361783652
if( sqlite3StrICmp(zLeft,"journal_mode")==0 ){
83618
- int eMode; /* One of the PAGER_JOURNALMODE_XXX symbols */
83653
+ int eMode; /* One of the PAGER_JOURNALMODE_XXX symbols */
83654
+ int ii; /* Loop counter */
8361983655
83656
+ /* Force the schema to be loaded on all databases. This cases all
83657
+ ** database files to be opened and the journal_modes set. */
8362083658
if( sqlite3ReadSchema(pParse) ){
8362183659
goto pragma_out;
8362283660
}
8362383661
8362483662
sqlite3VdbeSetNumCols(v, 1);
8362583663
sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "journal_mode", SQLITE_STATIC);
8362683664
8362783665
if( zRight==0 ){
83666
+ /* If there is no "=MODE" part of the pragma, do a query for the
83667
+ ** current mode */
8362883668
eMode = PAGER_JOURNALMODE_QUERY;
8362983669
}else{
8363083670
const char *zMode;
8363183671
int n = sqlite3Strlen30(zRight);
8363283672
for(eMode=0; (zMode = sqlite3JournalModename(eMode))!=0; eMode++){
8363383673
if( sqlite3StrNICmp(zRight, zMode, n)==0 ) break;
8363483674
}
8363583675
if( !zMode ){
83676
+ /* If the "=MODE" part does not match any known journal mode,
83677
+ ** then do a query */
8363683678
eMode = PAGER_JOURNALMODE_QUERY;
8363783679
}
8363883680
}
83639
- if( pId2->n==0 && eMode==PAGER_JOURNALMODE_QUERY ){
83640
- /* Simple "PRAGMA journal_mode;" statement. This is a query for
83641
- ** the current default journal mode (which may be different to
83642
- ** the journal-mode of the main database).
83643
- */
83644
- eMode = db->dfltJournalMode;
83645
- sqlite3VdbeAddOp2(v, OP_String8, 0, 1);
83646
- sqlite3VdbeChangeP4(v, -1, sqlite3JournalModename(eMode), P4_STATIC);
83647
- }else{
83648
- int ii;
83649
-
83650
- if( pId2->n==0 ){
83651
- /* When there is no database name before the "journal_mode" keyword
83652
- ** in the PRAGMA, then the journal-mode will be set on
83653
- ** all attached databases, as well as the main db file.
83654
- **
83655
- ** Also, the sqlite3.dfltJournalMode variable is set so that
83656
- ** any subsequently attached databases also use the specified
83657
- ** journal mode.
83658
- */
83659
- db->dfltJournalMode = (u8)eMode;
83660
- }
83661
-
83662
- for(ii=db->nDb-1; ii>=0; ii--){
83663
- if( db->aDb[ii].pBt && (ii==iDb || pId2->n==0) ){
83664
- sqlite3VdbeUsesBtree(v, ii);
83665
- sqlite3VdbeAddOp3(v, OP_JournalMode, ii, 1, eMode);
83666
- }
83667
- }
83668
- }
83669
-
83681
+ if( eMode==PAGER_JOURNALMODE_QUERY && pId2->n==0 ){
83682
+ /* Convert "PRAGMA journal_mode" into "PRAGMA main.journal_mode" */
83683
+ iDb = 0;
83684
+ pId2->n = 1;
83685
+ }
83686
+ for(ii=db->nDb-1; ii>=0; ii--){
83687
+ if( db->aDb[ii].pBt && (ii==iDb || pId2->n==0) ){
83688
+ sqlite3VdbeUsesBtree(v, ii);
83689
+ sqlite3VdbeAddOp3(v, OP_JournalMode, ii, 1, eMode);
83690
+ }
83691
+ }
8367083692
sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 1);
8367183693
}else
8367283694
8367383695
/*
8367483696
** PRAGMA [database.]journal_size_limit
8367583697
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -643,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 **
@@ -8572,11 +8572,10 @@
8572 int errMask; /* & result codes with this before returning */
8573 u8 autoCommit; /* The auto-commit flag. */
8574 u8 temp_store; /* 1: file 2: memory 0: default */
8575 u8 mallocFailed; /* True if we have seen a malloc failure */
8576 u8 dfltLockMode; /* Default locking-mode for attached dbs */
8577 u8 dfltJournalMode; /* Default journal mode for attached dbs */
8578 signed char nextAutovac; /* Autovac setting after VACUUM if >=0 */
8579 u8 suppressErr; /* Do not issue error messages if true */
8580 int nextPagesize; /* Pagesize after VACUUM if >0 */
8581 int nTable; /* Number of tables in the database */
8582 CollSeq *pDfltColl; /* The default collating sequence (BINARY) */
@@ -29420,10 +29419,11 @@
29420 assert( id!=0 );
29421 assert( pFile->pShm==0 );
29422 OSTRACE(("CLOSE %d\n", pFile->h));
29423 do{
29424 rc = CloseHandle(pFile->h);
 
29425 }while( rc==0 && ++cnt < MX_CLOSE_ATTEMPT && (Sleep(100), 1) );
29426 #if SQLITE_OS_WINCE
29427 #define WINCE_DELETION_ATTEMPTS 3
29428 winceDestroyLock(pFile);
29429 if( pFile->zDeleteOnClose ){
@@ -29577,31 +29577,44 @@
29577
29578 /*
29579 ** Make sure all writes to a particular file are committed to disk.
29580 */
29581 static int winSync(sqlite3_file *id, int flags){
29582 #ifndef SQLITE_NO_SYNC
29583 winFile *pFile = (winFile*)id;
29584
29585 assert( id!=0 );
29586 OSTRACE(("SYNC %d lock=%d\n", pFile->h, pFile->locktype));
29587 #else
29588 UNUSED_PARAMETER(id);
29589 #endif
 
 
 
 
 
 
 
 
 
29590 #ifndef SQLITE_TEST
29591 UNUSED_PARAMETER(flags);
29592 #else
29593 if( flags & SQLITE_SYNC_FULL ){
29594 sqlite3_fullsync_count++;
29595 }
29596 sqlite3_sync_count++;
29597 #endif
 
 
 
 
 
 
 
29598 /* If we compiled with the SQLITE_NO_SYNC flag, then syncing is a
29599 ** no-op
29600 */
29601 #ifdef SQLITE_NO_SYNC
29602 return SQLITE_OK;
29603 #else
29604 if( FlushFileBuffers(pFile->h) ){
29605 return SQLITE_OK;
29606 }else{
29607 pFile->lastErrno = GetLastError();
@@ -29840,10 +29853,12 @@
29840 */
29841 static int winCheckReservedLock(sqlite3_file *id, int *pResOut){
29842 int rc;
29843 winFile *pFile = (winFile*)id;
29844
 
 
29845 assert( id!=0 );
29846 if( pFile->locktype>=RESERVED_LOCK ){
29847 rc = 1;
29848 OSTRACE(("TEST WR-LOCK %d %d (local)\n", pFile->h, rc));
29849 }else{
@@ -29912,11 +29927,13 @@
29912 *(int*)pArg = (int)((winFile*)id)->lastErrno;
29913 return SQLITE_OK;
29914 }
29915 case SQLITE_FCNTL_SIZE_HINT: {
29916 sqlite3_int64 sz = *(sqlite3_int64*)pArg;
 
29917 winTruncate(id, sz);
 
29918 return SQLITE_OK;
29919 }
29920 }
29921 return SQLITE_ERROR;
29922 }
@@ -30123,14 +30140,20 @@
30123 if( p->mutex ) sqlite3_mutex_free(p->mutex);
30124 for(i=0; i<p->nRegion; i++){
30125 UnmapViewOfFile(p->aRegion[i].pMap);
30126 CloseHandle(p->aRegion[i].hMap);
30127 }
30128 if( p->hFile.h != INVALID_HANDLE_VALUE ) {
 
30129 winClose((sqlite3_file *)&p->hFile);
 
30130 }
30131 if( deleteFlag ) winDelete(pVfs, p->zFilename, 0);
 
 
 
 
30132 *pp = p->pNext;
30133 sqlite3_free(p->aRegion);
30134 sqlite3_free(p);
30135 }else{
30136 pp = &p->pNext;
@@ -30528,10 +30551,17 @@
30528 "abcdefghijklmnopqrstuvwxyz"
30529 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
30530 "0123456789";
30531 size_t i, j;
30532 char zTempPath[MAX_PATH+1];
 
 
 
 
 
 
 
30533 if( sqlite3_temp_directory ){
30534 sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", sqlite3_temp_directory);
30535 }else if( isNT() ){
30536 char *zMulti;
30537 WCHAR zWidePath[MAX_PATH];
@@ -30559,20 +30589,30 @@
30559 }else{
30560 return SQLITE_NOMEM;
30561 }
30562 #endif
30563 }
 
 
 
 
 
 
 
 
30564 for(i=sqlite3Strlen30(zTempPath); i>0 && zTempPath[i-1]=='\\'; i--){}
30565 zTempPath[i] = 0;
30566 sqlite3_snprintf(nBuf-30, zBuf,
 
30567 "%s\\"SQLITE_TEMP_FILE_PREFIX, zTempPath);
30568 j = sqlite3Strlen30(zBuf);
30569 sqlite3_randomness(20, &zBuf[j]);
30570 for(i=0; i<20; i++, j++){
30571 zBuf[j] = (char)zChars[ ((unsigned char)zBuf[j])%(sizeof(zChars)-1) ];
30572 }
30573 zBuf[j] = 0;
 
30574 OSTRACE(("TEMP FILENAME: %s\n", zBuf));
30575 return SQLITE_OK;
30576 }
30577
30578 /*
@@ -30812,17 +30852,19 @@
30812 int syncDir /* Not used on win32 */
30813 ){
30814 int cnt = 0;
30815 DWORD rc;
30816 DWORD error = 0;
30817 void *zConverted = convertUtf8Filename(zFilename);
30818 UNUSED_PARAMETER(pVfs);
30819 UNUSED_PARAMETER(syncDir);
 
 
 
30820 if( zConverted==0 ){
30821 return SQLITE_NOMEM;
30822 }
30823 SimulateIOError(return SQLITE_IOERR_DELETE);
30824 if( isNT() ){
30825 do{
30826 DeleteFileW(zConverted);
30827 }while( ( ((rc = GetFileAttributesW(zConverted)) != INVALID_FILE_ATTRIBUTES)
30828 || ((error = GetLastError()) == ERROR_ACCESS_DENIED))
@@ -30931,16 +30973,18 @@
30931 int nFull, /* Size of output buffer in bytes */
30932 char *zFull /* Output buffer */
30933 ){
30934
30935 #if defined(__CYGWIN__)
 
30936 UNUSED_PARAMETER(nFull);
30937 cygwin_conv_to_full_win32_path(zRelative, zFull);
30938 return SQLITE_OK;
30939 #endif
30940
30941 #if SQLITE_OS_WINCE
 
30942 UNUSED_PARAMETER(nFull);
30943 /* WinCE has no concept of a relative pathname, or so I am told. */
30944 sqlite3_snprintf(pVfs->mxPathname, zFull, "%s", zRelative);
30945 return SQLITE_OK;
30946 #endif
@@ -30947,10 +30991,17 @@
30947
30948 #if !SQLITE_OS_WINCE && !defined(__CYGWIN__)
30949 int nByte;
30950 void *zConverted;
30951 char *zOut;
 
 
 
 
 
 
 
30952 UNUSED_PARAMETER(nFull);
30953 zConverted = convertUtf8Filename(zRelative);
30954 if( isNT() ){
30955 WCHAR *zTemp;
30956 nByte = GetFullPathNameW((WCHAR*)zConverted, 0, 0, 0) + 3;
@@ -31014,11 +31065,13 @@
31014 /*
31015 ** We need to get the full path name of the file
31016 ** to get the drive letter to look up the sector
31017 ** size.
31018 */
 
31019 rc = winFullPathname(pVfs, zRelative, MAX_PATH, zFullpath);
 
31020 if( rc == SQLITE_OK )
31021 {
31022 void *zConverted = convertUtf8Filename(zFullpath);
31023 if( zConverted ){
31024 if( isNT() ){
@@ -36166,10 +36219,11 @@
36166
36167 /* Set the database size back to the value it was before the savepoint
36168 ** being reverted was opened.
36169 */
36170 pPager->dbSize = pSavepoint ? pSavepoint->nOrig : pPager->dbOrigSize;
 
36171
36172 if( !pSavepoint && pagerUseWal(pPager) ){
36173 return pagerRollbackWal(pPager);
36174 }
36175
@@ -36983,11 +37037,12 @@
36983 }
36984
36985 /* Before the first write, give the VFS a hint of what the final
36986 ** file size will be.
36987 */
36988 if( pPager->dbSize > (pPager->dbOrigSize+1) && isOpen(pPager->fd) ){
 
36989 sqlite3_int64 szFile = pPager->pageSize * (sqlite3_int64)pPager->dbSize;
36990 sqlite3OsFileControl(pPager->fd, SQLITE_FCNTL_SIZE_HINT, &szFile);
36991 }
36992
36993 while( rc==SQLITE_OK && pList ){
@@ -40983,11 +41038,10 @@
40983
40984 pRet->pVfs = pVfs;
40985 pRet->pWalFd = (sqlite3_file *)&pRet[1];
40986 pRet->pDbFd = pDbFd;
40987 pRet->readLock = -1;
40988 sqlite3_randomness(8, &pRet->hdr.aSalt);
40989 pRet->zWalName = zWalName;
40990 rc = sqlite3OsShmOpen(pDbFd);
40991
40992 /* Open file handle on the write-ahead log file. */
40993 if( rc==SQLITE_OK ){
@@ -42156,10 +42210,11 @@
42156
42157 sqlite3Put4byte(&aWalHdr[0], (WAL_MAGIC | SQLITE_BIGENDIAN));
42158 sqlite3Put4byte(&aWalHdr[4], WAL_MAX_VERSION);
42159 sqlite3Put4byte(&aWalHdr[8], szPage);
42160 sqlite3Put4byte(&aWalHdr[12], pWal->nCkpt);
 
42161 memcpy(&aWalHdr[16], pWal->hdr.aSalt, 8);
42162 walChecksumBytes(1, aWalHdr, WAL_HDRSIZE-2*4, 0, aCksum);
42163 sqlite3Put4byte(&aWalHdr[24], aCksum[0]);
42164 sqlite3Put4byte(&aWalHdr[28], aCksum[1]);
42165
@@ -63531,15 +63586,10 @@
63531 ** operation. No IO is required.
63532 **
63533 ** If changing into or out of WAL mode the procedure is more complicated.
63534 **
63535 ** Write a string containing the final journal-mode to register P2.
63536 **
63537 ** If an attempt to change in to or out of WAL mode fails because another
63538 ** connection also has the same database open, then an SQLITE_BUSY error
63539 ** is raised if P5==0, or of P5!=0 the journal mode changed is skipped
63540 ** without signaling the error.
63541 */
63542 case OP_JournalMode: { /* out2-prerelease */
63543 #if 0 /* local variables moved into u.cd */
63544 Btree *pBt; /* Btree to change journal mode of */
63545 Pager *pPager; /* Pager associated with pBt */
@@ -63635,11 +63685,10 @@
63635 }
63636 }
63637 #endif /* ifndef SQLITE_OMIT_WAL */
63638
63639 if( rc ){
63640 if( rc==SQLITE_BUSY && pOp->p5!=0 ) rc = SQLITE_OK;
63641 u.cd.eNew = u.cd.eOld;
63642 }
63643 u.cd.eNew = sqlite3PagerSetJournalMode(u.cd.pPager, u.cd.eNew);
63644
63645 pOut = &aMem[pOp->p2];
@@ -71860,12 +71909,10 @@
71860 "attached databases must use the same text encoding as main database");
71861 rc = SQLITE_ERROR;
71862 }
71863 pPager = sqlite3BtreePager(aNew->pBt);
71864 sqlite3PagerLockingMode(pPager, db->dfltLockMode);
71865 /* journal_mode set by the OP_JournalMode opcode that will following
71866 ** the OP_Function opcode that invoked this function. */
71867 sqlite3BtreeSecureDelete(aNew->pBt,
71868 sqlite3BtreeSecureDelete(db->aDb[0].pBt,-1) );
71869 }
71870 aNew->safety_level = 3;
71871 aNew->zName = sqlite3DbStrDup(db, zName);
@@ -72057,21 +72104,10 @@
72057 sqlite3VdbeAddOp3(v, OP_Function, 0, regArgs+3-pFunc->nArg, regArgs+3);
72058 assert( pFunc->nArg==-1 || (pFunc->nArg&0xff)==pFunc->nArg );
72059 sqlite3VdbeChangeP5(v, (u8)(pFunc->nArg));
72060 sqlite3VdbeChangeP4(v, -1, (char *)pFunc, P4_FUNCDEF);
72061
72062 if( type==SQLITE_ATTACH ){
72063 /* On an attach, also set the journal mode. Note that
72064 ** sqlite3VdbeUsesBtree() is not call here since the iDb index
72065 ** will be out of range prior to the new database being attached.
72066 ** The OP_JournalMode opcode will all sqlite3VdbeUsesBtree() for us.
72067 */
72068 sqlite3VdbeAddOp3(v, OP_JournalMode, db->nDb, regArgs+3,
72069 db->dfltJournalMode);
72070 sqlite3VdbeChangeP5(v, 1);
72071 }
72072
72073 /* Code an OP_Expire. For an ATTACH statement, set P1 to true (expire this
72074 ** statement only). For DETACH, set it to false (expire all existing
72075 ** statements).
72076 */
72077 sqlite3VdbeAddOp1(v, OP_Expire, (type==SQLITE_ATTACH));
@@ -75944,11 +75980,10 @@
75944 assert( db->aDb[1].pSchema );
75945 if( SQLITE_NOMEM==sqlite3BtreeSetPageSize(pBt, db->nextPagesize, -1, 0) ){
75946 db->mallocFailed = 1;
75947 return 1;
75948 }
75949 sqlite3PagerSetJournalMode(sqlite3BtreePager(pBt), db->dfltJournalMode);
75950 }
75951 return 0;
75952 }
75953
75954 /*
@@ -83613,62 +83648,49 @@
83613 ** PRAGMA [database.]journal_mode
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 }
83638 }
83639 if( pId2->n==0 && eMode==PAGER_JOURNALMODE_QUERY ){
83640 /* Simple "PRAGMA journal_mode;" statement. This is a query for
83641 ** the current default journal mode (which may be different to
83642 ** the journal-mode of the main database).
83643 */
83644 eMode = db->dfltJournalMode;
83645 sqlite3VdbeAddOp2(v, OP_String8, 0, 1);
83646 sqlite3VdbeChangeP4(v, -1, sqlite3JournalModename(eMode), P4_STATIC);
83647 }else{
83648 int ii;
83649
83650 if( pId2->n==0 ){
83651 /* When there is no database name before the "journal_mode" keyword
83652 ** in the PRAGMA, then the journal-mode will be set on
83653 ** all attached databases, as well as the main db file.
83654 **
83655 ** Also, the sqlite3.dfltJournalMode variable is set so that
83656 ** any subsequently attached databases also use the specified
83657 ** journal mode.
83658 */
83659 db->dfltJournalMode = (u8)eMode;
83660 }
83661
83662 for(ii=db->nDb-1; ii>=0; ii--){
83663 if( db->aDb[ii].pBt && (ii==iDb || pId2->n==0) ){
83664 sqlite3VdbeUsesBtree(v, ii);
83665 sqlite3VdbeAddOp3(v, OP_JournalMode, ii, 1, eMode);
83666 }
83667 }
83668 }
83669
83670 sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 1);
83671 }else
83672
83673 /*
83674 ** PRAGMA [database.]journal_size_limit
83675
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -643,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-08 17:40:38 e396184cd3bdb96e29ac33af5d1f631cac553341"
649
650 /*
651 ** CAPI3REF: Run-Time Library Version Numbers
652 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
653 **
@@ -8572,11 +8572,10 @@
8572 int errMask; /* & result codes with this before returning */
8573 u8 autoCommit; /* The auto-commit flag. */
8574 u8 temp_store; /* 1: file 2: memory 0: default */
8575 u8 mallocFailed; /* True if we have seen a malloc failure */
8576 u8 dfltLockMode; /* Default locking-mode for attached dbs */
 
8577 signed char nextAutovac; /* Autovac setting after VACUUM if >=0 */
8578 u8 suppressErr; /* Do not issue error messages if true */
8579 int nextPagesize; /* Pagesize after VACUUM if >0 */
8580 int nTable; /* Number of tables in the database */
8581 CollSeq *pDfltColl; /* The default collating sequence (BINARY) */
@@ -29420,10 +29419,11 @@
29419 assert( id!=0 );
29420 assert( pFile->pShm==0 );
29421 OSTRACE(("CLOSE %d\n", pFile->h));
29422 do{
29423 rc = CloseHandle(pFile->h);
29424 /* SimulateIOError( rc=0; cnt=MX_CLOSE_ATTEMPT; ); */
29425 }while( rc==0 && ++cnt < MX_CLOSE_ATTEMPT && (Sleep(100), 1) );
29426 #if SQLITE_OS_WINCE
29427 #define WINCE_DELETION_ATTEMPTS 3
29428 winceDestroyLock(pFile);
29429 if( pFile->zDeleteOnClose ){
@@ -29577,31 +29577,44 @@
29577
29578 /*
29579 ** Make sure all writes to a particular file are committed to disk.
29580 */
29581 static int winSync(sqlite3_file *id, int flags){
29582 #if !defined(NDEBUG) || !defined(SQLITE_NO_SYNC) || defined(SQLITE_DEBUG)
29583 winFile *pFile = (winFile*)id;
 
 
 
29584 #else
29585 UNUSED_PARAMETER(id);
29586 #endif
29587
29588 assert( pFile );
29589 /* Check that one of SQLITE_SYNC_NORMAL or FULL was passed */
29590 assert((flags&0x0F)==SQLITE_SYNC_NORMAL
29591 || (flags&0x0F)==SQLITE_SYNC_FULL
29592 );
29593
29594 OSTRACE(("SYNC %d lock=%d\n", pFile->h, pFile->locktype));
29595
29596 #ifndef SQLITE_TEST
29597 UNUSED_PARAMETER(flags);
29598 #else
29599 if( flags & SQLITE_SYNC_FULL ){
29600 sqlite3_fullsync_count++;
29601 }
29602 sqlite3_sync_count++;
29603 #endif
29604
29605 /* Unix cannot, but some systems may return SQLITE_FULL from here. This
29606 ** line is to test that doing so does not cause any problems.
29607 */
29608 SimulateDiskfullError( return SQLITE_FULL );
29609 SimulateIOError( return SQLITE_IOERR; );
29610
29611 /* If we compiled with the SQLITE_NO_SYNC flag, then syncing is a
29612 ** no-op
29613 */
29614 #ifdef SQLITE_NO_SYNC
29615 return SQLITE_OK;
29616 #else
29617 if( FlushFileBuffers(pFile->h) ){
29618 return SQLITE_OK;
29619 }else{
29620 pFile->lastErrno = GetLastError();
@@ -29840,10 +29853,12 @@
29853 */
29854 static int winCheckReservedLock(sqlite3_file *id, int *pResOut){
29855 int rc;
29856 winFile *pFile = (winFile*)id;
29857
29858 SimulateIOError( return SQLITE_IOERR_CHECKRESERVEDLOCK; );
29859
29860 assert( id!=0 );
29861 if( pFile->locktype>=RESERVED_LOCK ){
29862 rc = 1;
29863 OSTRACE(("TEST WR-LOCK %d %d (local)\n", pFile->h, rc));
29864 }else{
@@ -29912,11 +29927,13 @@
29927 *(int*)pArg = (int)((winFile*)id)->lastErrno;
29928 return SQLITE_OK;
29929 }
29930 case SQLITE_FCNTL_SIZE_HINT: {
29931 sqlite3_int64 sz = *(sqlite3_int64*)pArg;
29932 SimulateIOErrorBenign(1);
29933 winTruncate(id, sz);
29934 SimulateIOErrorBenign(0);
29935 return SQLITE_OK;
29936 }
29937 }
29938 return SQLITE_ERROR;
29939 }
@@ -30123,14 +30140,20 @@
30140 if( p->mutex ) sqlite3_mutex_free(p->mutex);
30141 for(i=0; i<p->nRegion; i++){
30142 UnmapViewOfFile(p->aRegion[i].pMap);
30143 CloseHandle(p->aRegion[i].hMap);
30144 }
30145 if( p->hFile.h != INVALID_HANDLE_VALUE ){
30146 SimulateIOErrorBenign(1);
30147 winClose((sqlite3_file *)&p->hFile);
30148 SimulateIOErrorBenign(0);
30149 }
30150 if( deleteFlag ){
30151 SimulateIOErrorBenign(1);
30152 winDelete(pVfs, p->zFilename, 0);
30153 SimulateIOErrorBenign(0);
30154 }
30155 *pp = p->pNext;
30156 sqlite3_free(p->aRegion);
30157 sqlite3_free(p);
30158 }else{
30159 pp = &p->pNext;
@@ -30528,10 +30551,17 @@
30551 "abcdefghijklmnopqrstuvwxyz"
30552 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
30553 "0123456789";
30554 size_t i, j;
30555 char zTempPath[MAX_PATH+1];
30556
30557 /* It's odd to simulate an io-error here, but really this is just
30558 ** using the io-error infrastructure to test that SQLite handles this
30559 ** function failing.
30560 */
30561 SimulateIOError( return SQLITE_IOERR );
30562
30563 if( sqlite3_temp_directory ){
30564 sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", sqlite3_temp_directory);
30565 }else if( isNT() ){
30566 char *zMulti;
30567 WCHAR zWidePath[MAX_PATH];
@@ -30559,20 +30589,30 @@
30589 }else{
30590 return SQLITE_NOMEM;
30591 }
30592 #endif
30593 }
30594
30595 /* Check that the output buffer is large enough for the temporary file
30596 ** name. If it is not, return SQLITE_ERROR.
30597 */
30598 if( (sqlite3Strlen30(zTempPath) + sqlite3Strlen30(SQLITE_TEMP_FILE_PREFIX) + 17) >= nBuf ){
30599 return SQLITE_ERROR;
30600 }
30601
30602 for(i=sqlite3Strlen30(zTempPath); i>0 && zTempPath[i-1]=='\\'; i--){}
30603 zTempPath[i] = 0;
30604
30605 sqlite3_snprintf(nBuf-17, zBuf,
30606 "%s\\"SQLITE_TEMP_FILE_PREFIX, zTempPath);
30607 j = sqlite3Strlen30(zBuf);
30608 sqlite3_randomness(15, &zBuf[j]);
30609 for(i=0; i<15; i++, j++){
30610 zBuf[j] = (char)zChars[ ((unsigned char)zBuf[j])%(sizeof(zChars)-1) ];
30611 }
30612 zBuf[j] = 0;
30613
30614 OSTRACE(("TEMP FILENAME: %s\n", zBuf));
30615 return SQLITE_OK;
30616 }
30617
30618 /*
@@ -30812,17 +30852,19 @@
30852 int syncDir /* Not used on win32 */
30853 ){
30854 int cnt = 0;
30855 DWORD rc;
30856 DWORD error = 0;
30857 void *zConverted;
30858 UNUSED_PARAMETER(pVfs);
30859 UNUSED_PARAMETER(syncDir);
30860
30861 SimulateIOError(return SQLITE_IOERR_DELETE);
30862 zConverted = convertUtf8Filename(zFilename);
30863 if( zConverted==0 ){
30864 return SQLITE_NOMEM;
30865 }
 
30866 if( isNT() ){
30867 do{
30868 DeleteFileW(zConverted);
30869 }while( ( ((rc = GetFileAttributesW(zConverted)) != INVALID_FILE_ATTRIBUTES)
30870 || ((error = GetLastError()) == ERROR_ACCESS_DENIED))
@@ -30931,16 +30973,18 @@
30973 int nFull, /* Size of output buffer in bytes */
30974 char *zFull /* Output buffer */
30975 ){
30976
30977 #if defined(__CYGWIN__)
30978 SimulateIOError( return SQLITE_ERROR );
30979 UNUSED_PARAMETER(nFull);
30980 cygwin_conv_to_full_win32_path(zRelative, zFull);
30981 return SQLITE_OK;
30982 #endif
30983
30984 #if SQLITE_OS_WINCE
30985 SimulateIOError( return SQLITE_ERROR );
30986 UNUSED_PARAMETER(nFull);
30987 /* WinCE has no concept of a relative pathname, or so I am told. */
30988 sqlite3_snprintf(pVfs->mxPathname, zFull, "%s", zRelative);
30989 return SQLITE_OK;
30990 #endif
@@ -30947,10 +30991,17 @@
30991
30992 #if !SQLITE_OS_WINCE && !defined(__CYGWIN__)
30993 int nByte;
30994 void *zConverted;
30995 char *zOut;
30996
30997 /* It's odd to simulate an io-error here, but really this is just
30998 ** using the io-error infrastructure to test that SQLite handles this
30999 ** function failing. This function could fail if, for example, the
31000 ** current working directory has been unlinked.
31001 */
31002 SimulateIOError( return SQLITE_ERROR );
31003 UNUSED_PARAMETER(nFull);
31004 zConverted = convertUtf8Filename(zRelative);
31005 if( isNT() ){
31006 WCHAR *zTemp;
31007 nByte = GetFullPathNameW((WCHAR*)zConverted, 0, 0, 0) + 3;
@@ -31014,11 +31065,13 @@
31065 /*
31066 ** We need to get the full path name of the file
31067 ** to get the drive letter to look up the sector
31068 ** size.
31069 */
31070 SimulateIOErrorBenign(1);
31071 rc = winFullPathname(pVfs, zRelative, MAX_PATH, zFullpath);
31072 SimulateIOErrorBenign(0);
31073 if( rc == SQLITE_OK )
31074 {
31075 void *zConverted = convertUtf8Filename(zFullpath);
31076 if( zConverted ){
31077 if( isNT() ){
@@ -36166,10 +36219,11 @@
36219
36220 /* Set the database size back to the value it was before the savepoint
36221 ** being reverted was opened.
36222 */
36223 pPager->dbSize = pSavepoint ? pSavepoint->nOrig : pPager->dbOrigSize;
36224 pPager->changeCountDone = pPager->tempFile;
36225
36226 if( !pSavepoint && pagerUseWal(pPager) ){
36227 return pagerRollbackWal(pPager);
36228 }
36229
@@ -36983,11 +37037,12 @@
37037 }
37038
37039 /* Before the first write, give the VFS a hint of what the final
37040 ** file size will be.
37041 */
37042 assert( rc!=SQLITE_OK || isOpen(pPager->fd) );
37043 if( rc==SQLITE_OK && pPager->dbSize>(pPager->dbOrigSize+1) ){
37044 sqlite3_int64 szFile = pPager->pageSize * (sqlite3_int64)pPager->dbSize;
37045 sqlite3OsFileControl(pPager->fd, SQLITE_FCNTL_SIZE_HINT, &szFile);
37046 }
37047
37048 while( rc==SQLITE_OK && pList ){
@@ -40983,11 +41038,10 @@
41038
41039 pRet->pVfs = pVfs;
41040 pRet->pWalFd = (sqlite3_file *)&pRet[1];
41041 pRet->pDbFd = pDbFd;
41042 pRet->readLock = -1;
 
41043 pRet->zWalName = zWalName;
41044 rc = sqlite3OsShmOpen(pDbFd);
41045
41046 /* Open file handle on the write-ahead log file. */
41047 if( rc==SQLITE_OK ){
@@ -42156,10 +42210,11 @@
42210
42211 sqlite3Put4byte(&aWalHdr[0], (WAL_MAGIC | SQLITE_BIGENDIAN));
42212 sqlite3Put4byte(&aWalHdr[4], WAL_MAX_VERSION);
42213 sqlite3Put4byte(&aWalHdr[8], szPage);
42214 sqlite3Put4byte(&aWalHdr[12], pWal->nCkpt);
42215 sqlite3_randomness(8, pWal->hdr.aSalt);
42216 memcpy(&aWalHdr[16], pWal->hdr.aSalt, 8);
42217 walChecksumBytes(1, aWalHdr, WAL_HDRSIZE-2*4, 0, aCksum);
42218 sqlite3Put4byte(&aWalHdr[24], aCksum[0]);
42219 sqlite3Put4byte(&aWalHdr[28], aCksum[1]);
42220
@@ -63531,15 +63586,10 @@
63586 ** operation. No IO is required.
63587 **
63588 ** If changing into or out of WAL mode the procedure is more complicated.
63589 **
63590 ** Write a string containing the final journal-mode to register P2.
 
 
 
 
 
63591 */
63592 case OP_JournalMode: { /* out2-prerelease */
63593 #if 0 /* local variables moved into u.cd */
63594 Btree *pBt; /* Btree to change journal mode of */
63595 Pager *pPager; /* Pager associated with pBt */
@@ -63635,11 +63685,10 @@
63685 }
63686 }
63687 #endif /* ifndef SQLITE_OMIT_WAL */
63688
63689 if( rc ){
 
63690 u.cd.eNew = u.cd.eOld;
63691 }
63692 u.cd.eNew = sqlite3PagerSetJournalMode(u.cd.pPager, u.cd.eNew);
63693
63694 pOut = &aMem[pOp->p2];
@@ -71860,12 +71909,10 @@
71909 "attached databases must use the same text encoding as main database");
71910 rc = SQLITE_ERROR;
71911 }
71912 pPager = sqlite3BtreePager(aNew->pBt);
71913 sqlite3PagerLockingMode(pPager, db->dfltLockMode);
 
 
71914 sqlite3BtreeSecureDelete(aNew->pBt,
71915 sqlite3BtreeSecureDelete(db->aDb[0].pBt,-1) );
71916 }
71917 aNew->safety_level = 3;
71918 aNew->zName = sqlite3DbStrDup(db, zName);
@@ -72057,21 +72104,10 @@
72104 sqlite3VdbeAddOp3(v, OP_Function, 0, regArgs+3-pFunc->nArg, regArgs+3);
72105 assert( pFunc->nArg==-1 || (pFunc->nArg&0xff)==pFunc->nArg );
72106 sqlite3VdbeChangeP5(v, (u8)(pFunc->nArg));
72107 sqlite3VdbeChangeP4(v, -1, (char *)pFunc, P4_FUNCDEF);
72108
 
 
 
 
 
 
 
 
 
 
 
72109 /* Code an OP_Expire. For an ATTACH statement, set P1 to true (expire this
72110 ** statement only). For DETACH, set it to false (expire all existing
72111 ** statements).
72112 */
72113 sqlite3VdbeAddOp1(v, OP_Expire, (type==SQLITE_ATTACH));
@@ -75944,11 +75980,10 @@
75980 assert( db->aDb[1].pSchema );
75981 if( SQLITE_NOMEM==sqlite3BtreeSetPageSize(pBt, db->nextPagesize, -1, 0) ){
75982 db->mallocFailed = 1;
75983 return 1;
75984 }
 
75985 }
75986 return 0;
75987 }
75988
75989 /*
@@ -83613,62 +83648,49 @@
83648 ** PRAGMA [database.]journal_mode
83649 ** PRAGMA [database.]journal_mode =
83650 ** (delete|persist|off|truncate|memory|wal|off)
83651 */
83652 if( sqlite3StrICmp(zLeft,"journal_mode")==0 ){
83653 int eMode; /* One of the PAGER_JOURNALMODE_XXX symbols */
83654 int ii; /* Loop counter */
83655
83656 /* Force the schema to be loaded on all databases. This cases all
83657 ** database files to be opened and the journal_modes set. */
83658 if( sqlite3ReadSchema(pParse) ){
83659 goto pragma_out;
83660 }
83661
83662 sqlite3VdbeSetNumCols(v, 1);
83663 sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "journal_mode", SQLITE_STATIC);
83664
83665 if( zRight==0 ){
83666 /* If there is no "=MODE" part of the pragma, do a query for the
83667 ** current mode */
83668 eMode = PAGER_JOURNALMODE_QUERY;
83669 }else{
83670 const char *zMode;
83671 int n = sqlite3Strlen30(zRight);
83672 for(eMode=0; (zMode = sqlite3JournalModename(eMode))!=0; eMode++){
83673 if( sqlite3StrNICmp(zRight, zMode, n)==0 ) break;
83674 }
83675 if( !zMode ){
83676 /* If the "=MODE" part does not match any known journal mode,
83677 ** then do a query */
83678 eMode = PAGER_JOURNALMODE_QUERY;
83679 }
83680 }
83681 if( eMode==PAGER_JOURNALMODE_QUERY && pId2->n==0 ){
83682 /* Convert "PRAGMA journal_mode" into "PRAGMA main.journal_mode" */
83683 iDb = 0;
83684 pId2->n = 1;
83685 }
83686 for(ii=db->nDb-1; ii>=0; ii--){
83687 if( db->aDb[ii].pBt && (ii==iDb || pId2->n==0) ){
83688 sqlite3VdbeUsesBtree(v, ii);
83689 sqlite3VdbeAddOp3(v, OP_JournalMode, ii, 1, eMode);
83690 }
83691 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83692 sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 1);
83693 }else
83694
83695 /*
83696 ** PRAGMA [database.]journal_size_limit
83697
+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-07 14:45:41 8eefc287265443ec043bdab629597e79c9d22006"
112
+#define SQLITE_SOURCE_ID "2010-07-08 17:40:38 e396184cd3bdb96e29ac33af5d1f631cac553341"
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-07 14:45:41 8eefc287265443ec043bdab629597e79c9d22006"
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-08 17:40:38 e396184cd3bdb96e29ac33af5d1f631cac553341"
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