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

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

Issue 3108030: Move bundled copy of sqlite one level deeper to better separate it... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « third_party/sqlite/src/btmutex.c ('k') | third_party/sqlite/src/btree.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 ** @(#) $Id: btree.h,v 1.120 2009/07/22 00:35:24 drh Exp $
17 */
18 #ifndef _BTREE_H_
19 #define _BTREE_H_
20
21 /* TODO: This definition is just included so other modules compile. It
22 ** needs to be revisited.
23 */
24 #define SQLITE_N_BTREE_META 10
25
26 /*
27 ** If defined as non-zero, auto-vacuum is enabled by default. Otherwise
28 ** it must be turned on for each database using "PRAGMA auto_vacuum = 1".
29 */
30 #ifndef SQLITE_DEFAULT_AUTOVACUUM
31 #define SQLITE_DEFAULT_AUTOVACUUM 0
32 #endif
33
34 #define BTREE_AUTOVACUUM_NONE 0 /* Do not do auto-vacuum */
35 #define BTREE_AUTOVACUUM_FULL 1 /* Do full auto-vacuum */
36 #define BTREE_AUTOVACUUM_INCR 2 /* Incremental vacuum */
37
38 /*
39 ** Forward declarations of structure
40 */
41 typedef struct Btree Btree;
42 typedef struct BtCursor BtCursor;
43 typedef struct BtShared BtShared;
44 typedef struct BtreeMutexArray BtreeMutexArray;
45
46 /*
47 ** This structure records all of the Btrees that need to hold
48 ** a mutex before we enter sqlite3VdbeExec(). The Btrees are
49 ** are placed in aBtree[] in order of aBtree[]->pBt. That way,
50 ** we can always lock and unlock them all quickly.
51 */
52 struct BtreeMutexArray {
53 int nMutex;
54 Btree *aBtree[SQLITE_MAX_ATTACHED+1];
55 };
56
57
58 int sqlite3BtreeOpen(
59 const char *zFilename, /* Name of database file to open */
60 sqlite3 *db, /* Associated database connection */
61 Btree **ppBtree, /* Return open Btree* here */
62 int flags, /* Flags */
63 int vfsFlags /* Flags passed through to VFS open */
64 );
65
66 /* The flags parameter to sqlite3BtreeOpen can be the bitwise or of the
67 ** following values.
68 **
69 ** NOTE: These values must match the corresponding PAGER_ values in
70 ** pager.h.
71 */
72 #define BTREE_OMIT_JOURNAL 1 /* Do not use journal. No argument */
73 #define BTREE_NO_READLOCK 2 /* Omit readlocks on readonly files */
74 #define BTREE_MEMORY 4 /* In-memory DB. No argument */
75 #define BTREE_READONLY 8 /* Open the database in read-only mode */
76 #define BTREE_READWRITE 16 /* Open for both reading and writing */
77 #define BTREE_CREATE 32 /* Create the database if it does not exist */
78
79 int sqlite3BtreeClose(Btree*);
80 int sqlite3BtreeSetCacheSize(Btree*,int);
81 int sqlite3BtreeSetSafetyLevel(Btree*,int,int);
82 int sqlite3BtreeSyncDisabled(Btree*);
83 int sqlite3BtreeSetPageSize(Btree *p, int nPagesize, int nReserve, int eFix);
84 int sqlite3BtreeGetPageSize(Btree*);
85 int sqlite3BtreeMaxPageCount(Btree*,int);
86 int sqlite3BtreeGetReserve(Btree*);
87 int sqlite3BtreeSetAutoVacuum(Btree *, int);
88 int sqlite3BtreeGetAutoVacuum(Btree *);
89 int sqlite3BtreeBeginTrans(Btree*,int);
90 int sqlite3BtreeCommitPhaseOne(Btree*, const char *zMaster);
91 int sqlite3BtreeCommitPhaseTwo(Btree*);
92 int sqlite3BtreeCommit(Btree*);
93 int sqlite3BtreeRollback(Btree*);
94 int sqlite3BtreeBeginStmt(Btree*,int);
95 int sqlite3BtreeCreateTable(Btree*, int*, int flags);
96 int sqlite3BtreeIsInTrans(Btree*);
97 int sqlite3BtreeIsInReadTrans(Btree*);
98 int sqlite3BtreeIsInBackup(Btree*);
99 void *sqlite3BtreeSchema(Btree *, int, void(*)(void *));
100 int sqlite3BtreeSchemaLocked(Btree *pBtree);
101 int sqlite3BtreeLockTable(Btree *pBtree, int iTab, u8 isWriteLock);
102 int sqlite3BtreeSavepoint(Btree *, int, int);
103
104 const char *sqlite3BtreeGetFilename(Btree *);
105 const char *sqlite3BtreeGetJournalname(Btree *);
106 int sqlite3BtreeCopyFile(Btree *, Btree *);
107
108 int sqlite3BtreeIncrVacuum(Btree *);
109
110 /* The flags parameter to sqlite3BtreeCreateTable can be the bitwise OR
111 ** of the following flags:
112 */
113 #define BTREE_INTKEY 1 /* Table has only 64-bit signed integer keys */
114 #define BTREE_ZERODATA 2 /* Table has keys only - no data */
115 #define BTREE_LEAFDATA 4 /* Data stored in leaves only. Implies INTKEY */
116
117 int sqlite3BtreeDropTable(Btree*, int, int*);
118 int sqlite3BtreeClearTable(Btree*, int, int*);
119 void sqlite3BtreeTripAllCursors(Btree*, int);
120
121 void sqlite3BtreeGetMeta(Btree *pBtree, int idx, u32 *pValue);
122 int sqlite3BtreeUpdateMeta(Btree*, int idx, u32 value);
123
124 /*
125 ** The second parameter to sqlite3BtreeGetMeta or sqlite3BtreeUpdateMeta
126 ** should be one of the following values. The integer values are assigned
127 ** to constants so that the offset of the corresponding field in an
128 ** SQLite database header may be found using the following formula:
129 **
130 ** offset = 36 + (idx * 4)
131 **
132 ** For example, the free-page-count field is located at byte offset 36 of
133 ** the database file header. The incr-vacuum-flag field is located at
134 ** byte offset 64 (== 36+4*7).
135 */
136 #define BTREE_FREE_PAGE_COUNT 0
137 #define BTREE_SCHEMA_VERSION 1
138 #define BTREE_FILE_FORMAT 2
139 #define BTREE_DEFAULT_CACHE_SIZE 3
140 #define BTREE_LARGEST_ROOT_PAGE 4
141 #define BTREE_TEXT_ENCODING 5
142 #define BTREE_USER_VERSION 6
143 #define BTREE_INCR_VACUUM 7
144
145 int sqlite3BtreeCursor(
146 Btree*, /* BTree containing table to open */
147 int iTable, /* Index of root page */
148 int wrFlag, /* 1 for writing. 0 for read-only */
149 struct KeyInfo*, /* First argument to compare function */
150 BtCursor *pCursor /* Space to write cursor structure */
151 );
152 int sqlite3BtreeCursorSize(void);
153
154 int sqlite3BtreeCloseCursor(BtCursor*);
155 int sqlite3BtreeMovetoUnpacked(
156 BtCursor*,
157 UnpackedRecord *pUnKey,
158 i64 intKey,
159 int bias,
160 int *pRes
161 );
162 int sqlite3BtreeCursorHasMoved(BtCursor*, int*);
163 int sqlite3BtreeDelete(BtCursor*);
164 int sqlite3BtreeInsert(BtCursor*, const void *pKey, i64 nKey,
165 const void *pData, int nData,
166 int nZero, int bias, int seekResult);
167 int sqlite3BtreeFirst(BtCursor*, int *pRes);
168 int sqlite3BtreeLast(BtCursor*, int *pRes);
169 int sqlite3BtreeNext(BtCursor*, int *pRes);
170 int sqlite3BtreeEof(BtCursor*);
171 int sqlite3BtreePrevious(BtCursor*, int *pRes);
172 int sqlite3BtreeKeySize(BtCursor*, i64 *pSize);
173 int sqlite3BtreeKey(BtCursor*, u32 offset, u32 amt, void*);
174 const void *sqlite3BtreeKeyFetch(BtCursor*, int *pAmt);
175 const void *sqlite3BtreeDataFetch(BtCursor*, int *pAmt);
176 int sqlite3BtreeDataSize(BtCursor*, u32 *pSize);
177 int sqlite3BtreeData(BtCursor*, u32 offset, u32 amt, void*);
178 void sqlite3BtreeSetCachedRowid(BtCursor*, sqlite3_int64);
179 sqlite3_int64 sqlite3BtreeGetCachedRowid(BtCursor*);
180
181 char *sqlite3BtreeIntegrityCheck(Btree*, int *aRoot, int nRoot, int, int*);
182 struct Pager *sqlite3BtreePager(Btree*);
183
184 int sqlite3BtreePutData(BtCursor*, u32 offset, u32 amt, void*);
185 void sqlite3BtreeCacheOverflow(BtCursor *);
186 void sqlite3BtreeClearCursor(BtCursor *);
187
188 #ifndef NDEBUG
189 int sqlite3BtreeCursorIsValid(BtCursor*);
190 #endif
191
192 #ifndef SQLITE_OMIT_BTREECOUNT
193 int sqlite3BtreeCount(BtCursor *, i64 *);
194 #endif
195
196 #ifdef SQLITE_TEST
197 int sqlite3BtreeCursorInfo(BtCursor*, int*, int);
198 void sqlite3BtreeCursorList(Btree*);
199 #endif
200
201 /*
202 ** If we are not using shared cache, then there is no need to
203 ** use mutexes to access the BtShared structures. So make the
204 ** Enter and Leave procedures no-ops.
205 */
206 #ifndef SQLITE_OMIT_SHARED_CACHE
207 void sqlite3BtreeEnter(Btree*);
208 void sqlite3BtreeEnterAll(sqlite3*);
209 #else
210 # define sqlite3BtreeEnter(X)
211 # define sqlite3BtreeEnterAll(X)
212 #endif
213
214 #if !defined(SQLITE_OMIT_SHARED_CACHE) && SQLITE_THREADSAFE
215 void sqlite3BtreeLeave(Btree*);
216 void sqlite3BtreeEnterCursor(BtCursor*);
217 void sqlite3BtreeLeaveCursor(BtCursor*);
218 void sqlite3BtreeLeaveAll(sqlite3*);
219 void sqlite3BtreeMutexArrayEnter(BtreeMutexArray*);
220 void sqlite3BtreeMutexArrayLeave(BtreeMutexArray*);
221 void sqlite3BtreeMutexArrayInsert(BtreeMutexArray*, Btree*);
222 #ifndef NDEBUG
223 /* These routines are used inside assert() statements only. */
224 int sqlite3BtreeHoldsMutex(Btree*);
225 int sqlite3BtreeHoldsAllMutexes(sqlite3*);
226 #endif
227 #else
228
229 # define sqlite3BtreeLeave(X)
230 # define sqlite3BtreeEnterCursor(X)
231 # define sqlite3BtreeLeaveCursor(X)
232 # define sqlite3BtreeLeaveAll(X)
233 # define sqlite3BtreeMutexArrayEnter(X)
234 # define sqlite3BtreeMutexArrayLeave(X)
235 # define sqlite3BtreeMutexArrayInsert(X,Y)
236
237 # define sqlite3BtreeHoldsMutex(X) 1
238 # define sqlite3BtreeHoldsAllMutexes(X) 1
239 #endif
240
241
242 #endif /* _BTREE_H_ */
OLDNEW
« no previous file with comments | « third_party/sqlite/src/btmutex.c ('k') | third_party/sqlite/src/btree.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698