Eneboo - Documentación para desarrolladores
|
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: qt/btree.h 3.3.8 edited Mar 30 2004 $ 00017 */ 00018 #ifndef _BTREE_H_ 00019 #define _BTREE_H_ 00020 00021 /* 00022 ** Forward declarations of structure 00023 */ 00024 typedef struct Btree Btree; 00025 typedef struct BtCursor BtCursor; 00026 typedef struct BtOps BtOps; 00027 typedef struct BtCursorOps BtCursorOps; 00028 00029 00030 /* 00031 ** An instance of the following structure contains pointers to all 00032 ** methods against an open BTree. Alternative BTree implementations 00033 ** (examples: file based versus in-memory) can be created by substituting 00034 ** different methods. Users of the BTree cannot tell the difference. 00035 ** 00036 ** In C++ we could do this by defining a virtual base class and then 00037 ** creating subclasses for each different implementation. But this is 00038 ** C not C++ so we have to be a little more explicit. 00039 */ 00040 struct BtOps { 00041 int (*Close)(Btree*); 00042 int (*SetCacheSize)(Btree*, int); 00043 int (*SetSafetyLevel)(Btree*, int); 00044 int (*BeginTrans)(Btree*); 00045 int (*Commit)(Btree*); 00046 int (*Rollback)(Btree*); 00047 int (*BeginCkpt)(Btree*); 00048 int (*CommitCkpt)(Btree*); 00049 int (*RollbackCkpt)(Btree*); 00050 int (*CreateTable)(Btree*, int*); 00051 int (*CreateIndex)(Btree*, int*); 00052 int (*DropTable)(Btree*, int); 00053 int (*ClearTable)(Btree*, int); 00054 int (*Cursor)(Btree*, int iTable, int wrFlag, BtCursor **ppCur); 00055 int (*GetMeta)(Btree*, int*); 00056 int (*UpdateMeta)(Btree*, int*); 00057 char *(*IntegrityCheck)(Btree*, int*, int); 00058 const char *(*GetFilename)(Btree*); 00059 int (*Copyfile)(Btree*,Btree*); 00060 struct Pager *(*Pager)(Btree*); 00061 #ifdef SQLITE_TEST 00062 int (*PageDump)(Btree*, int, int); 00063 #endif 00064 }; 00065 00066 /* 00067 ** An instance of this structure defines all of the methods that can 00068 ** be executed against a cursor. 00069 */ 00070 struct BtCursorOps { 00071 int (*Moveto)(BtCursor*, const void *pKey, int nKey, int *pRes); 00072 int (*Delete)(BtCursor*); 00073 int (*Insert)(BtCursor*, const void *pKey, int nKey, 00074 const void *pData, int nData); 00075 int (*First)(BtCursor*, int *pRes); 00076 int (*Last)(BtCursor*, int *pRes); 00077 int (*Next)(BtCursor*, int *pRes); 00078 int (*Previous)(BtCursor*, int *pRes); 00079 int (*KeySize)(BtCursor*, int *pSize); 00080 int (*Key)(BtCursor*, int offset, int amt, char *zBuf); 00081 int (*KeyCompare)(BtCursor*, const void *pKey, int nKey, 00082 int nIgnore, int *pRes); 00083 int (*DataSize)(BtCursor*, int *pSize); 00084 int (*Data)(BtCursor*, int offset, int amt, char *zBuf); 00085 int (*CloseCursor)(BtCursor*); 00086 #ifdef SQLITE_TEST 00087 int (*CursorDump)(BtCursor*, int*); 00088 #endif 00089 }; 00090 00091 /* 00092 ** The number of 4-byte "meta" values contained on the first page of each 00093 ** database file. 00094 */ 00095 #define SQLITE_N_BTREE_META 10 00096 00097 int sqliteBtreeOpen(const char *zFilename, int mode, int nPg, Btree **ppBtree); 00098 int sqliteRbtreeOpen(const char *zFilename, int mode, int nPg, Btree **ppBtree); 00099 00100 #define btOps(pBt) (*((BtOps **)(pBt))) 00101 #define btCOps(pCur) (*((BtCursorOps **)(pCur))) 00102 00103 #define sqliteBtreeClose(pBt) (btOps(pBt)->Close(pBt)) 00104 #define sqliteBtreeSetCacheSize(pBt, sz) (btOps(pBt)->SetCacheSize(pBt, sz)) 00105 #define sqliteBtreeSetSafetyLevel(pBt, sl) (btOps(pBt)->SetSafetyLevel(pBt, sl)) 00106 #define sqliteBtreeBeginTrans(pBt) (btOps(pBt)->BeginTrans(pBt)) 00107 #define sqliteBtreeCommit(pBt) (btOps(pBt)->Commit(pBt)) 00108 #define sqliteBtreeRollback(pBt) (btOps(pBt)->Rollback(pBt)) 00109 #define sqliteBtreeBeginCkpt(pBt) (btOps(pBt)->BeginCkpt(pBt)) 00110 #define sqliteBtreeCommitCkpt(pBt) (btOps(pBt)->CommitCkpt(pBt)) 00111 #define sqliteBtreeRollbackCkpt(pBt) (btOps(pBt)->RollbackCkpt(pBt)) 00112 #define sqliteBtreeCreateTable(pBt,piTable)\ 00113 (btOps(pBt)->CreateTable(pBt,piTable)) 00114 #define sqliteBtreeCreateIndex(pBt, piIndex)\ 00115 (btOps(pBt)->CreateIndex(pBt, piIndex)) 00116 #define sqliteBtreeDropTable(pBt, iTable) (btOps(pBt)->DropTable(pBt, iTable)) 00117 #define sqliteBtreeClearTable(pBt, iTable)\ 00118 (btOps(pBt)->ClearTable(pBt, iTable)) 00119 #define sqliteBtreeCursor(pBt, iTable, wrFlag, ppCur)\ 00120 (btOps(pBt)->Cursor(pBt, iTable, wrFlag, ppCur)) 00121 #define sqliteBtreeMoveto(pCur, pKey, nKey, pRes)\ 00122 (btCOps(pCur)->Moveto(pCur, pKey, nKey, pRes)) 00123 #define sqliteBtreeDelete(pCur) (btCOps(pCur)->Delete(pCur)) 00124 #define sqliteBtreeInsert(pCur, pKey, nKey, pData, nData) \ 00125 (btCOps(pCur)->Insert(pCur, pKey, nKey, pData, nData)) 00126 #define sqliteBtreeFirst(pCur, pRes) (btCOps(pCur)->First(pCur, pRes)) 00127 #define sqliteBtreeLast(pCur, pRes) (btCOps(pCur)->Last(pCur, pRes)) 00128 #define sqliteBtreeNext(pCur, pRes) (btCOps(pCur)->Next(pCur, pRes)) 00129 #define sqliteBtreePrevious(pCur, pRes) (btCOps(pCur)->Previous(pCur, pRes)) 00130 #define sqliteBtreeKeySize(pCur, pSize) (btCOps(pCur)->KeySize(pCur, pSize) ) 00131 #define sqliteBtreeKey(pCur, offset, amt, zBuf)\ 00132 (btCOps(pCur)->Key(pCur, offset, amt, zBuf)) 00133 #define sqliteBtreeKeyCompare(pCur, pKey, nKey, nIgnore, pRes)\ 00134 (btCOps(pCur)->KeyCompare(pCur, pKey, nKey, nIgnore, pRes)) 00135 #define sqliteBtreeDataSize(pCur, pSize) (btCOps(pCur)->DataSize(pCur, pSize)) 00136 #define sqliteBtreeData(pCur, offset, amt, zBuf)\ 00137 (btCOps(pCur)->Data(pCur, offset, amt, zBuf)) 00138 #define sqliteBtreeCloseCursor(pCur) (btCOps(pCur)->CloseCursor(pCur)) 00139 #define sqliteBtreeGetMeta(pBt, aMeta) (btOps(pBt)->GetMeta(pBt, aMeta)) 00140 #define sqliteBtreeUpdateMeta(pBt, aMeta) (btOps(pBt)->UpdateMeta(pBt, aMeta)) 00141 #define sqliteBtreeIntegrityCheck(pBt, aRoot, nRoot)\ 00142 (btOps(pBt)->IntegrityCheck(pBt, aRoot, nRoot)) 00143 #define sqliteBtreeGetFilename(pBt) (btOps(pBt)->GetFilename(pBt)) 00144 #define sqliteBtreeCopyFile(pBt1, pBt2) (btOps(pBt1)->Copyfile(pBt1, pBt2)) 00145 #define sqliteBtreePager(pBt) (btOps(pBt)->Pager(pBt)) 00146 00147 #ifdef SQLITE_TEST 00148 #define sqliteBtreePageDump(pBt, pgno, recursive)\ 00149 (btOps(pBt)->PageDump(pBt, pgno, recursive)) 00150 #define sqliteBtreeCursorDump(pCur, aResult)\ 00151 (btCOps(pCur)->CursorDump(pCur, aResult)) 00152 int btree_native_byte_order; 00153 #endif /* SQLITE_TEST */ 00154 00155 00156 #endif /* _BTREE_H_ */