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

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

Issue 1610543003: [sql] Import reference version of SQLite 3.10.2. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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
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 B-Tree file 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 13 ** subsystem. See comments in the source code for a detailed description
14 ** of what each interface routine does. 14 ** of what each interface routine does.
15 */ 15 */
16 #ifndef _BTREE_H_ 16 #ifndef _BTREE_H_
17 #define _BTREE_H_ 17 #define _BTREE_H_
18 18
19 /* TODO: This definition is just included so other modules compile. It 19 /* TODO: This definition is just included so other modules compile. It
20 ** needs to be revisited. 20 ** needs to be revisited.
21 */ 21 */
22 #define SQLITE_N_BTREE_META 10 22 #define SQLITE_N_BTREE_META 16
23 23
24 /* 24 /*
25 ** If defined as non-zero, auto-vacuum is enabled by default. Otherwise 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". 26 ** it must be turned on for each database using "PRAGMA auto_vacuum = 1".
27 */ 27 */
28 #ifndef SQLITE_DEFAULT_AUTOVACUUM 28 #ifndef SQLITE_DEFAULT_AUTOVACUUM
29 #define SQLITE_DEFAULT_AUTOVACUUM 0 29 #define SQLITE_DEFAULT_AUTOVACUUM 0
30 #endif 30 #endif
31 31
32 #define BTREE_AUTOVACUUM_NONE 0 /* Do not do auto-vacuum */ 32 #define BTREE_AUTOVACUUM_NONE 0 /* Do not do auto-vacuum */
(...skipping 23 matching lines...) Expand all
56 ** NOTE: These values must match the corresponding PAGER_ values in 56 ** NOTE: These values must match the corresponding PAGER_ values in
57 ** pager.h. 57 ** pager.h.
58 */ 58 */
59 #define BTREE_OMIT_JOURNAL 1 /* Do not create or use a rollback journal */ 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 */ 60 #define BTREE_MEMORY 2 /* This is an in-memory DB */
61 #define BTREE_SINGLE 4 /* The file contains at most 1 b-tree */ 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 */ 62 #define BTREE_UNORDERED 8 /* Use of a hash implementation is OK */
63 63
64 int sqlite3BtreeClose(Btree*); 64 int sqlite3BtreeClose(Btree*);
65 int sqlite3BtreeSetCacheSize(Btree*,int); 65 int sqlite3BtreeSetCacheSize(Btree*,int);
66 int sqlite3BtreeSetSpillSize(Btree*,int);
66 #if SQLITE_MAX_MMAP_SIZE>0 67 #if SQLITE_MAX_MMAP_SIZE>0
67 int sqlite3BtreeSetMmapLimit(Btree*,sqlite3_int64); 68 int sqlite3BtreeSetMmapLimit(Btree*,sqlite3_int64);
68 #endif 69 #endif
69 int sqlite3BtreeSetPagerFlags(Btree*,unsigned); 70 int sqlite3BtreeSetPagerFlags(Btree*,unsigned);
70 int sqlite3BtreeSyncDisabled(Btree*); 71 int sqlite3BtreeSyncDisabled(Btree*);
71 int sqlite3BtreeSetPageSize(Btree *p, int nPagesize, int nReserve, int eFix); 72 int sqlite3BtreeSetPageSize(Btree *p, int nPagesize, int nReserve, int eFix);
72 int sqlite3BtreeGetPageSize(Btree*); 73 int sqlite3BtreeGetPageSize(Btree*);
73 int sqlite3BtreeMaxPageCount(Btree*,int); 74 int sqlite3BtreeMaxPageCount(Btree*,int);
74 u32 sqlite3BtreeLastPage(Btree*); 75 u32 sqlite3BtreeLastPage(Btree*);
75 int sqlite3BtreeSecureDelete(Btree*,int); 76 int sqlite3BtreeSecureDelete(Btree*,int);
76 int sqlite3BtreeGetReserve(Btree*); 77 int sqlite3BtreeGetOptimalReserve(Btree*);
77 #if defined(SQLITE_HAS_CODEC) || defined(SQLITE_DEBUG)
78 int sqlite3BtreeGetReserveNoMutex(Btree *p); 78 int sqlite3BtreeGetReserveNoMutex(Btree *p);
79 #endif
80 int sqlite3BtreeSetAutoVacuum(Btree *, int); 79 int sqlite3BtreeSetAutoVacuum(Btree *, int);
81 int sqlite3BtreeGetAutoVacuum(Btree *); 80 int sqlite3BtreeGetAutoVacuum(Btree *);
82 int sqlite3BtreeBeginTrans(Btree*,int); 81 int sqlite3BtreeBeginTrans(Btree*,int);
83 int sqlite3BtreeCommitPhaseOne(Btree*, const char *zMaster); 82 int sqlite3BtreeCommitPhaseOne(Btree*, const char *zMaster);
84 int sqlite3BtreeCommitPhaseTwo(Btree*, int); 83 int sqlite3BtreeCommitPhaseTwo(Btree*, int);
85 int sqlite3BtreeCommit(Btree*); 84 int sqlite3BtreeCommit(Btree*);
86 int sqlite3BtreeRollback(Btree*,int,int); 85 int sqlite3BtreeRollback(Btree*,int,int);
87 int sqlite3BtreeBeginStmt(Btree*,int); 86 int sqlite3BtreeBeginStmt(Btree*,int);
88 int sqlite3BtreeCreateTable(Btree*, int*, int flags); 87 int sqlite3BtreeCreateTable(Btree*, int*, int flags);
89 int sqlite3BtreeIsInTrans(Btree*); 88 int sqlite3BtreeIsInTrans(Btree*);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 ** The second parameter to sqlite3BtreeGetMeta or sqlite3BtreeUpdateMeta 126 ** The second parameter to sqlite3BtreeGetMeta or sqlite3BtreeUpdateMeta
128 ** should be one of the following values. The integer values are assigned 127 ** should be one of the following values. The integer values are assigned
129 ** to constants so that the offset of the corresponding field in an 128 ** to constants so that the offset of the corresponding field in an
130 ** SQLite database header may be found using the following formula: 129 ** SQLite database header may be found using the following formula:
131 ** 130 **
132 ** offset = 36 + (idx * 4) 131 ** offset = 36 + (idx * 4)
133 ** 132 **
134 ** For example, the free-page-count field is located at byte offset 36 of 133 ** For example, the free-page-count field is located at byte offset 36 of
135 ** the database file header. The incr-vacuum-flag field is located at 134 ** the database file header. The incr-vacuum-flag field is located at
136 ** byte offset 64 (== 36+4*7). 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".
137 */ 141 */
138 #define BTREE_FREE_PAGE_COUNT 0 142 #define BTREE_FREE_PAGE_COUNT 0
139 #define BTREE_SCHEMA_VERSION 1 143 #define BTREE_SCHEMA_VERSION 1
140 #define BTREE_FILE_FORMAT 2 144 #define BTREE_FILE_FORMAT 2
141 #define BTREE_DEFAULT_CACHE_SIZE 3 145 #define BTREE_DEFAULT_CACHE_SIZE 3
142 #define BTREE_LARGEST_ROOT_PAGE 4 146 #define BTREE_LARGEST_ROOT_PAGE 4
143 #define BTREE_TEXT_ENCODING 5 147 #define BTREE_TEXT_ENCODING 5
144 #define BTREE_USER_VERSION 6 148 #define BTREE_USER_VERSION 6
145 #define BTREE_INCR_VACUUM 7 149 #define BTREE_INCR_VACUUM 7
146 #define BTREE_APPLICATION_ID 8 150 #define BTREE_APPLICATION_ID 8
151 #define BTREE_DATA_VERSION 15 /* A virtual meta-value */
147 152
148 /* 153 /*
149 ** Values that may be OR'd together to form the second argument of an 154 ** Kinds of hints that can be passed into the sqlite3BtreeCursorHint()
150 ** sqlite3BtreeCursorHints() call. 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.
151 */ 179 */
152 #define BTREE_BULKLOAD 0x00000001 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 */
153 213
154 int sqlite3BtreeCursor( 214 int sqlite3BtreeCursor(
155 Btree*, /* BTree containing table to open */ 215 Btree*, /* BTree containing table to open */
156 int iTable, /* Index of root page */ 216 int iTable, /* Index of root page */
157 int wrFlag, /* 1 for writing. 0 for read-only */ 217 int wrFlag, /* 1 for writing. 0 for read-only */
158 struct KeyInfo*, /* First argument to compare function */ 218 struct KeyInfo*, /* First argument to compare function */
159 BtCursor *pCursor /* Space to write cursor structure */ 219 BtCursor *pCursor /* Space to write cursor structure */
160 ); 220 );
161 int sqlite3BtreeCursorSize(void); 221 int sqlite3BtreeCursorSize(void);
162 void sqlite3BtreeCursorZero(BtCursor*); 222 void sqlite3BtreeCursorZero(BtCursor*);
223 void sqlite3BtreeCursorHintFlags(BtCursor*, unsigned);
224 #ifdef SQLITE_ENABLE_CURSOR_HINTS
225 void sqlite3BtreeCursorHint(BtCursor*, int, ...);
226 #endif
163 227
164 int sqlite3BtreeCloseCursor(BtCursor*); 228 int sqlite3BtreeCloseCursor(BtCursor*);
165 int sqlite3BtreeMovetoUnpacked( 229 int sqlite3BtreeMovetoUnpacked(
166 BtCursor*, 230 BtCursor*,
167 UnpackedRecord *pUnKey, 231 UnpackedRecord *pUnKey,
168 i64 intKey, 232 i64 intKey,
169 int bias, 233 int bias,
170 int *pRes 234 int *pRes
171 ); 235 );
172 int sqlite3BtreeCursorHasMoved(BtCursor*); 236 int sqlite3BtreeCursorHasMoved(BtCursor*);
173 int sqlite3BtreeCursorRestore(BtCursor*, int*); 237 int sqlite3BtreeCursorRestore(BtCursor*, int*);
174 int sqlite3BtreeDelete(BtCursor*); 238 int sqlite3BtreeDelete(BtCursor*, int);
175 int sqlite3BtreeInsert(BtCursor*, const void *pKey, i64 nKey, 239 int sqlite3BtreeInsert(BtCursor*, const void *pKey, i64 nKey,
176 const void *pData, int nData, 240 const void *pData, int nData,
177 int nZero, int bias, int seekResult); 241 int nZero, int bias, int seekResult);
178 int sqlite3BtreeFirst(BtCursor*, int *pRes); 242 int sqlite3BtreeFirst(BtCursor*, int *pRes);
179 int sqlite3BtreeLast(BtCursor*, int *pRes); 243 int sqlite3BtreeLast(BtCursor*, int *pRes);
180 int sqlite3BtreeNext(BtCursor*, int *pRes); 244 int sqlite3BtreeNext(BtCursor*, int *pRes);
181 int sqlite3BtreeEof(BtCursor*); 245 int sqlite3BtreeEof(BtCursor*);
182 int sqlite3BtreePrevious(BtCursor*, int *pRes); 246 int sqlite3BtreePrevious(BtCursor*, int *pRes);
183 int sqlite3BtreeKeySize(BtCursor*, i64 *pSize); 247 int sqlite3BtreeKeySize(BtCursor*, i64 *pSize);
184 int sqlite3BtreeKey(BtCursor*, u32 offset, u32 amt, void*); 248 int sqlite3BtreeKey(BtCursor*, u32 offset, u32 amt, void*);
185 const void *sqlite3BtreeKeyFetch(BtCursor*, u32 *pAmt); 249 const void *sqlite3BtreeKeyFetch(BtCursor*, u32 *pAmt);
186 const void *sqlite3BtreeDataFetch(BtCursor*, u32 *pAmt); 250 const void *sqlite3BtreeDataFetch(BtCursor*, u32 *pAmt);
187 int sqlite3BtreeDataSize(BtCursor*, u32 *pSize); 251 int sqlite3BtreeDataSize(BtCursor*, u32 *pSize);
188 int sqlite3BtreeData(BtCursor*, u32 offset, u32 amt, void*); 252 int sqlite3BtreeData(BtCursor*, u32 offset, u32 amt, void*);
189 253
190 char *sqlite3BtreeIntegrityCheck(Btree*, int *aRoot, int nRoot, int, int*); 254 char *sqlite3BtreeIntegrityCheck(Btree*, int *aRoot, int nRoot, int, int*);
191 struct Pager *sqlite3BtreePager(Btree*); 255 struct Pager *sqlite3BtreePager(Btree*);
192 256
193 int sqlite3BtreePutData(BtCursor*, u32 offset, u32 amt, void*); 257 int sqlite3BtreePutData(BtCursor*, u32 offset, u32 amt, void*);
194 void sqlite3BtreeIncrblobCursor(BtCursor *); 258 void sqlite3BtreeIncrblobCursor(BtCursor *);
195 void sqlite3BtreeClearCursor(BtCursor *); 259 void sqlite3BtreeClearCursor(BtCursor *);
196 int sqlite3BtreeSetVersion(Btree *pBt, int iVersion); 260 int sqlite3BtreeSetVersion(Btree *pBt, int iVersion);
197 void sqlite3BtreeCursorHints(BtCursor *, unsigned int mask); 261 int sqlite3BtreeCursorHasHint(BtCursor*, unsigned int mask);
198 int sqlite3BtreeIsReadonly(Btree *pBt); 262 int sqlite3BtreeIsReadonly(Btree *pBt);
263 int sqlite3HeaderSizeBtree(void);
199 264
200 #ifndef NDEBUG 265 #ifndef NDEBUG
201 int sqlite3BtreeCursorIsValid(BtCursor*); 266 int sqlite3BtreeCursorIsValid(BtCursor*);
202 #endif 267 #endif
203 268
204 #ifndef SQLITE_OMIT_BTREECOUNT 269 #ifndef SQLITE_OMIT_BTREECOUNT
205 int sqlite3BtreeCount(BtCursor *, i64 *); 270 int sqlite3BtreeCount(BtCursor *, i64 *);
206 #endif 271 #endif
207 272
208 #ifdef SQLITE_TEST 273 #ifdef SQLITE_TEST
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 # define sqlite3BtreeLeaveCursor(X) 312 # define sqlite3BtreeLeaveCursor(X)
248 # define sqlite3BtreeLeaveAll(X) 313 # define sqlite3BtreeLeaveAll(X)
249 314
250 # define sqlite3BtreeHoldsMutex(X) 1 315 # define sqlite3BtreeHoldsMutex(X) 1
251 # define sqlite3BtreeHoldsAllMutexes(X) 1 316 # define sqlite3BtreeHoldsAllMutexes(X) 1
252 # define sqlite3SchemaMutexHeld(X,Y,Z) 1 317 # define sqlite3SchemaMutexHeld(X,Y,Z) 1
253 #endif 318 #endif
254 319
255 320
256 #endif /* _BTREE_H_ */ 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