Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(32)

Side by Side Diff: third_party/sqlite/sqlite-src-3100200/src/btree.h

Issue 2846743003: [sql] Remove SQLite 3.10.2 reference directory. (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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 B-Tree file
13 ** subsystem. See comments in the source code for a detailed description
14 ** of what each interface routine does.
15 */
16 #ifndef _BTREE_H_
17 #define _BTREE_H_
18
19 /* TODO: This definition is just included so other modules compile. It
20 ** needs to be revisited.
21 */
22 #define SQLITE_N_BTREE_META 16
23
24 /*
25 ** If defined as non-zero, auto-vacuum is enabled by default. Otherwise
26 ** it must be turned on for each database using "PRAGMA auto_vacuum = 1".
27 */
28 #ifndef SQLITE_DEFAULT_AUTOVACUUM
29 #define SQLITE_DEFAULT_AUTOVACUUM 0
30 #endif
31
32 #define BTREE_AUTOVACUUM_NONE 0 /* Do not do auto-vacuum */
33 #define BTREE_AUTOVACUUM_FULL 1 /* Do full auto-vacuum */
34 #define BTREE_AUTOVACUUM_INCR 2 /* Incremental vacuum */
35
36 /*
37 ** Forward declarations of structure
38 */
39 typedef struct Btree Btree;
40 typedef struct BtCursor BtCursor;
41 typedef struct BtShared BtShared;
42
43
44 int sqlite3BtreeOpen(
45 sqlite3_vfs *pVfs, /* VFS to use with this b-tree */
46 const char *zFilename, /* Name of database file to open */
47 sqlite3 *db, /* Associated database connection */
48 Btree **ppBtree, /* Return open Btree* here */
49 int flags, /* Flags */
50 int vfsFlags /* Flags passed through to VFS open */
51 );
52
53 /* The flags parameter to sqlite3BtreeOpen can be the bitwise or of the
54 ** following values.
55 **
56 ** NOTE: These values must match the corresponding PAGER_ values in
57 ** pager.h.
58 */
59 #define BTREE_OMIT_JOURNAL 1 /* Do not create or use a rollback journal */
60 #define BTREE_MEMORY 2 /* This is an in-memory DB */
61 #define BTREE_SINGLE 4 /* The file contains at most 1 b-tree */
62 #define BTREE_UNORDERED 8 /* Use of a hash implementation is OK */
63
64 int sqlite3BtreeClose(Btree*);
65 int sqlite3BtreeSetCacheSize(Btree*,int);
66 int sqlite3BtreeSetSpillSize(Btree*,int);
67 #if SQLITE_MAX_MMAP_SIZE>0
68 int sqlite3BtreeSetMmapLimit(Btree*,sqlite3_int64);
69 #endif
70 int sqlite3BtreeSetPagerFlags(Btree*,unsigned);
71 int sqlite3BtreeSyncDisabled(Btree*);
72 int sqlite3BtreeSetPageSize(Btree *p, int nPagesize, int nReserve, int eFix);
73 int sqlite3BtreeGetPageSize(Btree*);
74 int sqlite3BtreeMaxPageCount(Btree*,int);
75 u32 sqlite3BtreeLastPage(Btree*);
76 int sqlite3BtreeSecureDelete(Btree*,int);
77 int sqlite3BtreeGetOptimalReserve(Btree*);
78 int sqlite3BtreeGetReserveNoMutex(Btree *p);
79 int sqlite3BtreeSetAutoVacuum(Btree *, int);
80 int sqlite3BtreeGetAutoVacuum(Btree *);
81 int sqlite3BtreeBeginTrans(Btree*,int);
82 int sqlite3BtreeCommitPhaseOne(Btree*, const char *zMaster);
83 int sqlite3BtreeCommitPhaseTwo(Btree*, int);
84 int sqlite3BtreeCommit(Btree*);
85 int sqlite3BtreeRollback(Btree*,int,int);
86 int sqlite3BtreeBeginStmt(Btree*,int);
87 int sqlite3BtreeCreateTable(Btree*, int*, int flags);
88 int sqlite3BtreeIsInTrans(Btree*);
89 int sqlite3BtreeIsInReadTrans(Btree*);
90 int sqlite3BtreeIsInBackup(Btree*);
91 void *sqlite3BtreeSchema(Btree *, int, void(*)(void *));
92 int sqlite3BtreeSchemaLocked(Btree *pBtree);
93 int sqlite3BtreeLockTable(Btree *pBtree, int iTab, u8 isWriteLock);
94 int sqlite3BtreeSavepoint(Btree *, int, int);
95
96 const char *sqlite3BtreeGetFilename(Btree *);
97 const char *sqlite3BtreeGetJournalname(Btree *);
98 int sqlite3BtreeCopyFile(Btree *, Btree *);
99
100 int sqlite3BtreeIncrVacuum(Btree *);
101
102 /* The flags parameter to sqlite3BtreeCreateTable can be the bitwise OR
103 ** of the flags shown below.
104 **
105 ** Every SQLite table must have either BTREE_INTKEY or BTREE_BLOBKEY set.
106 ** With BTREE_INTKEY, the table key is a 64-bit integer and arbitrary data
107 ** is stored in the leaves. (BTREE_INTKEY is used for SQL tables.) With
108 ** BTREE_BLOBKEY, the key is an arbitrary BLOB and no content is stored
109 ** anywhere - the key is the content. (BTREE_BLOBKEY is used for SQL
110 ** indices.)
111 */
112 #define BTREE_INTKEY 1 /* Table has only 64-bit signed integer keys */
113 #define BTREE_BLOBKEY 2 /* Table has keys only - no data */
114
115 int sqlite3BtreeDropTable(Btree*, int, int*);
116 int sqlite3BtreeClearTable(Btree*, int, int*);
117 int sqlite3BtreeClearTableOfCursor(BtCursor*);
118 int sqlite3BtreeTripAllCursors(Btree*, int, int);
119
120 void sqlite3BtreeGetMeta(Btree *pBtree, int idx, u32 *pValue);
121 int sqlite3BtreeUpdateMeta(Btree*, int idx, u32 value);
122
123 int sqlite3BtreeNewDb(Btree *p);
124
125 /*
126 ** The second parameter to sqlite3BtreeGetMeta or sqlite3BtreeUpdateMeta
127 ** should be one of the following values. The integer values are assigned
128 ** to constants so that the offset of the corresponding field in an
129 ** SQLite database header may be found using the following formula:
130 **
131 ** offset = 36 + (idx * 4)
132 **
133 ** For example, the free-page-count field is located at byte offset 36 of
134 ** the database file header. The incr-vacuum-flag field is located at
135 ** byte offset 64 (== 36+4*7).
136 **
137 ** The BTREE_DATA_VERSION value is not really a value stored in the header.
138 ** It is a read-only number computed by the pager. But we merge it with
139 ** the header value access routines since its access pattern is the same.
140 ** Call it a "virtual meta value".
141 */
142 #define BTREE_FREE_PAGE_COUNT 0
143 #define BTREE_SCHEMA_VERSION 1
144 #define BTREE_FILE_FORMAT 2
145 #define BTREE_DEFAULT_CACHE_SIZE 3
146 #define BTREE_LARGEST_ROOT_PAGE 4
147 #define BTREE_TEXT_ENCODING 5
148 #define BTREE_USER_VERSION 6
149 #define BTREE_INCR_VACUUM 7
150 #define BTREE_APPLICATION_ID 8
151 #define BTREE_DATA_VERSION 15 /* A virtual meta-value */
152
153 /*
154 ** Kinds of hints that can be passed into the sqlite3BtreeCursorHint()
155 ** interface.
156 **
157 ** BTREE_HINT_RANGE (arguments: Expr*, Mem*)
158 **
159 ** The first argument is an Expr* (which is guaranteed to be constant for
160 ** the lifetime of the cursor) that defines constraints on which rows
161 ** might be fetched with this cursor. The Expr* tree may contain
162 ** TK_REGISTER nodes that refer to values stored in the array of registers
163 ** passed as the second parameter. In other words, if Expr.op==TK_REGISTER
164 ** then the value of the node is the value in Mem[pExpr.iTable]. Any
165 ** TK_COLUMN node in the expression tree refers to the Expr.iColumn-th
166 ** column of the b-tree of the cursor. The Expr tree will not contain
167 ** any function calls nor subqueries nor references to b-trees other than
168 ** the cursor being hinted.
169 **
170 ** The design of the _RANGE hint is aid b-tree implementations that try
171 ** to prefetch content from remote machines - to provide those
172 ** implementations with limits on what needs to be prefetched and thereby
173 ** reduce network bandwidth.
174 **
175 ** Note that BTREE_HINT_FLAGS with BTREE_BULKLOAD is the only hint used by
176 ** standard SQLite. The other hints are provided for extentions that use
177 ** the SQLite parser and code generator but substitute their own storage
178 ** engine.
179 */
180 #define BTREE_HINT_RANGE 0 /* Range constraints on queries */
181
182 /*
183 ** Values that may be OR'd together to form the argument to the
184 ** BTREE_HINT_FLAGS hint for sqlite3BtreeCursorHint():
185 **
186 ** The BTREE_BULKLOAD flag is set on index cursors when the index is going
187 ** to be filled with content that is already in sorted order.
188 **
189 ** The BTREE_SEEK_EQ flag is set on cursors that will get OP_SeekGE or
190 ** OP_SeekLE opcodes for a range search, but where the range of entries
191 ** selected will all have the same key. In other words, the cursor will
192 ** be used only for equality key searches.
193 **
194 */
195 #define BTREE_BULKLOAD 0x00000001 /* Used to full index in sorted order */
196 #define BTREE_SEEK_EQ 0x00000002 /* EQ seeks only - no range seeks */
197
198 /*
199 ** Flags passed as the third argument to sqlite3BtreeCursor().
200 **
201 ** For read-only cursors the wrFlag argument is always zero. For read-write
202 ** cursors it may be set to either (BTREE_WRCSR|BTREE_FORDELETE) or
203 ** (BTREE_WRCSR). If the BTREE_FORDELETE flag is set, then the cursor will
204 ** only be used by SQLite for the following:
205 **
206 ** * to seek to and delete specific entries, and/or
207 **
208 ** * to read values that will be used to create keys that other
209 ** BTREE_FORDELETE cursors will seek to and delete.
210 */
211 #define BTREE_WRCSR 0x00000004 /* read-write cursor */
212 #define BTREE_FORDELETE 0x00000008 /* Cursor is for seek/delete only */
213
214 int sqlite3BtreeCursor(
215 Btree*, /* BTree containing table to open */
216 int iTable, /* Index of root page */
217 int wrFlag, /* 1 for writing. 0 for read-only */
218 struct KeyInfo*, /* First argument to compare function */
219 BtCursor *pCursor /* Space to write cursor structure */
220 );
221 int sqlite3BtreeCursorSize(void);
222 void sqlite3BtreeCursorZero(BtCursor*);
223 void sqlite3BtreeCursorHintFlags(BtCursor*, unsigned);
224 #ifdef SQLITE_ENABLE_CURSOR_HINTS
225 void sqlite3BtreeCursorHint(BtCursor*, int, ...);
226 #endif
227
228 int sqlite3BtreeCloseCursor(BtCursor*);
229 int sqlite3BtreeMovetoUnpacked(
230 BtCursor*,
231 UnpackedRecord *pUnKey,
232 i64 intKey,
233 int bias,
234 int *pRes
235 );
236 int sqlite3BtreeCursorHasMoved(BtCursor*);
237 int sqlite3BtreeCursorRestore(BtCursor*, int*);
238 int sqlite3BtreeDelete(BtCursor*, int);
239 int sqlite3BtreeInsert(BtCursor*, const void *pKey, i64 nKey,
240 const void *pData, int nData,
241 int nZero, int bias, int seekResult);
242 int sqlite3BtreeFirst(BtCursor*, int *pRes);
243 int sqlite3BtreeLast(BtCursor*, int *pRes);
244 int sqlite3BtreeNext(BtCursor*, int *pRes);
245 int sqlite3BtreeEof(BtCursor*);
246 int sqlite3BtreePrevious(BtCursor*, int *pRes);
247 int sqlite3BtreeKeySize(BtCursor*, i64 *pSize);
248 int sqlite3BtreeKey(BtCursor*, u32 offset, u32 amt, void*);
249 const void *sqlite3BtreeKeyFetch(BtCursor*, u32 *pAmt);
250 const void *sqlite3BtreeDataFetch(BtCursor*, u32 *pAmt);
251 int sqlite3BtreeDataSize(BtCursor*, u32 *pSize);
252 int sqlite3BtreeData(BtCursor*, u32 offset, u32 amt, void*);
253
254 char *sqlite3BtreeIntegrityCheck(Btree*, int *aRoot, int nRoot, int, int*);
255 struct Pager *sqlite3BtreePager(Btree*);
256
257 int sqlite3BtreePutData(BtCursor*, u32 offset, u32 amt, void*);
258 void sqlite3BtreeIncrblobCursor(BtCursor *);
259 void sqlite3BtreeClearCursor(BtCursor *);
260 int sqlite3BtreeSetVersion(Btree *pBt, int iVersion);
261 int sqlite3BtreeCursorHasHint(BtCursor*, unsigned int mask);
262 int sqlite3BtreeIsReadonly(Btree *pBt);
263 int sqlite3HeaderSizeBtree(void);
264
265 #ifndef NDEBUG
266 int sqlite3BtreeCursorIsValid(BtCursor*);
267 #endif
268
269 #ifndef SQLITE_OMIT_BTREECOUNT
270 int sqlite3BtreeCount(BtCursor *, i64 *);
271 #endif
272
273 #ifdef SQLITE_TEST
274 int sqlite3BtreeCursorInfo(BtCursor*, int*, int);
275 void sqlite3BtreeCursorList(Btree*);
276 #endif
277
278 #ifndef SQLITE_OMIT_WAL
279 int sqlite3BtreeCheckpoint(Btree*, int, int *, int *);
280 #endif
281
282 /*
283 ** If we are not using shared cache, then there is no need to
284 ** use mutexes to access the BtShared structures. So make the
285 ** Enter and Leave procedures no-ops.
286 */
287 #ifndef SQLITE_OMIT_SHARED_CACHE
288 void sqlite3BtreeEnter(Btree*);
289 void sqlite3BtreeEnterAll(sqlite3*);
290 #else
291 # define sqlite3BtreeEnter(X)
292 # define sqlite3BtreeEnterAll(X)
293 #endif
294
295 #if !defined(SQLITE_OMIT_SHARED_CACHE) && SQLITE_THREADSAFE
296 int sqlite3BtreeSharable(Btree*);
297 void sqlite3BtreeLeave(Btree*);
298 void sqlite3BtreeEnterCursor(BtCursor*);
299 void sqlite3BtreeLeaveCursor(BtCursor*);
300 void sqlite3BtreeLeaveAll(sqlite3*);
301 #ifndef NDEBUG
302 /* These routines are used inside assert() statements only. */
303 int sqlite3BtreeHoldsMutex(Btree*);
304 int sqlite3BtreeHoldsAllMutexes(sqlite3*);
305 int sqlite3SchemaMutexHeld(sqlite3*,int,Schema*);
306 #endif
307 #else
308
309 # define sqlite3BtreeSharable(X) 0
310 # define sqlite3BtreeLeave(X)
311 # define sqlite3BtreeEnterCursor(X)
312 # define sqlite3BtreeLeaveCursor(X)
313 # define sqlite3BtreeLeaveAll(X)
314
315 # define sqlite3BtreeHoldsMutex(X) 1
316 # define sqlite3BtreeHoldsAllMutexes(X) 1
317 # define sqlite3SchemaMutexHeld(X,Y,Z) 1
318 #endif
319
320
321 #endif /* _BTREE_H_ */
OLDNEW
« no previous file with comments | « third_party/sqlite/sqlite-src-3100200/src/btmutex.c ('k') | third_party/sqlite/sqlite-src-3100200/src/btree.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698