Fossil SCM
Update to the latest SQLite which contains a bug fix in the current-time function on windows.
Commit
34178e2771d036b90c11df7a1c7bd8b5dcfaa795
Parent
d778ffea81e7f76…
2 files changed
+114
-76
+1
-1
+114
-76
| --- src/sqlite3.c | ||
| +++ src/sqlite3.c | ||
| @@ -636,11 +636,11 @@ | ||
| 636 | 636 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 637 | 637 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 638 | 638 | */ |
| 639 | 639 | #define SQLITE_VERSION "3.7.0" |
| 640 | 640 | #define SQLITE_VERSION_NUMBER 3007000 |
| 641 | -#define SQLITE_SOURCE_ID "2010-06-21 12:47:41 ee0acef1faffd480fd2136f81fb2b6f6a17b5388" | |
| 641 | +#define SQLITE_SOURCE_ID "2010-06-23 15:18:12 51ef43b9f7db8fabf73d9c8a76dae6c275e50d58" | |
| 642 | 642 | |
| 643 | 643 | /* |
| 644 | 644 | ** CAPI3REF: Run-Time Library Version Numbers |
| 645 | 645 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 646 | 646 | ** |
| @@ -7858,10 +7858,14 @@ | ||
| 7858 | 7858 | SQLITE_PRIVATE void *sqlite3PagerTempSpace(Pager*); |
| 7859 | 7859 | SQLITE_PRIVATE int sqlite3PagerIsMemdb(Pager*); |
| 7860 | 7860 | |
| 7861 | 7861 | /* Functions used to truncate the database file. */ |
| 7862 | 7862 | SQLITE_PRIVATE void sqlite3PagerTruncateImage(Pager*,Pgno); |
| 7863 | + | |
| 7864 | +#if defined(SQLITE_HAS_CODEC) && !defined(SQLITE_OMIT_WAL) | |
| 7865 | +SQLITE_PRIVATE void *sqlite3PagerCodec(DbPage *); | |
| 7866 | +#endif | |
| 7863 | 7867 | |
| 7864 | 7868 | /* Functions to support testing and debugging. */ |
| 7865 | 7869 | #if !defined(NDEBUG) || defined(SQLITE_TEST) |
| 7866 | 7870 | SQLITE_PRIVATE Pgno sqlite3PagerPagenumber(DbPage*); |
| 7867 | 7871 | SQLITE_PRIVATE int sqlite3PagerIswriteable(DbPage*); |
| @@ -31136,11 +31140,11 @@ | ||
| 31136 | 31140 | GetSystemTimeAsFileTime( &ft ); |
| 31137 | 31141 | #endif |
| 31138 | 31142 | |
| 31139 | 31143 | *piNow = winFiletimeEpoch + |
| 31140 | 31144 | ((((sqlite3_int64)ft.dwHighDateTime)*max32BitValue) + |
| 31141 | - (sqlite3_int64)ft.dwLowDateTime)/(sqlite3_int64)1000; | |
| 31145 | + (sqlite3_int64)ft.dwLowDateTime)/(sqlite3_int64)10000; | |
| 31142 | 31146 | |
| 31143 | 31147 | #ifdef SQLITE_TEST |
| 31144 | 31148 | if( sqlite3_current_time ){ |
| 31145 | 31149 | *piNow = 1000*(sqlite3_int64)sqlite3_current_time + unixEpoch; |
| 31146 | 31150 | } |
| @@ -34772,13 +34776,14 @@ | ||
| 34772 | 34776 | static void pager_unlock(Pager *pPager){ |
| 34773 | 34777 | if( !pPager->exclusiveMode ){ |
| 34774 | 34778 | int rc = SQLITE_OK; /* Return code */ |
| 34775 | 34779 | int iDc = isOpen(pPager->fd)?sqlite3OsDeviceCharacteristics(pPager->fd):0; |
| 34776 | 34780 | |
| 34777 | - /* Always close the journal file when dropping the database lock. | |
| 34778 | - ** Otherwise, another connection with journal_mode=delete might | |
| 34779 | - ** delete the file out from under us. | |
| 34781 | + /* If the operating system support deletion of open files, then | |
| 34782 | + ** close the journal file when dropping the database lock. Otherwise | |
| 34783 | + ** another connection with journal_mode=delete might delete the file | |
| 34784 | + ** out from under us. | |
| 34780 | 34785 | */ |
| 34781 | 34786 | assert( (PAGER_JOURNALMODE_MEMORY & 5)!=1 ); |
| 34782 | 34787 | assert( (PAGER_JOURNALMODE_OFF & 5)!=1 ); |
| 34783 | 34788 | assert( (PAGER_JOURNALMODE_WAL & 5)!=1 ); |
| 34784 | 34789 | assert( (PAGER_JOURNALMODE_DELETE & 5)!=1 ); |
| @@ -35346,10 +35351,13 @@ | ||
| 35346 | 35351 | int rc; /* Return code */ |
| 35347 | 35352 | sqlite3_file *pMaster; /* Malloc'd master-journal file descriptor */ |
| 35348 | 35353 | sqlite3_file *pJournal; /* Malloc'd child-journal file descriptor */ |
| 35349 | 35354 | char *zMasterJournal = 0; /* Contents of master journal file */ |
| 35350 | 35355 | i64 nMasterJournal; /* Size of master journal file */ |
| 35356 | + char *zJournal; /* Pointer to one journal within MJ file */ | |
| 35357 | + char *zMasterPtr; /* Space to hold MJ filename from a journal file */ | |
| 35358 | + int nMasterPtr; /* Amount of space allocated to zMasterPtr[] */ | |
| 35351 | 35359 | |
| 35352 | 35360 | /* Allocate space for both the pJournal and pMaster file descriptors. |
| 35353 | 35361 | ** If successful, open the master journal file for reading. |
| 35354 | 35362 | */ |
| 35355 | 35363 | pMaster = (sqlite3_file *)sqlite3MallocZero(pVfs->szOsFile * 2); |
| @@ -35360,77 +35368,72 @@ | ||
| 35360 | 35368 | const int flags = (SQLITE_OPEN_READONLY|SQLITE_OPEN_MASTER_JOURNAL); |
| 35361 | 35369 | rc = sqlite3OsOpen(pVfs, zMaster, pMaster, flags, 0); |
| 35362 | 35370 | } |
| 35363 | 35371 | if( rc!=SQLITE_OK ) goto delmaster_out; |
| 35364 | 35372 | |
| 35365 | - rc = sqlite3OsFileSize(pMaster, &nMasterJournal); | |
| 35366 | - if( rc!=SQLITE_OK ) goto delmaster_out; | |
| 35367 | - | |
| 35368 | - if( nMasterJournal>0 ){ | |
| 35369 | - char *zJournal; | |
| 35370 | - char *zMasterPtr = 0; | |
| 35371 | - int nMasterPtr = pVfs->mxPathname+1; | |
| 35372 | - | |
| 35373 | - /* Load the entire master journal file into space obtained from | |
| 35374 | - ** sqlite3_malloc() and pointed to by zMasterJournal. | |
| 35375 | - */ | |
| 35376 | - zMasterJournal = sqlite3Malloc((int)nMasterJournal + nMasterPtr + 1); | |
| 35377 | - if( !zMasterJournal ){ | |
| 35378 | - rc = SQLITE_NOMEM; | |
| 35379 | - goto delmaster_out; | |
| 35380 | - } | |
| 35381 | - zMasterPtr = &zMasterJournal[nMasterJournal+1]; | |
| 35382 | - rc = sqlite3OsRead(pMaster, zMasterJournal, (int)nMasterJournal, 0); | |
| 35383 | - if( rc!=SQLITE_OK ) goto delmaster_out; | |
| 35384 | - zMasterJournal[nMasterJournal] = 0; | |
| 35385 | - | |
| 35386 | - zJournal = zMasterJournal; | |
| 35387 | - while( (zJournal-zMasterJournal)<nMasterJournal ){ | |
| 35388 | - int exists; | |
| 35389 | - rc = sqlite3OsAccess(pVfs, zJournal, SQLITE_ACCESS_EXISTS, &exists); | |
| 35390 | - if( rc!=SQLITE_OK ){ | |
| 35391 | - goto delmaster_out; | |
| 35392 | - } | |
| 35393 | - if( exists ){ | |
| 35394 | - /* One of the journals pointed to by the master journal exists. | |
| 35395 | - ** Open it and check if it points at the master journal. If | |
| 35396 | - ** so, return without deleting the master journal file. | |
| 35397 | - */ | |
| 35398 | - int c; | |
| 35399 | - int flags = (SQLITE_OPEN_READONLY|SQLITE_OPEN_MAIN_JOURNAL); | |
| 35400 | - rc = sqlite3OsOpen(pVfs, zJournal, pJournal, flags, 0); | |
| 35401 | - if( rc!=SQLITE_OK ){ | |
| 35402 | - goto delmaster_out; | |
| 35403 | - } | |
| 35404 | - | |
| 35405 | - rc = readMasterJournal(pJournal, zMasterPtr, nMasterPtr); | |
| 35406 | - sqlite3OsClose(pJournal); | |
| 35407 | - if( rc!=SQLITE_OK ){ | |
| 35408 | - goto delmaster_out; | |
| 35409 | - } | |
| 35410 | - | |
| 35411 | - c = zMasterPtr[0]!=0 && strcmp(zMasterPtr, zMaster)==0; | |
| 35412 | - if( c ){ | |
| 35413 | - /* We have a match. Do not delete the master journal file. */ | |
| 35414 | - goto delmaster_out; | |
| 35415 | - } | |
| 35416 | - } | |
| 35417 | - zJournal += (sqlite3Strlen30(zJournal)+1); | |
| 35418 | - } | |
| 35419 | - } | |
| 35420 | - | |
| 35373 | + /* Load the entire master journal file into space obtained from | |
| 35374 | + ** sqlite3_malloc() and pointed to by zMasterJournal. Also obtain | |
| 35375 | + ** sufficient space (in zMasterPtr) to hold the names of master | |
| 35376 | + ** journal files extracted from regular rollback-journals. | |
| 35377 | + */ | |
| 35378 | + rc = sqlite3OsFileSize(pMaster, &nMasterJournal); | |
| 35379 | + if( rc!=SQLITE_OK ) goto delmaster_out; | |
| 35380 | + nMasterPtr = pVfs->mxPathname+1; | |
| 35381 | + zMasterJournal = sqlite3Malloc((int)nMasterJournal + nMasterPtr + 1); | |
| 35382 | + if( !zMasterJournal ){ | |
| 35383 | + rc = SQLITE_NOMEM; | |
| 35384 | + goto delmaster_out; | |
| 35385 | + } | |
| 35386 | + zMasterPtr = &zMasterJournal[nMasterJournal+1]; | |
| 35387 | + rc = sqlite3OsRead(pMaster, zMasterJournal, (int)nMasterJournal, 0); | |
| 35388 | + if( rc!=SQLITE_OK ) goto delmaster_out; | |
| 35389 | + zMasterJournal[nMasterJournal] = 0; | |
| 35390 | + | |
| 35391 | + zJournal = zMasterJournal; | |
| 35392 | + while( (zJournal-zMasterJournal)<nMasterJournal ){ | |
| 35393 | + int exists; | |
| 35394 | + rc = sqlite3OsAccess(pVfs, zJournal, SQLITE_ACCESS_EXISTS, &exists); | |
| 35395 | + if( rc!=SQLITE_OK ){ | |
| 35396 | + goto delmaster_out; | |
| 35397 | + } | |
| 35398 | + if( exists ){ | |
| 35399 | + /* One of the journals pointed to by the master journal exists. | |
| 35400 | + ** Open it and check if it points at the master journal. If | |
| 35401 | + ** so, return without deleting the master journal file. | |
| 35402 | + */ | |
| 35403 | + int c; | |
| 35404 | + int flags = (SQLITE_OPEN_READONLY|SQLITE_OPEN_MAIN_JOURNAL); | |
| 35405 | + rc = sqlite3OsOpen(pVfs, zJournal, pJournal, flags, 0); | |
| 35406 | + if( rc!=SQLITE_OK ){ | |
| 35407 | + goto delmaster_out; | |
| 35408 | + } | |
| 35409 | + | |
| 35410 | + rc = readMasterJournal(pJournal, zMasterPtr, nMasterPtr); | |
| 35411 | + sqlite3OsClose(pJournal); | |
| 35412 | + if( rc!=SQLITE_OK ){ | |
| 35413 | + goto delmaster_out; | |
| 35414 | + } | |
| 35415 | + | |
| 35416 | + c = zMasterPtr[0]!=0 && strcmp(zMasterPtr, zMaster)==0; | |
| 35417 | + if( c ){ | |
| 35418 | + /* We have a match. Do not delete the master journal file. */ | |
| 35419 | + goto delmaster_out; | |
| 35420 | + } | |
| 35421 | + } | |
| 35422 | + zJournal += (sqlite3Strlen30(zJournal)+1); | |
| 35423 | + } | |
| 35424 | + | |
| 35425 | + sqlite3OsClose(pMaster); | |
| 35421 | 35426 | rc = sqlite3OsDelete(pVfs, zMaster, 0); |
| 35422 | 35427 | |
| 35423 | 35428 | delmaster_out: |
| 35424 | - if( zMasterJournal ){ | |
| 35425 | - sqlite3_free(zMasterJournal); | |
| 35426 | - } | |
| 35429 | + sqlite3_free(zMasterJournal); | |
| 35427 | 35430 | if( pMaster ){ |
| 35428 | 35431 | sqlite3OsClose(pMaster); |
| 35429 | 35432 | assert( !isOpen(pJournal) ); |
| 35433 | + sqlite3_free(pMaster); | |
| 35430 | 35434 | } |
| 35431 | - sqlite3_free(pMaster); | |
| 35432 | 35435 | return rc; |
| 35433 | 35436 | } |
| 35434 | 35437 | |
| 35435 | 35438 | |
| 35436 | 35439 | /* |
| @@ -36125,11 +36128,11 @@ | ||
| 36125 | 36128 | for(ii=0; rc==SQLITE_OK && ii<nJRec && pPager->journalOff<szJ; ii++){ |
| 36126 | 36129 | rc = pager_playback_one_page(pPager, &pPager->journalOff, pDone, 1, 1); |
| 36127 | 36130 | } |
| 36128 | 36131 | assert( rc!=SQLITE_DONE ); |
| 36129 | 36132 | } |
| 36130 | - assert( rc!=SQLITE_OK || pPager->journalOff==szJ ); | |
| 36133 | + assert( rc!=SQLITE_OK || pPager->journalOff>=szJ ); | |
| 36131 | 36134 | |
| 36132 | 36135 | /* Finally, rollback pages from the sub-journal. Page that were |
| 36133 | 36136 | ** previously rolled back out of the main journal (and are hence in pDone) |
| 36134 | 36137 | ** will be skipped. Out-of-range pages are also skipped. |
| 36135 | 36138 | */ |
| @@ -38256,11 +38259,11 @@ | ||
| 38256 | 38259 | */ |
| 38257 | 38260 | rc = sqlite3PagerBegin(pPager, 0, pPager->subjInMemory); |
| 38258 | 38261 | if( rc!=SQLITE_OK ){ |
| 38259 | 38262 | return rc; |
| 38260 | 38263 | } |
| 38261 | - if( !isOpen(pPager->jfd) | |
| 38264 | + if( pPager->pInJournal==0 | |
| 38262 | 38265 | && pPager->journalMode!=PAGER_JOURNALMODE_OFF |
| 38263 | 38266 | && !pagerUseWal(pPager) |
| 38264 | 38267 | ){ |
| 38265 | 38268 | assert( pPager->useJournal ); |
| 38266 | 38269 | rc = pager_open_journal(pPager); |
| @@ -38571,13 +38574,16 @@ | ||
| 38571 | 38574 | put32bits(((char*)pPgHdr->pData)+92, change_counter); |
| 38572 | 38575 | put32bits(((char*)pPgHdr->pData)+96, SQLITE_VERSION_NUMBER); |
| 38573 | 38576 | |
| 38574 | 38577 | /* If running in direct mode, write the contents of page 1 to the file. */ |
| 38575 | 38578 | if( DIRECT_MODE ){ |
| 38576 | - const void *zBuf = pPgHdr->pData; | |
| 38579 | + const void *zBuf; | |
| 38577 | 38580 | assert( pPager->dbFileSize>0 ); |
| 38578 | - rc = sqlite3OsWrite(pPager->fd, zBuf, pPager->pageSize, 0); | |
| 38581 | + CODEC2(pPager, pPgHdr->pData, 1, 6, rc=SQLITE_NOMEM, zBuf); | |
| 38582 | + if( rc==SQLITE_OK ){ | |
| 38583 | + rc = sqlite3OsWrite(pPager->fd, zBuf, pPager->pageSize, 0); | |
| 38584 | + } | |
| 38579 | 38585 | if( rc==SQLITE_OK ){ |
| 38580 | 38586 | pPager->changeCountDone = 1; |
| 38581 | 38587 | } |
| 38582 | 38588 | }else{ |
| 38583 | 38589 | pPager->changeCountDone = 1; |
| @@ -39647,11 +39653,27 @@ | ||
| 39647 | 39653 | sqlite3OsUnlock(pPager->fd, SQLITE_LOCK_SHARED); |
| 39648 | 39654 | } |
| 39649 | 39655 | } |
| 39650 | 39656 | return rc; |
| 39651 | 39657 | } |
| 39652 | -#endif | |
| 39658 | + | |
| 39659 | +#ifdef SQLITE_HAS_CODEC | |
| 39660 | +/* | |
| 39661 | +** This function is called by the wal module when writing page content | |
| 39662 | +** into the log file. | |
| 39663 | +** | |
| 39664 | +** This function returns a pointer to a buffer containing the encrypted | |
| 39665 | +** page content. If a malloc fails, this function may return NULL. | |
| 39666 | +*/ | |
| 39667 | +SQLITE_PRIVATE void *sqlite3PagerCodec(PgHdr *pPg){ | |
| 39668 | + void *aData = 0; | |
| 39669 | + CODEC2(pPg->pPager, pPg->pData, pPg->pgno, 6, return 0, aData); | |
| 39670 | + return aData; | |
| 39671 | +} | |
| 39672 | +#endif /* SQLITE_HAS_CODEC */ | |
| 39673 | + | |
| 39674 | +#endif /* !SQLITE_OMIT_WAL */ | |
| 39653 | 39675 | |
| 39654 | 39676 | #endif /* SQLITE_OMIT_DISKIO */ |
| 39655 | 39677 | |
| 39656 | 39678 | /************** End of pager.c ***********************************************/ |
| 39657 | 39679 | /************** Begin file wal.c *********************************************/ |
| @@ -41940,23 +41962,30 @@ | ||
| 41940 | 41962 | |
| 41941 | 41963 | /* Write the log file. */ |
| 41942 | 41964 | for(p=pList; p; p=p->pDirty){ |
| 41943 | 41965 | u32 nDbsize; /* Db-size field for frame header */ |
| 41944 | 41966 | i64 iOffset; /* Write offset in log file */ |
| 41945 | - | |
| 41967 | + void *pData; | |
| 41968 | + | |
| 41969 | + | |
| 41946 | 41970 | iOffset = walFrameOffset(++iFrame, szPage); |
| 41947 | 41971 | |
| 41948 | 41972 | /* Populate and write the frame header */ |
| 41949 | 41973 | nDbsize = (isCommit && p->pDirty==0) ? nTruncate : 0; |
| 41950 | - walEncodeFrame(pWal, p->pgno, nDbsize, p->pData, aFrame); | |
| 41974 | +#if defined(SQLITE_HAS_CODEC) | |
| 41975 | + if( (pData = sqlite3PagerCodec(p))==0 ) return SQLITE_NOMEM; | |
| 41976 | +#else | |
| 41977 | + pData = p->pData; | |
| 41978 | +#endif | |
| 41979 | + walEncodeFrame(pWal, p->pgno, nDbsize, pData, aFrame); | |
| 41951 | 41980 | rc = sqlite3OsWrite(pWal->pWalFd, aFrame, sizeof(aFrame), iOffset); |
| 41952 | 41981 | if( rc!=SQLITE_OK ){ |
| 41953 | 41982 | return rc; |
| 41954 | 41983 | } |
| 41955 | 41984 | |
| 41956 | 41985 | /* Write the page data */ |
| 41957 | - rc = sqlite3OsWrite(pWal->pWalFd, p->pData, szPage, iOffset+sizeof(aFrame)); | |
| 41986 | + rc = sqlite3OsWrite(pWal->pWalFd, pData, szPage, iOffset+sizeof(aFrame)); | |
| 41958 | 41987 | if( rc!=SQLITE_OK ){ |
| 41959 | 41988 | return rc; |
| 41960 | 41989 | } |
| 41961 | 41990 | pLast = p; |
| 41962 | 41991 | } |
| @@ -41969,18 +41998,23 @@ | ||
| 41969 | 41998 | assert( isCommit ); |
| 41970 | 41999 | assert( iSegment>0 ); |
| 41971 | 42000 | |
| 41972 | 42001 | iSegment = (((iOffset+iSegment-1)/iSegment) * iSegment); |
| 41973 | 42002 | while( iOffset<iSegment ){ |
| 41974 | - walEncodeFrame(pWal, pLast->pgno, nTruncate, pLast->pData, aFrame); | |
| 42003 | + void *pData; | |
| 42004 | +#if defined(SQLITE_HAS_CODEC) | |
| 42005 | + if( (pData = sqlite3PagerCodec(pLast))==0 ) return SQLITE_NOMEM; | |
| 42006 | +#else | |
| 42007 | + pData = pLast->pData; | |
| 42008 | +#endif | |
| 42009 | + walEncodeFrame(pWal, pLast->pgno, nTruncate, pData, aFrame); | |
| 41975 | 42010 | rc = sqlite3OsWrite(pWal->pWalFd, aFrame, sizeof(aFrame), iOffset); |
| 41976 | 42011 | if( rc!=SQLITE_OK ){ |
| 41977 | 42012 | return rc; |
| 41978 | 42013 | } |
| 41979 | - | |
| 41980 | 42014 | iOffset += WAL_FRAME_HDRSIZE; |
| 41981 | - rc = sqlite3OsWrite(pWal->pWalFd, pLast->pData, szPage, iOffset); | |
| 42015 | + rc = sqlite3OsWrite(pWal->pWalFd, pData, szPage, iOffset); | |
| 41982 | 42016 | if( rc!=SQLITE_OK ){ |
| 41983 | 42017 | return rc; |
| 41984 | 42018 | } |
| 41985 | 42019 | nLast++; |
| 41986 | 42020 | iOffset += szPage; |
| @@ -63351,10 +63385,14 @@ | ||
| 63351 | 63385 | */ |
| 63352 | 63386 | rc = sqlite3PagerCloseWal(u.cd.pPager); |
| 63353 | 63387 | if( rc==SQLITE_OK ){ |
| 63354 | 63388 | sqlite3PagerSetJournalMode(u.cd.pPager, u.cd.eNew); |
| 63355 | 63389 | } |
| 63390 | + }else if( u.cd.eOld==PAGER_JOURNALMODE_MEMORY ){ | |
| 63391 | + /* Cannot transition directly from MEMORY to WAL. Use mode OFF | |
| 63392 | + ** as an intermediate */ | |
| 63393 | + sqlite3PagerSetJournalMode(u.cd.pPager, PAGER_JOURNALMODE_OFF); | |
| 63356 | 63394 | } |
| 63357 | 63395 | |
| 63358 | 63396 | /* Open a transaction on the database file. Regardless of the journal |
| 63359 | 63397 | ** mode, this transaction always uses a rollback journal. |
| 63360 | 63398 | */ |
| 63361 | 63399 |
| --- src/sqlite3.c | |
| +++ src/sqlite3.c | |
| @@ -636,11 +636,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-06-21 12:47:41 ee0acef1faffd480fd2136f81fb2b6f6a17b5388" |
| 642 | |
| 643 | /* |
| 644 | ** CAPI3REF: Run-Time Library Version Numbers |
| 645 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 646 | ** |
| @@ -7858,10 +7858,14 @@ | |
| 7858 | SQLITE_PRIVATE void *sqlite3PagerTempSpace(Pager*); |
| 7859 | SQLITE_PRIVATE int sqlite3PagerIsMemdb(Pager*); |
| 7860 | |
| 7861 | /* Functions used to truncate the database file. */ |
| 7862 | SQLITE_PRIVATE void sqlite3PagerTruncateImage(Pager*,Pgno); |
| 7863 | |
| 7864 | /* Functions to support testing and debugging. */ |
| 7865 | #if !defined(NDEBUG) || defined(SQLITE_TEST) |
| 7866 | SQLITE_PRIVATE Pgno sqlite3PagerPagenumber(DbPage*); |
| 7867 | SQLITE_PRIVATE int sqlite3PagerIswriteable(DbPage*); |
| @@ -31136,11 +31140,11 @@ | |
| 31136 | GetSystemTimeAsFileTime( &ft ); |
| 31137 | #endif |
| 31138 | |
| 31139 | *piNow = winFiletimeEpoch + |
| 31140 | ((((sqlite3_int64)ft.dwHighDateTime)*max32BitValue) + |
| 31141 | (sqlite3_int64)ft.dwLowDateTime)/(sqlite3_int64)1000; |
| 31142 | |
| 31143 | #ifdef SQLITE_TEST |
| 31144 | if( sqlite3_current_time ){ |
| 31145 | *piNow = 1000*(sqlite3_int64)sqlite3_current_time + unixEpoch; |
| 31146 | } |
| @@ -34772,13 +34776,14 @@ | |
| 34772 | static void pager_unlock(Pager *pPager){ |
| 34773 | if( !pPager->exclusiveMode ){ |
| 34774 | int rc = SQLITE_OK; /* Return code */ |
| 34775 | int iDc = isOpen(pPager->fd)?sqlite3OsDeviceCharacteristics(pPager->fd):0; |
| 34776 | |
| 34777 | /* Always close the journal file when dropping the database lock. |
| 34778 | ** Otherwise, another connection with journal_mode=delete might |
| 34779 | ** delete the file out from under us. |
| 34780 | */ |
| 34781 | assert( (PAGER_JOURNALMODE_MEMORY & 5)!=1 ); |
| 34782 | assert( (PAGER_JOURNALMODE_OFF & 5)!=1 ); |
| 34783 | assert( (PAGER_JOURNALMODE_WAL & 5)!=1 ); |
| 34784 | assert( (PAGER_JOURNALMODE_DELETE & 5)!=1 ); |
| @@ -35346,10 +35351,13 @@ | |
| 35346 | int rc; /* Return code */ |
| 35347 | sqlite3_file *pMaster; /* Malloc'd master-journal file descriptor */ |
| 35348 | sqlite3_file *pJournal; /* Malloc'd child-journal file descriptor */ |
| 35349 | char *zMasterJournal = 0; /* Contents of master journal file */ |
| 35350 | i64 nMasterJournal; /* Size of master journal file */ |
| 35351 | |
| 35352 | /* Allocate space for both the pJournal and pMaster file descriptors. |
| 35353 | ** If successful, open the master journal file for reading. |
| 35354 | */ |
| 35355 | pMaster = (sqlite3_file *)sqlite3MallocZero(pVfs->szOsFile * 2); |
| @@ -35360,77 +35368,72 @@ | |
| 35360 | const int flags = (SQLITE_OPEN_READONLY|SQLITE_OPEN_MASTER_JOURNAL); |
| 35361 | rc = sqlite3OsOpen(pVfs, zMaster, pMaster, flags, 0); |
| 35362 | } |
| 35363 | if( rc!=SQLITE_OK ) goto delmaster_out; |
| 35364 | |
| 35365 | rc = sqlite3OsFileSize(pMaster, &nMasterJournal); |
| 35366 | if( rc!=SQLITE_OK ) goto delmaster_out; |
| 35367 | |
| 35368 | if( nMasterJournal>0 ){ |
| 35369 | char *zJournal; |
| 35370 | char *zMasterPtr = 0; |
| 35371 | int nMasterPtr = pVfs->mxPathname+1; |
| 35372 | |
| 35373 | /* Load the entire master journal file into space obtained from |
| 35374 | ** sqlite3_malloc() and pointed to by zMasterJournal. |
| 35375 | */ |
| 35376 | zMasterJournal = sqlite3Malloc((int)nMasterJournal + nMasterPtr + 1); |
| 35377 | if( !zMasterJournal ){ |
| 35378 | rc = SQLITE_NOMEM; |
| 35379 | goto delmaster_out; |
| 35380 | } |
| 35381 | zMasterPtr = &zMasterJournal[nMasterJournal+1]; |
| 35382 | rc = sqlite3OsRead(pMaster, zMasterJournal, (int)nMasterJournal, 0); |
| 35383 | if( rc!=SQLITE_OK ) goto delmaster_out; |
| 35384 | zMasterJournal[nMasterJournal] = 0; |
| 35385 | |
| 35386 | zJournal = zMasterJournal; |
| 35387 | while( (zJournal-zMasterJournal)<nMasterJournal ){ |
| 35388 | int exists; |
| 35389 | rc = sqlite3OsAccess(pVfs, zJournal, SQLITE_ACCESS_EXISTS, &exists); |
| 35390 | if( rc!=SQLITE_OK ){ |
| 35391 | goto delmaster_out; |
| 35392 | } |
| 35393 | if( exists ){ |
| 35394 | /* One of the journals pointed to by the master journal exists. |
| 35395 | ** Open it and check if it points at the master journal. If |
| 35396 | ** so, return without deleting the master journal file. |
| 35397 | */ |
| 35398 | int c; |
| 35399 | int flags = (SQLITE_OPEN_READONLY|SQLITE_OPEN_MAIN_JOURNAL); |
| 35400 | rc = sqlite3OsOpen(pVfs, zJournal, pJournal, flags, 0); |
| 35401 | if( rc!=SQLITE_OK ){ |
| 35402 | goto delmaster_out; |
| 35403 | } |
| 35404 | |
| 35405 | rc = readMasterJournal(pJournal, zMasterPtr, nMasterPtr); |
| 35406 | sqlite3OsClose(pJournal); |
| 35407 | if( rc!=SQLITE_OK ){ |
| 35408 | goto delmaster_out; |
| 35409 | } |
| 35410 | |
| 35411 | c = zMasterPtr[0]!=0 && strcmp(zMasterPtr, zMaster)==0; |
| 35412 | if( c ){ |
| 35413 | /* We have a match. Do not delete the master journal file. */ |
| 35414 | goto delmaster_out; |
| 35415 | } |
| 35416 | } |
| 35417 | zJournal += (sqlite3Strlen30(zJournal)+1); |
| 35418 | } |
| 35419 | } |
| 35420 | |
| 35421 | rc = sqlite3OsDelete(pVfs, zMaster, 0); |
| 35422 | |
| 35423 | delmaster_out: |
| 35424 | if( zMasterJournal ){ |
| 35425 | sqlite3_free(zMasterJournal); |
| 35426 | } |
| 35427 | if( pMaster ){ |
| 35428 | sqlite3OsClose(pMaster); |
| 35429 | assert( !isOpen(pJournal) ); |
| 35430 | } |
| 35431 | sqlite3_free(pMaster); |
| 35432 | return rc; |
| 35433 | } |
| 35434 | |
| 35435 | |
| 35436 | /* |
| @@ -36125,11 +36128,11 @@ | |
| 36125 | for(ii=0; rc==SQLITE_OK && ii<nJRec && pPager->journalOff<szJ; ii++){ |
| 36126 | rc = pager_playback_one_page(pPager, &pPager->journalOff, pDone, 1, 1); |
| 36127 | } |
| 36128 | assert( rc!=SQLITE_DONE ); |
| 36129 | } |
| 36130 | assert( rc!=SQLITE_OK || pPager->journalOff==szJ ); |
| 36131 | |
| 36132 | /* Finally, rollback pages from the sub-journal. Page that were |
| 36133 | ** previously rolled back out of the main journal (and are hence in pDone) |
| 36134 | ** will be skipped. Out-of-range pages are also skipped. |
| 36135 | */ |
| @@ -38256,11 +38259,11 @@ | |
| 38256 | */ |
| 38257 | rc = sqlite3PagerBegin(pPager, 0, pPager->subjInMemory); |
| 38258 | if( rc!=SQLITE_OK ){ |
| 38259 | return rc; |
| 38260 | } |
| 38261 | if( !isOpen(pPager->jfd) |
| 38262 | && pPager->journalMode!=PAGER_JOURNALMODE_OFF |
| 38263 | && !pagerUseWal(pPager) |
| 38264 | ){ |
| 38265 | assert( pPager->useJournal ); |
| 38266 | rc = pager_open_journal(pPager); |
| @@ -38571,13 +38574,16 @@ | |
| 38571 | put32bits(((char*)pPgHdr->pData)+92, change_counter); |
| 38572 | put32bits(((char*)pPgHdr->pData)+96, SQLITE_VERSION_NUMBER); |
| 38573 | |
| 38574 | /* If running in direct mode, write the contents of page 1 to the file. */ |
| 38575 | if( DIRECT_MODE ){ |
| 38576 | const void *zBuf = pPgHdr->pData; |
| 38577 | assert( pPager->dbFileSize>0 ); |
| 38578 | rc = sqlite3OsWrite(pPager->fd, zBuf, pPager->pageSize, 0); |
| 38579 | if( rc==SQLITE_OK ){ |
| 38580 | pPager->changeCountDone = 1; |
| 38581 | } |
| 38582 | }else{ |
| 38583 | pPager->changeCountDone = 1; |
| @@ -39647,11 +39653,27 @@ | |
| 39647 | sqlite3OsUnlock(pPager->fd, SQLITE_LOCK_SHARED); |
| 39648 | } |
| 39649 | } |
| 39650 | return rc; |
| 39651 | } |
| 39652 | #endif |
| 39653 | |
| 39654 | #endif /* SQLITE_OMIT_DISKIO */ |
| 39655 | |
| 39656 | /************** End of pager.c ***********************************************/ |
| 39657 | /************** Begin file wal.c *********************************************/ |
| @@ -41940,23 +41962,30 @@ | |
| 41940 | |
| 41941 | /* Write the log file. */ |
| 41942 | for(p=pList; p; p=p->pDirty){ |
| 41943 | u32 nDbsize; /* Db-size field for frame header */ |
| 41944 | i64 iOffset; /* Write offset in log file */ |
| 41945 | |
| 41946 | iOffset = walFrameOffset(++iFrame, szPage); |
| 41947 | |
| 41948 | /* Populate and write the frame header */ |
| 41949 | nDbsize = (isCommit && p->pDirty==0) ? nTruncate : 0; |
| 41950 | walEncodeFrame(pWal, p->pgno, nDbsize, p->pData, aFrame); |
| 41951 | rc = sqlite3OsWrite(pWal->pWalFd, aFrame, sizeof(aFrame), iOffset); |
| 41952 | if( rc!=SQLITE_OK ){ |
| 41953 | return rc; |
| 41954 | } |
| 41955 | |
| 41956 | /* Write the page data */ |
| 41957 | rc = sqlite3OsWrite(pWal->pWalFd, p->pData, szPage, iOffset+sizeof(aFrame)); |
| 41958 | if( rc!=SQLITE_OK ){ |
| 41959 | return rc; |
| 41960 | } |
| 41961 | pLast = p; |
| 41962 | } |
| @@ -41969,18 +41998,23 @@ | |
| 41969 | assert( isCommit ); |
| 41970 | assert( iSegment>0 ); |
| 41971 | |
| 41972 | iSegment = (((iOffset+iSegment-1)/iSegment) * iSegment); |
| 41973 | while( iOffset<iSegment ){ |
| 41974 | walEncodeFrame(pWal, pLast->pgno, nTruncate, pLast->pData, aFrame); |
| 41975 | rc = sqlite3OsWrite(pWal->pWalFd, aFrame, sizeof(aFrame), iOffset); |
| 41976 | if( rc!=SQLITE_OK ){ |
| 41977 | return rc; |
| 41978 | } |
| 41979 | |
| 41980 | iOffset += WAL_FRAME_HDRSIZE; |
| 41981 | rc = sqlite3OsWrite(pWal->pWalFd, pLast->pData, szPage, iOffset); |
| 41982 | if( rc!=SQLITE_OK ){ |
| 41983 | return rc; |
| 41984 | } |
| 41985 | nLast++; |
| 41986 | iOffset += szPage; |
| @@ -63351,10 +63385,14 @@ | |
| 63351 | */ |
| 63352 | rc = sqlite3PagerCloseWal(u.cd.pPager); |
| 63353 | if( rc==SQLITE_OK ){ |
| 63354 | sqlite3PagerSetJournalMode(u.cd.pPager, u.cd.eNew); |
| 63355 | } |
| 63356 | } |
| 63357 | |
| 63358 | /* Open a transaction on the database file. Regardless of the journal |
| 63359 | ** mode, this transaction always uses a rollback journal. |
| 63360 | */ |
| 63361 |
| --- src/sqlite3.c | |
| +++ src/sqlite3.c | |
| @@ -636,11 +636,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-06-23 15:18:12 51ef43b9f7db8fabf73d9c8a76dae6c275e50d58" |
| 642 | |
| 643 | /* |
| 644 | ** CAPI3REF: Run-Time Library Version Numbers |
| 645 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 646 | ** |
| @@ -7858,10 +7858,14 @@ | |
| 7858 | SQLITE_PRIVATE void *sqlite3PagerTempSpace(Pager*); |
| 7859 | SQLITE_PRIVATE int sqlite3PagerIsMemdb(Pager*); |
| 7860 | |
| 7861 | /* Functions used to truncate the database file. */ |
| 7862 | SQLITE_PRIVATE void sqlite3PagerTruncateImage(Pager*,Pgno); |
| 7863 | |
| 7864 | #if defined(SQLITE_HAS_CODEC) && !defined(SQLITE_OMIT_WAL) |
| 7865 | SQLITE_PRIVATE void *sqlite3PagerCodec(DbPage *); |
| 7866 | #endif |
| 7867 | |
| 7868 | /* Functions to support testing and debugging. */ |
| 7869 | #if !defined(NDEBUG) || defined(SQLITE_TEST) |
| 7870 | SQLITE_PRIVATE Pgno sqlite3PagerPagenumber(DbPage*); |
| 7871 | SQLITE_PRIVATE int sqlite3PagerIswriteable(DbPage*); |
| @@ -31136,11 +31140,11 @@ | |
| 31140 | GetSystemTimeAsFileTime( &ft ); |
| 31141 | #endif |
| 31142 | |
| 31143 | *piNow = winFiletimeEpoch + |
| 31144 | ((((sqlite3_int64)ft.dwHighDateTime)*max32BitValue) + |
| 31145 | (sqlite3_int64)ft.dwLowDateTime)/(sqlite3_int64)10000; |
| 31146 | |
| 31147 | #ifdef SQLITE_TEST |
| 31148 | if( sqlite3_current_time ){ |
| 31149 | *piNow = 1000*(sqlite3_int64)sqlite3_current_time + unixEpoch; |
| 31150 | } |
| @@ -34772,13 +34776,14 @@ | |
| 34776 | static void pager_unlock(Pager *pPager){ |
| 34777 | if( !pPager->exclusiveMode ){ |
| 34778 | int rc = SQLITE_OK; /* Return code */ |
| 34779 | int iDc = isOpen(pPager->fd)?sqlite3OsDeviceCharacteristics(pPager->fd):0; |
| 34780 | |
| 34781 | /* If the operating system support deletion of open files, then |
| 34782 | ** close the journal file when dropping the database lock. Otherwise |
| 34783 | ** another connection with journal_mode=delete might delete the file |
| 34784 | ** out from under us. |
| 34785 | */ |
| 34786 | assert( (PAGER_JOURNALMODE_MEMORY & 5)!=1 ); |
| 34787 | assert( (PAGER_JOURNALMODE_OFF & 5)!=1 ); |
| 34788 | assert( (PAGER_JOURNALMODE_WAL & 5)!=1 ); |
| 34789 | assert( (PAGER_JOURNALMODE_DELETE & 5)!=1 ); |
| @@ -35346,10 +35351,13 @@ | |
| 35351 | int rc; /* Return code */ |
| 35352 | sqlite3_file *pMaster; /* Malloc'd master-journal file descriptor */ |
| 35353 | sqlite3_file *pJournal; /* Malloc'd child-journal file descriptor */ |
| 35354 | char *zMasterJournal = 0; /* Contents of master journal file */ |
| 35355 | i64 nMasterJournal; /* Size of master journal file */ |
| 35356 | char *zJournal; /* Pointer to one journal within MJ file */ |
| 35357 | char *zMasterPtr; /* Space to hold MJ filename from a journal file */ |
| 35358 | int nMasterPtr; /* Amount of space allocated to zMasterPtr[] */ |
| 35359 | |
| 35360 | /* Allocate space for both the pJournal and pMaster file descriptors. |
| 35361 | ** If successful, open the master journal file for reading. |
| 35362 | */ |
| 35363 | pMaster = (sqlite3_file *)sqlite3MallocZero(pVfs->szOsFile * 2); |
| @@ -35360,77 +35368,72 @@ | |
| 35368 | const int flags = (SQLITE_OPEN_READONLY|SQLITE_OPEN_MASTER_JOURNAL); |
| 35369 | rc = sqlite3OsOpen(pVfs, zMaster, pMaster, flags, 0); |
| 35370 | } |
| 35371 | if( rc!=SQLITE_OK ) goto delmaster_out; |
| 35372 | |
| 35373 | /* Load the entire master journal file into space obtained from |
| 35374 | ** sqlite3_malloc() and pointed to by zMasterJournal. Also obtain |
| 35375 | ** sufficient space (in zMasterPtr) to hold the names of master |
| 35376 | ** journal files extracted from regular rollback-journals. |
| 35377 | */ |
| 35378 | rc = sqlite3OsFileSize(pMaster, &nMasterJournal); |
| 35379 | if( rc!=SQLITE_OK ) goto delmaster_out; |
| 35380 | nMasterPtr = pVfs->mxPathname+1; |
| 35381 | zMasterJournal = sqlite3Malloc((int)nMasterJournal + nMasterPtr + 1); |
| 35382 | if( !zMasterJournal ){ |
| 35383 | rc = SQLITE_NOMEM; |
| 35384 | goto delmaster_out; |
| 35385 | } |
| 35386 | zMasterPtr = &zMasterJournal[nMasterJournal+1]; |
| 35387 | rc = sqlite3OsRead(pMaster, zMasterJournal, (int)nMasterJournal, 0); |
| 35388 | if( rc!=SQLITE_OK ) goto delmaster_out; |
| 35389 | zMasterJournal[nMasterJournal] = 0; |
| 35390 | |
| 35391 | zJournal = zMasterJournal; |
| 35392 | while( (zJournal-zMasterJournal)<nMasterJournal ){ |
| 35393 | int exists; |
| 35394 | rc = sqlite3OsAccess(pVfs, zJournal, SQLITE_ACCESS_EXISTS, &exists); |
| 35395 | if( rc!=SQLITE_OK ){ |
| 35396 | goto delmaster_out; |
| 35397 | } |
| 35398 | if( exists ){ |
| 35399 | /* One of the journals pointed to by the master journal exists. |
| 35400 | ** Open it and check if it points at the master journal. If |
| 35401 | ** so, return without deleting the master journal file. |
| 35402 | */ |
| 35403 | int c; |
| 35404 | int flags = (SQLITE_OPEN_READONLY|SQLITE_OPEN_MAIN_JOURNAL); |
| 35405 | rc = sqlite3OsOpen(pVfs, zJournal, pJournal, flags, 0); |
| 35406 | if( rc!=SQLITE_OK ){ |
| 35407 | goto delmaster_out; |
| 35408 | } |
| 35409 | |
| 35410 | rc = readMasterJournal(pJournal, zMasterPtr, nMasterPtr); |
| 35411 | sqlite3OsClose(pJournal); |
| 35412 | if( rc!=SQLITE_OK ){ |
| 35413 | goto delmaster_out; |
| 35414 | } |
| 35415 | |
| 35416 | c = zMasterPtr[0]!=0 && strcmp(zMasterPtr, zMaster)==0; |
| 35417 | if( c ){ |
| 35418 | /* We have a match. Do not delete the master journal file. */ |
| 35419 | goto delmaster_out; |
| 35420 | } |
| 35421 | } |
| 35422 | zJournal += (sqlite3Strlen30(zJournal)+1); |
| 35423 | } |
| 35424 | |
| 35425 | sqlite3OsClose(pMaster); |
| 35426 | rc = sqlite3OsDelete(pVfs, zMaster, 0); |
| 35427 | |
| 35428 | delmaster_out: |
| 35429 | sqlite3_free(zMasterJournal); |
| 35430 | if( pMaster ){ |
| 35431 | sqlite3OsClose(pMaster); |
| 35432 | assert( !isOpen(pJournal) ); |
| 35433 | sqlite3_free(pMaster); |
| 35434 | } |
| 35435 | return rc; |
| 35436 | } |
| 35437 | |
| 35438 | |
| 35439 | /* |
| @@ -36125,11 +36128,11 @@ | |
| 36128 | for(ii=0; rc==SQLITE_OK && ii<nJRec && pPager->journalOff<szJ; ii++){ |
| 36129 | rc = pager_playback_one_page(pPager, &pPager->journalOff, pDone, 1, 1); |
| 36130 | } |
| 36131 | assert( rc!=SQLITE_DONE ); |
| 36132 | } |
| 36133 | assert( rc!=SQLITE_OK || pPager->journalOff>=szJ ); |
| 36134 | |
| 36135 | /* Finally, rollback pages from the sub-journal. Page that were |
| 36136 | ** previously rolled back out of the main journal (and are hence in pDone) |
| 36137 | ** will be skipped. Out-of-range pages are also skipped. |
| 36138 | */ |
| @@ -38256,11 +38259,11 @@ | |
| 38259 | */ |
| 38260 | rc = sqlite3PagerBegin(pPager, 0, pPager->subjInMemory); |
| 38261 | if( rc!=SQLITE_OK ){ |
| 38262 | return rc; |
| 38263 | } |
| 38264 | if( pPager->pInJournal==0 |
| 38265 | && pPager->journalMode!=PAGER_JOURNALMODE_OFF |
| 38266 | && !pagerUseWal(pPager) |
| 38267 | ){ |
| 38268 | assert( pPager->useJournal ); |
| 38269 | rc = pager_open_journal(pPager); |
| @@ -38571,13 +38574,16 @@ | |
| 38574 | put32bits(((char*)pPgHdr->pData)+92, change_counter); |
| 38575 | put32bits(((char*)pPgHdr->pData)+96, SQLITE_VERSION_NUMBER); |
| 38576 | |
| 38577 | /* If running in direct mode, write the contents of page 1 to the file. */ |
| 38578 | if( DIRECT_MODE ){ |
| 38579 | const void *zBuf; |
| 38580 | assert( pPager->dbFileSize>0 ); |
| 38581 | CODEC2(pPager, pPgHdr->pData, 1, 6, rc=SQLITE_NOMEM, zBuf); |
| 38582 | if( rc==SQLITE_OK ){ |
| 38583 | rc = sqlite3OsWrite(pPager->fd, zBuf, pPager->pageSize, 0); |
| 38584 | } |
| 38585 | if( rc==SQLITE_OK ){ |
| 38586 | pPager->changeCountDone = 1; |
| 38587 | } |
| 38588 | }else{ |
| 38589 | pPager->changeCountDone = 1; |
| @@ -39647,11 +39653,27 @@ | |
| 39653 | sqlite3OsUnlock(pPager->fd, SQLITE_LOCK_SHARED); |
| 39654 | } |
| 39655 | } |
| 39656 | return rc; |
| 39657 | } |
| 39658 | |
| 39659 | #ifdef SQLITE_HAS_CODEC |
| 39660 | /* |
| 39661 | ** This function is called by the wal module when writing page content |
| 39662 | ** into the log file. |
| 39663 | ** |
| 39664 | ** This function returns a pointer to a buffer containing the encrypted |
| 39665 | ** page content. If a malloc fails, this function may return NULL. |
| 39666 | */ |
| 39667 | SQLITE_PRIVATE void *sqlite3PagerCodec(PgHdr *pPg){ |
| 39668 | void *aData = 0; |
| 39669 | CODEC2(pPg->pPager, pPg->pData, pPg->pgno, 6, return 0, aData); |
| 39670 | return aData; |
| 39671 | } |
| 39672 | #endif /* SQLITE_HAS_CODEC */ |
| 39673 | |
| 39674 | #endif /* !SQLITE_OMIT_WAL */ |
| 39675 | |
| 39676 | #endif /* SQLITE_OMIT_DISKIO */ |
| 39677 | |
| 39678 | /************** End of pager.c ***********************************************/ |
| 39679 | /************** Begin file wal.c *********************************************/ |
| @@ -41940,23 +41962,30 @@ | |
| 41962 | |
| 41963 | /* Write the log file. */ |
| 41964 | for(p=pList; p; p=p->pDirty){ |
| 41965 | u32 nDbsize; /* Db-size field for frame header */ |
| 41966 | i64 iOffset; /* Write offset in log file */ |
| 41967 | void *pData; |
| 41968 | |
| 41969 | |
| 41970 | iOffset = walFrameOffset(++iFrame, szPage); |
| 41971 | |
| 41972 | /* Populate and write the frame header */ |
| 41973 | nDbsize = (isCommit && p->pDirty==0) ? nTruncate : 0; |
| 41974 | #if defined(SQLITE_HAS_CODEC) |
| 41975 | if( (pData = sqlite3PagerCodec(p))==0 ) return SQLITE_NOMEM; |
| 41976 | #else |
| 41977 | pData = p->pData; |
| 41978 | #endif |
| 41979 | walEncodeFrame(pWal, p->pgno, nDbsize, pData, aFrame); |
| 41980 | rc = sqlite3OsWrite(pWal->pWalFd, aFrame, sizeof(aFrame), iOffset); |
| 41981 | if( rc!=SQLITE_OK ){ |
| 41982 | return rc; |
| 41983 | } |
| 41984 | |
| 41985 | /* Write the page data */ |
| 41986 | rc = sqlite3OsWrite(pWal->pWalFd, pData, szPage, iOffset+sizeof(aFrame)); |
| 41987 | if( rc!=SQLITE_OK ){ |
| 41988 | return rc; |
| 41989 | } |
| 41990 | pLast = p; |
| 41991 | } |
| @@ -41969,18 +41998,23 @@ | |
| 41998 | assert( isCommit ); |
| 41999 | assert( iSegment>0 ); |
| 42000 | |
| 42001 | iSegment = (((iOffset+iSegment-1)/iSegment) * iSegment); |
| 42002 | while( iOffset<iSegment ){ |
| 42003 | void *pData; |
| 42004 | #if defined(SQLITE_HAS_CODEC) |
| 42005 | if( (pData = sqlite3PagerCodec(pLast))==0 ) return SQLITE_NOMEM; |
| 42006 | #else |
| 42007 | pData = pLast->pData; |
| 42008 | #endif |
| 42009 | walEncodeFrame(pWal, pLast->pgno, nTruncate, pData, aFrame); |
| 42010 | rc = sqlite3OsWrite(pWal->pWalFd, aFrame, sizeof(aFrame), iOffset); |
| 42011 | if( rc!=SQLITE_OK ){ |
| 42012 | return rc; |
| 42013 | } |
| 42014 | iOffset += WAL_FRAME_HDRSIZE; |
| 42015 | rc = sqlite3OsWrite(pWal->pWalFd, pData, szPage, iOffset); |
| 42016 | if( rc!=SQLITE_OK ){ |
| 42017 | return rc; |
| 42018 | } |
| 42019 | nLast++; |
| 42020 | iOffset += szPage; |
| @@ -63351,10 +63385,14 @@ | |
| 63385 | */ |
| 63386 | rc = sqlite3PagerCloseWal(u.cd.pPager); |
| 63387 | if( rc==SQLITE_OK ){ |
| 63388 | sqlite3PagerSetJournalMode(u.cd.pPager, u.cd.eNew); |
| 63389 | } |
| 63390 | }else if( u.cd.eOld==PAGER_JOURNALMODE_MEMORY ){ |
| 63391 | /* Cannot transition directly from MEMORY to WAL. Use mode OFF |
| 63392 | ** as an intermediate */ |
| 63393 | sqlite3PagerSetJournalMode(u.cd.pPager, PAGER_JOURNALMODE_OFF); |
| 63394 | } |
| 63395 | |
| 63396 | /* Open a transaction on the database file. Regardless of the journal |
| 63397 | ** mode, this transaction always uses a rollback journal. |
| 63398 | */ |
| 63399 |
+1
-1
| --- src/sqlite3.h | ||
| +++ src/sqlite3.h | ||
| @@ -107,11 +107,11 @@ | ||
| 107 | 107 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 108 | 108 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 109 | 109 | */ |
| 110 | 110 | #define SQLITE_VERSION "3.7.0" |
| 111 | 111 | #define SQLITE_VERSION_NUMBER 3007000 |
| 112 | -#define SQLITE_SOURCE_ID "2010-06-21 12:47:41 ee0acef1faffd480fd2136f81fb2b6f6a17b5388" | |
| 112 | +#define SQLITE_SOURCE_ID "2010-06-23 15:18:12 51ef43b9f7db8fabf73d9c8a76dae6c275e50d58" | |
| 113 | 113 | |
| 114 | 114 | /* |
| 115 | 115 | ** CAPI3REF: Run-Time Library Version Numbers |
| 116 | 116 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 117 | 117 | ** |
| 118 | 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-06-21 12:47:41 ee0acef1faffd480fd2136f81fb2b6f6a17b5388" |
| 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-06-23 15:18:12 51ef43b9f7db8fabf73d9c8a76dae6c275e50d58" |
| 113 | |
| 114 | /* |
| 115 | ** CAPI3REF: Run-Time Library Version Numbers |
| 116 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 117 | ** |
| 118 |