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 ** |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 ** for details. | 51 ** for details. |
52 */ | 52 */ |
53 #define PAGER_MJ_PGNO(x) ((Pgno)((PENDING_BYTE/((x)->pageSize))+1)) | 53 #define PAGER_MJ_PGNO(x) ((Pgno)((PENDING_BYTE/((x)->pageSize))+1)) |
54 | 54 |
55 /* | 55 /* |
56 ** Allowed values for the flags parameter to sqlite3PagerOpen(). | 56 ** Allowed values for the flags parameter to sqlite3PagerOpen(). |
57 ** | 57 ** |
58 ** NOTE: These values must match the corresponding BTREE_ values in btree.h. | 58 ** NOTE: These values must match the corresponding BTREE_ values in btree.h. |
59 */ | 59 */ |
60 #define PAGER_OMIT_JOURNAL 0x0001 /* Do not use a rollback journal */ | 60 #define PAGER_OMIT_JOURNAL 0x0001 /* Do not use a rollback journal */ |
61 #define PAGER_NO_READLOCK 0x0002 /* Omit readlocks on readonly files */ | 61 #define PAGER_MEMORY 0x0002 /* In-memory database */ |
62 #define PAGER_MEMORY 0x0004 /* In-memory database */ | |
63 | 62 |
64 /* | 63 /* |
65 ** Valid values for the second argument to sqlite3PagerLockingMode(). | 64 ** Valid values for the second argument to sqlite3PagerLockingMode(). |
66 */ | 65 */ |
67 #define PAGER_LOCKINGMODE_QUERY -1 | 66 #define PAGER_LOCKINGMODE_QUERY -1 |
68 #define PAGER_LOCKINGMODE_NORMAL 0 | 67 #define PAGER_LOCKINGMODE_NORMAL 0 |
69 #define PAGER_LOCKINGMODE_EXCLUSIVE 1 | 68 #define PAGER_LOCKINGMODE_EXCLUSIVE 1 |
70 | 69 |
71 /* | 70 /* |
72 ** Numeric constants that encode the journalmode. | 71 ** Numeric constants that encode the journalmode. |
73 */ | 72 */ |
74 #define PAGER_JOURNALMODE_QUERY (-1) /* Query the value of journalmode */ | 73 #define PAGER_JOURNALMODE_QUERY (-1) /* Query the value of journalmode */ |
75 #define PAGER_JOURNALMODE_DELETE 0 /* Commit by deleting journal file */ | 74 #define PAGER_JOURNALMODE_DELETE 0 /* Commit by deleting journal file */ |
76 #define PAGER_JOURNALMODE_PERSIST 1 /* Commit by zeroing journal header */ | 75 #define PAGER_JOURNALMODE_PERSIST 1 /* Commit by zeroing journal header */ |
77 #define PAGER_JOURNALMODE_OFF 2 /* Journal omitted. */ | 76 #define PAGER_JOURNALMODE_OFF 2 /* Journal omitted. */ |
78 #define PAGER_JOURNALMODE_TRUNCATE 3 /* Commit by truncating journal */ | 77 #define PAGER_JOURNALMODE_TRUNCATE 3 /* Commit by truncating journal */ |
79 #define PAGER_JOURNALMODE_MEMORY 4 /* In-memory journal file */ | 78 #define PAGER_JOURNALMODE_MEMORY 4 /* In-memory journal file */ |
80 #define PAGER_JOURNALMODE_WAL 5 /* Use write-ahead logging */ | 79 #define PAGER_JOURNALMODE_WAL 5 /* Use write-ahead logging */ |
81 | 80 |
82 /* | 81 /* |
| 82 ** Flags that make up the mask passed to sqlite3PagerAcquire(). |
| 83 */ |
| 84 #define PAGER_GET_NOCONTENT 0x01 /* Do not load data from disk */ |
| 85 #define PAGER_GET_READONLY 0x02 /* Read-only page is acceptable */ |
| 86 |
| 87 /* |
| 88 ** Flags for sqlite3PagerSetFlags() |
| 89 */ |
| 90 #define PAGER_SYNCHRONOUS_OFF 0x01 /* PRAGMA synchronous=OFF */ |
| 91 #define PAGER_SYNCHRONOUS_NORMAL 0x02 /* PRAGMA synchronous=NORMAL */ |
| 92 #define PAGER_SYNCHRONOUS_FULL 0x03 /* PRAGMA synchronous=FULL */ |
| 93 #define PAGER_SYNCHRONOUS_MASK 0x03 /* Mask for three values above */ |
| 94 #define PAGER_FULLFSYNC 0x04 /* PRAGMA fullfsync=ON */ |
| 95 #define PAGER_CKPT_FULLFSYNC 0x08 /* PRAGMA checkpoint_fullfsync=ON */ |
| 96 #define PAGER_CACHESPILL 0x10 /* PRAGMA cache_spill=ON */ |
| 97 #define PAGER_FLAGS_MASK 0x1c /* All above except SYNCHRONOUS */ |
| 98 |
| 99 /* |
83 ** The remainder of this file contains the declarations of the functions | 100 ** 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 | 101 ** that make up the Pager sub-system API. See source code comments for |
85 ** a detailed description of each routine. | 102 ** a detailed description of each routine. |
86 */ | 103 */ |
87 | 104 |
88 /* Open and close a Pager connection. */ | 105 /* Open and close a Pager connection. */ |
89 int sqlite3PagerOpen( | 106 int sqlite3PagerOpen( |
90 sqlite3_vfs*, | 107 sqlite3_vfs*, |
91 Pager **ppPager, | 108 Pager **ppPager, |
92 const char*, | 109 const char*, |
93 int, | 110 int, |
94 int, | 111 int, |
95 int, | 112 int, |
96 void(*)(DbPage*) | 113 void(*)(DbPage*) |
97 ); | 114 ); |
98 int sqlite3PagerClose(Pager *pPager); | 115 int sqlite3PagerClose(Pager *pPager); |
99 int sqlite3PagerReadFileheader(Pager*, int, unsigned char*); | 116 int sqlite3PagerReadFileheader(Pager*, int, unsigned char*); |
100 | 117 |
101 /* Functions used to configure a Pager object. */ | 118 /* Functions used to configure a Pager object. */ |
102 void sqlite3PagerSetBusyhandler(Pager*, int(*)(void *), void *); | 119 void sqlite3PagerSetBusyhandler(Pager*, int(*)(void *), void *); |
103 int sqlite3PagerSetPagesize(Pager*, u32*, int); | 120 int sqlite3PagerSetPagesize(Pager*, u32*, int); |
104 int sqlite3PagerMaxPageCount(Pager*, int); | 121 int sqlite3PagerMaxPageCount(Pager*, int); |
105 void sqlite3PagerSetCachesize(Pager*, int); | 122 void sqlite3PagerSetCachesize(Pager*, int); |
106 void sqlite3PagerSetSafetyLevel(Pager*,int,int,int); | 123 void sqlite3PagerSetMmapLimit(Pager *, sqlite3_int64); |
| 124 void sqlite3PagerShrink(Pager*); |
| 125 void sqlite3PagerSetFlags(Pager*,unsigned); |
107 int sqlite3PagerLockingMode(Pager *, int); | 126 int sqlite3PagerLockingMode(Pager *, int); |
108 int sqlite3PagerSetJournalMode(Pager *, int); | 127 int sqlite3PagerSetJournalMode(Pager *, int); |
109 int sqlite3PagerGetJournalMode(Pager*); | 128 int sqlite3PagerGetJournalMode(Pager*); |
110 int sqlite3PagerOkToChangeJournalMode(Pager*); | 129 int sqlite3PagerOkToChangeJournalMode(Pager*); |
111 i64 sqlite3PagerJournalSizeLimit(Pager *, i64); | 130 i64 sqlite3PagerJournalSizeLimit(Pager *, i64); |
112 sqlite3_backup **sqlite3PagerBackupPtr(Pager*); | 131 sqlite3_backup **sqlite3PagerBackupPtr(Pager*); |
113 | 132 |
114 /* Functions used to obtain and release page references. */ | 133 /* Functions used to obtain and release page references. */ |
115 int sqlite3PagerAcquire(Pager *pPager, Pgno pgno, DbPage **ppPage, int clrFlag); | 134 int sqlite3PagerAcquire(Pager *pPager, Pgno pgno, DbPage **ppPage, int clrFlag); |
116 #define sqlite3PagerGet(A,B,C) sqlite3PagerAcquire(A,B,C,0) | 135 #define sqlite3PagerGet(A,B,C) sqlite3PagerAcquire(A,B,C,0) |
117 DbPage *sqlite3PagerLookup(Pager *pPager, Pgno pgno); | 136 DbPage *sqlite3PagerLookup(Pager *pPager, Pgno pgno); |
118 void sqlite3PagerRef(DbPage*); | 137 void sqlite3PagerRef(DbPage*); |
119 void sqlite3PagerUnref(DbPage*); | 138 void sqlite3PagerUnref(DbPage*); |
| 139 void sqlite3PagerUnrefNotNull(DbPage*); |
120 | 140 |
121 /* Operations on page references. */ | 141 /* Operations on page references. */ |
122 int sqlite3PagerWrite(DbPage*); | 142 int sqlite3PagerWrite(DbPage*); |
123 void sqlite3PagerDontWrite(DbPage*); | 143 void sqlite3PagerDontWrite(DbPage*); |
124 int sqlite3PagerMovepage(Pager*,DbPage*,Pgno,int); | 144 int sqlite3PagerMovepage(Pager*,DbPage*,Pgno,int); |
125 int sqlite3PagerPageRefcount(DbPage*); | 145 int sqlite3PagerPageRefcount(DbPage*); |
126 void *sqlite3PagerGetData(DbPage *); | 146 void *sqlite3PagerGetData(DbPage *); |
127 void *sqlite3PagerGetExtra(DbPage *); | 147 void *sqlite3PagerGetExtra(DbPage *); |
128 | 148 |
129 /* Functions used to manage pager transactions and savepoints. */ | 149 /* Functions used to manage pager transactions and savepoints. */ |
130 void sqlite3PagerPagecount(Pager*, int*); | 150 void sqlite3PagerPagecount(Pager*, int*); |
131 int sqlite3PagerBegin(Pager*, int exFlag, int); | 151 int sqlite3PagerBegin(Pager*, int exFlag, int); |
132 int sqlite3PagerCommitPhaseOne(Pager*,const char *zMaster, int); | 152 int sqlite3PagerCommitPhaseOne(Pager*,const char *zMaster, int); |
133 int sqlite3PagerExclusiveLock(Pager*); | 153 int sqlite3PagerExclusiveLock(Pager*); |
134 int sqlite3PagerSync(Pager *pPager); | 154 int sqlite3PagerSync(Pager *pPager, const char *zMaster); |
135 int sqlite3PagerCommitPhaseTwo(Pager*); | 155 int sqlite3PagerCommitPhaseTwo(Pager*); |
136 int sqlite3PagerRollback(Pager*); | 156 int sqlite3PagerRollback(Pager*); |
137 int sqlite3PagerOpenSavepoint(Pager *pPager, int n); | 157 int sqlite3PagerOpenSavepoint(Pager *pPager, int n); |
138 int sqlite3PagerSavepoint(Pager *pPager, int op, int iSavepoint); | 158 int sqlite3PagerSavepoint(Pager *pPager, int op, int iSavepoint); |
139 int sqlite3PagerSharedLock(Pager *pPager); | 159 int sqlite3PagerSharedLock(Pager *pPager); |
140 | 160 |
141 int sqlite3PagerCheckpoint(Pager *pPager, int, int*, int*); | 161 #ifndef SQLITE_OMIT_WAL |
142 int sqlite3PagerWalSupported(Pager *pPager); | 162 int sqlite3PagerCheckpoint(Pager *pPager, int, int*, int*); |
143 int sqlite3PagerWalCallback(Pager *pPager); | 163 int sqlite3PagerWalSupported(Pager *pPager); |
144 int sqlite3PagerOpenWal(Pager *pPager, int *pisOpen); | 164 int sqlite3PagerWalCallback(Pager *pPager); |
145 int sqlite3PagerCloseWal(Pager *pPager); | 165 int sqlite3PagerOpenWal(Pager *pPager, int *pisOpen); |
| 166 int sqlite3PagerCloseWal(Pager *pPager); |
| 167 #endif |
| 168 |
| 169 #ifdef SQLITE_ENABLE_ZIPVFS |
| 170 int sqlite3PagerWalFramesize(Pager *pPager); |
| 171 #endif |
146 | 172 |
147 /* Functions used to query pager state and configuration. */ | 173 /* Functions used to query pager state and configuration. */ |
148 u8 sqlite3PagerIsreadonly(Pager*); | 174 u8 sqlite3PagerIsreadonly(Pager*); |
149 int sqlite3PagerRefcount(Pager*); | 175 int sqlite3PagerRefcount(Pager*); |
150 int sqlite3PagerMemUsed(Pager*); | 176 int sqlite3PagerMemUsed(Pager*); |
151 const char *sqlite3PagerFilename(Pager*); | 177 const char *sqlite3PagerFilename(Pager*, int); |
152 const sqlite3_vfs *sqlite3PagerVfs(Pager*); | 178 const sqlite3_vfs *sqlite3PagerVfs(Pager*); |
153 sqlite3_file *sqlite3PagerFile(Pager*); | 179 sqlite3_file *sqlite3PagerFile(Pager*); |
154 const char *sqlite3PagerJournalname(Pager*); | 180 const char *sqlite3PagerJournalname(Pager*); |
155 int sqlite3PagerNosync(Pager*); | 181 int sqlite3PagerNosync(Pager*); |
156 void *sqlite3PagerTempSpace(Pager*); | 182 void *sqlite3PagerTempSpace(Pager*); |
157 int sqlite3PagerIsMemdb(Pager*); | 183 int sqlite3PagerIsMemdb(Pager*); |
| 184 void sqlite3PagerCacheStat(Pager *, int, int, int *); |
| 185 void sqlite3PagerClearCache(Pager *); |
| 186 int sqlite3SectorSize(sqlite3_file *); |
158 | 187 |
159 /* Functions used to truncate the database file. */ | 188 /* Functions used to truncate the database file. */ |
160 void sqlite3PagerTruncateImage(Pager*,Pgno); | 189 void sqlite3PagerTruncateImage(Pager*,Pgno); |
161 | 190 |
162 #if defined(SQLITE_HAS_CODEC) && !defined(SQLITE_OMIT_WAL) | 191 #if defined(SQLITE_HAS_CODEC) && !defined(SQLITE_OMIT_WAL) |
163 void *sqlite3PagerCodec(DbPage *); | 192 void *sqlite3PagerCodec(DbPage *); |
164 #endif | 193 #endif |
165 | 194 |
166 /* Functions to support testing and debugging. */ | 195 /* Functions to support testing and debugging. */ |
167 #if !defined(NDEBUG) || defined(SQLITE_TEST) | 196 #if !defined(NDEBUG) || defined(SQLITE_TEST) |
168 Pgno sqlite3PagerPagenumber(DbPage*); | 197 Pgno sqlite3PagerPagenumber(DbPage*); |
169 int sqlite3PagerIswriteable(DbPage*); | 198 int sqlite3PagerIswriteable(DbPage*); |
170 #endif | 199 #endif |
171 #ifdef SQLITE_TEST | 200 #ifdef SQLITE_TEST |
172 int *sqlite3PagerStats(Pager*); | 201 int *sqlite3PagerStats(Pager*); |
173 void sqlite3PagerRefdump(Pager*); | 202 void sqlite3PagerRefdump(Pager*); |
174 void disable_simulated_io_errors(void); | 203 void disable_simulated_io_errors(void); |
175 void enable_simulated_io_errors(void); | 204 void enable_simulated_io_errors(void); |
176 #else | 205 #else |
177 # define disable_simulated_io_errors() | 206 # define disable_simulated_io_errors() |
178 # define enable_simulated_io_errors() | 207 # define enable_simulated_io_errors() |
179 #endif | 208 #endif |
180 | 209 |
181 #endif /* _PAGER_H_ */ | 210 #endif /* _PAGER_H_ */ |
OLD | NEW |