os/persistentdata/persistentstorage/sql/SQLite364/btree.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/persistentdata/persistentstorage/sql/SQLite364/btree.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,224 @@
     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: btree.h,v 1.104 2008/10/08 17:58:49 danielk1977 Exp $
    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 +int sqlite3BtreeClose(Btree*);
    1.83 +int sqlite3BtreeSetCacheSize(Btree*,int);
    1.84 +int sqlite3BtreeSetSafetyLevel(Btree*,int,int);
    1.85 +int sqlite3BtreeSyncDisabled(Btree*);
    1.86 +int sqlite3BtreeSetPageSize(Btree*,int,int);
    1.87 +int sqlite3BtreeGetPageSize(Btree*);
    1.88 +int sqlite3BtreeMaxPageCount(Btree*,int);
    1.89 +int sqlite3BtreeGetReserve(Btree*);
    1.90 +int sqlite3BtreeSetAutoVacuum(Btree *, int);
    1.91 +int sqlite3BtreeGetAutoVacuum(Btree *);
    1.92 +int sqlite3BtreeBeginTrans(Btree*,int);
    1.93 +int sqlite3BtreeCommitPhaseOne(Btree*, const char *zMaster);
    1.94 +int sqlite3BtreeCommitPhaseTwo(Btree*);
    1.95 +int sqlite3BtreeCommit(Btree*);
    1.96 +int sqlite3BtreeRollback(Btree*);
    1.97 +int sqlite3BtreeBeginStmt(Btree*);
    1.98 +int sqlite3BtreeCommitStmt(Btree*);
    1.99 +int sqlite3BtreeRollbackStmt(Btree*);
   1.100 +int sqlite3BtreeCreateTable(Btree*, int*, int flags);
   1.101 +int sqlite3BtreeIsInTrans(Btree*);
   1.102 +int sqlite3BtreeIsInStmt(Btree*);
   1.103 +int sqlite3BtreeIsInReadTrans(Btree*);
   1.104 +void *sqlite3BtreeSchema(Btree *, int, void(*)(void *));
   1.105 +int sqlite3BtreeSchemaLocked(Btree *);
   1.106 +int sqlite3BtreeLockTable(Btree *, int, u8);
   1.107 +
   1.108 +const char *sqlite3BtreeGetFilename(Btree *);
   1.109 +const char *sqlite3BtreeGetDirname(Btree *);
   1.110 +const char *sqlite3BtreeGetJournalname(Btree *);
   1.111 +int sqlite3BtreeCopyFile(Btree *, Btree *);
   1.112 +
   1.113 +int sqlite3BtreeIncrVacuum(Btree *);
   1.114 +
   1.115 +/* The flags parameter to sqlite3BtreeCreateTable can be the bitwise OR
   1.116 +** of the following flags:
   1.117 +*/
   1.118 +#define BTREE_INTKEY     1    /* Table has only 64-bit signed integer keys */
   1.119 +#define BTREE_ZERODATA   2    /* Table has keys only - no data */
   1.120 +#define BTREE_LEAFDATA   4    /* Data stored in leaves only.  Implies INTKEY */
   1.121 +
   1.122 +int sqlite3BtreeDropTable(Btree*, int, int*);
   1.123 +int sqlite3BtreeClearTable(Btree*, int);
   1.124 +int sqlite3BtreeGetMeta(Btree*, int idx, u32 *pValue);
   1.125 +int sqlite3BtreeUpdateMeta(Btree*, int idx, u32 value);
   1.126 +void sqlite3BtreeTripAllCursors(Btree*, int);
   1.127 +
   1.128 +int sqlite3BtreeCursor(
   1.129 +  Btree*,                              /* BTree containing table to open */
   1.130 +  int iTable,                          /* Index of root page */
   1.131 +  int wrFlag,                          /* 1 for writing.  0 for read-only */
   1.132 +  struct KeyInfo*,                     /* First argument to compare function */
   1.133 +  BtCursor *pCursor                    /* Space to write cursor structure */
   1.134 +);
   1.135 +int sqlite3BtreeCursorSize(void);
   1.136 +
   1.137 +int sqlite3BtreeCloseCursor(BtCursor*);
   1.138 +int sqlite3BtreeMoveto(
   1.139 +  BtCursor*,
   1.140 +  const void *pKey,
   1.141 +  i64 nKey,
   1.142 +  int bias,
   1.143 +  int *pRes
   1.144 +);
   1.145 +int sqlite3BtreeMovetoUnpacked(
   1.146 +  BtCursor*,
   1.147 +  UnpackedRecord *pUnKey,
   1.148 +  i64 intKey,
   1.149 +  int bias,
   1.150 +  int *pRes
   1.151 +);
   1.152 +int sqlite3BtreeCursorHasMoved(BtCursor*, int*);
   1.153 +int sqlite3BtreeDelete(BtCursor*);
   1.154 +int sqlite3BtreeInsert(BtCursor*, const void *pKey, i64 nKey,
   1.155 +                                  const void *pData, int nData,
   1.156 +                                  int nZero, int bias);
   1.157 +int sqlite3BtreeFirst(BtCursor*, int *pRes);
   1.158 +int sqlite3BtreeLast(BtCursor*, int *pRes);
   1.159 +int sqlite3BtreeNext(BtCursor*, int *pRes);
   1.160 +int sqlite3BtreeEof(BtCursor*);
   1.161 +int sqlite3BtreeFlags(BtCursor*);
   1.162 +int sqlite3BtreePrevious(BtCursor*, int *pRes);
   1.163 +int sqlite3BtreeKeySize(BtCursor*, i64 *pSize);
   1.164 +int sqlite3BtreeKey(BtCursor*, u32 offset, u32 amt, void*);
   1.165 +sqlite3 *sqlite3BtreeCursorDb(const BtCursor*);
   1.166 +const void *sqlite3BtreeKeyFetch(BtCursor*, int *pAmt);
   1.167 +const void *sqlite3BtreeDataFetch(BtCursor*, int *pAmt);
   1.168 +int sqlite3BtreeDataSize(BtCursor*, u32 *pSize);
   1.169 +int sqlite3BtreeData(BtCursor*, u32 offset, u32 amt, void*);
   1.170 +
   1.171 +char *sqlite3BtreeIntegrityCheck(Btree*, int *aRoot, int nRoot, int, int*);
   1.172 +struct Pager *sqlite3BtreePager(Btree*);
   1.173 +
   1.174 +int sqlite3BtreePutData(BtCursor*, u32 offset, u32 amt, void*);
   1.175 +void sqlite3BtreeCacheOverflow(BtCursor *);
   1.176 +void sqlite3BtreeClearCursor(BtCursor *);
   1.177 +
   1.178 +#ifdef SQLITE_TEST
   1.179 +int sqlite3BtreeCursorInfo(BtCursor*, int*, int);
   1.180 +void sqlite3BtreeCursorList(Btree*);
   1.181 +#endif
   1.182 +
   1.183 +/*
   1.184 +** If we are not using shared cache, then there is no need to
   1.185 +** use mutexes to access the BtShared structures.  So make the
   1.186 +** Enter and Leave procedures no-ops.
   1.187 +*/
   1.188 +#if !defined(SQLITE_OMIT_SHARED_CACHE) && SQLITE_THREADSAFE
   1.189 +  void sqlite3BtreeEnter(Btree*);
   1.190 +  void sqlite3BtreeLeave(Btree*);
   1.191 +#ifndef NDEBUG
   1.192 +  /* This routine is used inside assert() statements only. */
   1.193 +  int sqlite3BtreeHoldsMutex(Btree*);
   1.194 +#endif
   1.195 +  void sqlite3BtreeEnterCursor(BtCursor*);
   1.196 +  void sqlite3BtreeLeaveCursor(BtCursor*);
   1.197 +  void sqlite3BtreeEnterAll(sqlite3*);
   1.198 +  void sqlite3BtreeLeaveAll(sqlite3*);
   1.199 +#ifndef NDEBUG
   1.200 +  /* This routine is used inside assert() statements only. */
   1.201 +  int sqlite3BtreeHoldsAllMutexes(sqlite3*);
   1.202 +#endif
   1.203 +  void sqlite3BtreeMutexArrayEnter(BtreeMutexArray*);
   1.204 +  void sqlite3BtreeMutexArrayLeave(BtreeMutexArray*);
   1.205 +  void sqlite3BtreeMutexArrayInsert(BtreeMutexArray*, Btree*);
   1.206 +#else
   1.207 +# define sqlite3BtreeEnter(X)
   1.208 +# define sqlite3BtreeLeave(X)
   1.209 +#ifndef NDEBUG
   1.210 +  /* This routine is used inside assert() statements only. */
   1.211 +# define sqlite3BtreeHoldsMutex(X) 1
   1.212 +#endif
   1.213 +# define sqlite3BtreeEnterCursor(X)
   1.214 +# define sqlite3BtreeLeaveCursor(X)
   1.215 +# define sqlite3BtreeEnterAll(X)
   1.216 +# define sqlite3BtreeLeaveAll(X)
   1.217 +#ifndef NDEBUG
   1.218 +  /* This routine is used inside assert() statements only. */
   1.219 +# define sqlite3BtreeHoldsAllMutexes(X) 1
   1.220 +#endif
   1.221 +# define sqlite3BtreeMutexArrayEnter(X)
   1.222 +# define sqlite3BtreeMutexArrayLeave(X)
   1.223 +# define sqlite3BtreeMutexArrayInsert(X,Y)
   1.224 +#endif
   1.225 +
   1.226 +
   1.227 +#endif /* _BTREE_H_ */