Back to index

lightning-sunbird  0.9+nobinonly
btree.h
Go to the documentation of this file.
00001 /*
00002 ** 2001 September 15
00003 **
00004 ** The author disclaims copyright to this source code.  In place of
00005 ** a legal notice, here is a blessing:
00006 **
00007 **    May you do good and not evil.
00008 **    May you find forgiveness for yourself and forgive others.
00009 **    May you share freely, never taking more than you give.
00010 **
00011 *************************************************************************
00012 ** This header file defines the interface that the sqlite B-Tree file
00013 ** subsystem.  See comments in the source code for a detailed description
00014 ** of what each interface routine does.
00015 **
00016 ** @(#) $Id: btree.h,v 1.70 2006/02/11 01:25:51 drh Exp $
00017 */
00018 #ifndef _BTREE_H_
00019 #define _BTREE_H_
00020 
00021 /* TODO: This definition is just included so other modules compile. It
00022 ** needs to be revisited.
00023 */
00024 #define SQLITE_N_BTREE_META 10
00025 
00026 /*
00027 ** If defined as non-zero, auto-vacuum is enabled by default. Otherwise
00028 ** it must be turned on for each database using "PRAGMA auto_vacuum = 1".
00029 */
00030 #ifndef SQLITE_DEFAULT_AUTOVACUUM
00031   #define SQLITE_DEFAULT_AUTOVACUUM 0
00032 #endif
00033 
00034 /*
00035 ** Forward declarations of structure
00036 */
00037 typedef struct Btree Btree;
00038 typedef struct BtCursor BtCursor;
00039 typedef struct BtShared BtShared;
00040 
00041 
00042 int sqlite3BtreeOpen(
00043   const char *zFilename,   /* Name of database file to open */
00044   sqlite3 *db,             /* Associated database connection */
00045   Btree **,                /* Return open Btree* here */
00046   int flags                /* Flags */
00047 );
00048 
00049 /* The flags parameter to sqlite3BtreeOpen can be the bitwise or of the
00050 ** following values.
00051 **
00052 ** NOTE:  These values must match the corresponding PAGER_ values in
00053 ** pager.h.
00054 */
00055 #define BTREE_OMIT_JOURNAL  1  /* Do not use journal.  No argument */
00056 #define BTREE_NO_READLOCK   2  /* Omit readlocks on readonly files */
00057 #define BTREE_MEMORY        4  /* In-memory DB.  No argument */
00058 
00059 int sqlite3BtreeClose(Btree*);
00060 int sqlite3BtreeSetBusyHandler(Btree*,BusyHandler*);
00061 int sqlite3BtreeSetCacheSize(Btree*,int);
00062 int sqlite3BtreeSetSafetyLevel(Btree*,int,int);
00063 int sqlite3BtreeSyncDisabled(Btree*);
00064 int sqlite3BtreeSetPageSize(Btree*,int,int);
00065 int sqlite3BtreeGetPageSize(Btree*);
00066 int sqlite3BtreeGetReserve(Btree*);
00067 int sqlite3BtreeSetAutoVacuum(Btree *, int);
00068 int sqlite3BtreeGetAutoVacuum(Btree *);
00069 int sqlite3BtreeBeginTrans(Btree*,int);
00070 int sqlite3BtreeCommit(Btree*);
00071 int sqlite3BtreeRollback(Btree*);
00072 int sqlite3BtreeBeginStmt(Btree*);
00073 int sqlite3BtreeCommitStmt(Btree*);
00074 int sqlite3BtreeRollbackStmt(Btree*);
00075 int sqlite3BtreeCreateTable(Btree*, int*, int flags);
00076 int sqlite3BtreeIsInTrans(Btree*);
00077 int sqlite3BtreeIsInStmt(Btree*);
00078 int sqlite3BtreeSync(Btree*, const char *zMaster);
00079 void *sqlite3BtreeSchema(Btree *, int, void(*)(void *));
00080 int sqlite3BtreeSchemaLocked(Btree *);
00081 int sqlite3BtreeLockTable(Btree *, int, u8);
00082 
00083 const char *sqlite3BtreeGetFilename(Btree *);
00084 const char *sqlite3BtreeGetDirname(Btree *);
00085 const char *sqlite3BtreeGetJournalname(Btree *);
00086 int sqlite3BtreeCopyFile(Btree *, Btree *);
00087 
00088 /* The flags parameter to sqlite3BtreeCreateTable can be the bitwise OR
00089 ** of the following flags:
00090 */
00091 #define BTREE_INTKEY     1    /* Table has only 64-bit signed integer keys */
00092 #define BTREE_ZERODATA   2    /* Table has keys only - no data */
00093 #define BTREE_LEAFDATA   4    /* Data stored in leaves only.  Implies INTKEY */
00094 
00095 int sqlite3BtreeDropTable(Btree*, int, int*);
00096 int sqlite3BtreeClearTable(Btree*, int);
00097 int sqlite3BtreeGetMeta(Btree*, int idx, u32 *pValue);
00098 int sqlite3BtreeUpdateMeta(Btree*, int idx, u32 value);
00099 
00100 int sqlite3BtreeCursor(
00101   Btree*,                              /* BTree containing table to open */
00102   int iTable,                          /* Index of root page */
00103   int wrFlag,                          /* 1 for writing.  0 for read-only */
00104   int(*)(void*,int,const void*,int,const void*),  /* Key comparison function */
00105   void*,                               /* First argument to compare function */
00106   BtCursor **ppCursor                  /* Returned cursor */
00107 );
00108 
00109 void sqlite3BtreeSetCompare(
00110   BtCursor *,
00111   int(*)(void*,int,const void*,int,const void*),
00112   void*
00113 );
00114 
00115 int sqlite3BtreeCloseCursor(BtCursor*);
00116 int sqlite3BtreeMoveto(BtCursor*, const void *pKey, i64 nKey, int *pRes);
00117 int sqlite3BtreeDelete(BtCursor*);
00118 int sqlite3BtreeInsert(BtCursor*, const void *pKey, i64 nKey,
00119                                   const void *pData, int nData);
00120 int sqlite3BtreeFirst(BtCursor*, int *pRes);
00121 int sqlite3BtreeLast(BtCursor*, int *pRes);
00122 int sqlite3BtreeNext(BtCursor*, int *pRes);
00123 int sqlite3BtreeEof(BtCursor*);
00124 int sqlite3BtreeFlags(BtCursor*);
00125 int sqlite3BtreePrevious(BtCursor*, int *pRes);
00126 int sqlite3BtreeKeySize(BtCursor*, i64 *pSize);
00127 int sqlite3BtreeKey(BtCursor*, u32 offset, u32 amt, void*);
00128 const void *sqlite3BtreeKeyFetch(BtCursor*, int *pAmt);
00129 const void *sqlite3BtreeDataFetch(BtCursor*, int *pAmt);
00130 int sqlite3BtreeDataSize(BtCursor*, u32 *pSize);
00131 int sqlite3BtreeData(BtCursor*, u32 offset, u32 amt, void*);
00132 
00133 char *sqlite3BtreeIntegrityCheck(Btree*, int *aRoot, int nRoot);
00134 struct Pager *sqlite3BtreePager(Btree*);
00135 
00136 
00137 #ifdef SQLITE_TEST
00138 int sqlite3BtreeCursorInfo(BtCursor*, int*, int);
00139 void sqlite3BtreeCursorList(Btree*);
00140 #endif
00141 
00142 #ifdef SQLITE_DEBUG
00143 int sqlite3BtreePageDump(Btree*, int, int recursive);
00144 #else
00145 #define sqlite3BtreePageDump(X,Y,Z) SQLITE_OK
00146 #endif
00147 
00148 #endif /* _BTREE_H_ */