31
31
#define SQLITE_DEFAULT_AUTOVACUUM 0
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 */
35
39
** Forward declarations of structure
37
41
typedef struct Btree Btree;
38
42
typedef struct BtCursor BtCursor;
39
43
typedef struct BtShared BtShared;
44
typedef struct BtreeMutexArray BtreeMutexArray;
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.
52
struct BtreeMutexArray {
54
Btree *aBtree[SQLITE_MAX_ATTACHED+1];
42
58
int sqlite3BtreeOpen(
43
59
const char *zFilename, /* Name of database file to open */
44
60
sqlite3 *db, /* Associated database connection */
45
61
Btree **, /* Return open Btree* here */
62
int flags, /* Flags */
63
int vfsFlags /* Flags passed through to VFS open */
49
66
/* The flags parameter to sqlite3BtreeOpen can be the bitwise or of the
55
72
#define BTREE_OMIT_JOURNAL 1 /* Do not use journal. No argument */
56
73
#define BTREE_NO_READLOCK 2 /* Omit readlocks on readonly files */
57
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 */
79
/* Additional values for the 4th argument of sqlite3BtreeOpen that
80
** are not associated with PAGER_ values.
82
#define BTREE_PRIVATE 64 /* Never share with other connections */
59
84
int sqlite3BtreeClose(Btree*);
60
int sqlite3BtreeSetBusyHandler(Btree*,BusyHandler*);
61
85
int sqlite3BtreeSetCacheSize(Btree*,int);
62
86
int sqlite3BtreeSetSafetyLevel(Btree*,int,int);
63
87
int sqlite3BtreeSyncDisabled(Btree*);
64
88
int sqlite3BtreeSetPageSize(Btree*,int,int);
65
89
int sqlite3BtreeGetPageSize(Btree*);
90
int sqlite3BtreeMaxPageCount(Btree*,int);
66
91
int sqlite3BtreeGetReserve(Btree*);
67
92
int sqlite3BtreeSetAutoVacuum(Btree *, int);
68
93
int sqlite3BtreeGetAutoVacuum(Btree *);
69
94
int sqlite3BtreeBeginTrans(Btree*,int);
95
int sqlite3BtreeCommitPhaseOne(Btree*, const char *zMaster);
96
int sqlite3BtreeCommitPhaseTwo(Btree*);
70
97
int sqlite3BtreeCommit(Btree*);
71
98
int sqlite3BtreeRollback(Btree*);
72
99
int sqlite3BtreeBeginStmt(Btree*);
76
103
int sqlite3BtreeIsInTrans(Btree*);
77
104
int sqlite3BtreeIsInStmt(Btree*);
78
105
int sqlite3BtreeIsInReadTrans(Btree*);
79
int sqlite3BtreeSync(Btree*, const char *zMaster);
80
106
void *sqlite3BtreeSchema(Btree *, int, void(*)(void *));
81
107
int sqlite3BtreeSchemaLocked(Btree *);
82
108
int sqlite3BtreeLockTable(Btree *, int, u8);
97
125
int sqlite3BtreeClearTable(Btree*, int);
98
126
int sqlite3BtreeGetMeta(Btree*, int idx, u32 *pValue);
99
127
int sqlite3BtreeUpdateMeta(Btree*, int idx, u32 value);
128
void sqlite3BtreeTripAllCursors(Btree*, int);
130
struct UnpackedRecord; /* Forward declaration. Definition in vdbeaux.c. */
101
132
int sqlite3BtreeCursor(
102
133
Btree*, /* BTree containing table to open */
103
134
int iTable, /* Index of root page */
104
135
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 */
110
void sqlite3BtreeSetCompare(
112
int(*)(void*,int,const void*,int,const void*),
136
struct KeyInfo*, /* First argument to compare function */
137
BtCursor *pCursor /* Space to write cursor structure */
139
int sqlite3BtreeCursorSize(void);
116
141
int sqlite3BtreeCloseCursor(BtCursor*);
117
int sqlite3BtreeMoveto(BtCursor*, const void *pKey, i64 nKey, int *pRes);
142
int sqlite3BtreeMoveto(
145
struct UnpackedRecord *pUnKey,
118
150
int sqlite3BtreeDelete(BtCursor*);
119
151
int sqlite3BtreeInsert(BtCursor*, const void *pKey, i64 nKey,
120
const void *pData, int nData);
152
const void *pData, int nData,
153
int nZero, int bias);
121
154
int sqlite3BtreeFirst(BtCursor*, int *pRes);
122
155
int sqlite3BtreeLast(BtCursor*, int *pRes);
123
156
int sqlite3BtreeNext(BtCursor*, int *pRes);
126
159
int sqlite3BtreePrevious(BtCursor*, int *pRes);
127
160
int sqlite3BtreeKeySize(BtCursor*, i64 *pSize);
128
161
int sqlite3BtreeKey(BtCursor*, u32 offset, u32 amt, void*);
162
sqlite3 *sqlite3BtreeCursorDb(const BtCursor*);
129
163
const void *sqlite3BtreeKeyFetch(BtCursor*, int *pAmt);
130
164
const void *sqlite3BtreeDataFetch(BtCursor*, int *pAmt);
131
165
int sqlite3BtreeDataSize(BtCursor*, u32 *pSize);
132
166
int sqlite3BtreeData(BtCursor*, u32 offset, u32 amt, void*);
134
char *sqlite3BtreeIntegrityCheck(Btree*, int *aRoot, int nRoot);
168
char *sqlite3BtreeIntegrityCheck(Btree*, int *aRoot, int nRoot, int, int*);
135
169
struct Pager *sqlite3BtreePager(Btree*);
171
int sqlite3BtreePutData(BtCursor*, u32 offset, u32 amt, void*);
172
void sqlite3BtreeCacheOverflow(BtCursor *);
138
174
#ifdef SQLITE_TEST
139
175
int sqlite3BtreeCursorInfo(BtCursor*, int*, int);
140
176
void sqlite3BtreeCursorList(Btree*);
144
177
int sqlite3BtreePageDump(Btree*, int, int recursive);
181
** If we are not using shared cache, then there is no need to
182
** use mutexes to access the BtShared structures. So make the
183
** Enter and Leave procedures no-ops.
185
#if !defined(SQLITE_OMIT_SHARED_CACHE) && SQLITE_THREADSAFE
186
void sqlite3BtreeEnter(Btree*);
187
void sqlite3BtreeLeave(Btree*);
188
int sqlite3BtreeHoldsMutex(Btree*);
189
void sqlite3BtreeEnterCursor(BtCursor*);
190
void sqlite3BtreeLeaveCursor(BtCursor*);
191
void sqlite3BtreeEnterAll(sqlite3*);
192
void sqlite3BtreeLeaveAll(sqlite3*);
193
int sqlite3BtreeHoldsAllMutexes(sqlite3*);
194
void sqlite3BtreeMutexArrayEnter(BtreeMutexArray*);
195
void sqlite3BtreeMutexArrayLeave(BtreeMutexArray*);
196
void sqlite3BtreeMutexArrayInsert(BtreeMutexArray*, Btree*);
146
#define sqlite3BtreePageDump(X,Y,Z) SQLITE_OK
198
# define sqlite3BtreeEnter(X)
199
# define sqlite3BtreeLeave(X)
200
# define sqlite3BtreeHoldsMutex(X) 1
201
# define sqlite3BtreeEnterCursor(X)
202
# define sqlite3BtreeLeaveCursor(X)
203
# define sqlite3BtreeEnterAll(X)
204
# define sqlite3BtreeLeaveAll(X)
205
# define sqlite3BtreeHoldsAllMutexes(X) 1
206
# define sqlite3BtreeMutexArrayEnter(X)
207
# define sqlite3BtreeMutexArrayLeave(X)
208
# define sqlite3BtreeMutexArrayInsert(X,Y)
149
212
#endif /* _BTREE_H_ */