|
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.71 2006/06/27 16:34:57 danielk1977 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 /* |
|
35 ** Forward declarations of structure |
|
36 */ |
|
37 typedef struct Btree Btree; |
|
38 typedef struct BtCursor BtCursor; |
|
39 typedef struct BtShared BtShared; |
|
40 |
|
41 |
|
42 int sqlite3BtreeOpen( |
|
43 const char *zFilename, /* Name of database file to open */ |
|
44 sqlite3 *db, /* Associated database connection */ |
|
45 Btree **, /* Return open Btree* here */ |
|
46 int flags /* Flags */ |
|
47 ); |
|
48 |
|
49 /* The flags parameter to sqlite3BtreeOpen can be the bitwise or of the |
|
50 ** following values. |
|
51 ** |
|
52 ** NOTE: These values must match the corresponding PAGER_ values in |
|
53 ** pager.h. |
|
54 */ |
|
55 #define BTREE_OMIT_JOURNAL 1 /* Do not use journal. No argument */ |
|
56 #define BTREE_NO_READLOCK 2 /* Omit readlocks on readonly files */ |
|
57 #define BTREE_MEMORY 4 /* In-memory DB. No argument */ |
|
58 |
|
59 int sqlite3BtreeClose(Btree*); |
|
60 int sqlite3BtreeSetBusyHandler(Btree*,BusyHandler*); |
|
61 int sqlite3BtreeSetCacheSize(Btree*,int); |
|
62 int sqlite3BtreeSetSafetyLevel(Btree*,int,int); |
|
63 int sqlite3BtreeSyncDisabled(Btree*); |
|
64 int sqlite3BtreeSetPageSize(Btree*,int,int); |
|
65 int sqlite3BtreeGetPageSize(Btree*); |
|
66 int sqlite3BtreeGetReserve(Btree*); |
|
67 int sqlite3BtreeSetAutoVacuum(Btree *, int); |
|
68 int sqlite3BtreeGetAutoVacuum(Btree *); |
|
69 int sqlite3BtreeBeginTrans(Btree*,int); |
|
70 int sqlite3BtreeCommit(Btree*); |
|
71 int sqlite3BtreeRollback(Btree*); |
|
72 int sqlite3BtreeBeginStmt(Btree*); |
|
73 int sqlite3BtreeCommitStmt(Btree*); |
|
74 int sqlite3BtreeRollbackStmt(Btree*); |
|
75 int sqlite3BtreeCreateTable(Btree*, int*, int flags); |
|
76 int sqlite3BtreeIsInTrans(Btree*); |
|
77 int sqlite3BtreeIsInStmt(Btree*); |
|
78 int sqlite3BtreeIsInReadTrans(Btree*); |
|
79 int sqlite3BtreeSync(Btree*, const char *zMaster); |
|
80 void *sqlite3BtreeSchema(Btree *, int, void(*)(void *)); |
|
81 int sqlite3BtreeSchemaLocked(Btree *); |
|
82 int sqlite3BtreeLockTable(Btree *, int, u8); |
|
83 |
|
84 const char *sqlite3BtreeGetFilename(Btree *); |
|
85 const char *sqlite3BtreeGetDirname(Btree *); |
|
86 const char *sqlite3BtreeGetJournalname(Btree *); |
|
87 int sqlite3BtreeCopyFile(Btree *, Btree *); |
|
88 |
|
89 /* The flags parameter to sqlite3BtreeCreateTable can be the bitwise OR |
|
90 ** of the following flags: |
|
91 */ |
|
92 #define BTREE_INTKEY 1 /* Table has only 64-bit signed integer keys */ |
|
93 #define BTREE_ZERODATA 2 /* Table has keys only - no data */ |
|
94 #define BTREE_LEAFDATA 4 /* Data stored in leaves only. Implies INTKEY */ |
|
95 |
|
96 int sqlite3BtreeDropTable(Btree*, int, int*); |
|
97 int sqlite3BtreeClearTable(Btree*, int); |
|
98 int sqlite3BtreeGetMeta(Btree*, int idx, u32 *pValue); |
|
99 int sqlite3BtreeUpdateMeta(Btree*, int idx, u32 value); |
|
100 |
|
101 int sqlite3BtreeCursor( |
|
102 Btree*, /* BTree containing table to open */ |
|
103 int iTable, /* Index of root page */ |
|
104 int wrFlag, /* 1 for writing. 0 for read-only */ |
|
105 int(*)(void*,int,const void*,int,const void*), /* Key comparison function */ |
|
106 void*, /* First argument to compare function */ |
|
107 BtCursor **ppCursor /* Returned cursor */ |
|
108 ); |
|
109 |
|
110 void sqlite3BtreeSetCompare( |
|
111 BtCursor *, |
|
112 int(*)(void*,int,const void*,int,const void*), |
|
113 void* |
|
114 ); |
|
115 |
|
116 int sqlite3BtreeCloseCursor(BtCursor*); |
|
117 int sqlite3BtreeMoveto(BtCursor*, const void *pKey, i64 nKey, int *pRes); |
|
118 int sqlite3BtreeDelete(BtCursor*); |
|
119 int sqlite3BtreeInsert(BtCursor*, const void *pKey, i64 nKey, |
|
120 const void *pData, int nData); |
|
121 int sqlite3BtreeFirst(BtCursor*, int *pRes); |
|
122 int sqlite3BtreeLast(BtCursor*, int *pRes); |
|
123 int sqlite3BtreeNext(BtCursor*, int *pRes); |
|
124 int sqlite3BtreeEof(BtCursor*); |
|
125 int sqlite3BtreeFlags(BtCursor*); |
|
126 int sqlite3BtreePrevious(BtCursor*, int *pRes); |
|
127 int sqlite3BtreeKeySize(BtCursor*, i64 *pSize); |
|
128 int sqlite3BtreeKey(BtCursor*, u32 offset, u32 amt, void*); |
|
129 const void *sqlite3BtreeKeyFetch(BtCursor*, int *pAmt); |
|
130 const void *sqlite3BtreeDataFetch(BtCursor*, int *pAmt); |
|
131 int sqlite3BtreeDataSize(BtCursor*, u32 *pSize); |
|
132 int sqlite3BtreeData(BtCursor*, u32 offset, u32 amt, void*); |
|
133 |
|
134 char *sqlite3BtreeIntegrityCheck(Btree*, int *aRoot, int nRoot); |
|
135 struct Pager *sqlite3BtreePager(Btree*); |
|
136 |
|
137 |
|
138 #ifdef SQLITE_TEST |
|
139 int sqlite3BtreeCursorInfo(BtCursor*, int*, int); |
|
140 void sqlite3BtreeCursorList(Btree*); |
|
141 #endif |
|
142 |
|
143 #ifdef SQLITE_DEBUG |
|
144 int sqlite3BtreePageDump(Btree*, int, int recursive); |
|
145 #else |
|
146 #define sqlite3BtreePageDump(X,Y,Z) SQLITE_OK |
|
147 #endif |
|
148 |
|
149 #endif /* _BTREE_H_ */ |