-C Merge\swith\strunk\scommit\s[3e646e3f4c].
-D 2010-04-17T15:45:35
+C Do\snot\ssync\sany\sfiles\sin\swal\smode\sif\s"PRAGMA\ssynchronous=off"\sis\sset.\sIf\sfiles\sare\ssynced,\spass\seither\sSQLITE_SYNC_FULL\sor\sSQLITE_SYNC_NORMAL\sto\sthe\sxSync()\scallback\sas\sconfigured\sby\s"PRAGMA\sfullfsync".
+D 2010-04-17T17:34:42
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
F Makefile.in 4f2f967b7e58a35bb74fb7ec8ae90e0f4ca7868b
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
F src/legacy.c a199d7683d60cef73089e892409113e69c23a99f
F src/lempar.c 7f026423f4d71d989e719a743f98a1cbd4e6d99e
F src/loadext.c 1c7a61ce1281041f437333f366a96aa0d29bb581
-F src/log.c a72baea84cecef9a4e45308b1504e6fe69c8284e
-F src/log.h a2654af46ce7b5732f4d5a731abfdd180f0a06d9
+F src/log.c 8bcd490de703a12563c939a59cb4e187a0c67fe3
+F src/log.h 3cfec02156f5db3d233352897a47601930a29955
F src/main.c c0e7192bad5b90544508b241eb2487ac661de890
F src/malloc.c a08f16d134f0bfab6b20c3cd142ebf3e58235a6a
F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645
F src/os_os2.c 75a8c7b9a00a2cf1a65f9fa4afbc27d46634bb2f
F src/os_unix.c 5bf0015cebe2f21635da2af983c348eb88b3b4c1
F src/os_win.c 1c7453c2df4dab26d90ff6f91272aea18bcf7053
-F src/pager.c 751ada65b9a4aa0b31c36ffa3f6548200a55ca16
+F src/pager.c 344eddf3c59eed4b4aca31abbf762d0e301ae44d
F src/pager.h ce5d076f3860a5f2d7460c582cd68383343b33cf
F src/parse.y ace5c7a125d9f2a410e431ee3209034105045f7e
F src/pcache.c ace8f6a5ecd4711cc66a1b23053be7109bd437cf
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
-P 9bc9b6847303d0324543a9ded8dd0473490122d8 3e646e3f4cd0ca288e444561e951cecfdaee2ab5
-R 9ec1fc417b85c6217c6e7a04071a1912
+P 43463970f5885fb116588695146f2a56cb22804a
+R 0e49b7b76893a9b984350c6fdab0ea9a
U dan
-Z 5c9ba544c6cd36a35ee164445a4a1f25
+Z ad3f9c0ef28635a13cd67b8f240d7d22
LogSummary *pSummary; /* Log file summary data */
sqlite3_vfs *pVfs; /* The VFS used to create pFd */
sqlite3_file *pFd; /* File handle for log file */
- int sync_flags; /* Flags to use with OsSync() */
int isLocked; /* Non-zero if a snapshot is held open */
int isWriteLocked; /* True if this is the writer connection */
LogSummaryHdr hdr; /* Log summary header for current snapshot */
z[j] = 0;
}
-/*
-** Lock the summary file pSummary->fd.
-*/
-static int logSummaryLock(LogSummary *pSummary){
- int rc;
- struct flock f;
- memset(&f, 0, sizeof(f));
- f.l_type = F_WRLCK;
- f.l_whence = SEEK_SET;
- f.l_start = 0;
- f.l_len = 1;
- rc = fcntl(pSummary->fd, F_SETLKW, &f);
- if( rc!=0 ){
- return SQLITE_IOERR;
- }
- return SQLITE_OK;
-}
-
-/*
-** Unlock the summary file pSummary->fd.
-*/
-static int logSummaryUnlock(LogSummary *pSummary){
- int rc;
- struct flock f;
- memset(&f, 0, sizeof(f));
- f.l_type = F_UNLCK;
- f.l_whence = SEEK_SET;
- f.l_start = 0;
- f.l_len = 1;
- rc = fcntl(pSummary->fd, F_SETLK, &f);
- if( rc!=0 ){
- return SQLITE_IOERR;
- }
- return SQLITE_OK;
-}
-
/*
** Memory map the first nByte bytes of the summary file opened with
** pSummary->fd at pSummary->aData. If the summary file is smaller than
if( !pRet ) goto out;
pRet->pVfs = pVfs;
pRet->pFd = (sqlite3_file *)&pRet[1];
- pRet->sync_flags = SQLITE_SYNC_NORMAL;
/* Normalize the path name. */
zWal = sqlite3_mprintf("%s-wal", zDb);
static int logCheckpoint(
Log *pLog, /* Log connection */
sqlite3_file *pFd, /* File descriptor open on db file */
+ int sync_flags, /* Flags for OsSync() (or 0) */
u8 *zBuf /* Temporary buffer to use */
){
int rc; /* Return code */
if( !pIter ) return SQLITE_NOMEM;
/* Sync the log file to disk */
- rc = sqlite3OsSync(pLog->pFd, pLog->sync_flags);
- if( rc!=SQLITE_OK ) goto out;
+ if( sync_flags ){
+ rc = sqlite3OsSync(pLog->pFd, sync_flags);
+ if( rc!=SQLITE_OK ) goto out;
+ }
/* Iterate through the contents of the log, copying data to the db file. */
while( 0==logIteratorNext(pIter, &iDbpage, &iFrame) ){
if( rc!=SQLITE_OK ) goto out;
/* Sync the database file. If successful, update the log-summary. */
- rc = sqlite3OsSync(pFd, pLog->sync_flags);
- if( rc!=SQLITE_OK ) goto out;
+ if( sync_flags ){
+ rc = sqlite3OsSync(pFd, sync_flags);
+ if( rc!=SQLITE_OK ) goto out;
+ }
pLog->hdr.iLastPg = 0;
pLog->hdr.iCheck1 = 2;
pLog->hdr.iCheck2 = 3;
int sqlite3LogClose(
Log *pLog, /* Log to close */
sqlite3_file *pFd, /* Database file */
+ int sync_flags, /* Flags to pass to OsSync() (or 0) */
u8 *zBuf /* Buffer of at least page-size bytes */
){
int rc = SQLITE_OK;
** 2. Truncate the log file.
** 3. Unlink the log-summary file.
*/
- rc = logCheckpoint(pLog, pFd, zBuf);
+ rc = logCheckpoint(pLog, pFd, sync_flags, zBuf);
if( rc==SQLITE_OK ){
rc = sqlite3OsDelete(pLog->pVfs, pSummary->zPath, 0);
}
return rc;
}
-/*
-** Set the flags to pass to the sqlite3OsSync() function when syncing
-** the log file.
-*/
-#if 0
-void sqlite3LogSetSyncflags(Log *pLog, int sync_flags){
- assert( sync_flags==SQLITE_SYNC_NORMAL || sync_flags==SQLITE_SYNC_FULL );
- pLog->sync_flags = sync_flags;
-}
-#endif
-
/*
** Enter and leave the log-summary mutex. In this context, entering the
** log-summary mutex means:
PgHdr *pList, /* List of dirty pages to write */
Pgno nTruncate, /* Database size after this commit */
int isCommit, /* True if this is a commit */
- int isSync /* True to sync the log file */
+ int sync_flags /* Flags to pass to OsSync() (or 0) */
){
int rc; /* Used to catch return codes */
u32 iFrame; /* Next frame address */
}
/* Sync the log file if the 'isSync' flag was specified. */
- if( isSync ){
+ if( sync_flags ){
i64 iSegment = sqlite3OsSectorSize(pLog->pFd);
i64 iOffset = logFrameOffset(iFrame+1, nPgsz);
iOffset += nPgsz;
}
- rc = sqlite3OsSync(pLog->pFd, pLog->sync_flags);
+ rc = sqlite3OsSync(pLog->pFd, sync_flags);
if( rc!=SQLITE_OK ){
return rc;
}
int sqlite3LogCheckpoint(
Log *pLog, /* Log connection */
sqlite3_file *pFd, /* File descriptor open on db file */
+ int sync_flags, /* Flags to sync db file with (or 0) */
u8 *zBuf, /* Temporary buffer to use */
int (*xBusyHandler)(void *), /* Pointer to busy-handler function */
void *pBusyHandlerArg /* Argument to pass to xBusyHandler */
/* Copy data from the log to the database file. */
rc = logSummaryReadHdr(pLog, 0);
if( rc==SQLITE_OK ){
- rc = logCheckpoint(pLog, pFd, zBuf);
+ rc = logCheckpoint(pLog, pFd, sync_flags, zBuf);
}
/* Release the locks. */
#include "sqliteInt.h"
-/* Flags that may be set in the 'flags' argument to sqlite3LogWrite(): */
-#define LOG_MASK_COMMIT 0x08
-#define LOG_MASK_MASTERJOURNAL 0x10
-#define LOG_MASK_TRUNCATE 0x20
-
-
-#define LOG_TRUNCATE_BIT 0x80000000
-
/* Connection to a log file. There is one object of this type for each pager. */
typedef struct Log Log;
/* Open and close a connection to a log file. */
int sqlite3LogOpen(sqlite3_vfs*, const char *zDb, Log **ppLog);
-int sqlite3LogClose(Log *pLog, sqlite3_file *pFd, u8 *zBuf);
-
-/* Configure the log connection. */
-void sqlite3LogSetSyncflags(Log *, int sync_flags);
+int sqlite3LogClose(Log *pLog, sqlite3_file *pFd, int sync_flags, u8 *zBuf);
-/* Used by readers to open (lock) and close (unlock) a database snapshot. */
+/* Used by readers to open (lock) and close (unlock) a snapshot. */
int sqlite3LogOpenSnapshot(Log *pLog, int *);
void sqlite3LogCloseSnapshot(Log *pLog);
/* Obtain or release the WRITER lock. */
int sqlite3LogWriteLock(Log *pLog, int op);
-/* Write a segment to the log. */
+/* Write a frame or frames to the log. */
int sqlite3LogFrames(Log *pLog, int, PgHdr *, Pgno, int, int);
/* Copy pages from the log to the database file */
int sqlite3LogCheckpoint(
Log *pLog, /* Log connection */
sqlite3_file *pFd, /* File descriptor open on db file */
+ int sync_flags, /* Flags to sync db file with (or 0) */
u8 *zBuf, /* Temporary buffer to use */
int (*xBusyHandler)(void *), /* Pointer to busy-handler function */
void *pBusyHandlerArg /* Argument to pass to xBusyHandler */
sqlite3BeginBenignMalloc();
pPager->errCode = 0;
pPager->exclusiveMode = 0;
- sqlite3LogClose(pPager->pLog, pPager->fd, pTmp);
+ sqlite3LogClose(pPager->pLog, pPager->fd,
+ (pPager->noSync ? 0 : pPager->sync_flags), pTmp
+ );
pPager->pLog = 0;
pager_reset(pPager);
if( MEMDB ){
PgHdr *pList = sqlite3PcacheDirtyList(pPager->pPCache);
if( pList ){
rc = sqlite3LogFrames(pPager->pLog, pPager->pageSize, pList,
- pPager->dbSize, 1, pPager->fullSync
+ pPager->dbSize, 1, (pPager->fullSync ? pPager->sync_flags : 0)
);
}
sqlite3PcacheCleanAll(pPager->pPCache);
if( pPager->pLog ){
u8 *zBuf = (u8 *)pPager->pTmpSpace;
rc = sqlite3LogCheckpoint(pPager->pLog, pPager->fd,
+ (pPager->noSync ? 0 : pPager->sync_flags),
zBuf, pPager->xBusyHandler, pPager->pBusyHandlerArg
);
}