1 /* 2 ** 2001 September 15 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 that the sqlite page cache 13 ** subsystem. The page cache subsystem reads and writes a file a page 14 ** at a time and provides a journal for rollback. 15 ** 16 ** @(#) $Id: pager.h,v 1.70 2008/03/20 11:04:21 danielk1977 Exp $ 17 */ 18 19 #ifndef _PAGER_H_ 20 #define _PAGER_H_ 21 22 /* 23 ** The type used to represent a page number. The first page in a file 24 ** is called page 1. 0 is used to represent "not a page". 25 */ 26 typedef unsigned int Pgno; 27 28 /* 29 ** Each open file is managed by a separate instance of the "Pager" structure. 30 */ 31 typedef struct Pager Pager; 32 33 /* 34 ** Handle type for pages. 35 */ 36 typedef struct PgHdr DbPage; 37 38 /* 39 ** Allowed values for the flags parameter to sqlite3PagerOpen(). 40 ** 41 ** NOTE: This values must match the corresponding BTREE_ values in btree.h. 42 */ 43 #define PAGER_OMIT_JOURNAL 0x0001 /* Do not use a rollback journal */ 44 #define PAGER_NO_READLOCK 0x0002 /* Omit readlocks on readonly files */ 45 46 /* 47 ** Valid values for the second argument to sqlite3PagerLockingMode(). 48 */ 49 #define PAGER_LOCKINGMODE_QUERY -1 50 #define PAGER_LOCKINGMODE_NORMAL 0 51 #define PAGER_LOCKINGMODE_EXCLUSIVE 1 52 53 /* 54 ** See source code comments for a detailed description of the following 55 ** routines: 56 */ 57 int sqlite3PagerOpen(sqlite3_vfs *, Pager **ppPager, const char*, int,int,int); 58 void sqlite3PagerSetBusyhandler(Pager*, BusyHandler *pBusyHandler); 59 void sqlite3PagerSetDestructor(Pager*, void(*)(DbPage*,int)); 60 void sqlite3PagerSetReiniter(Pager*, void(*)(DbPage*,int)); 61 int sqlite3PagerSetPagesize(Pager*, u16*); 62 int sqlite3PagerMaxPageCount(Pager*, int); 63 int sqlite3PagerReadFileheader(Pager*, int, unsigned char*); 64 void sqlite3PagerSetCachesize(Pager*, int); 65 int sqlite3PagerClose(Pager *pPager); 66 int sqlite3PagerAcquire(Pager *pPager, Pgno pgno, DbPage **ppPage, int clrFlag); 67 #define sqlite3PagerGet(A,B,C) sqlite3PagerAcquire(A,B,C,0) 68 DbPage *sqlite3PagerLookup(Pager *pPager, Pgno pgno); 69 int sqlite3PagerRef(DbPage*); 70 int sqlite3PagerUnref(DbPage*); 71 int sqlite3PagerWrite(DbPage*); 72 int sqlite3PagerOverwrite(Pager *pPager, Pgno pgno, void*); 73 int sqlite3PagerPagecount(Pager*); 74 int sqlite3PagerTruncate(Pager*,Pgno); 75 int sqlite3PagerBegin(DbPage*, int exFlag); 76 int sqlite3PagerCommitPhaseOne(Pager*,const char *zMaster, Pgno, int); 77 int sqlite3PagerCommitPhaseTwo(Pager*); 78 int sqlite3PagerRollback(Pager*); 79 int sqlite3PagerIsreadonly(Pager*); 80 int sqlite3PagerStmtBegin(Pager*); 81 int sqlite3PagerStmtCommit(Pager*); 82 int sqlite3PagerStmtRollback(Pager*); 83 void sqlite3PagerDontRollback(DbPage*); 84 void sqlite3PagerDontWrite(DbPage*); 85 int sqlite3PagerRefcount(Pager*); 86 void sqlite3PagerSetSafetyLevel(Pager*,int,int); 87 const char *sqlite3PagerFilename(Pager*); 88 const sqlite3_vfs *sqlite3PagerVfs(Pager*); 89 sqlite3_file *sqlite3PagerFile(Pager*); 90 const char *sqlite3PagerDirname(Pager*); 91 const char *sqlite3PagerJournalname(Pager*); 92 int sqlite3PagerNosync(Pager*); 93 int sqlite3PagerMovepage(Pager*,DbPage*,Pgno); 94 void *sqlite3PagerGetData(DbPage *); 95 void *sqlite3PagerGetExtra(DbPage *); 96 int sqlite3PagerLockingMode(Pager *, int); 97 void *sqlite3PagerTempSpace(Pager*); 98 int sqlite3PagerSync(Pager *pPager); 99 100 #if defined(SQLITE_ENABLE_MEMORY_MANAGEMENT) && !defined(SQLITE_OMIT_DISKIO) 101 int sqlite3PagerReleaseMemory(int); 102 #endif 103 104 #ifdef SQLITE_HAS_CODEC 105 void sqlite3PagerSetCodec(Pager*,void*(*)(void*,void*,Pgno,int),void*); 106 #endif 107 108 #if !defined(NDEBUG) || defined(SQLITE_TEST) 109 Pgno sqlite3PagerPagenumber(DbPage*); 110 int sqlite3PagerIswriteable(DbPage*); 111 #endif 112 113 #ifdef SQLITE_TEST 114 int *sqlite3PagerStats(Pager*); 115 void sqlite3PagerRefdump(Pager*); 116 #endif 117 118 #ifdef SQLITE_TEST 119 void disable_simulated_io_errors(void); 120 void enable_simulated_io_errors(void); 121 #else 122 # define disable_simulated_io_errors() 123 # define enable_simulated_io_errors() 124 #endif 125 126 #endif /* _PAGER_H_ */ 127