annotate sqlite/btree.h @ 1632:978ada910173 trunk

[svn] - module fixes
author nenolod
date Wed, 06 Sep 2006 15:24:15 -0700
parents b6b61becdf4e
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1434
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
1 /*
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
2 ** 2001 September 15
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
3 **
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
4 ** The author disclaims copyright to this source code. In place of
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
5 ** a legal notice, here is a blessing:
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
6 **
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
7 ** May you do good and not evil.
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
8 ** May you find forgiveness for yourself and forgive others.
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
9 ** May you share freely, never taking more than you give.
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
10 **
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
11 *************************************************************************
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
12 ** This header file defines the interface that the sqlite B-Tree file
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
13 ** subsystem. See comments in the source code for a detailed description
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
14 ** of what each interface routine does.
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
15 **
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
16 ** @(#) $Id: btree.h,v 1.70 2006/02/11 01:25:51 drh Exp $
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
17 */
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
18 #ifndef _BTREE_H_
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
19 #define _BTREE_H_
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
20
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
21 /* TODO: This definition is just included so other modules compile. It
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
22 ** needs to be revisited.
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
23 */
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
24 #define SQLITE_N_BTREE_META 10
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
25
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
26 /*
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
27 ** If defined as non-zero, auto-vacuum is enabled by default. Otherwise
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
28 ** it must be turned on for each database using "PRAGMA auto_vacuum = 1".
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
29 */
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
30 #ifndef SQLITE_DEFAULT_AUTOVACUUM
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
31 #define SQLITE_DEFAULT_AUTOVACUUM 0
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
32 #endif
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
33
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
34 /*
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
35 ** Forward declarations of structure
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
36 */
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
37 typedef struct Btree Btree;
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
38 typedef struct BtCursor BtCursor;
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
39 typedef struct BtShared BtShared;
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
40
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
41
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
42 int sqlite3BtreeOpen(
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
43 const char *zFilename, /* Name of database file to open */
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
44 sqlite3 *db, /* Associated database connection */
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
45 Btree **, /* Return open Btree* here */
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
46 int flags /* Flags */
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
47 );
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
48
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
49 /* The flags parameter to sqlite3BtreeOpen can be the bitwise or of the
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
50 ** following values.
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
51 **
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
52 ** NOTE: These values must match the corresponding PAGER_ values in
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
53 ** pager.h.
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
54 */
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
55 #define BTREE_OMIT_JOURNAL 1 /* Do not use journal. No argument */
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
56 #define BTREE_NO_READLOCK 2 /* Omit readlocks on readonly files */
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
57 #define BTREE_MEMORY 4 /* In-memory DB. No argument */
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
58
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
59 int sqlite3BtreeClose(Btree*);
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
60 int sqlite3BtreeSetBusyHandler(Btree*,BusyHandler*);
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
61 int sqlite3BtreeSetCacheSize(Btree*,int);
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
62 int sqlite3BtreeSetSafetyLevel(Btree*,int,int);
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
63 int sqlite3BtreeSyncDisabled(Btree*);
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
64 int sqlite3BtreeSetPageSize(Btree*,int,int);
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
65 int sqlite3BtreeGetPageSize(Btree*);
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
66 int sqlite3BtreeGetReserve(Btree*);
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
67 int sqlite3BtreeSetAutoVacuum(Btree *, int);
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
68 int sqlite3BtreeGetAutoVacuum(Btree *);
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
69 int sqlite3BtreeBeginTrans(Btree*,int);
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
70 int sqlite3BtreeCommit(Btree*);
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
71 int sqlite3BtreeRollback(Btree*);
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
72 int sqlite3BtreeBeginStmt(Btree*);
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
73 int sqlite3BtreeCommitStmt(Btree*);
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
74 int sqlite3BtreeRollbackStmt(Btree*);
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
75 int sqlite3BtreeCreateTable(Btree*, int*, int flags);
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
76 int sqlite3BtreeIsInTrans(Btree*);
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
77 int sqlite3BtreeIsInStmt(Btree*);
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
78 int sqlite3BtreeSync(Btree*, const char *zMaster);
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
79 void *sqlite3BtreeSchema(Btree *, int, void(*)(void *));
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
80 int sqlite3BtreeSchemaLocked(Btree *);
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
81 int sqlite3BtreeLockTable(Btree *, int, u8);
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
82
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
83 const char *sqlite3BtreeGetFilename(Btree *);
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
84 const char *sqlite3BtreeGetDirname(Btree *);
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
85 const char *sqlite3BtreeGetJournalname(Btree *);
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
86 int sqlite3BtreeCopyFile(Btree *, Btree *);
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
87
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
88 /* The flags parameter to sqlite3BtreeCreateTable can be the bitwise OR
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
89 ** of the following flags:
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
90 */
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
91 #define BTREE_INTKEY 1 /* Table has only 64-bit signed integer keys */
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
92 #define BTREE_ZERODATA 2 /* Table has keys only - no data */
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
93 #define BTREE_LEAFDATA 4 /* Data stored in leaves only. Implies INTKEY */
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
94
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
95 int sqlite3BtreeDropTable(Btree*, int, int*);
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
96 int sqlite3BtreeClearTable(Btree*, int);
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
97 int sqlite3BtreeGetMeta(Btree*, int idx, u32 *pValue);
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
98 int sqlite3BtreeUpdateMeta(Btree*, int idx, u32 value);
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
99
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
100 int sqlite3BtreeCursor(
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
101 Btree*, /* BTree containing table to open */
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
102 int iTable, /* Index of root page */
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
103 int wrFlag, /* 1 for writing. 0 for read-only */
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
104 int(*)(void*,int,const void*,int,const void*), /* Key comparison function */
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
105 void*, /* First argument to compare function */
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
106 BtCursor **ppCursor /* Returned cursor */
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
107 );
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
108
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
109 void sqlite3BtreeSetCompare(
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
110 BtCursor *,
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
111 int(*)(void*,int,const void*,int,const void*),
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
112 void*
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
113 );
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
114
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
115 int sqlite3BtreeCloseCursor(BtCursor*);
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
116 int sqlite3BtreeMoveto(BtCursor*, const void *pKey, i64 nKey, int *pRes);
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
117 int sqlite3BtreeDelete(BtCursor*);
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
118 int sqlite3BtreeInsert(BtCursor*, const void *pKey, i64 nKey,
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
119 const void *pData, int nData);
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
120 int sqlite3BtreeFirst(BtCursor*, int *pRes);
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
121 int sqlite3BtreeLast(BtCursor*, int *pRes);
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
122 int sqlite3BtreeNext(BtCursor*, int *pRes);
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
123 int sqlite3BtreeEof(BtCursor*);
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
124 int sqlite3BtreeFlags(BtCursor*);
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
125 int sqlite3BtreePrevious(BtCursor*, int *pRes);
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
126 int sqlite3BtreeKeySize(BtCursor*, i64 *pSize);
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
127 int sqlite3BtreeKey(BtCursor*, u32 offset, u32 amt, void*);
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
128 const void *sqlite3BtreeKeyFetch(BtCursor*, int *pAmt);
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
129 const void *sqlite3BtreeDataFetch(BtCursor*, int *pAmt);
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
130 int sqlite3BtreeDataSize(BtCursor*, u32 *pSize);
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
131 int sqlite3BtreeData(BtCursor*, u32 offset, u32 amt, void*);
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
132
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
133 char *sqlite3BtreeIntegrityCheck(Btree*, int *aRoot, int nRoot);
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
134 struct Pager *sqlite3BtreePager(Btree*);
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
135
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
136
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
137 #ifdef SQLITE_TEST
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
138 int sqlite3BtreeCursorInfo(BtCursor*, int*, int);
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
139 void sqlite3BtreeCursorList(Btree*);
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
140 #endif
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
141
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
142 #ifdef SQLITE_DEBUG
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
143 int sqlite3BtreePageDump(Btree*, int, int recursive);
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
144 #else
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
145 #define sqlite3BtreePageDump(X,Y,Z) SQLITE_OK
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
146 #endif
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
147
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
148 #endif /* _BTREE_H_ */