blob: 02201c837e8d7f6f816b86e1388065b704fab58c [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
dan6700d022010-04-12 19:05:58 +000022/* Connection to a log file. There is one object of this type for each pager. */
23typedef struct Log Log;
24
25/* Open and close a connection to a log file. */
26int sqlite3LogOpen(sqlite3_vfs*, const char *zDb, Log **ppLog);
danc5118782010-04-17 17:34:41 +000027int sqlite3LogClose(Log *pLog, sqlite3_file *pFd, int sync_flags, u8 *zBuf);
dan6700d022010-04-12 19:05:58 +000028
danc5118782010-04-17 17:34:41 +000029/* Used by readers to open (lock) and close (unlock) a snapshot. */
dan6700d022010-04-12 19:05:58 +000030int sqlite3LogOpenSnapshot(Log *pLog, int *);
31void sqlite3LogCloseSnapshot(Log *pLog);
32
33/* Read a page from the log, if it is present. */
34int sqlite3LogRead(Log *pLog, Pgno pgno, int *pInLog, u8 *pOut);
dan8d22a172010-04-19 18:03:51 +000035void sqlite3LogDbsize(Log *pLog, Pgno *pPgno);
dan6700d022010-04-12 19:05:58 +000036
37/* Obtain or release the WRITER lock. */
38int sqlite3LogWriteLock(Log *pLog, int op);
39
dan3306c4a2010-04-23 19:15:00 +000040/* Return true if data has been written but not committed to the log file. */
41int sqlite3LogDirty(Log *pLog);
42
danc5118782010-04-17 17:34:41 +000043/* Write a frame or frames to the log. */
dan6700d022010-04-12 19:05:58 +000044int sqlite3LogFrames(Log *pLog, int, PgHdr *, Pgno, int, int);
45
46/* Copy pages from the log to the database file */
47int sqlite3LogCheckpoint(
48 Log *pLog, /* Log connection */
49 sqlite3_file *pFd, /* File descriptor open on db file */
danc5118782010-04-17 17:34:41 +000050 int sync_flags, /* Flags to sync db file with (or 0) */
dan64d039e2010-04-13 19:27:31 +000051 u8 *zBuf, /* Temporary buffer to use */
52 int (*xBusyHandler)(void *), /* Pointer to busy-handler function */
53 void *pBusyHandlerArg /* Argument to pass to xBusyHandler */
dan6700d022010-04-12 19:05:58 +000054);
55
dan8d22a172010-04-19 18:03:51 +000056/* Return the value to pass to a log callback. Or 0 for no callback. */
57int sqlite3LogCallback(Log *pLog);
58
dan6700d022010-04-12 19:05:58 +000059#endif /* _LOG_H_ */