dan | 6700d02 | 2010-04-12 19:05:58 +0000 | [diff] [blame] | 1 | /* |
| 2 | ** 2010 February 1 |
| 3 | ** |
| 4 | ** The author disclaims copyright to this source code. In place of |
| 5 | ** a legal notice, here is a blessing: |
| 6 | ** |
| 7 | ** May you do good and not evil. |
| 8 | ** May you find forgiveness for yourself and forgive others. |
| 9 | ** May you share freely, never taking more than you give. |
| 10 | ** |
| 11 | ************************************************************************* |
| 12 | ** This header file defines the interface to the write-ahead logging |
| 13 | ** system. Refer to the comments below and the header comment attached to |
| 14 | ** the implementation of each function in log.c for further details. |
| 15 | */ |
| 16 | |
| 17 | #ifndef _LOG_H_ |
| 18 | #define _LOG_H_ |
| 19 | |
| 20 | #include "sqliteInt.h" |
| 21 | |
dan | 6700d02 | 2010-04-12 19:05:58 +0000 | [diff] [blame] | 22 | /* Connection to a log file. There is one object of this type for each pager. */ |
| 23 | typedef struct Log Log; |
| 24 | |
| 25 | /* Open and close a connection to a log file. */ |
| 26 | int sqlite3LogOpen(sqlite3_vfs*, const char *zDb, Log **ppLog); |
dan | c511878 | 2010-04-17 17:34:41 +0000 | [diff] [blame^] | 27 | int sqlite3LogClose(Log *pLog, sqlite3_file *pFd, int sync_flags, u8 *zBuf); |
dan | 6700d02 | 2010-04-12 19:05:58 +0000 | [diff] [blame] | 28 | |
dan | c511878 | 2010-04-17 17:34:41 +0000 | [diff] [blame^] | 29 | /* Used by readers to open (lock) and close (unlock) a snapshot. */ |
dan | 6700d02 | 2010-04-12 19:05:58 +0000 | [diff] [blame] | 30 | int sqlite3LogOpenSnapshot(Log *pLog, int *); |
| 31 | void sqlite3LogCloseSnapshot(Log *pLog); |
| 32 | |
| 33 | /* Read a page from the log, if it is present. */ |
| 34 | int sqlite3LogRead(Log *pLog, Pgno pgno, int *pInLog, u8 *pOut); |
| 35 | void sqlite3LogMaxpgno(Log *pLog, Pgno *pPgno); |
| 36 | |
| 37 | /* Obtain or release the WRITER lock. */ |
| 38 | int sqlite3LogWriteLock(Log *pLog, int op); |
| 39 | |
dan | c511878 | 2010-04-17 17:34:41 +0000 | [diff] [blame^] | 40 | /* Write a frame or frames to the log. */ |
dan | 6700d02 | 2010-04-12 19:05:58 +0000 | [diff] [blame] | 41 | int sqlite3LogFrames(Log *pLog, int, PgHdr *, Pgno, int, int); |
| 42 | |
| 43 | /* Copy pages from the log to the database file */ |
| 44 | int sqlite3LogCheckpoint( |
| 45 | Log *pLog, /* Log connection */ |
| 46 | sqlite3_file *pFd, /* File descriptor open on db file */ |
dan | c511878 | 2010-04-17 17:34:41 +0000 | [diff] [blame^] | 47 | int sync_flags, /* Flags to sync db file with (or 0) */ |
dan | 64d039e | 2010-04-13 19:27:31 +0000 | [diff] [blame] | 48 | u8 *zBuf, /* Temporary buffer to use */ |
| 49 | int (*xBusyHandler)(void *), /* Pointer to busy-handler function */ |
| 50 | void *pBusyHandlerArg /* Argument to pass to xBusyHandler */ |
dan | 6700d02 | 2010-04-12 19:05:58 +0000 | [diff] [blame] | 51 | ); |
| 52 | |
| 53 | #endif /* _LOG_H_ */ |