1 /* 2 ** 2001 September 15 3 ** 4 ** The author disclaims copyright to this source code. In place of 5 ** a legal notice, here is a blessing: 6 ** 7 ** May you do good and not evil. 8 ** May you find forgiveness for yourself and forgive others. 9 ** May you share freely, never taking more than you give. 10 ** 11 ************************************************************************* 12 ** This header file defines the interface that the sqlite B-Tree file 13 ** subsystem. See comments in the source code for a detailed description 14 ** of what each interface routine does. 15 ** 16 ** @(#) $Id: btree.h,v 1.53 2004/06/04 06:22:01 danielk1977 Exp $ 17 */ 18 #ifndef _BTREE_H_ 19 #define _BTREE_H_ 20 21 /* TODO: This definition is just included so other modules compile. It 22 ** needs to be revisited. 23 */ 24 #define SQLITE_N_BTREE_META 10 25 26 /* 27 ** Forward declarations of structure 28 */ 29 typedef struct Btree Btree; 30 typedef struct BtCursor BtCursor; 31 32 33 int sqlite3BtreeOpen( 34 const char *zFilename, 35 Btree **, 36 int nCache, 37 int flags, 38 void *pBusyHandler 39 ); 40 41 /* The flags parameter to sqlite3BtreeOpen can be the bitwise or of the 42 ** following values. 43 */ 44 #define BTREE_OMIT_JOURNAL 1 /* Do not use journal. No argument */ 45 #define BTREE_MEMORY 2 /* In-memory DB. No argument */ 46 47 int sqlite3BtreeClose(Btree*); 48 int sqlite3BtreeSetCacheSize(Btree*,int); 49 int sqlite3BtreeSetSafetyLevel(Btree*,int); 50 int sqlite3BtreeBeginTrans(Btree*,int,int); 51 int sqlite3BtreeCommit(Btree*); 52 int sqlite3BtreeRollback(Btree*); 53 int sqlite3BtreeBeginStmt(Btree*); 54 int sqlite3BtreeCommitStmt(Btree*); 55 int sqlite3BtreeRollbackStmt(Btree*); 56 int sqlite3BtreeCreateTable(Btree*, int*, int flags); 57 int sqlite3BtreeIsInTrans(Btree*); 58 int sqlite3BtreeIsInStmt(Btree*); 59 int sqlite3BtreeSync(Btree*, const char *zMaster); 60 61 const char *sqlite3BtreeGetFilename(Btree *); 62 int sqlite3BtreeCopyFile(Btree *, Btree *); 63 64 /* The flags parameter to sqlite3BtreeCreateTable can be the bitwise OR 65 ** of the following flags: 66 */ 67 #define BTREE_INTKEY 1 /* Table has only 64-bit signed integer keys */ 68 #define BTREE_ZERODATA 2 /* Table has keys only - no data */ 69 #define BTREE_LEAFDATA 4 /* Data stored in leaves only. Implies INTKEY */ 70 71 int sqlite3BtreeDropTable(Btree*, int); 72 int sqlite3BtreeClearTable(Btree*, int); 73 int sqlite3BtreeGetMeta(Btree*, int idx, u32 *pValue); 74 int sqlite3BtreeUpdateMeta(Btree*, int idx, u32 value); 75 76 int sqlite3BtreeCursor( 77 Btree*, /* BTree containing table to open */ 78 int iTable, /* Index of root page */ 79 int wrFlag, /* 1 for writing. 0 for read-only */ 80 int(*)(void*,int,const void*,int,const void*), /* Key comparison function */ 81 void*, /* First argument to compare function */ 82 BtCursor **ppCursor /* Returned cursor */ 83 ); 84 85 void sqlite3BtreeSetCompare( 86 BtCursor *, 87 int(*)(void*,int,const void*,int,const void*), 88 void* 89 ); 90 91 int sqlite3BtreeCloseCursor(BtCursor*); 92 int sqlite3BtreeMoveto(BtCursor*, const void *pKey, i64 nKey, int *pRes); 93 int sqlite3BtreeDelete(BtCursor*); 94 int sqlite3BtreeInsert(BtCursor*, const void *pKey, i64 nKey, 95 const void *pData, int nData); 96 int sqlite3BtreeFirst(BtCursor*, int *pRes); 97 int sqlite3BtreeLast(BtCursor*, int *pRes); 98 int sqlite3BtreeNext(BtCursor*, int *pRes); 99 int sqlite3BtreeEof(BtCursor*); 100 int sqlite3BtreeFlags(BtCursor*); 101 int sqlite3BtreePrevious(BtCursor*, int *pRes); 102 int sqlite3BtreeKeySize(BtCursor*, i64 *pSize); 103 int sqlite3BtreeKey(BtCursor*, u32 offset, u32 amt, void*); 104 const void *sqlite3BtreeKeyFetch(BtCursor*, int *pAmt); 105 const void *sqlite3BtreeDataFetch(BtCursor*, int *pAmt); 106 int sqlite3BtreeDataSize(BtCursor*, u32 *pSize); 107 int sqlite3BtreeData(BtCursor*, u32 offset, u32 amt, void*); 108 109 char *sqlite3BtreeIntegrityCheck(Btree*, int *aRoot, int nRoot); 110 struct Pager *sqlite3BtreePager(Btree*); 111 112 113 #ifdef SQLITE_TEST 114 int sqlite3BtreeCursorInfo(BtCursor*, int*); 115 void sqlite3BtreeCursorList(Btree*); 116 int sqlite3BtreePageDump(Btree*, int, int recursive); 117 #endif 118 119 120 #endif /* _BTREE_H_ */ 121