extensions/sqlite/sqlite-source/btree.h
branchrefac-jit
changeset 2284 026da5437111
parent 2192 7602d7fb60d9
child 2288 15c77b21589a
     1.1 --- a/extensions/sqlite/sqlite-source/btree.h	Fri Jul 11 06:51:21 2008 +0000
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,204 +0,0 @@
     1.4 -/*
     1.5 -** 2001 September 15
     1.6 -**
     1.7 -** The author disclaims copyright to this source code.  In place of
     1.8 -** a legal notice, here is a blessing:
     1.9 -**
    1.10 -**    May you do good and not evil.
    1.11 -**    May you find forgiveness for yourself and forgive others.
    1.12 -**    May you share freely, never taking more than you give.
    1.13 -**
    1.14 -*************************************************************************
    1.15 -** This header file defines the interface that the sqlite B-Tree file
    1.16 -** subsystem.  See comments in the source code for a detailed description
    1.17 -** of what each interface routine does.
    1.18 -**
    1.19 -** @(#) $Id$
    1.20 -*/
    1.21 -#ifndef _BTREE_H_
    1.22 -#define _BTREE_H_
    1.23 -
    1.24 -/* TODO: This definition is just included so other modules compile. It
    1.25 -** needs to be revisited.
    1.26 -*/
    1.27 -#define SQLITE_N_BTREE_META 10
    1.28 -
    1.29 -/*
    1.30 -** If defined as non-zero, auto-vacuum is enabled by default. Otherwise
    1.31 -** it must be turned on for each database using "PRAGMA auto_vacuum = 1".
    1.32 -*/
    1.33 -#ifndef SQLITE_DEFAULT_AUTOVACUUM
    1.34 -  #define SQLITE_DEFAULT_AUTOVACUUM 0
    1.35 -#endif
    1.36 -
    1.37 -#define BTREE_AUTOVACUUM_NONE 0        /* Do not do auto-vacuum */
    1.38 -#define BTREE_AUTOVACUUM_FULL 1        /* Do full auto-vacuum */
    1.39 -#define BTREE_AUTOVACUUM_INCR 2        /* Incremental vacuum */
    1.40 -
    1.41 -/*
    1.42 -** Forward declarations of structure
    1.43 -*/
    1.44 -typedef struct Btree Btree;
    1.45 -typedef struct BtCursor BtCursor;
    1.46 -typedef struct BtShared BtShared;
    1.47 -typedef struct BtreeMutexArray BtreeMutexArray;
    1.48 -
    1.49 -/*
    1.50 -** This structure records all of the Btrees that need to hold
    1.51 -** a mutex before we enter sqlite3VdbeExec().  The Btrees are
    1.52 -** are placed in aBtree[] in order of aBtree[]->pBt.  That way,
    1.53 -** we can always lock and unlock them all quickly.
    1.54 -*/
    1.55 -struct BtreeMutexArray {
    1.56 -  int nMutex;
    1.57 -  Btree *aBtree[SQLITE_MAX_ATTACHED+1];
    1.58 -};
    1.59 -
    1.60 -
    1.61 -int sqlite3BtreeOpen(
    1.62 -  const char *zFilename,   /* Name of database file to open */
    1.63 -  sqlite3 *db,             /* Associated database connection */
    1.64 -  Btree **,                /* Return open Btree* here */
    1.65 -  int flags,               /* Flags */
    1.66 -  int vfsFlags             /* Flags passed through to VFS open */
    1.67 -);
    1.68 -
    1.69 -/* The flags parameter to sqlite3BtreeOpen can be the bitwise or of the
    1.70 -** following values.
    1.71 -**
    1.72 -** NOTE:  These values must match the corresponding PAGER_ values in
    1.73 -** pager.h.
    1.74 -*/
    1.75 -#define BTREE_OMIT_JOURNAL  1  /* Do not use journal.  No argument */
    1.76 -#define BTREE_NO_READLOCK   2  /* Omit readlocks on readonly files */
    1.77 -#define BTREE_MEMORY        4  /* In-memory DB.  No argument */
    1.78 -#define BTREE_READONLY      8  /* Open the database in read-only mode */
    1.79 -#define BTREE_READWRITE    16  /* Open for both reading and writing */
    1.80 -#define BTREE_CREATE       32  /* Create the database if it does not exist */
    1.81 -
    1.82 -/* Additional values for the 4th argument of sqlite3BtreeOpen that
    1.83 -** are not associated with PAGER_ values.
    1.84 -*/
    1.85 -#define BTREE_PRIVATE      64  /* Never share with other connections */
    1.86 -
    1.87 -int sqlite3BtreeClose(Btree*);
    1.88 -int sqlite3BtreeSetBusyHandler(Btree*,BusyHandler*);
    1.89 -int sqlite3BtreeSetCacheSize(Btree*,int);
    1.90 -int sqlite3BtreeSetSafetyLevel(Btree*,int,int);
    1.91 -int sqlite3BtreeSyncDisabled(Btree*);
    1.92 -int sqlite3BtreeSetPageSize(Btree*,int,int);
    1.93 -int sqlite3BtreeGetPageSize(Btree*);
    1.94 -int sqlite3BtreeMaxPageCount(Btree*,int);
    1.95 -int sqlite3BtreeGetReserve(Btree*);
    1.96 -int sqlite3BtreeSetAutoVacuum(Btree *, int);
    1.97 -int sqlite3BtreeGetAutoVacuum(Btree *);
    1.98 -int sqlite3BtreeBeginTrans(Btree*,int);
    1.99 -int sqlite3BtreeCommitPhaseOne(Btree*, const char *zMaster);
   1.100 -int sqlite3BtreeCommitPhaseTwo(Btree*);
   1.101 -int sqlite3BtreeCommit(Btree*);
   1.102 -int sqlite3BtreeRollback(Btree*);
   1.103 -int sqlite3BtreeBeginStmt(Btree*);
   1.104 -int sqlite3BtreeCommitStmt(Btree*);
   1.105 -int sqlite3BtreeRollbackStmt(Btree*);
   1.106 -int sqlite3BtreeCreateTable(Btree*, int*, int flags);
   1.107 -int sqlite3BtreeIsInTrans(Btree*);
   1.108 -int sqlite3BtreeIsInStmt(Btree*);
   1.109 -int sqlite3BtreeIsInReadTrans(Btree*);
   1.110 -void *sqlite3BtreeSchema(Btree *, int, void(*)(void *));
   1.111 -int sqlite3BtreeSchemaLocked(Btree *);
   1.112 -int sqlite3BtreeLockTable(Btree *, int, u8);
   1.113 -
   1.114 -const char *sqlite3BtreeGetFilename(Btree *);
   1.115 -const char *sqlite3BtreeGetDirname(Btree *);
   1.116 -const char *sqlite3BtreeGetJournalname(Btree *);
   1.117 -int sqlite3BtreeCopyFile(Btree *, Btree *);
   1.118 -
   1.119 -int sqlite3BtreeIncrVacuum(Btree *);
   1.120 -
   1.121 -/* The flags parameter to sqlite3BtreeCreateTable can be the bitwise OR
   1.122 -** of the following flags:
   1.123 -*/
   1.124 -#define BTREE_INTKEY     1    /* Table has only 64-bit signed integer keys */
   1.125 -#define BTREE_ZERODATA   2    /* Table has keys only - no data */
   1.126 -#define BTREE_LEAFDATA   4    /* Data stored in leaves only.  Implies INTKEY */
   1.127 -
   1.128 -int sqlite3BtreeDropTable(Btree*, int, int*);
   1.129 -int sqlite3BtreeClearTable(Btree*, int);
   1.130 -int sqlite3BtreeGetMeta(Btree*, int idx, u32 *pValue);
   1.131 -int sqlite3BtreeUpdateMeta(Btree*, int idx, u32 value);
   1.132 -void sqlite3BtreeTripAllCursors(Btree*, int);
   1.133 -
   1.134 -int sqlite3BtreeCursor(
   1.135 -  Btree*,                              /* BTree containing table to open */
   1.136 -  int iTable,                          /* Index of root page */
   1.137 -  int wrFlag,                          /* 1 for writing.  0 for read-only */
   1.138 -  int(*)(void*,int,const void*,int,const void*),  /* Key comparison function */
   1.139 -  void*,                               /* First argument to compare function */
   1.140 -  BtCursor **ppCursor                  /* Returned cursor */
   1.141 -);
   1.142 -
   1.143 -int sqlite3BtreeCloseCursor(BtCursor*);
   1.144 -int sqlite3BtreeMoveto(BtCursor*,const void *pKey,i64 nKey,int bias,int *pRes);
   1.145 -int sqlite3BtreeDelete(BtCursor*);
   1.146 -int sqlite3BtreeInsert(BtCursor*, const void *pKey, i64 nKey,
   1.147 -                                  const void *pData, int nData,
   1.148 -                                  int nZero, int bias);
   1.149 -int sqlite3BtreeFirst(BtCursor*, int *pRes);
   1.150 -int sqlite3BtreeLast(BtCursor*, int *pRes);
   1.151 -int sqlite3BtreeNext(BtCursor*, int *pRes);
   1.152 -int sqlite3BtreeEof(BtCursor*);
   1.153 -int sqlite3BtreeFlags(BtCursor*);
   1.154 -int sqlite3BtreePrevious(BtCursor*, int *pRes);
   1.155 -int sqlite3BtreeKeySize(BtCursor*, i64 *pSize);
   1.156 -int sqlite3BtreeKey(BtCursor*, u32 offset, u32 amt, void*);
   1.157 -sqlite3 *sqlite3BtreeCursorDb(const BtCursor*);
   1.158 -const void *sqlite3BtreeKeyFetch(BtCursor*, int *pAmt);
   1.159 -const void *sqlite3BtreeDataFetch(BtCursor*, int *pAmt);
   1.160 -int sqlite3BtreeDataSize(BtCursor*, u32 *pSize);
   1.161 -int sqlite3BtreeData(BtCursor*, u32 offset, u32 amt, void*);
   1.162 -
   1.163 -char *sqlite3BtreeIntegrityCheck(Btree*, int *aRoot, int nRoot, int, int*);
   1.164 -struct Pager *sqlite3BtreePager(Btree*);
   1.165 -
   1.166 -int sqlite3BtreePutData(BtCursor*, u32 offset, u32 amt, void*);
   1.167 -void sqlite3BtreeCacheOverflow(BtCursor *);
   1.168 -
   1.169 -#ifdef SQLITE_TEST
   1.170 -int sqlite3BtreeCursorInfo(BtCursor*, int*, int);
   1.171 -void sqlite3BtreeCursorList(Btree*);
   1.172 -int sqlite3BtreePageDump(Btree*, int, int recursive);
   1.173 -#endif
   1.174 -
   1.175 -/*
   1.176 -** If we are not using shared cache, then there is no need to
   1.177 -** use mutexes to access the BtShared structures.  So make the
   1.178 -** Enter and Leave procedures no-ops.
   1.179 -*/
   1.180 -#if !defined(SQLITE_OMIT_SHARED_CACHE) && SQLITE_THREADSAFE
   1.181 -  void sqlite3BtreeEnter(Btree*);
   1.182 -  void sqlite3BtreeLeave(Btree*);
   1.183 -  int sqlite3BtreeHoldsMutex(Btree*);
   1.184 -  void sqlite3BtreeEnterCursor(BtCursor*);
   1.185 -  void sqlite3BtreeLeaveCursor(BtCursor*);
   1.186 -  void sqlite3BtreeEnterAll(sqlite3*);
   1.187 -  void sqlite3BtreeLeaveAll(sqlite3*);
   1.188 -  int sqlite3BtreeHoldsAllMutexes(sqlite3*);
   1.189 -  void sqlite3BtreeMutexArrayEnter(BtreeMutexArray*);
   1.190 -  void sqlite3BtreeMutexArrayLeave(BtreeMutexArray*);
   1.191 -  void sqlite3BtreeMutexArrayInsert(BtreeMutexArray*, Btree*);
   1.192 -#else
   1.193 -# define sqlite3BtreeEnter(X)
   1.194 -# define sqlite3BtreeLeave(X)
   1.195 -# define sqlite3BtreeHoldsMutex(X) 1
   1.196 -# define sqlite3BtreeEnterCursor(X)
   1.197 -# define sqlite3BtreeLeaveCursor(X)
   1.198 -# define sqlite3BtreeEnterAll(X)
   1.199 -# define sqlite3BtreeLeaveAll(X)
   1.200 -# define sqlite3BtreeHoldsAllMutexes(X) 1
   1.201 -# define sqlite3BtreeMutexArrayEnter(X)
   1.202 -# define sqlite3BtreeMutexArrayLeave(X)
   1.203 -# define sqlite3BtreeMutexArrayInsert(X,Y)
   1.204 -#endif
   1.205 -
   1.206 -
   1.207 -#endif /* _BTREE_H_ */