blob: 63fa8ae4335a55879baa0672cba87966ce59e6e7 [file] [log] [blame]
dan6700d022010-04-12 19:05:58 +00001/*
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
22/* Flags that may be set in the 'flags' argument to sqlite3LogWrite(): */
23#define LOG_MASK_COMMIT 0x08
24#define LOG_MASK_MASTERJOURNAL 0x10
25#define LOG_MASK_TRUNCATE 0x20
26
27
28#define LOG_TRUNCATE_BIT 0x80000000
29
30/* Connection to a log file. There is one object of this type for each pager. */
31typedef struct Log Log;
32
33/* Open and close a connection to a log file. */
34int sqlite3LogOpen(sqlite3_vfs*, const char *zDb, Log **ppLog);
35int sqlite3LogClose(Log *pLog, sqlite3_file *pFd, u8 *zBuf);
36
37/* Configure the log connection. */
38void sqlite3LogSetSyncflags(Log *, int sync_flags);
39
40/* Used by readers to open (lock) and close (unlock) a database snapshot. */
41int sqlite3LogOpenSnapshot(Log *pLog, int *);
42void sqlite3LogCloseSnapshot(Log *pLog);
43
44/* Read a page from the log, if it is present. */
45int sqlite3LogRead(Log *pLog, Pgno pgno, int *pInLog, u8 *pOut);
46void sqlite3LogMaxpgno(Log *pLog, Pgno *pPgno);
47
48/* Obtain or release the WRITER lock. */
49int sqlite3LogWriteLock(Log *pLog, int op);
50
51/* Write a segment to the log. */
52int sqlite3LogFrames(Log *pLog, int, PgHdr *, Pgno, int, int);
53
54/* Copy pages from the log to the database file */
55int sqlite3LogCheckpoint(
56 Log *pLog, /* Log connection */
57 sqlite3_file *pFd, /* File descriptor open on db file */
58 u8 *zBuf /* Temporary buffer to use */
59);
60
61#endif /* _LOG_H_ */