pager.h

Go to the documentation of this file.
00001 /*
00002 ** 2001 September 15
00003 **
00004 ** The author disclaims copyright to this source code.  In place of
00005 ** a legal notice, here is a blessing:
00006 **
00007 **    May you do good and not evil.
00008 **    May you find forgiveness for yourself and forgive others.
00009 **    May you share freely, never taking more than you give.
00010 **
00011 *************************************************************************
00012 ** This header file defines the interface that the sqlite page cache
00013 ** subsystem.  The page cache subsystem reads and writes a file a page
00014 ** at a time and provides a journal for rollback.
00015 **
00016 ** @(#) $Id: pager.h,v 1.86 2008/10/17 18:51:53 danielk1977 Exp $
00017 */
00018 
00019 #ifndef _PAGER_H_
00020 #define _PAGER_H_
00021 
00022 /*
00023 ** If defined as non-zero, auto-vacuum is enabled by default. Otherwise
00024 ** it must be turned on for each database using "PRAGMA auto_vacuum = 1".
00025 */
00026 #ifndef SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT
00027   #define SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT -1
00028 #endif
00029 
00030 /*
00031 ** The type used to represent a page number.  The first page in a file
00032 ** is called page 1.  0 is used to represent "not a page".
00033 */
00034 typedef u32 Pgno;
00035 
00036 /*
00037 ** Each open file is managed by a separate instance of the "Pager" structure.
00038 */
00039 typedef struct Pager Pager;
00040 
00041 /*
00042 ** Handle type for pages.
00043 */
00044 typedef struct PgHdr DbPage;
00045 
00046 /*
00047 ** Allowed values for the flags parameter to sqlite3PagerOpen().
00048 **
00049 ** NOTE: This values must match the corresponding BTREE_ values in btree.h.
00050 */
00051 #define PAGER_OMIT_JOURNAL  0x0001    /* Do not use a rollback journal */
00052 #define PAGER_NO_READLOCK   0x0002    /* Omit readlocks on readonly files */
00053 
00054 /*
00055 ** Valid values for the second argument to sqlite3PagerLockingMode().
00056 */
00057 #define PAGER_LOCKINGMODE_QUERY      -1
00058 #define PAGER_LOCKINGMODE_NORMAL      0
00059 #define PAGER_LOCKINGMODE_EXCLUSIVE   1
00060 
00061 /*
00062 ** Valid values for the second argument to sqlite3PagerJournalMode().
00063 */
00064 #define PAGER_JOURNALMODE_QUERY      -1
00065 #define PAGER_JOURNALMODE_DELETE      0   /* Commit by deleting journal file */
00066 #define PAGER_JOURNALMODE_PERSIST     1   /* Commit by zeroing journal header */
00067 #define PAGER_JOURNALMODE_OFF         2   /* Journal omitted.  */
00068 #define PAGER_JOURNALMODE_TRUNCATE    3   /* Commit by truncating journal */
00069 #define PAGER_JOURNALMODE_MEMORY      4   /* In-memory journal file */
00070 
00071 /*
00072 ** See source code comments for a detailed description of the following
00073 ** routines:
00074 */
00075 int sqlite3PagerOpen(sqlite3_vfs *, Pager **ppPager, const char*, int,int,int);
00076 void sqlite3PagerSetBusyhandler(Pager*, BusyHandler *pBusyHandler);
00077 void sqlite3PagerSetReiniter(Pager*, void(*)(DbPage*));
00078 int sqlite3PagerSetPagesize(Pager*, u16*);
00079 int sqlite3PagerMaxPageCount(Pager*, int);
00080 int sqlite3PagerReadFileheader(Pager*, int, unsigned char*);
00081 void sqlite3PagerSetCachesize(Pager*, int);
00082 int sqlite3PagerClose(Pager *pPager);
00083 int sqlite3PagerAcquire(Pager *pPager, Pgno pgno, DbPage **ppPage, int clrFlag);
00084 #define sqlite3PagerGet(A,B,C) sqlite3PagerAcquire(A,B,C,0)
00085 DbPage *sqlite3PagerLookup(Pager *pPager, Pgno pgno);
00086 int sqlite3PagerPageRefcount(DbPage*);
00087 int sqlite3PagerRef(DbPage*);
00088 int sqlite3PagerUnref(DbPage*);
00089 int sqlite3PagerWrite(DbPage*);
00090 int sqlite3PagerPagecount(Pager*, int*);
00091 int sqlite3PagerTruncate(Pager*,Pgno);
00092 int sqlite3PagerBegin(DbPage*, int exFlag);
00093 int sqlite3PagerCommitPhaseOne(Pager*,const char *zMaster, Pgno, int);
00094 int sqlite3PagerCommitPhaseTwo(Pager*);
00095 int sqlite3PagerRollback(Pager*);
00096 int sqlite3PagerIsreadonly(Pager*);
00097 int sqlite3PagerStmtBegin(Pager*);
00098 int sqlite3PagerStmtCommit(Pager*);
00099 int sqlite3PagerStmtRollback(Pager*);
00100 void sqlite3PagerDontRollback(DbPage*);
00101 int sqlite3PagerDontWrite(DbPage*);
00102 int sqlite3PagerRefcount(Pager*);
00103 void sqlite3PagerSetSafetyLevel(Pager*,int,int);
00104 const char *sqlite3PagerFilename(Pager*);
00105 const sqlite3_vfs *sqlite3PagerVfs(Pager*);
00106 sqlite3_file *sqlite3PagerFile(Pager*);
00107 const char *sqlite3PagerDirname(Pager*);
00108 const char *sqlite3PagerJournalname(Pager*);
00109 int sqlite3PagerNosync(Pager*);
00110 int sqlite3PagerMovepage(Pager*,DbPage*,Pgno,int);
00111 void *sqlite3PagerGetData(DbPage *); 
00112 void *sqlite3PagerGetExtra(DbPage *); 
00113 int sqlite3PagerLockingMode(Pager *, int);
00114 int sqlite3PagerJournalMode(Pager *, int);
00115 i64 sqlite3PagerJournalSizeLimit(Pager *, i64);
00116 void *sqlite3PagerTempSpace(Pager*);
00117 int sqlite3PagerSync(Pager *pPager);
00118 
00119 #ifdef SQLITE_HAS_CODEC
00120   void sqlite3PagerSetCodec(Pager*,void*(*)(void*,void*,Pgno,int),void*);
00121 #endif
00122 
00123 #if !defined(NDEBUG) || defined(SQLITE_TEST)
00124   Pgno sqlite3PagerPagenumber(DbPage*);
00125   int sqlite3PagerIswriteable(DbPage*);
00126 #endif
00127 
00128 #ifdef SQLITE_TEST
00129   int *sqlite3PagerStats(Pager*);
00130   void sqlite3PagerRefdump(Pager*);
00131   int sqlite3PagerIsMemdb(Pager*);
00132 #endif
00133 
00134 #ifdef SQLITE_TEST
00135 void disable_simulated_io_errors(void);
00136 void enable_simulated_io_errors(void);
00137 #else
00138 # define disable_simulated_io_errors()
00139 # define enable_simulated_io_errors()
00140 #endif
00141 
00142 #endif /* _PAGER_H_ */

ContextLogger2—ContextLogger2 Logger Daemon Internals—Generated on Mon May 2 13:49:55 2011 by Doxygen 1.6.1