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 ** | |
16 ** @(#) $Id: pager.h,v 1.104 2009/07/24 19:01:19 drh Exp $ | |
17 */ | 15 */ |
18 | 16 |
19 #ifndef _PAGER_H_ | 17 #ifndef _PAGER_H_ |
20 #define _PAGER_H_ | 18 #define _PAGER_H_ |
21 | 19 |
22 /* | 20 /* |
23 ** Default maximum size for persistent journal files. A negative | 21 ** Default maximum size for persistent journal files. A negative |
24 ** value means no limit. This value may be overridden using the | 22 ** value means no limit. This value may be overridden using the |
25 ** sqlite3PagerJournalSizeLimit() API. See also "PRAGMA journal_size_limit". | 23 ** sqlite3PagerJournalSizeLimit() API. See also "PRAGMA journal_size_limit". |
26 */ | 24 */ |
(...skipping 27 matching lines...) Expand all Loading... |
54 */ | 52 */ |
55 #define PAGER_MJ_PGNO(x) ((Pgno)((PENDING_BYTE/((x)->pageSize))+1)) | 53 #define PAGER_MJ_PGNO(x) ((Pgno)((PENDING_BYTE/((x)->pageSize))+1)) |
56 | 54 |
57 /* | 55 /* |
58 ** Allowed values for the flags parameter to sqlite3PagerOpen(). | 56 ** Allowed values for the flags parameter to sqlite3PagerOpen(). |
59 ** | 57 ** |
60 ** 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. |
61 */ | 59 */ |
62 #define PAGER_OMIT_JOURNAL 0x0001 /* Do not use a rollback journal */ | 60 #define PAGER_OMIT_JOURNAL 0x0001 /* Do not use a rollback journal */ |
63 #define PAGER_NO_READLOCK 0x0002 /* Omit readlocks on readonly files */ | 61 #define PAGER_NO_READLOCK 0x0002 /* Omit readlocks on readonly files */ |
| 62 #define PAGER_MEMORY 0x0004 /* In-memory database */ |
64 | 63 |
65 /* | 64 /* |
66 ** Valid values for the second argument to sqlite3PagerLockingMode(). | 65 ** Valid values for the second argument to sqlite3PagerLockingMode(). |
67 */ | 66 */ |
68 #define PAGER_LOCKINGMODE_QUERY -1 | 67 #define PAGER_LOCKINGMODE_QUERY -1 |
69 #define PAGER_LOCKINGMODE_NORMAL 0 | 68 #define PAGER_LOCKINGMODE_NORMAL 0 |
70 #define PAGER_LOCKINGMODE_EXCLUSIVE 1 | 69 #define PAGER_LOCKINGMODE_EXCLUSIVE 1 |
71 | 70 |
72 /* | 71 /* |
73 ** Valid values for the second argument to sqlite3PagerJournalMode(). | 72 ** Numeric constants that encode the journalmode. |
74 */ | 73 */ |
75 #define PAGER_JOURNALMODE_QUERY -1 | 74 #define PAGER_JOURNALMODE_QUERY (-1) /* Query the value of journalmode */ |
76 #define PAGER_JOURNALMODE_DELETE 0 /* Commit by deleting journal file */ | 75 #define PAGER_JOURNALMODE_DELETE 0 /* Commit by deleting journal file */ |
77 #define PAGER_JOURNALMODE_PERSIST 1 /* Commit by zeroing journal header */ | 76 #define PAGER_JOURNALMODE_PERSIST 1 /* Commit by zeroing journal header */ |
78 #define PAGER_JOURNALMODE_OFF 2 /* Journal omitted. */ | 77 #define PAGER_JOURNALMODE_OFF 2 /* Journal omitted. */ |
79 #define PAGER_JOURNALMODE_TRUNCATE 3 /* Commit by truncating journal */ | 78 #define PAGER_JOURNALMODE_TRUNCATE 3 /* Commit by truncating journal */ |
80 #define PAGER_JOURNALMODE_MEMORY 4 /* In-memory journal file */ | 79 #define PAGER_JOURNALMODE_MEMORY 4 /* In-memory journal file */ |
| 80 #define PAGER_JOURNALMODE_WAL 5 /* Use write-ahead logging */ |
81 | 81 |
82 /* | 82 /* |
83 ** The remainder of this file contains the declarations of the functions | 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 | 84 ** that make up the Pager sub-system API. See source code comments for |
85 ** a detailed description of each routine. | 85 ** a detailed description of each routine. |
86 */ | 86 */ |
87 | 87 |
88 /* Open and close a Pager connection. */ | 88 /* Open and close a Pager connection. */ |
89 int sqlite3PagerOpen( | 89 int sqlite3PagerOpen( |
90 sqlite3_vfs*, | 90 sqlite3_vfs*, |
91 Pager **ppPager, | 91 Pager **ppPager, |
92 const char*, | 92 const char*, |
93 int, | 93 int, |
94 int, | 94 int, |
95 int, | 95 int, |
96 void(*)(DbPage*) | 96 void(*)(DbPage*) |
97 ); | 97 ); |
98 int sqlite3PagerClose(Pager *pPager); | 98 int sqlite3PagerClose(Pager *pPager); |
99 int sqlite3PagerReadFileheader(Pager*, int, unsigned char*); | 99 int sqlite3PagerReadFileheader(Pager*, int, unsigned char*); |
100 | 100 |
101 /* Functions used to configure a Pager object. */ | 101 /* Functions used to configure a Pager object. */ |
102 void sqlite3PagerSetBusyhandler(Pager*, int(*)(void *), void *); | 102 void sqlite3PagerSetBusyhandler(Pager*, int(*)(void *), void *); |
103 int sqlite3PagerSetPagesize(Pager*, u16*, int); | 103 int sqlite3PagerSetPagesize(Pager*, u32*, int); |
104 int sqlite3PagerMaxPageCount(Pager*, int); | 104 int sqlite3PagerMaxPageCount(Pager*, int); |
105 void sqlite3PagerSetCachesize(Pager*, int); | 105 void sqlite3PagerSetCachesize(Pager*, int); |
106 void sqlite3PagerSetSafetyLevel(Pager*,int,int); | 106 void sqlite3PagerSetSafetyLevel(Pager*,int,int,int); |
107 int sqlite3PagerLockingMode(Pager *, int); | 107 int sqlite3PagerLockingMode(Pager *, int); |
108 int sqlite3PagerJournalMode(Pager *, int); | 108 int sqlite3PagerSetJournalMode(Pager *, int); |
| 109 int sqlite3PagerGetJournalMode(Pager*); |
| 110 int sqlite3PagerOkToChangeJournalMode(Pager*); |
109 i64 sqlite3PagerJournalSizeLimit(Pager *, i64); | 111 i64 sqlite3PagerJournalSizeLimit(Pager *, i64); |
110 sqlite3_backup **sqlite3PagerBackupPtr(Pager*); | 112 sqlite3_backup **sqlite3PagerBackupPtr(Pager*); |
111 | 113 |
112 /* Functions used to obtain and release page references. */ | 114 /* Functions used to obtain and release page references. */ |
113 int sqlite3PagerAcquire(Pager *pPager, Pgno pgno, DbPage **ppPage, int clrFlag); | 115 int sqlite3PagerAcquire(Pager *pPager, Pgno pgno, DbPage **ppPage, int clrFlag); |
114 #define sqlite3PagerGet(A,B,C) sqlite3PagerAcquire(A,B,C,0) | 116 #define sqlite3PagerGet(A,B,C) sqlite3PagerAcquire(A,B,C,0) |
115 DbPage *sqlite3PagerLookup(Pager *pPager, Pgno pgno); | 117 DbPage *sqlite3PagerLookup(Pager *pPager, Pgno pgno); |
116 void sqlite3PagerRef(DbPage*); | 118 void sqlite3PagerRef(DbPage*); |
117 void sqlite3PagerUnref(DbPage*); | 119 void sqlite3PagerUnref(DbPage*); |
118 | 120 |
119 /* Operations on page references. */ | 121 /* Operations on page references. */ |
120 int sqlite3PagerWrite(DbPage*); | 122 int sqlite3PagerWrite(DbPage*); |
121 void sqlite3PagerDontWrite(DbPage*); | 123 void sqlite3PagerDontWrite(DbPage*); |
122 int sqlite3PagerMovepage(Pager*,DbPage*,Pgno,int); | 124 int sqlite3PagerMovepage(Pager*,DbPage*,Pgno,int); |
123 int sqlite3PagerPageRefcount(DbPage*); | 125 int sqlite3PagerPageRefcount(DbPage*); |
124 void *sqlite3PagerGetData(DbPage *); | 126 void *sqlite3PagerGetData(DbPage *); |
125 void *sqlite3PagerGetExtra(DbPage *); | 127 void *sqlite3PagerGetExtra(DbPage *); |
126 | 128 |
127 /* Functions used to manage pager transactions and savepoints. */ | 129 /* Functions used to manage pager transactions and savepoints. */ |
128 int sqlite3PagerPagecount(Pager*, int*); | 130 void sqlite3PagerPagecount(Pager*, int*); |
129 int sqlite3PagerBegin(Pager*, int exFlag, int); | 131 int sqlite3PagerBegin(Pager*, int exFlag, int); |
130 int sqlite3PagerCommitPhaseOne(Pager*,const char *zMaster, int); | 132 int sqlite3PagerCommitPhaseOne(Pager*,const char *zMaster, int); |
| 133 int sqlite3PagerExclusiveLock(Pager*); |
131 int sqlite3PagerSync(Pager *pPager); | 134 int sqlite3PagerSync(Pager *pPager); |
132 int sqlite3PagerCommitPhaseTwo(Pager*); | 135 int sqlite3PagerCommitPhaseTwo(Pager*); |
133 int sqlite3PagerRollback(Pager*); | 136 int sqlite3PagerRollback(Pager*); |
134 int sqlite3PagerOpenSavepoint(Pager *pPager, int n); | 137 int sqlite3PagerOpenSavepoint(Pager *pPager, int n); |
135 int sqlite3PagerSavepoint(Pager *pPager, int op, int iSavepoint); | 138 int sqlite3PagerSavepoint(Pager *pPager, int op, int iSavepoint); |
136 int sqlite3PagerSharedLock(Pager *pPager); | 139 int sqlite3PagerSharedLock(Pager *pPager); |
137 | 140 |
| 141 int sqlite3PagerCheckpoint(Pager *pPager, int, int*, int*); |
| 142 int sqlite3PagerWalSupported(Pager *pPager); |
| 143 int sqlite3PagerWalCallback(Pager *pPager); |
| 144 int sqlite3PagerOpenWal(Pager *pPager, int *pisOpen); |
| 145 int sqlite3PagerCloseWal(Pager *pPager); |
| 146 |
138 /* Functions used to query pager state and configuration. */ | 147 /* Functions used to query pager state and configuration. */ |
139 u8 sqlite3PagerIsreadonly(Pager*); | 148 u8 sqlite3PagerIsreadonly(Pager*); |
140 int sqlite3PagerRefcount(Pager*); | 149 int sqlite3PagerRefcount(Pager*); |
| 150 int sqlite3PagerMemUsed(Pager*); |
141 const char *sqlite3PagerFilename(Pager*); | 151 const char *sqlite3PagerFilename(Pager*); |
142 const sqlite3_vfs *sqlite3PagerVfs(Pager*); | 152 const sqlite3_vfs *sqlite3PagerVfs(Pager*); |
143 sqlite3_file *sqlite3PagerFile(Pager*); | 153 sqlite3_file *sqlite3PagerFile(Pager*); |
144 const char *sqlite3PagerJournalname(Pager*); | 154 const char *sqlite3PagerJournalname(Pager*); |
145 int sqlite3PagerNosync(Pager*); | 155 int sqlite3PagerNosync(Pager*); |
146 /* This function is for preload-cache.patch for Chromium: */ | 156 /* This function is for preload-cache.patch for Chromium: */ |
147 int sqlite3PagerLoadall(Pager*); | 157 int sqlite3PagerLoadall(Pager*); |
148 void *sqlite3PagerTempSpace(Pager*); | 158 void *sqlite3PagerTempSpace(Pager*); |
149 int sqlite3PagerIsMemdb(Pager*); | 159 int sqlite3PagerIsMemdb(Pager*); |
150 | 160 |
151 /* Functions used to truncate the database file. */ | 161 /* Functions used to truncate the database file. */ |
152 void sqlite3PagerTruncateImage(Pager*,Pgno); | 162 void sqlite3PagerTruncateImage(Pager*,Pgno); |
153 | 163 |
| 164 #if defined(SQLITE_HAS_CODEC) && !defined(SQLITE_OMIT_WAL) |
| 165 void *sqlite3PagerCodec(DbPage *); |
| 166 #endif |
| 167 |
154 /* Functions to support testing and debugging. */ | 168 /* Functions to support testing and debugging. */ |
155 #if !defined(NDEBUG) || defined(SQLITE_TEST) | 169 #if !defined(NDEBUG) || defined(SQLITE_TEST) |
156 Pgno sqlite3PagerPagenumber(DbPage*); | 170 Pgno sqlite3PagerPagenumber(DbPage*); |
157 int sqlite3PagerIswriteable(DbPage*); | 171 int sqlite3PagerIswriteable(DbPage*); |
158 #endif | 172 #endif |
159 #ifdef SQLITE_TEST | 173 #ifdef SQLITE_TEST |
160 int *sqlite3PagerStats(Pager*); | 174 int *sqlite3PagerStats(Pager*); |
161 void sqlite3PagerRefdump(Pager*); | 175 void sqlite3PagerRefdump(Pager*); |
162 void disable_simulated_io_errors(void); | 176 void disable_simulated_io_errors(void); |
163 void enable_simulated_io_errors(void); | 177 void enable_simulated_io_errors(void); |
164 #else | 178 #else |
165 # define disable_simulated_io_errors() | 179 # define disable_simulated_io_errors() |
166 # define enable_simulated_io_errors() | 180 # define enable_simulated_io_errors() |
167 #endif | 181 #endif |
168 | 182 |
169 #endif /* _PAGER_H_ */ | 183 #endif /* _PAGER_H_ */ |
OLD | NEW |