| OLD | NEW |
| 1 /* | 1 /* |
| 2 ** 2001 September 15 | 2 ** 2001 September 15 |
| 3 ** | 3 ** |
| 4 ** The author disclaims copyright to this source code. In place of | 4 ** The author disclaims copyright to this source code. In place of |
| 5 ** a legal notice, here is a blessing: | 5 ** a legal notice, here is a blessing: |
| 6 ** | 6 ** |
| 7 ** May you do good and not evil. | 7 ** May you do good and not evil. |
| 8 ** May you find forgiveness for yourself and forgive others. | 8 ** May you find forgiveness for yourself and forgive others. |
| 9 ** May you share freely, never taking more than you give. | 9 ** May you share freely, never taking more than you give. |
| 10 ** | 10 ** |
| 11 ************************************************************************* | 11 ************************************************************************* |
| 12 ** This header file defines the interface that the sqlite page cache | 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 | 13 ** subsystem. The page cache subsystem reads and writes a file a page |
| 14 ** at a time and provides a journal for rollback. | 14 ** at a time and provides a journal for rollback. |
| 15 */ | 15 */ |
| 16 | 16 |
| 17 #ifndef _PAGER_H_ | 17 #ifndef SQLITE_PAGER_H |
| 18 #define _PAGER_H_ | 18 #define SQLITE_PAGER_H |
| 19 | 19 |
| 20 /* | 20 /* |
| 21 ** Default maximum size for persistent journal files. A negative | 21 ** Default maximum size for persistent journal files. A negative |
| 22 ** value means no limit. This value may be overridden using the | 22 ** value means no limit. This value may be overridden using the |
| 23 ** sqlite3PagerJournalSizeLimit() API. See also "PRAGMA journal_size_limit". | 23 ** sqlite3PagerJournalSizeLimit() API. See also "PRAGMA journal_size_limit". |
| 24 */ | 24 */ |
| 25 #ifndef SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT | 25 #ifndef SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT |
| 26 #define SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT -1 | 26 #define SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT -1 |
| 27 #endif | 27 #endif |
| 28 | 28 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 #define PAGER_MEMORY 0x0002 /* In-memory database */ | 61 #define PAGER_MEMORY 0x0002 /* In-memory database */ |
| 62 | 62 |
| 63 /* | 63 /* |
| 64 ** Valid values for the second argument to sqlite3PagerLockingMode(). | 64 ** Valid values for the second argument to sqlite3PagerLockingMode(). |
| 65 */ | 65 */ |
| 66 #define PAGER_LOCKINGMODE_QUERY -1 | 66 #define PAGER_LOCKINGMODE_QUERY -1 |
| 67 #define PAGER_LOCKINGMODE_NORMAL 0 | 67 #define PAGER_LOCKINGMODE_NORMAL 0 |
| 68 #define PAGER_LOCKINGMODE_EXCLUSIVE 1 | 68 #define PAGER_LOCKINGMODE_EXCLUSIVE 1 |
| 69 | 69 |
| 70 /* | 70 /* |
| 71 ** Numeric constants that encode the journalmode. | 71 ** Numeric constants that encode the journalmode. |
| 72 ** |
| 73 ** The numeric values encoded here (other than PAGER_JOURNALMODE_QUERY) |
| 74 ** are exposed in the API via the "PRAGMA journal_mode" command and |
| 75 ** therefore cannot be changed without a compatibility break. |
| 72 */ | 76 */ |
| 73 #define PAGER_JOURNALMODE_QUERY (-1) /* Query the value of journalmode */ | 77 #define PAGER_JOURNALMODE_QUERY (-1) /* Query the value of journalmode */ |
| 74 #define PAGER_JOURNALMODE_DELETE 0 /* Commit by deleting journal file */ | 78 #define PAGER_JOURNALMODE_DELETE 0 /* Commit by deleting journal file */ |
| 75 #define PAGER_JOURNALMODE_PERSIST 1 /* Commit by zeroing journal header */ | 79 #define PAGER_JOURNALMODE_PERSIST 1 /* Commit by zeroing journal header */ |
| 76 #define PAGER_JOURNALMODE_OFF 2 /* Journal omitted. */ | 80 #define PAGER_JOURNALMODE_OFF 2 /* Journal omitted. */ |
| 77 #define PAGER_JOURNALMODE_TRUNCATE 3 /* Commit by truncating journal */ | 81 #define PAGER_JOURNALMODE_TRUNCATE 3 /* Commit by truncating journal */ |
| 78 #define PAGER_JOURNALMODE_MEMORY 4 /* In-memory journal file */ | 82 #define PAGER_JOURNALMODE_MEMORY 4 /* In-memory journal file */ |
| 79 #define PAGER_JOURNALMODE_WAL 5 /* Use write-ahead logging */ | 83 #define PAGER_JOURNALMODE_WAL 5 /* Use write-ahead logging */ |
| 80 | 84 |
| 81 /* | 85 /* |
| 82 ** Flags that make up the mask passed to sqlite3PagerGet(). | 86 ** Flags that make up the mask passed to sqlite3PagerGet(). |
| 83 */ | 87 */ |
| 84 #define PAGER_GET_NOCONTENT 0x01 /* Do not load data from disk */ | 88 #define PAGER_GET_NOCONTENT 0x01 /* Do not load data from disk */ |
| 85 #define PAGER_GET_READONLY 0x02 /* Read-only page is acceptable */ | 89 #define PAGER_GET_READONLY 0x02 /* Read-only page is acceptable */ |
| 86 | 90 |
| 87 /* | 91 /* |
| 88 ** Flags for sqlite3PagerSetFlags() | 92 ** Flags for sqlite3PagerSetFlags() |
| 93 ** |
| 94 ** Value constraints (enforced via assert()): |
| 95 ** PAGER_FULLFSYNC == SQLITE_FullFSync |
| 96 ** PAGER_CKPT_FULLFSYNC == SQLITE_CkptFullFSync |
| 97 ** PAGER_CACHE_SPILL == SQLITE_CacheSpill |
| 89 */ | 98 */ |
| 90 #define PAGER_SYNCHRONOUS_OFF 0x01 /* PRAGMA synchronous=OFF */ | 99 #define PAGER_SYNCHRONOUS_OFF 0x01 /* PRAGMA synchronous=OFF */ |
| 91 #define PAGER_SYNCHRONOUS_NORMAL 0x02 /* PRAGMA synchronous=NORMAL */ | 100 #define PAGER_SYNCHRONOUS_NORMAL 0x02 /* PRAGMA synchronous=NORMAL */ |
| 92 #define PAGER_SYNCHRONOUS_FULL 0x03 /* PRAGMA synchronous=FULL */ | 101 #define PAGER_SYNCHRONOUS_FULL 0x03 /* PRAGMA synchronous=FULL */ |
| 93 #define PAGER_SYNCHRONOUS_MASK 0x03 /* Mask for three values above */ | 102 #define PAGER_SYNCHRONOUS_EXTRA 0x04 /* PRAGMA synchronous=EXTRA */ |
| 94 #define PAGER_FULLFSYNC 0x04 /* PRAGMA fullfsync=ON */ | 103 #define PAGER_SYNCHRONOUS_MASK 0x07 /* Mask for four values above */ |
| 95 #define PAGER_CKPT_FULLFSYNC 0x08 /* PRAGMA checkpoint_fullfsync=ON */ | 104 #define PAGER_FULLFSYNC 0x08 /* PRAGMA fullfsync=ON */ |
| 96 #define PAGER_CACHESPILL 0x10 /* PRAGMA cache_spill=ON */ | 105 #define PAGER_CKPT_FULLFSYNC 0x10 /* PRAGMA checkpoint_fullfsync=ON */ |
| 97 #define PAGER_FLAGS_MASK 0x1c /* All above except SYNCHRONOUS */ | 106 #define PAGER_CACHESPILL 0x20 /* PRAGMA cache_spill=ON */ |
| 107 #define PAGER_FLAGS_MASK 0x38 /* All above except SYNCHRONOUS */ |
| 98 | 108 |
| 99 /* | 109 /* |
| 100 ** The remainder of this file contains the declarations of the functions | 110 ** The remainder of this file contains the declarations of the functions |
| 101 ** that make up the Pager sub-system API. See source code comments for | 111 ** that make up the Pager sub-system API. See source code comments for |
| 102 ** a detailed description of each routine. | 112 ** a detailed description of each routine. |
| 103 */ | 113 */ |
| 104 | 114 |
| 105 /* Open and close a Pager connection. */ | 115 /* Open and close a Pager connection. */ |
| 106 int sqlite3PagerOpen( | 116 int sqlite3PagerOpen( |
| 107 sqlite3_vfs*, | 117 sqlite3_vfs*, |
| 108 Pager **ppPager, | 118 Pager **ppPager, |
| 109 const char*, | 119 const char*, |
| 110 int, | 120 int, |
| 111 int, | 121 int, |
| 112 int, | 122 int, |
| 113 void(*)(DbPage*) | 123 void(*)(DbPage*) |
| 114 ); | 124 ); |
| 115 int sqlite3PagerClose(Pager *pPager); | 125 int sqlite3PagerClose(Pager *pPager, sqlite3*); |
| 116 int sqlite3PagerReadFileheader(Pager*, int, unsigned char*); | 126 int sqlite3PagerReadFileheader(Pager*, int, unsigned char*); |
| 117 | 127 |
| 118 /* Functions used to configure a Pager object. */ | 128 /* Functions used to configure a Pager object. */ |
| 119 void sqlite3PagerSetBusyhandler(Pager*, int(*)(void *), void *); | 129 void sqlite3PagerSetBusyhandler(Pager*, int(*)(void *), void *); |
| 120 int sqlite3PagerSetPagesize(Pager*, u32*, int); | 130 int sqlite3PagerSetPagesize(Pager*, u32*, int); |
| 121 #ifdef SQLITE_HAS_CODEC | 131 #ifdef SQLITE_HAS_CODEC |
| 122 void sqlite3PagerAlignReserve(Pager*,Pager*); | 132 void sqlite3PagerAlignReserve(Pager*,Pager*); |
| 123 #endif | 133 #endif |
| 124 int sqlite3PagerMaxPageCount(Pager*, int); | 134 int sqlite3PagerMaxPageCount(Pager*, int); |
| 125 void sqlite3PagerSetCachesize(Pager*, int); | 135 void sqlite3PagerSetCachesize(Pager*, int); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 156 int sqlite3PagerCommitPhaseOne(Pager*,const char *zMaster, int); | 166 int sqlite3PagerCommitPhaseOne(Pager*,const char *zMaster, int); |
| 157 int sqlite3PagerExclusiveLock(Pager*); | 167 int sqlite3PagerExclusiveLock(Pager*); |
| 158 int sqlite3PagerSync(Pager *pPager, const char *zMaster); | 168 int sqlite3PagerSync(Pager *pPager, const char *zMaster); |
| 159 int sqlite3PagerCommitPhaseTwo(Pager*); | 169 int sqlite3PagerCommitPhaseTwo(Pager*); |
| 160 int sqlite3PagerRollback(Pager*); | 170 int sqlite3PagerRollback(Pager*); |
| 161 int sqlite3PagerOpenSavepoint(Pager *pPager, int n); | 171 int sqlite3PagerOpenSavepoint(Pager *pPager, int n); |
| 162 int sqlite3PagerSavepoint(Pager *pPager, int op, int iSavepoint); | 172 int sqlite3PagerSavepoint(Pager *pPager, int op, int iSavepoint); |
| 163 int sqlite3PagerSharedLock(Pager *pPager); | 173 int sqlite3PagerSharedLock(Pager *pPager); |
| 164 | 174 |
| 165 #ifndef SQLITE_OMIT_WAL | 175 #ifndef SQLITE_OMIT_WAL |
| 166 int sqlite3PagerCheckpoint(Pager *pPager, int, int*, int*); | 176 int sqlite3PagerCheckpoint(Pager *pPager, sqlite3*, int, int*, int*); |
| 167 int sqlite3PagerWalSupported(Pager *pPager); | 177 int sqlite3PagerWalSupported(Pager *pPager); |
| 168 int sqlite3PagerWalCallback(Pager *pPager); | 178 int sqlite3PagerWalCallback(Pager *pPager); |
| 169 int sqlite3PagerOpenWal(Pager *pPager, int *pisOpen); | 179 int sqlite3PagerOpenWal(Pager *pPager, int *pisOpen); |
| 170 int sqlite3PagerCloseWal(Pager *pPager); | 180 int sqlite3PagerCloseWal(Pager *pPager, sqlite3*); |
| 181 # ifdef SQLITE_DIRECT_OVERFLOW_READ |
| 182 int sqlite3PagerUseWal(Pager *pPager, Pgno); |
| 183 # endif |
| 171 # ifdef SQLITE_ENABLE_SNAPSHOT | 184 # ifdef SQLITE_ENABLE_SNAPSHOT |
| 172 int sqlite3PagerSnapshotGet(Pager *pPager, sqlite3_snapshot **ppSnapshot); | 185 int sqlite3PagerSnapshotGet(Pager *pPager, sqlite3_snapshot **ppSnapshot); |
| 173 int sqlite3PagerSnapshotOpen(Pager *pPager, sqlite3_snapshot *pSnapshot); | 186 int sqlite3PagerSnapshotOpen(Pager *pPager, sqlite3_snapshot *pSnapshot); |
| 187 int sqlite3PagerSnapshotRecover(Pager *pPager); |
| 174 # endif | 188 # endif |
| 189 #else |
| 190 # define sqlite3PagerUseWal(x,y) 0 |
| 175 #endif | 191 #endif |
| 176 | 192 |
| 177 #ifdef SQLITE_ENABLE_ZIPVFS | 193 #ifdef SQLITE_ENABLE_ZIPVFS |
| 178 int sqlite3PagerWalFramesize(Pager *pPager); | 194 int sqlite3PagerWalFramesize(Pager *pPager); |
| 179 #endif | 195 #endif |
| 180 | 196 |
| 181 /* Functions used to query pager state and configuration. */ | 197 /* Functions used to query pager state and configuration. */ |
| 182 u8 sqlite3PagerIsreadonly(Pager*); | 198 u8 sqlite3PagerIsreadonly(Pager*); |
| 183 u32 sqlite3PagerDataVersion(Pager*); | 199 u32 sqlite3PagerDataVersion(Pager*); |
| 184 #ifdef SQLITE_DEBUG | 200 #ifdef SQLITE_DEBUG |
| 185 int sqlite3PagerRefcount(Pager*); | 201 int sqlite3PagerRefcount(Pager*); |
| 186 #endif | 202 #endif |
| 187 int sqlite3PagerMemUsed(Pager*); | 203 int sqlite3PagerMemUsed(Pager*); |
| 188 const char *sqlite3PagerFilename(Pager*, int); | 204 const char *sqlite3PagerFilename(Pager*, int); |
| 189 sqlite3_vfs *sqlite3PagerVfs(Pager*); | 205 sqlite3_vfs *sqlite3PagerVfs(Pager*); |
| 190 sqlite3_file *sqlite3PagerFile(Pager*); | 206 sqlite3_file *sqlite3PagerFile(Pager*); |
| 191 sqlite3_file *sqlite3PagerJrnlFile(Pager*); | 207 sqlite3_file *sqlite3PagerJrnlFile(Pager*); |
| 192 const char *sqlite3PagerJournalname(Pager*); | 208 const char *sqlite3PagerJournalname(Pager*); |
| 193 int sqlite3PagerNosync(Pager*); | |
| 194 void *sqlite3PagerTempSpace(Pager*); | 209 void *sqlite3PagerTempSpace(Pager*); |
| 195 int sqlite3PagerIsMemdb(Pager*); | 210 int sqlite3PagerIsMemdb(Pager*); |
| 196 void sqlite3PagerCacheStat(Pager *, int, int, int *); | 211 void sqlite3PagerCacheStat(Pager *, int, int, int *); |
| 197 void sqlite3PagerClearCache(Pager *); | 212 void sqlite3PagerClearCache(Pager*); |
| 198 int sqlite3SectorSize(sqlite3_file *); | 213 int sqlite3SectorSize(sqlite3_file *); |
| 199 | 214 |
| 200 /* Functions used to truncate the database file. */ | 215 /* Functions used to truncate the database file. */ |
| 201 void sqlite3PagerTruncateImage(Pager*,Pgno); | 216 void sqlite3PagerTruncateImage(Pager*,Pgno); |
| 202 | 217 |
| 203 void sqlite3PagerRekey(DbPage*, Pgno, u16); | 218 void sqlite3PagerRekey(DbPage*, Pgno, u16); |
| 204 | 219 |
| 205 #if defined(SQLITE_HAS_CODEC) && !defined(SQLITE_OMIT_WAL) | 220 #if defined(SQLITE_HAS_CODEC) && !defined(SQLITE_OMIT_WAL) |
| 206 void *sqlite3PagerCodec(DbPage *); | 221 void *sqlite3PagerCodec(DbPage *); |
| 207 #endif | 222 #endif |
| 208 | 223 |
| 209 /* Functions to support testing and debugging. */ | 224 /* Functions to support testing and debugging. */ |
| 210 #if !defined(NDEBUG) || defined(SQLITE_TEST) | 225 #if !defined(NDEBUG) || defined(SQLITE_TEST) |
| 211 Pgno sqlite3PagerPagenumber(DbPage*); | 226 Pgno sqlite3PagerPagenumber(DbPage*); |
| 212 int sqlite3PagerIswriteable(DbPage*); | 227 int sqlite3PagerIswriteable(DbPage*); |
| 213 #endif | 228 #endif |
| 214 #ifdef SQLITE_TEST | 229 #ifdef SQLITE_TEST |
| 215 int *sqlite3PagerStats(Pager*); | 230 int *sqlite3PagerStats(Pager*); |
| 216 void sqlite3PagerRefdump(Pager*); | 231 void sqlite3PagerRefdump(Pager*); |
| 217 void disable_simulated_io_errors(void); | 232 void disable_simulated_io_errors(void); |
| 218 void enable_simulated_io_errors(void); | 233 void enable_simulated_io_errors(void); |
| 219 #else | 234 #else |
| 220 # define disable_simulated_io_errors() | 235 # define disable_simulated_io_errors() |
| 221 # define enable_simulated_io_errors() | 236 # define enable_simulated_io_errors() |
| 222 #endif | 237 #endif |
| 223 | 238 |
| 224 #endif /* _PAGER_H_ */ | 239 #endif /* SQLITE_PAGER_H */ |
| OLD | NEW |