Change the names of the log.c and log.h source files to wal.c and wal.h.

FossilOrigin-Name: 56fe5d7624f840417152bcc63efbe21a5f557920
This commit is contained in:
drh
2010-04-26 00:19:45 +00:00
parent f2424c521b
commit c438efd68a
8 changed files with 73 additions and 69 deletions
+17 -17
View File
@@ -20,7 +20,7 @@
*/
#ifndef SQLITE_OMIT_DISKIO
#include "sqliteInt.h"
#include "log.h"
#include "wal.h"
/*
******************** NOTES ON THE DESIGN OF THE PAGER ************************
@@ -1227,7 +1227,7 @@ static void pager_unlock(Pager *pPager){
pPager->dbSizeValid = 0;
if( pagerUseLog(pPager) ){
sqlite3LogCloseSnapshot(pPager->pLog);
sqlite3WalCloseSnapshot(pPager->pLog);
}else{
rc = osUnlock(pPager->fd, NO_LOCK);
}
@@ -1426,7 +1426,7 @@ static int pager_end_transaction(Pager *pPager, int hasMaster){
sqlite3PcacheCleanAll(pPager->pPCache);
if( pagerUseLog(pPager) ){
rc2 = sqlite3LogWriteLock(pPager->pLog, 0);
rc2 = sqlite3WalWriteLock(pPager->pLog, 0);
pPager->state = PAGER_SHARED;
}else if( !pPager->exclusiveMode ){
rc2 = osUnlock(pPager->fd, SHARED_LOCK);
@@ -2193,7 +2193,7 @@ static int readDbPage(PgHdr *pPg){
if( pagerUseLog(pPager) ){
/* Try to pull the page from the write-ahead log. */
rc = sqlite3LogRead(pPager->pLog, pgno, &isInLog, pPg->pData);
rc = sqlite3WalRead(pPager->pLog, pgno, &isInLog, pPg->pData);
}
if( rc==SQLITE_OK && !isInLog ){
iOffset = (pgno-1)*(i64)pPager->pageSize;
@@ -2282,7 +2282,7 @@ static int pagerRollbackLog(Pager *pPager){
** also copied into the backup databases) as part of this transaction,
** the backups must be restarted.
*/
if( sqlite3LogDirty(pPager->pLog) ){
if( sqlite3WalDirty(pPager->pLog) ){
sqlite3BackupRestart(pPager->pBackup);
}
@@ -2294,7 +2294,7 @@ static int pagerRollbackLog(Pager *pPager){
** + Reload page content from the database (if refcount>0).
*/
pPager->dbSize = pPager->dbOrigSize;
rc = sqlite3LogUndo(pPager->pLog, pagerUndoCallback, (void *)pPager);
rc = sqlite3WalUndo(pPager->pLog, pagerUndoCallback, (void *)pPager);
pList = sqlite3PcacheDirtyList(pPager->pPCache);
while( pList && rc==SQLITE_OK ){
PgHdr *pNext = pList->pDirty;
@@ -2738,7 +2738,7 @@ int sqlite3PagerPagecount(Pager *pPager, int *pnPage){
i64 n = 0; /* File size in bytes returned by OsFileSize() */
if( pagerUseLog(pPager) ){
sqlite3LogDbsize(pPager->pLog, &nPage);
sqlite3WalDbsize(pPager->pLog, &nPage);
}
if( nPage==0 ){
@@ -2923,7 +2923,7 @@ int sqlite3PagerClose(Pager *pPager){
sqlite3BeginBenignMalloc();
pPager->errCode = 0;
pPager->exclusiveMode = 0;
sqlite3LogClose(pPager->pLog, pPager->fd,
sqlite3WalClose(pPager->pLog, pPager->fd,
(pPager->noSync ? 0 : pPager->sync_flags), pTmp
);
pPager->pLog = 0;
@@ -3270,7 +3270,7 @@ static int subjournalPage(PgHdr *pPg){
}
/*
** This function is a wrapper around sqlite3LogFrames(). As well as logging
** This function is a wrapper around sqlite3WalFrames(). As well as logging
** the contents of the list of pages headed by pList (connected by pDirty),
** this function notifies any active backup processes that the pages have
** changed.
@@ -3285,7 +3285,7 @@ static int pagerLogFrames(
int rc; /* Return code */
assert( pPager->pLog );
rc = sqlite3LogFrames(pPager->pLog,
rc = sqlite3WalFrames(pPager->pLog,
pPager->pageSize, pList, nTruncate, isCommit, sync_flags
);
if( rc==SQLITE_OK && pPager->pBackup ){
@@ -3838,7 +3838,7 @@ static int pagerOpenSnapshot(Pager *pPager){
assert( pagerUseLog(pPager) );
rc = sqlite3LogOpenSnapshot(pPager->pLog, &changed);
rc = sqlite3WalOpenSnapshot(pPager->pLog, &changed);
if( rc==SQLITE_OK ){
int dummy;
if( changed ){
@@ -4456,7 +4456,7 @@ int sqlite3PagerBegin(Pager *pPager, int exFlag, int subjInMemory){
** The busy-handler is not invoked if another connection already
** holds the write-lock. If possible, the upper layer will call it.
*/
rc = sqlite3LogWriteLock(pPager->pLog, 1);
rc = sqlite3WalWriteLock(pPager->pLog, 1);
if( rc==SQLITE_OK ){
pPager->dbOrigSize = pPager->dbSize;
pPager->state = PAGER_RESERVED;
@@ -5777,7 +5777,7 @@ int sqlite3PagerCheckpoint(Pager *pPager){
int rc = SQLITE_OK;
if( pPager->pLog ){
u8 *zBuf = (u8 *)pPager->pTmpSpace;
rc = sqlite3LogCheckpoint(pPager->pLog, pPager->fd,
rc = sqlite3WalCheckpoint(pPager->pLog, pPager->fd,
(pPager->noSync ? 0 : pPager->sync_flags),
zBuf, pPager->xBusyHandler, pPager->pBusyHandlerArg
);
@@ -5786,7 +5786,7 @@ int sqlite3PagerCheckpoint(Pager *pPager){
}
int sqlite3PagerLogCallback(Pager *pPager){
return sqlite3LogCallback(pPager->pLog);
return sqlite3WalCallback(pPager->pLog);
}
/*
@@ -5806,7 +5806,7 @@ int sqlite3PagerOpenLog(Pager *pPager, int *pisOpen){
** (e.g. due to malloc() failure), unlock the database file and
** return an error code.
*/
rc = sqlite3LogOpen(pPager->pVfs, pPager->zFilename, &pPager->pLog);
rc = sqlite3WalOpen(pPager->pVfs, pPager->zFilename, &pPager->pLog);
if( rc==SQLITE_OK ){
pPager->journalMode = PAGER_JOURNALMODE_WAL;
}
@@ -5843,7 +5843,7 @@ int sqlite3PagerCloseLog(Pager *pPager){
rc = pagerHasWAL(pPager, &logexists);
}
if( rc==SQLITE_OK && logexists ){
rc = sqlite3LogOpen(pPager->pVfs, pPager->zFilename, &pPager->pLog);
rc = sqlite3WalOpen(pPager->pVfs, pPager->zFilename, &pPager->pLog);
}
}
@@ -5853,7 +5853,7 @@ int sqlite3PagerCloseLog(Pager *pPager){
if( rc==SQLITE_OK && pPager->pLog ){
rc = sqlite3OsLock(pPager->fd, SQLITE_LOCK_EXCLUSIVE);
if( rc==SQLITE_OK ){
rc = sqlite3LogClose(pPager->pLog, pPager->fd,
rc = sqlite3WalClose(pPager->pLog, pPager->fd,
(pPager->noSync ? 0 : pPager->sync_flags),
(u8*)pPager->pTmpSpace
);
+14 -15
View File
@@ -57,7 +57,7 @@
** not the same as the iCheck1 and iCheck2 fields of the LogSummaryHdr.
*/
#include "log.h"
#include "wal.h"
#include <unistd.h>
#include <fcntl.h>
@@ -1006,7 +1006,7 @@ static int logSummaryInit(
** were to do this just after this client opened one of these files, the
** system would be badly broken.
*/
int sqlite3LogOpen(
int sqlite3WalOpen(
sqlite3_vfs *pVfs, /* vfs module to open log file with */
const char *zDb, /* Name of database file */
Log **ppLog /* OUT: Allocated Log handle */
@@ -1264,7 +1264,7 @@ static int logCheckpoint(
/*
** Close a connection to a log file.
*/
int sqlite3LogClose(
int sqlite3WalClose(
Log *pLog, /* Log to close */
sqlite3_file *pFd, /* Database file */
int sync_flags, /* Flags to pass to OsSync() (or 0) */
@@ -1444,7 +1444,7 @@ int logSummaryReadHdr(Log *pLog, int *pChanged){
** is left unmodified. This is used by the pager layer to determine whether
** or not any cached pages may be safely reused.
*/
int sqlite3LogOpenSnapshot(Log *pLog, int *pChanged){
int sqlite3WalOpenSnapshot(Log *pLog, int *pChanged){
int rc = SQLITE_OK;
if( pLog->isLocked==0 ){
int nAttempt;
@@ -1480,7 +1480,7 @@ int sqlite3LogOpenSnapshot(Log *pLog, int *pChanged){
rc = logSummaryReadHdr(pLog, pChanged);
if( rc!=SQLITE_OK ){
/* An error occured while attempting log recovery. */
sqlite3LogCloseSnapshot(pLog);
sqlite3WalCloseSnapshot(pLog);
}
}
return rc;
@@ -1489,7 +1489,7 @@ int sqlite3LogOpenSnapshot(Log *pLog, int *pChanged){
/*
** Unlock the current snapshot.
*/
void sqlite3LogCloseSnapshot(Log *pLog){
void sqlite3WalCloseSnapshot(Log *pLog){
if( pLog->isLocked ){
assert( pLog->isLocked==LOG_REGION_A || pLog->isLocked==LOG_REGION_D );
logLockRegion(pLog, pLog->isLocked, LOG_UNLOCK);
@@ -1500,7 +1500,7 @@ void sqlite3LogCloseSnapshot(Log *pLog){
/*
** Read a page from the log, if it is present.
*/
int sqlite3LogRead(Log *pLog, Pgno pgno, int *pInLog, u8 *pOut){
int sqlite3WalRead(Log *pLog, Pgno pgno, int *pInLog, u8 *pOut){
u32 iRead = 0;
u32 *aData = pLog->pSummary->aData;
int iFrame = (pLog->hdr.iLastPg & 0xFFFFFF00);
@@ -1566,7 +1566,7 @@ int sqlite3LogRead(Log *pLog, Pgno pgno, int *pInLog, u8 *pOut){
/*
** Set *pPgno to the size of the database file (or zero, if unknown).
*/
void sqlite3LogDbsize(Log *pLog, Pgno *pPgno){
void sqlite3WalDbsize(Log *pLog, Pgno *pPgno){
assert( pLog->isLocked );
*pPgno = pLog->hdr.nPage;
}
@@ -1576,7 +1576,7 @@ void sqlite3LogDbsize(Log *pLog, Pgno *pPgno){
** Otherwise, if the caller is operating on a snapshot that has already
** been overwritten by another writer, SQLITE_BUSY is returned.
*/
int sqlite3LogWriteLock(Log *pLog, int op){
int sqlite3WalWriteLock(Log *pLog, int op){
assert( pLog->isLocked );
if( op ){
@@ -1636,7 +1636,7 @@ int sqlite3LogWriteLock(Log *pLog, int op){
** Otherwise, if the callback function does not return an error, this
** function returns SQLITE_OK.
*/
int sqlite3LogUndo(Log *pLog, int (*xUndo)(void *, Pgno), void *pUndoCtx){
int sqlite3WalUndo(Log *pLog, int (*xUndo)(void *, Pgno), void *pUndoCtx){
int rc = SQLITE_OK;
Pgno iMax = pLog->hdr.iLastPg;
Pgno iFrame;
@@ -1652,7 +1652,7 @@ int sqlite3LogUndo(Log *pLog, int (*xUndo)(void *, Pgno), void *pUndoCtx){
/*
** Return true if data has been written but not committed to the log file.
*/
int sqlite3LogDirty(Log *pLog){
int sqlite3WalDirty(Log *pLog){
assert( pLog->isWriteLocked );
return( pLog->hdr.iLastPg!=((LogSummaryHdr*)pLog->pSummary->aData)->iLastPg );
}
@@ -1661,7 +1661,7 @@ int sqlite3LogDirty(Log *pLog){
** Write a set of frames to the log. The caller must hold at least a
** RESERVED lock on the database file.
*/
int sqlite3LogFrames(
int sqlite3WalFrames(
Log *pLog, /* Log handle to write to */
int nPgsz, /* Database page-size in bytes */
PgHdr *pList, /* List of dirty pages to write */
@@ -1801,7 +1801,7 @@ int sqlite3LogFrames(
** 4. Zero the log-summary header (so new readers will ignore the log).
** 5. Drop the locks obtained in steps 1 and 2.
*/
int sqlite3LogCheckpoint(
int sqlite3WalCheckpoint(
Log *pLog, /* Log connection */
sqlite3_file *pFd, /* File descriptor open on db file */
int sync_flags, /* Flags to sync db file with (or 0) */
@@ -1839,7 +1839,7 @@ int sqlite3LogCheckpoint(
return rc;
}
int sqlite3LogCallback(Log *pLog){
int sqlite3WalCallback(Log *pLog){
u32 ret = 0;
if( pLog ){
ret = pLog->iCallback;
@@ -1847,4 +1847,3 @@ int sqlite3LogCallback(Log *pLog){
}
return (int)ret;
}
+15 -15
View File
@@ -14,8 +14,8 @@
** the implementation of each function in log.c for further details.
*/
#ifndef _LOG_H_
#define _LOG_H_
#ifndef _WAL_H_
#define _WAL_H_
#include "sqliteInt.h"
@@ -23,31 +23,31 @@
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, int sync_flags, u8 *zBuf);
int sqlite3WalOpen(sqlite3_vfs*, const char *zDb, Log **ppLog);
int sqlite3WalClose(Log *pLog, sqlite3_file *pFd, int sync_flags, u8 *zBuf);
/* Used by readers to open (lock) and close (unlock) a snapshot. */
int sqlite3LogOpenSnapshot(Log *pLog, int *);
void sqlite3LogCloseSnapshot(Log *pLog);
int sqlite3WalOpenSnapshot(Log *pLog, int *);
void sqlite3WalCloseSnapshot(Log *pLog);
/* Read a page from the log, if it is present. */
int sqlite3LogRead(Log *pLog, Pgno pgno, int *pInLog, u8 *pOut);
void sqlite3LogDbsize(Log *pLog, Pgno *pPgno);
int sqlite3WalRead(Log *pLog, Pgno pgno, int *pInLog, u8 *pOut);
void sqlite3WalDbsize(Log *pLog, Pgno *pPgno);
/* Obtain or release the WRITER lock. */
int sqlite3LogWriteLock(Log *pLog, int op);
int sqlite3WalWriteLock(Log *pLog, int op);
/* Undo any frames written (but not committed) to the log */
int sqlite3LogUndo(Log *pLog, int (*xUndo)(void *, Pgno), void *pUndoCtx);
int sqlite3WalUndo(Log *pLog, int (*xUndo)(void *, Pgno), void *pUndoCtx);
/* Return true if data has been written but not committed to the log file. */
int sqlite3LogDirty(Log *pLog);
int sqlite3WalDirty(Log *pLog);
/* Write a frame or frames to the log. */
int sqlite3LogFrames(Log *pLog, int, PgHdr *, Pgno, int, int);
int sqlite3WalFrames(Log *pLog, int, PgHdr *, Pgno, int, int);
/* Copy pages from the log to the database file */
int sqlite3LogCheckpoint(
int sqlite3WalCheckpoint(
Log *pLog, /* Log connection */
sqlite3_file *pFd, /* File descriptor open on db file */
int sync_flags, /* Flags to sync db file with (or 0) */
@@ -57,6 +57,6 @@ int sqlite3LogCheckpoint(
);
/* Return the value to pass to a log callback. Or 0 for no callback. */
int sqlite3LogCallback(Log *pLog);
int sqlite3WalCallback(Log *pLog);
#endif /* _LOG_H_ */
#endif /* _WAL_H_ */