Annotation of embedaddon/sqlite3/src/pager.h, revision 1.1
1.1 ! misho 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:
! 17: #ifndef _PAGER_H_
! 18: #define _PAGER_H_
! 19:
! 20: /*
! 21: ** Default maximum size for persistent journal files. A negative
! 22: ** value means no limit. This value may be overridden using the
! 23: ** sqlite3PagerJournalSizeLimit() API. See also "PRAGMA journal_size_limit".
! 24: */
! 25: #ifndef SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT
! 26: #define SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT -1
! 27: #endif
! 28:
! 29: /*
! 30: ** The type used to represent a page number. The first page in a file
! 31: ** is called page 1. 0 is used to represent "not a page".
! 32: */
! 33: typedef u32 Pgno;
! 34:
! 35: /*
! 36: ** Each open file is managed by a separate instance of the "Pager" structure.
! 37: */
! 38: typedef struct Pager Pager;
! 39:
! 40: /*
! 41: ** Handle type for pages.
! 42: */
! 43: typedef struct PgHdr DbPage;
! 44:
! 45: /*
! 46: ** Page number PAGER_MJ_PGNO is never used in an SQLite database (it is
! 47: ** reserved for working around a windows/posix incompatibility). It is
! 48: ** used in the journal to signify that the remainder of the journal file
! 49: ** is devoted to storing a master journal name - there are no more pages to
! 50: ** roll back. See comments for function writeMasterJournal() in pager.c
! 51: ** for details.
! 52: */
! 53: #define PAGER_MJ_PGNO(x) ((Pgno)((PENDING_BYTE/((x)->pageSize))+1))
! 54:
! 55: /*
! 56: ** Allowed values for the flags parameter to sqlite3PagerOpen().
! 57: **
! 58: ** NOTE: These values must match the corresponding BTREE_ values in btree.h.
! 59: */
! 60: #define PAGER_OMIT_JOURNAL 0x0001 /* Do not use a rollback journal */
! 61: #define PAGER_NO_READLOCK 0x0002 /* Omit readlocks on readonly files */
! 62: #define PAGER_MEMORY 0x0004 /* In-memory database */
! 63:
! 64: /*
! 65: ** Valid values for the second argument to sqlite3PagerLockingMode().
! 66: */
! 67: #define PAGER_LOCKINGMODE_QUERY -1
! 68: #define PAGER_LOCKINGMODE_NORMAL 0
! 69: #define PAGER_LOCKINGMODE_EXCLUSIVE 1
! 70:
! 71: /*
! 72: ** Numeric constants that encode the journalmode.
! 73: */
! 74: #define PAGER_JOURNALMODE_QUERY (-1) /* Query the value of journalmode */
! 75: #define PAGER_JOURNALMODE_DELETE 0 /* Commit by deleting journal file */
! 76: #define PAGER_JOURNALMODE_PERSIST 1 /* Commit by zeroing journal header */
! 77: #define PAGER_JOURNALMODE_OFF 2 /* Journal omitted. */
! 78: #define PAGER_JOURNALMODE_TRUNCATE 3 /* Commit by truncating journal */
! 79: #define PAGER_JOURNALMODE_MEMORY 4 /* In-memory journal file */
! 80: #define PAGER_JOURNALMODE_WAL 5 /* Use write-ahead logging */
! 81:
! 82: /*
! 83: ** The remainder of this file contains the declarations of the functions
! 84: ** that make up the Pager sub-system API. See source code comments for
! 85: ** a detailed description of each routine.
! 86: */
! 87:
! 88: /* Open and close a Pager connection. */
! 89: int sqlite3PagerOpen(
! 90: sqlite3_vfs*,
! 91: Pager **ppPager,
! 92: const char*,
! 93: int,
! 94: int,
! 95: int,
! 96: void(*)(DbPage*)
! 97: );
! 98: int sqlite3PagerClose(Pager *pPager);
! 99: int sqlite3PagerReadFileheader(Pager*, int, unsigned char*);
! 100:
! 101: /* Functions used to configure a Pager object. */
! 102: void sqlite3PagerSetBusyhandler(Pager*, int(*)(void *), void *);
! 103: int sqlite3PagerSetPagesize(Pager*, u32*, int);
! 104: int sqlite3PagerMaxPageCount(Pager*, int);
! 105: void sqlite3PagerSetCachesize(Pager*, int);
! 106: void sqlite3PagerShrink(Pager*);
! 107: void sqlite3PagerSetSafetyLevel(Pager*,int,int,int);
! 108: int sqlite3PagerLockingMode(Pager *, int);
! 109: int sqlite3PagerSetJournalMode(Pager *, int);
! 110: int sqlite3PagerGetJournalMode(Pager*);
! 111: int sqlite3PagerOkToChangeJournalMode(Pager*);
! 112: i64 sqlite3PagerJournalSizeLimit(Pager *, i64);
! 113: sqlite3_backup **sqlite3PagerBackupPtr(Pager*);
! 114:
! 115: /* Functions used to obtain and release page references. */
! 116: int sqlite3PagerAcquire(Pager *pPager, Pgno pgno, DbPage **ppPage, int clrFlag);
! 117: #define sqlite3PagerGet(A,B,C) sqlite3PagerAcquire(A,B,C,0)
! 118: DbPage *sqlite3PagerLookup(Pager *pPager, Pgno pgno);
! 119: void sqlite3PagerRef(DbPage*);
! 120: void sqlite3PagerUnref(DbPage*);
! 121:
! 122: /* Operations on page references. */
! 123: int sqlite3PagerWrite(DbPage*);
! 124: void sqlite3PagerDontWrite(DbPage*);
! 125: int sqlite3PagerMovepage(Pager*,DbPage*,Pgno,int);
! 126: int sqlite3PagerPageRefcount(DbPage*);
! 127: void *sqlite3PagerGetData(DbPage *);
! 128: void *sqlite3PagerGetExtra(DbPage *);
! 129:
! 130: /* Functions used to manage pager transactions and savepoints. */
! 131: void sqlite3PagerPagecount(Pager*, int*);
! 132: int sqlite3PagerBegin(Pager*, int exFlag, int);
! 133: int sqlite3PagerCommitPhaseOne(Pager*,const char *zMaster, int);
! 134: int sqlite3PagerExclusiveLock(Pager*);
! 135: int sqlite3PagerSync(Pager *pPager);
! 136: int sqlite3PagerCommitPhaseTwo(Pager*);
! 137: int sqlite3PagerRollback(Pager*);
! 138: int sqlite3PagerOpenSavepoint(Pager *pPager, int n);
! 139: int sqlite3PagerSavepoint(Pager *pPager, int op, int iSavepoint);
! 140: int sqlite3PagerSharedLock(Pager *pPager);
! 141:
! 142: int sqlite3PagerCheckpoint(Pager *pPager, int, int*, int*);
! 143: int sqlite3PagerWalSupported(Pager *pPager);
! 144: int sqlite3PagerWalCallback(Pager *pPager);
! 145: int sqlite3PagerOpenWal(Pager *pPager, int *pisOpen);
! 146: int sqlite3PagerCloseWal(Pager *pPager);
! 147:
! 148: /* Functions used to query pager state and configuration. */
! 149: u8 sqlite3PagerIsreadonly(Pager*);
! 150: int sqlite3PagerRefcount(Pager*);
! 151: int sqlite3PagerMemUsed(Pager*);
! 152: const char *sqlite3PagerFilename(Pager*);
! 153: const sqlite3_vfs *sqlite3PagerVfs(Pager*);
! 154: sqlite3_file *sqlite3PagerFile(Pager*);
! 155: const char *sqlite3PagerJournalname(Pager*);
! 156: int sqlite3PagerNosync(Pager*);
! 157: void *sqlite3PagerTempSpace(Pager*);
! 158: int sqlite3PagerIsMemdb(Pager*);
! 159: void sqlite3PagerCacheStat(Pager *, int, int, int *);
! 160: void sqlite3PagerClearCache(Pager *);
! 161:
! 162: /* Functions used to truncate the database file. */
! 163: void sqlite3PagerTruncateImage(Pager*,Pgno);
! 164:
! 165: #if defined(SQLITE_HAS_CODEC) && !defined(SQLITE_OMIT_WAL)
! 166: void *sqlite3PagerCodec(DbPage *);
! 167: #endif
! 168:
! 169: /* Functions to support testing and debugging. */
! 170: #if !defined(NDEBUG) || defined(SQLITE_TEST)
! 171: Pgno sqlite3PagerPagenumber(DbPage*);
! 172: int sqlite3PagerIswriteable(DbPage*);
! 173: #endif
! 174: #ifdef SQLITE_TEST
! 175: int *sqlite3PagerStats(Pager*);
! 176: void sqlite3PagerRefdump(Pager*);
! 177: void disable_simulated_io_errors(void);
! 178: void enable_simulated_io_errors(void);
! 179: #else
! 180: # define disable_simulated_io_errors()
! 181: # define enable_simulated_io_errors()
! 182: #endif
! 183:
! 184: #endif /* _PAGER_H_ */
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>