1434
|
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.70 2006/02/11 01:25:51 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 /*
|
|
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 sqlite3BtreeSync(Btree*, const char *zMaster);
|
|
79 void *sqlite3BtreeSchema(Btree *, int, void(*)(void *));
|
|
80 int sqlite3BtreeSchemaLocked(Btree *);
|
|
81 int sqlite3BtreeLockTable(Btree *, int, u8);
|
|
82
|
|
83 const char *sqlite3BtreeGetFilename(Btree *);
|
|
84 const char *sqlite3BtreeGetDirname(Btree *);
|
|
85 const char *sqlite3BtreeGetJournalname(Btree *);
|
|
86 int sqlite3BtreeCopyFile(Btree *, Btree *);
|
|
87
|
|
88 /* The flags parameter to sqlite3BtreeCreateTable can be the bitwise OR
|
|
89 ** of the following flags:
|
|
90 */
|
|
91 #define BTREE_INTKEY 1 /* Table has only 64-bit signed integer keys */
|
|
92 #define BTREE_ZERODATA 2 /* Table has keys only - no data */
|
|
93 #define BTREE_LEAFDATA 4 /* Data stored in leaves only. Implies INTKEY */
|
|
94
|
|
95 int sqlite3BtreeDropTable(Btree*, int, int*);
|
|
96 int sqlite3BtreeClearTable(Btree*, int);
|
|
97 int sqlite3BtreeGetMeta(Btree*, int idx, u32 *pValue);
|
|
98 int sqlite3BtreeUpdateMeta(Btree*, int idx, u32 value);
|
|
99
|
|
100 int sqlite3BtreeCursor(
|
|
101 Btree*, /* BTree containing table to open */
|
|
102 int iTable, /* Index of root page */
|
|
103 int wrFlag, /* 1 for writing. 0 for read-only */
|
|
104 int(*)(void*,int,const void*,int,const void*), /* Key comparison function */
|
|
105 void*, /* First argument to compare function */
|
|
106 BtCursor **ppCursor /* Returned cursor */
|
|
107 );
|
|
108
|
|
109 void sqlite3BtreeSetCompare(
|
|
110 BtCursor *,
|
|
111 int(*)(void*,int,const void*,int,const void*),
|
|
112 void*
|
|
113 );
|
|
114
|
|
115 int sqlite3BtreeCloseCursor(BtCursor*);
|
|
116 int sqlite3BtreeMoveto(BtCursor*, const void *pKey, i64 nKey, int *pRes);
|
|
117 int sqlite3BtreeDelete(BtCursor*);
|
|
118 int sqlite3BtreeInsert(BtCursor*, const void *pKey, i64 nKey,
|
|
119 const void *pData, int nData);
|
|
120 int sqlite3BtreeFirst(BtCursor*, int *pRes);
|
|
121 int sqlite3BtreeLast(BtCursor*, int *pRes);
|
|
122 int sqlite3BtreeNext(BtCursor*, int *pRes);
|
|
123 int sqlite3BtreeEof(BtCursor*);
|
|
124 int sqlite3BtreeFlags(BtCursor*);
|
|
125 int sqlite3BtreePrevious(BtCursor*, int *pRes);
|
|
126 int sqlite3BtreeKeySize(BtCursor*, i64 *pSize);
|
|
127 int sqlite3BtreeKey(BtCursor*, u32 offset, u32 amt, void*);
|
|
128 const void *sqlite3BtreeKeyFetch(BtCursor*, int *pAmt);
|
|
129 const void *sqlite3BtreeDataFetch(BtCursor*, int *pAmt);
|
|
130 int sqlite3BtreeDataSize(BtCursor*, u32 *pSize);
|
|
131 int sqlite3BtreeData(BtCursor*, u32 offset, u32 amt, void*);
|
|
132
|
|
133 char *sqlite3BtreeIntegrityCheck(Btree*, int *aRoot, int nRoot);
|
|
134 struct Pager *sqlite3BtreePager(Btree*);
|
|
135
|
|
136
|
|
137 #ifdef SQLITE_TEST
|
|
138 int sqlite3BtreeCursorInfo(BtCursor*, int*, int);
|
|
139 void sqlite3BtreeCursorList(Btree*);
|
|
140 #endif
|
|
141
|
|
142 #ifdef SQLITE_DEBUG
|
|
143 int sqlite3BtreePageDump(Btree*, int, int recursive);
|
|
144 #else
|
|
145 #define sqlite3BtreePageDump(X,Y,Z) SQLITE_OK
|
|
146 #endif
|
|
147
|
|
148 #endif /* _BTREE_H_ */
|