~ubuntu-branches/ubuntu/maverick/sqlite3/maverick-updates

« back to all changes in this revision

Viewing changes to src/btree.h

  • Committer: Bazaar Package Importer
  • Author(s): Laszlo Boszormenyi (GCS)
  • Date: 2008-10-01 20:16:18 UTC
  • mfrom: (3.1.20 intrepid)
  • Revision ID: james.westby@ubuntu.com-20081001201618-yfvqqj1qs29wdtcc
Tags: 3.5.9-5
Backport fix for distinct on indexes (closes: #500792).

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
** subsystem.  See comments in the source code for a detailed description
14
14
** of what each interface routine does.
15
15
**
16
 
** @(#) $Id: btree.h,v 1.71 2006/06/27 16:34:57 danielk1977 Exp $
 
16
** @(#) $Id: btree.h,v 1.98 2008/04/26 13:39:47 drh Exp $
17
17
*/
18
18
#ifndef _BTREE_H_
19
19
#define _BTREE_H_
31
31
  #define SQLITE_DEFAULT_AUTOVACUUM 0
32
32
#endif
33
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
 
34
38
/*
35
39
** Forward declarations of structure
36
40
*/
37
41
typedef struct Btree Btree;
38
42
typedef struct BtCursor BtCursor;
39
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
};
40
56
 
41
57
 
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 */
46
 
  int flags                /* Flags */
 
62
  int flags,               /* Flags */
 
63
  int vfsFlags             /* Flags passed through to VFS open */
47
64
);
48
65
 
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 */
 
78
 
 
79
/* Additional values for the 4th argument of sqlite3BtreeOpen that
 
80
** are not associated with PAGER_ values.
 
81
*/
 
82
#define BTREE_PRIVATE      64  /* Never share with other connections */
58
83
 
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);
86
112
const char *sqlite3BtreeGetJournalname(Btree *);
87
113
int sqlite3BtreeCopyFile(Btree *, Btree *);
88
114
 
 
115
int sqlite3BtreeIncrVacuum(Btree *);
 
116
 
89
117
/* The flags parameter to sqlite3BtreeCreateTable can be the bitwise OR
90
118
** of the following flags:
91
119
*/
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);
 
129
 
 
130
struct UnpackedRecord;  /* Forward declaration.  Definition in vdbeaux.c. */
100
131
 
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 */
108
 
);
109
 
 
110
 
void sqlite3BtreeSetCompare(
111
 
  BtCursor *,
112
 
  int(*)(void*,int,const void*,int,const void*),
113
 
  void*
114
 
);
 
136
  struct KeyInfo*,                     /* First argument to compare function */
 
137
  BtCursor *pCursor                    /* Space to write cursor structure */
 
138
);
 
139
int sqlite3BtreeCursorSize(void);
115
140
 
116
141
int sqlite3BtreeCloseCursor(BtCursor*);
117
 
int sqlite3BtreeMoveto(BtCursor*, const void *pKey, i64 nKey, int *pRes);
 
142
int sqlite3BtreeMoveto(
 
143
  BtCursor*,
 
144
  const void *pKey,
 
145
  struct UnpackedRecord *pUnKey,
 
146
  i64 nKey,
 
147
  int bias,
 
148
  int *pRes
 
149
);
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*);
133
167
 
134
 
char *sqlite3BtreeIntegrityCheck(Btree*, int *aRoot, int nRoot);
 
168
char *sqlite3BtreeIntegrityCheck(Btree*, int *aRoot, int nRoot, int, int*);
135
169
struct Pager *sqlite3BtreePager(Btree*);
136
170
 
 
171
int sqlite3BtreePutData(BtCursor*, u32 offset, u32 amt, void*);
 
172
void sqlite3BtreeCacheOverflow(BtCursor *);
137
173
 
138
174
#ifdef SQLITE_TEST
139
175
int sqlite3BtreeCursorInfo(BtCursor*, int*, int);
140
176
void sqlite3BtreeCursorList(Btree*);
141
 
#endif
142
 
 
143
 
#ifdef SQLITE_DEBUG
144
177
int sqlite3BtreePageDump(Btree*, int, int recursive);
 
178
#endif
 
179
 
 
180
/*
 
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.
 
184
*/
 
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*);
145
197
#else
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)
147
209
#endif
148
210
 
 
211
 
149
212
#endif /* _BTREE_H_ */