blob: c0699ba6fbf651e4b2c082a53bb980e733a9344d [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
dan74d6cd82010-04-24 18:44:05 +000040/* Undo any frames written (but not committed) to the log */
41int sqlite3LogUndo(Log *pLog, int (*xUndo)(void *, Pgno), void *pUndoCtx);
42
dan3306c4a2010-04-23 19:15:00 +000043/* Return true if data has been written but not committed to the log file. */
44int sqlite3LogDirty(Log *pLog);
45
danc5118782010-04-17 17:34:41 +000046/* Write a frame or frames to the log. */
dan6700d022010-04-12 19:05:58 +000047int sqlite3LogFrames(Log *pLog, int, PgHdr *, Pgno, int, int);
48
49/* Copy pages from the log to the database file */
50int sqlite3LogCheckpoint(
51 Log *pLog, /* Log connection */
52 sqlite3_file *pFd, /* File descriptor open on db file */
danc5118782010-04-17 17:34:41 +000053 int sync_flags, /* Flags to sync db file with (or 0) */
dan64d039e2010-04-13 19:27:31 +000054 u8 *zBuf, /* Temporary buffer to use */
55 int (*xBusyHandler)(void *), /* Pointer to busy-handler function */
56 void *pBusyHandlerArg /* Argument to pass to xBusyHandler */
dan6700d022010-04-12 19:05:58 +000057);
58
dan8d22a172010-04-19 18:03:51 +000059/* Return the value to pass to a log callback. Or 0 for no callback. */
60int sqlite3LogCallback(Log *pLog);
61
dan6700d022010-04-12 19:05:58 +000062#endif /* _LOG_H_ */