sl@0: /* sl@0: ** 2001 September 15 sl@0: ** sl@0: ** The author disclaims copyright to this source code. In place of sl@0: ** a legal notice, here is a blessing: sl@0: ** sl@0: ** May you do good and not evil. sl@0: ** May you find forgiveness for yourself and forgive others. sl@0: ** May you share freely, never taking more than you give. sl@0: ** sl@0: ************************************************************************* sl@0: ** This header file defines the interface that the sqlite page cache sl@0: ** subsystem. The page cache subsystem reads and writes a file a page sl@0: ** at a time and provides a journal for rollback. sl@0: ** sl@0: ** @(#) $Id: pager.h,v 1.85 2008/09/29 11:49:48 danielk1977 Exp $ sl@0: */ sl@0: sl@0: #ifndef _PAGER_H_ sl@0: #define _PAGER_H_ sl@0: sl@0: /* sl@0: ** If defined as non-zero, auto-vacuum is enabled by default. Otherwise sl@0: ** it must be turned on for each database using "PRAGMA auto_vacuum = 1". sl@0: */ sl@0: #ifndef SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT sl@0: #define SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT -1 sl@0: #endif sl@0: sl@0: /* sl@0: ** The type used to represent a page number. The first page in a file sl@0: ** is called page 1. 0 is used to represent "not a page". sl@0: */ sl@0: typedef u32 Pgno; sl@0: sl@0: /* sl@0: ** Each open file is managed by a separate instance of the "Pager" structure. sl@0: */ sl@0: typedef struct Pager Pager; sl@0: sl@0: /* sl@0: ** Handle type for pages. sl@0: */ sl@0: typedef struct PgHdr DbPage; sl@0: sl@0: /* sl@0: ** Allowed values for the flags parameter to sqlite3PagerOpen(). sl@0: ** sl@0: ** NOTE: This values must match the corresponding BTREE_ values in btree.h. sl@0: */ sl@0: #define PAGER_OMIT_JOURNAL 0x0001 /* Do not use a rollback journal */ sl@0: #define PAGER_NO_READLOCK 0x0002 /* Omit readlocks on readonly files */ sl@0: sl@0: /* sl@0: ** Valid values for the second argument to sqlite3PagerLockingMode(). sl@0: */ sl@0: #define PAGER_LOCKINGMODE_QUERY -1 sl@0: #define PAGER_LOCKINGMODE_NORMAL 0 sl@0: #define PAGER_LOCKINGMODE_EXCLUSIVE 1 sl@0: sl@0: /* sl@0: ** Valid values for the second argument to sqlite3PagerJournalMode(). sl@0: */ sl@0: #define PAGER_JOURNALMODE_QUERY -1 sl@0: #define PAGER_JOURNALMODE_DELETE 0 /* Commit by deleting journal file */ sl@0: #define PAGER_JOURNALMODE_PERSIST 1 /* Commit by zeroing journal header */ sl@0: #define PAGER_JOURNALMODE_OFF 2 /* Journal omitted. */ sl@0: #define PAGER_JOURNALMODE_TRUNCATE 3 /* Commit by truncating journal */ sl@0: sl@0: /* sl@0: ** See source code comments for a detailed description of the following sl@0: ** routines: sl@0: */ sl@0: int sqlite3PagerOpen(sqlite3_vfs *, Pager **ppPager, const char*, int,int,int); sl@0: void sqlite3PagerSetBusyhandler(Pager*, BusyHandler *pBusyHandler); sl@0: void sqlite3PagerSetReiniter(Pager*, void(*)(DbPage*)); sl@0: int sqlite3PagerSetPagesize(Pager*, u16*); sl@0: int sqlite3PagerMaxPageCount(Pager*, int); sl@0: int sqlite3PagerReadFileheader(Pager*, int, unsigned char*); sl@0: void sqlite3PagerSetCachesize(Pager*, int); sl@0: int sqlite3PagerClose(Pager *pPager); sl@0: int sqlite3PagerAcquire(Pager *pPager, Pgno pgno, DbPage **ppPage, int clrFlag); sl@0: #define sqlite3PagerGet(A,B,C) sqlite3PagerAcquire(A,B,C,0) sl@0: DbPage *sqlite3PagerLookup(Pager *pPager, Pgno pgno); sl@0: int sqlite3PagerPageRefcount(DbPage*); sl@0: int sqlite3PagerRef(DbPage*); sl@0: int sqlite3PagerUnref(DbPage*); sl@0: int sqlite3PagerWrite(DbPage*); sl@0: int sqlite3PagerPagecount(Pager*, int*); sl@0: int sqlite3PagerTruncate(Pager*,Pgno); sl@0: int sqlite3PagerBegin(DbPage*, int exFlag); sl@0: int sqlite3PagerCommitPhaseOne(Pager*,const char *zMaster, Pgno, int); sl@0: int sqlite3PagerCommitPhaseTwo(Pager*); sl@0: int sqlite3PagerRollback(Pager*); sl@0: int sqlite3PagerIsreadonly(Pager*); sl@0: int sqlite3PagerStmtBegin(Pager*); sl@0: int sqlite3PagerStmtCommit(Pager*); sl@0: int sqlite3PagerStmtRollback(Pager*); sl@0: void sqlite3PagerDontRollback(DbPage*); sl@0: int sqlite3PagerDontWrite(DbPage*); sl@0: int sqlite3PagerRefcount(Pager*); sl@0: void sqlite3PagerSetSafetyLevel(Pager*,int,int); sl@0: const char *sqlite3PagerFilename(Pager*); sl@0: const sqlite3_vfs *sqlite3PagerVfs(Pager*); sl@0: sqlite3_file *sqlite3PagerFile(Pager*); sl@0: const char *sqlite3PagerDirname(Pager*); sl@0: const char *sqlite3PagerJournalname(Pager*); sl@0: int sqlite3PagerNosync(Pager*); sl@0: int sqlite3PagerMovepage(Pager*,DbPage*,Pgno,int); sl@0: void *sqlite3PagerGetData(DbPage *); sl@0: void *sqlite3PagerGetExtra(DbPage *); sl@0: int sqlite3PagerLockingMode(Pager *, int); sl@0: int sqlite3PagerJournalMode(Pager *, int); sl@0: i64 sqlite3PagerJournalSizeLimit(Pager *, i64); sl@0: void *sqlite3PagerTempSpace(Pager*); sl@0: int sqlite3PagerSync(Pager *pPager); sl@0: sl@0: #ifdef SQLITE_HAS_CODEC sl@0: void sqlite3PagerSetCodec(Pager*,void*(*)(void*,void*,Pgno,int),void*); sl@0: #endif sl@0: sl@0: #if !defined(NDEBUG) || defined(SQLITE_TEST) sl@0: Pgno sqlite3PagerPagenumber(DbPage*); sl@0: int sqlite3PagerIswriteable(DbPage*); sl@0: #endif sl@0: sl@0: #ifdef SQLITE_TEST sl@0: int *sqlite3PagerStats(Pager*); sl@0: void sqlite3PagerRefdump(Pager*); sl@0: int sqlite3PagerIsMemdb(Pager*); sl@0: #endif sl@0: sl@0: #ifdef SQLITE_TEST sl@0: void disable_simulated_io_errors(void); sl@0: void enable_simulated_io_errors(void); sl@0: #else sl@0: # define disable_simulated_io_errors() sl@0: # define enable_simulated_io_errors() sl@0: #endif sl@0: sl@0: #endif /* _PAGER_H_ */