Back to index

php5  5.3.10
Classes | Defines | Typedefs | Functions
btree.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  BtOps
struct  BtCursorOps

Defines

#define SQLITE_N_BTREE_META   10
#define btOps(pBt)   (*((BtOps **)(pBt)))
#define btCOps(pCur)   (*((BtCursorOps **)(pCur)))
#define sqliteBtreeClose(pBt)   (btOps(pBt)->Close(pBt))
#define sqliteBtreeSetCacheSize(pBt, sz)   (btOps(pBt)->SetCacheSize(pBt, sz))
#define sqliteBtreeSetSafetyLevel(pBt, sl)   (btOps(pBt)->SetSafetyLevel(pBt, sl))
#define sqliteBtreeBeginTrans(pBt)   (btOps(pBt)->BeginTrans(pBt))
#define sqliteBtreeCommit(pBt)   (btOps(pBt)->Commit(pBt))
#define sqliteBtreeRollback(pBt)   (btOps(pBt)->Rollback(pBt))
#define sqliteBtreeBeginCkpt(pBt)   (btOps(pBt)->BeginCkpt(pBt))
#define sqliteBtreeCommitCkpt(pBt)   (btOps(pBt)->CommitCkpt(pBt))
#define sqliteBtreeRollbackCkpt(pBt)   (btOps(pBt)->RollbackCkpt(pBt))
#define sqliteBtreeCreateTable(pBt, piTable)   (btOps(pBt)->CreateTable(pBt,piTable))
#define sqliteBtreeCreateIndex(pBt, piIndex)   (btOps(pBt)->CreateIndex(pBt, piIndex))
#define sqliteBtreeDropTable(pBt, iTable)   (btOps(pBt)->DropTable(pBt, iTable))
#define sqliteBtreeClearTable(pBt, iTable)   (btOps(pBt)->ClearTable(pBt, iTable))
#define sqliteBtreeCursor(pBt, iTable, wrFlag, ppCur)   (btOps(pBt)->Cursor(pBt, iTable, wrFlag, ppCur))
#define sqliteBtreeMoveto(pCur, pKey, nKey, pRes)   (btCOps(pCur)->Moveto(pCur, pKey, nKey, pRes))
#define sqliteBtreeDelete(pCur)   (btCOps(pCur)->Delete(pCur))
#define sqliteBtreeInsert(pCur, pKey, nKey, pData, nData)   (btCOps(pCur)->Insert(pCur, pKey, nKey, pData, nData))
#define sqliteBtreeFirst(pCur, pRes)   (btCOps(pCur)->First(pCur, pRes))
#define sqliteBtreeLast(pCur, pRes)   (btCOps(pCur)->Last(pCur, pRes))
#define sqliteBtreeNext(pCur, pRes)   (btCOps(pCur)->Next(pCur, pRes))
#define sqliteBtreePrevious(pCur, pRes)   (btCOps(pCur)->Previous(pCur, pRes))
#define sqliteBtreeKeySize(pCur, pSize)   (btCOps(pCur)->KeySize(pCur, pSize) )
#define sqliteBtreeKey(pCur, offset, amt, zBuf)   (btCOps(pCur)->Key(pCur, offset, amt, zBuf))
#define sqliteBtreeKeyCompare(pCur, pKey, nKey, nIgnore, pRes)   (btCOps(pCur)->KeyCompare(pCur, pKey, nKey, nIgnore, pRes))
#define sqliteBtreeDataSize(pCur, pSize)   (btCOps(pCur)->DataSize(pCur, pSize))
#define sqliteBtreeData(pCur, offset, amt, zBuf)   (btCOps(pCur)->Data(pCur, offset, amt, zBuf))
#define sqliteBtreeCloseCursor(pCur)   (btCOps(pCur)->CloseCursor(pCur))
#define sqliteBtreeGetMeta(pBt, aMeta)   (btOps(pBt)->GetMeta(pBt, aMeta))
#define sqliteBtreeUpdateMeta(pBt, aMeta)   (btOps(pBt)->UpdateMeta(pBt, aMeta))
#define sqliteBtreeIntegrityCheck(pBt, aRoot, nRoot)   (btOps(pBt)->IntegrityCheck(pBt, aRoot, nRoot))
#define sqliteBtreeGetFilename(pBt)   (btOps(pBt)->GetFilename(pBt))
#define sqliteBtreeCopyFile(pBt1, pBt2)   (btOps(pBt1)->Copyfile(pBt1, pBt2))
#define sqliteBtreePager(pBt)   (btOps(pBt)->Pager(pBt))

Typedefs

typedef struct Btree
typedef struct BtCursor
typedef struct BtOps
typedef struct BtCursorOps

Functions

int sqliteBtreeOpen (const char *zFilename, int mode, int nPg, Btree **ppBtree)
int sqliteRbtreeOpen (const char *zFilename, int mode, int nPg, Btree **ppBtree)

Define Documentation

#define btCOps (   pCur)    (*((BtCursorOps **)(pCur)))

Definition at line 101 of file btree.h.

#define btOps (   pBt)    (*((BtOps **)(pBt)))

Definition at line 100 of file btree.h.

#define SQLITE_N_BTREE_META   10

Definition at line 95 of file btree.h.

#define sqliteBtreeBeginCkpt (   pBt)    (btOps(pBt)->BeginCkpt(pBt))

Definition at line 109 of file btree.h.

#define sqliteBtreeBeginTrans (   pBt)    (btOps(pBt)->BeginTrans(pBt))

Definition at line 106 of file btree.h.

#define sqliteBtreeClearTable (   pBt,
  iTable 
)    (btOps(pBt)->ClearTable(pBt, iTable))

Definition at line 117 of file btree.h.

#define sqliteBtreeClose (   pBt)    (btOps(pBt)->Close(pBt))

Definition at line 103 of file btree.h.

#define sqliteBtreeCloseCursor (   pCur)    (btCOps(pCur)->CloseCursor(pCur))

Definition at line 138 of file btree.h.

#define sqliteBtreeCommit (   pBt)    (btOps(pBt)->Commit(pBt))

Definition at line 107 of file btree.h.

#define sqliteBtreeCommitCkpt (   pBt)    (btOps(pBt)->CommitCkpt(pBt))

Definition at line 110 of file btree.h.

#define sqliteBtreeCopyFile (   pBt1,
  pBt2 
)    (btOps(pBt1)->Copyfile(pBt1, pBt2))

Definition at line 144 of file btree.h.

#define sqliteBtreeCreateIndex (   pBt,
  piIndex 
)    (btOps(pBt)->CreateIndex(pBt, piIndex))

Definition at line 114 of file btree.h.

#define sqliteBtreeCreateTable (   pBt,
  piTable 
)    (btOps(pBt)->CreateTable(pBt,piTable))

Definition at line 112 of file btree.h.

#define sqliteBtreeCursor (   pBt,
  iTable,
  wrFlag,
  ppCur 
)    (btOps(pBt)->Cursor(pBt, iTable, wrFlag, ppCur))

Definition at line 119 of file btree.h.

#define sqliteBtreeData (   pCur,
  offset,
  amt,
  zBuf 
)    (btCOps(pCur)->Data(pCur, offset, amt, zBuf))

Definition at line 136 of file btree.h.

#define sqliteBtreeDataSize (   pCur,
  pSize 
)    (btCOps(pCur)->DataSize(pCur, pSize))

Definition at line 135 of file btree.h.

#define sqliteBtreeDelete (   pCur)    (btCOps(pCur)->Delete(pCur))

Definition at line 123 of file btree.h.

#define sqliteBtreeDropTable (   pBt,
  iTable 
)    (btOps(pBt)->DropTable(pBt, iTable))

Definition at line 116 of file btree.h.

#define sqliteBtreeFirst (   pCur,
  pRes 
)    (btCOps(pCur)->First(pCur, pRes))

Definition at line 126 of file btree.h.

#define sqliteBtreeGetFilename (   pBt)    (btOps(pBt)->GetFilename(pBt))

Definition at line 143 of file btree.h.

#define sqliteBtreeGetMeta (   pBt,
  aMeta 
)    (btOps(pBt)->GetMeta(pBt, aMeta))

Definition at line 139 of file btree.h.

#define sqliteBtreeInsert (   pCur,
  pKey,
  nKey,
  pData,
  nData 
)    (btCOps(pCur)->Insert(pCur, pKey, nKey, pData, nData))

Definition at line 124 of file btree.h.

#define sqliteBtreeIntegrityCheck (   pBt,
  aRoot,
  nRoot 
)    (btOps(pBt)->IntegrityCheck(pBt, aRoot, nRoot))

Definition at line 141 of file btree.h.

#define sqliteBtreeKey (   pCur,
  offset,
  amt,
  zBuf 
)    (btCOps(pCur)->Key(pCur, offset, amt, zBuf))

Definition at line 131 of file btree.h.

#define sqliteBtreeKeyCompare (   pCur,
  pKey,
  nKey,
  nIgnore,
  pRes 
)    (btCOps(pCur)->KeyCompare(pCur, pKey, nKey, nIgnore, pRes))

Definition at line 133 of file btree.h.

#define sqliteBtreeKeySize (   pCur,
  pSize 
)    (btCOps(pCur)->KeySize(pCur, pSize) )

Definition at line 130 of file btree.h.

#define sqliteBtreeLast (   pCur,
  pRes 
)    (btCOps(pCur)->Last(pCur, pRes))

Definition at line 127 of file btree.h.

#define sqliteBtreeMoveto (   pCur,
  pKey,
  nKey,
  pRes 
)    (btCOps(pCur)->Moveto(pCur, pKey, nKey, pRes))

Definition at line 121 of file btree.h.

#define sqliteBtreeNext (   pCur,
  pRes 
)    (btCOps(pCur)->Next(pCur, pRes))

Definition at line 128 of file btree.h.

#define sqliteBtreePager (   pBt)    (btOps(pBt)->Pager(pBt))

Definition at line 145 of file btree.h.

#define sqliteBtreePrevious (   pCur,
  pRes 
)    (btCOps(pCur)->Previous(pCur, pRes))

Definition at line 129 of file btree.h.

#define sqliteBtreeRollback (   pBt)    (btOps(pBt)->Rollback(pBt))

Definition at line 108 of file btree.h.

#define sqliteBtreeRollbackCkpt (   pBt)    (btOps(pBt)->RollbackCkpt(pBt))

Definition at line 111 of file btree.h.

#define sqliteBtreeSetCacheSize (   pBt,
  sz 
)    (btOps(pBt)->SetCacheSize(pBt, sz))

Definition at line 104 of file btree.h.

#define sqliteBtreeSetSafetyLevel (   pBt,
  sl 
)    (btOps(pBt)->SetSafetyLevel(pBt, sl))

Definition at line 105 of file btree.h.

#define sqliteBtreeUpdateMeta (   pBt,
  aMeta 
)    (btOps(pBt)->UpdateMeta(pBt, aMeta))

Definition at line 140 of file btree.h.


Typedef Documentation

typedef struct BtCursor

Definition at line 25 of file btree.h.

typedef struct BtCursorOps

Definition at line 27 of file btree.h.

typedef struct BtOps

Definition at line 26 of file btree.h.

typedef struct Btree

Definition at line 24 of file btree.h.


Function Documentation

int sqliteBtreeOpen ( const char *  zFilename,
int  mode,
int  nPg,
Btree **  ppBtree 
)

Definition at line 680 of file btree.c.

 {
  Btree *pBt;
  int rc;

  /*
  ** The following asserts make sure that structures used by the btree are
  ** the right size.  This is to guard against size changes that result
  ** when compiling on a different architecture.
  */
  assert( sizeof(u32)==4 );
  assert( sizeof(u16)==2 );
  assert( sizeof(Pgno)==4 );
  assert( sizeof(PageHdr)==8 );
  assert( sizeof(CellHdr)==12 );
  assert( sizeof(FreeBlk)==4 );
  assert( sizeof(OverflowPage)==SQLITE_USABLE_SIZE );
  assert( sizeof(FreelistInfo)==OVERFLOW_SIZE );
  assert( sizeof(ptr)==sizeof(char*) );
  assert( sizeof(uptr)==sizeof(ptr) );

  pBt = sqliteMalloc( sizeof(*pBt) );
  if( pBt==0 ){
    *ppBtree = 0;
    return SQLITE_NOMEM;
  }
  if( nCache<10 ) nCache = 10;
  rc = sqlitepager_open(&pBt->pPager, zFilename, nCache, EXTRA_SIZE,
                        !omitJournal);
  if( rc!=SQLITE_OK ){
    if( pBt->pPager ) sqlitepager_close(pBt->pPager);
    sqliteFree(pBt);
    *ppBtree = 0;
    return rc;
  }
  sqlitepager_set_destructor(pBt->pPager, pageDestructor);
  pBt->pCursor = 0;
  pBt->page1 = 0;
  pBt->readOnly = sqlitepager_isreadonly(pBt->pPager);
  pBt->pOps = &sqliteBtreeOps;
  *ppBtree = pBt;
  return SQLITE_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int sqliteRbtreeOpen ( const char *  zFilename,
int  mode,
int  nPg,
Btree **  ppBtree 
)

Definition at line 611 of file btree_rb.c.

 {
  Rbtree **ppRbtree = (Rbtree**)ppBtree;
  *ppRbtree = (Rbtree *)sqliteMalloc(sizeof(Rbtree));
  if( sqlite_malloc_failed ) goto open_no_mem;
  sqliteHashInit(&(*ppRbtree)->tblHash, SQLITE_HASH_INT, 0);

  /* Create a binary tree for the SQLITE_MASTER table at location 2 */
  btreeCreateTable(*ppRbtree, 2);
  if( sqlite_malloc_failed ) goto open_no_mem;
  (*ppRbtree)->next_idx = 3;
  (*ppRbtree)->pOps = &sqliteRbtreeOps;
  /* Set file type to 4; this is so that "attach ':memory:' as ...."  does not
  ** think that the database in uninitialised and refuse to attach
  */
  (*ppRbtree)->aMetaData[2] = 4;
  
  return SQLITE_OK;

open_no_mem:
  *ppBtree = 0;
  return SQLITE_NOMEM;

Here is the call graph for this function:

Here is the caller graph for this function: