Lines Matching defs:btree
16474 ** Defer sourcing vdbe.h and btree.h until after the "u8" and
16863 ** NOTE: These values must match the corresponding BTREE_ values in btree.h.
17071 /************** Include btree.h in the middle of sqliteInt.h *****************/
17072 /************** Begin file btree.h *******************************************/
17111 typedef struct Btree Btree;
17121 Btree **ppBtree, /* Return open Btree* here */
17137 SQLITE_PRIVATE int sqlite3BtreeClose(Btree*);
17138 SQLITE_PRIVATE int sqlite3BtreeSetCacheSize(Btree*,int);
17139 SQLITE_PRIVATE int sqlite3BtreeSetSpillSize(Btree*,int);
17141 SQLITE_PRIVATE int sqlite3BtreeSetMmapLimit(Btree*,sqlite3_int64);
17143 SQLITE_PRIVATE int sqlite3BtreeSetPagerFlags(Btree*,unsigned);
17144 SQLITE_PRIVATE int sqlite3BtreeSetPageSize(Btree *p, int nPagesize, int nReserve, int eFix);
17145 SQLITE_PRIVATE int sqlite3BtreeGetPageSize(Btree*);
17146 SQLITE_PRIVATE Pgno sqlite3BtreeMaxPageCount(Btree*,Pgno);
17147 SQLITE_PRIVATE Pgno sqlite3BtreeLastPage(Btree*);
17148 SQLITE_PRIVATE int sqlite3BtreeSecureDelete(Btree*,int);
17149 SQLITE_PRIVATE int sqlite3BtreeGetRequestedReserve(Btree*);
17150 SQLITE_PRIVATE int sqlite3BtreeGetReserveNoMutex(Btree *p);
17151 SQLITE_PRIVATE int sqlite3BtreeSetAutoVacuum(Btree *, int);
17152 SQLITE_PRIVATE int sqlite3BtreeGetAutoVacuum(Btree *);
17153 SQLITE_PRIVATE int sqlite3BtreeBeginTrans(Btree*,int,int*);
17154 SQLITE_PRIVATE int sqlite3BtreeCommitPhaseOne(Btree*, const char*);
17155 SQLITE_PRIVATE int sqlite3BtreeCommitPhaseTwo(Btree*, int);
17156 SQLITE_PRIVATE int sqlite3BtreeCommit(Btree*);
17157 SQLITE_PRIVATE int sqlite3BtreeRollback(Btree*,int,int);
17158 SQLITE_PRIVATE int sqlite3BtreeBeginStmt(Btree*,int);
17159 SQLITE_PRIVATE int sqlite3BtreeCreateTable(Btree*, Pgno*, int flags);
17160 SQLITE_PRIVATE int sqlite3BtreeTxnState(Btree*);
17161 SQLITE_PRIVATE int sqlite3BtreeIsInBackup(Btree*);
17163 SQLITE_PRIVATE void *sqlite3BtreeSchema(Btree *, int, void(*)(void *));
17164 SQLITE_PRIVATE int sqlite3BtreeSchemaLocked(Btree *pBtree);
17166 SQLITE_PRIVATE int sqlite3BtreeLockTable(Btree *pBtree, int iTab, u8 isWriteLock);
17171 SQLITE_PRIVATE int sqlite3BtreeSavepoint(Btree *, int, int);
17175 SQLITE_PRIVATE int sqlite3BtreeCheckpoint(Btree*, int, int *, int *);
17178 SQLITE_PRIVATE const char *sqlite3BtreeGetFilename(Btree *);
17179 SQLITE_PRIVATE const char *sqlite3BtreeGetJournalname(Btree *);
17180 SQLITE_PRIVATE int sqlite3BtreeCopyFile(Btree *, Btree *);
17182 SQLITE_PRIVATE int sqlite3BtreeIncrVacuum(Btree *);
17197 SQLITE_PRIVATE int sqlite3BtreeDropTable(Btree*, int, int*);
17198 SQLITE_PRIVATE int sqlite3BtreeClearTable(Btree*, int, i64*);
17200 SQLITE_PRIVATE int sqlite3BtreeTripAllCursors(Btree*, int, int);
17202 SQLITE_PRIVATE void sqlite3BtreeGetMeta(Btree *pBtree, int idx, u32 *pValue);
17203 SQLITE_PRIVATE int sqlite3BtreeUpdateMeta(Btree*, int idx, u32 value);
17205 SQLITE_PRIVATE int sqlite3BtreeNewDb(Btree *p);
17307 Btree*, /* BTree containing table to open */
17316 SQLITE_PRIVATE int sqlite3BtreeClosesWithCursor(Btree*,BtCursor*);
17347 ** entry in either an index or table btree.
17408 Btree *p, /* The btree to be checked */
17410 sqlite3_value *aCnt, /* OUT: entry counts for each btree in aRoot[] */
17416 SQLITE_PRIVATE struct Pager *sqlite3BtreePager(Btree*);
17425 SQLITE_PRIVATE int sqlite3BtreeSetVersion(Btree *pBt, int iVersion);
17427 SQLITE_PRIVATE int sqlite3BtreeIsReadonly(Btree *pBt);
17431 SQLITE_PRIVATE sqlite3_uint64 sqlite3BtreeSeekCount(Btree*);
17445 SQLITE_PRIVATE void sqlite3BtreeCursorList(Btree*);
17449 SQLITE_PRIVATE int sqlite3BtreeCheckpoint(Btree*, int, int *, int *);
17454 SQLITE_PRIVATE void sqlite3BtreeClearCache(Btree*);
17462 SQLITE_PRIVATE void sqlite3BtreeEnter(Btree*);
17464 SQLITE_PRIVATE int sqlite3BtreeSharable(Btree*);
17466 SQLITE_PRIVATE int sqlite3BtreeConnectionCount(Btree*);
17476 SQLITE_PRIVATE void sqlite3BtreeLeave(Btree*);
17481 SQLITE_PRIVATE int sqlite3BtreeHoldsMutex(Btree*);
17499 /************** End of btree.h ***********************************************/
18499 Btree *pBt; /* The B*Tree structure for this database file */
18508 ** Most Schema objects are associated with a Btree. The exception is
18513 ** Schema objects are automatically deallocated when the last Btree that
18517 ** A thread must be holding a mutex on the corresponding Btree in order
18519 ** holding a mutex on the sqlite3 connection pointer that owns the Btree.
18875 #define SQLITE_CellSizeCk 0x00200000 /* Check btree cell sizes on load */
19455 Pgno tnum; /* Root BTree page for this table */
19732 ** or greater than a key in the btree, respectively. These are normally
19828 u16 nColumn; /* Nr columns in btree. Can be 2*Table.nCol */
22031 SQLITE_PRIVATE Btree *sqlite3DbNameToBtree(sqlite3*,const char*);
22523 SQLITE_PRIVATE Schema *sqlite3SchemaGet(sqlite3 *, Btree *);
24366 Btree *pBtx; /* Separate file holding temporary table */
24387 BtCursor *pCursor; /* CURTYPE_BTREE or _PSEUDO. Btree cursor */
24393 Pgno pgnoRoot; /* Root page of the open btree cursor */
25279 Btree *pBt = db->aDb[i].pBt;
56016 Btree *pBt;
56714 ** btree layer only operates on the cached copy of the database pages.
57661 ** is the extension added by the btree.c module containing information such
57679 ** allocations. However, the btree layer needs a small (16-byte) overrun
57688 ** The btree.c module deals with pointers to MemPage objects.
60138 ** 28 of the database header by the btree). If the size of the file
63486 /* This routine is only called by btree immediately after creating
64303 ** (The extra space is used by btree as the MemPage object.)
64663 /* pPager->szMmap = SQLITE_DEFAULT_MMAP_SIZE // will be set by btree.c */
65359 ** The btree layer always holds page1 open until the end, so these first
66665 ** behavior. But when the Btree needs to know the filename for matching to
72076 ** This file contains code used to implement mutexes on Btree objects.
72077 ** This code really belongs in btree.c. But btree.c is getting too
72118 ** BTrees. Each BTree is identified by the index of its root page. The
72132 ** Each page can be either a btree page, a freelist page, an overflow
72135 ** The first page is always a btree page. The first 100 bytes of the first
72188 ** Each btree pages is divided into three sections: The header, the
72218 ** The flags define the format of this btree page. The leaf flag means that
72269 ** bytes of key and data in a btree cell.
72336 ** first byte of on-disk image of every BTree page.
72393 ** a btree handle is closed.
72396 Btree *pBtree; /* Btree handle holding this lock */
72406 /* A Btree handle
72423 ** in the referenced BtShared that point back to this Btree since those
72424 ** cursors have to go through this Btree to find their BtShared and
72427 struct Btree {
72428 sqlite3 *db; /* The database connection holding this btree */
72429 BtShared *pBt; /* Sharable content of this btree */
72435 int nBackup; /* Number of backup operations reading this btree */
72437 Btree *pNext; /* List of other sharable Btrees from the same db */
72438 Btree *pPrev; /* Back pointer of the same list */
72448 ** Btree.inTrans may take one of the following values.
72451 ** of the Btree structure. At most one of these may open a write transaction,
72478 ** private Btree object for the file and each of those Btrees points
72509 sqlite3 *db; /* Database connection currently using this Btree */
72537 BtLock *pLock; /* List of locks held on this shared-btree struct */
72538 Btree *pWriter; /* Btree with currently open write transaction */
72620 Btree *pBtree; /* The Btree to which this cursor belongs */
72649 #define BTCF_Multiple 0x20 /* Maybe another cursor on the same btree */
72740 ** PTRMAP_BTREE: The database page is a non-root btree page. The page number
72741 ** identifies the parent page in the btree.
72750 ** of handle p (type Btree*) are internally consistent.
72812 ** cell addresses in a btree header.
72834 static void lockBtreeMutex(Btree *p){
72848 static void SQLITE_NOINLINE unlockBtreeMutex(Btree *p){
72860 static void SQLITE_NOINLINE btreeLockCarefully(Btree *p);
72863 ** Enter a mutex on the given BTree object.
72867 ** But we keep a reference count in Btree.wantToLock so the behavior
72872 ** Btrees belonging to the same database connection as the p Btree
72878 SQLITE_PRIVATE void sqlite3BtreeEnter(Btree *p){
72879 /* Some basic sanity checking on the Btree. The list of Btrees
72881 ** Btree.pBt value. All elements of the list should belong to
72912 static void SQLITE_NOINLINE btreeLockCarefully(Btree *p){
72913 Btree *pLater;
72948 ** Exit the recursive mutex on a Btree.
72950 SQLITE_PRIVATE void sqlite3BtreeLeave(Btree *p){
72963 ** Return true if the BtShared mutex is held on the btree, or if the
72968 SQLITE_PRIVATE int sqlite3BtreeHoldsMutex(Btree *p){
72980 ** Enter the mutex on every Btree associated with a database
72996 Btree *p;
73012 Btree *p;
73036 Btree *p;
73060 Btree *p;
73078 ** are null #defines in btree.h.
73080 ** If shared cache is disabled, then all btree mutex routines, including
73081 ** the ones below, are no-ops and are null #defines in btree.h.
73084 SQLITE_PRIVATE void sqlite3BtreeEnter(Btree *p){
73090 Btree *p = db->aDb[i].pBt;
73100 ** Enter a mutex on a Btree given a cursor owned by that Btree.
73119 /************** Begin file btree.c *******************************************/
73159 ** from the header of a btree page. If the page size is 65536 and the page
73236 ** Return and reset the seek counter for a Btree object.
73238 SQLITE_PRIVATE sqlite3_uint64 sqlite3BtreeSeekCount(Btree *pBt){
73322 ** Btree connection pBtree:
73338 Btree *pBtree, /* Handle that must hold lock */
73417 ** It is illegal for pBtree to write if some other Btree object that
73419 ** the iRoot table. Except, if the other Btree object has the
73428 static int hasReadConflicts(Btree *pBtree, Pgno iRoot){
73443 ** Query to see if Btree handle p may obtain a lock of type eLock
73448 static int querySharedCacheTableLock(Btree *p, Pgno iTab, u8 eLock){
73457 /* If requesting a write-lock, then the Btree must have an open write
73504 ** Add a lock on the table with root-page iTable to the shared-btree used
73505 ** by Btree handle p. Parameter eLock must be either READ_LOCK or
73510 ** (a) The specified Btree object p is connected to a sharable
73513 ** (b) No other Btree objects hold a lock that conflicts
73520 static int setSharedCacheTableLock(Btree *p, Pgno iTable, u8 eLock){
73550 /* If the above search did not find a BtLock struct associating Btree p
73580 ** the setSharedCacheTableLock() procedure) held by Btree object p.
73582 ** This function assumes that Btree p has an open read or write
73586 static void clearAllSharedCacheTableLocks(Btree *p){
73616 /* This function is called when Btree p is concluding its
73630 ** This function changes all write-locks held by Btree p into read-locks.
73632 static void downgradeAllSharedCacheTableLocks(Btree *p){
73669 ** statements only and for the purpose of double-checking that the btree code
73680 ** on the shared btree structure pBt.
73686 ** on the shared btree structure pBt.
73711 Btree *pBtree, /* The database file to check */
73840 /* Only the rowid is required for a table btree */
73843 /* For an index btree, save the complete key content. It is possible
73907 ** the location in the btree is remembered in such a way that it can be
73908 ** moved back to the same spot after the btree has been modified. This
73912 ** If there are two or more cursors on the same btree, then all such
73980 BtCursor *pCur, /* Cursor open on the btree to be searched */
73981 const void *pKey, /* Packed key if the btree is an index */
74050 ** from under them, for example. Cursor might also move if a btree
74069 ** cursor returned must not be used with any other Btree interface.
74079 ** has been moved by some outside activity (such as a btree rebalance or
74206 ** as a btree page. */
74276 ** Given a btree page and a cell index (0 means the first cell on
74329 ** Given a record with nPayload bytes of payload stored within btree
74353 ** btreeParseCellPtr() => table btree leaf nodes
74354 ** btreeParseCellNoPayload() => table btree internal nodes
74355 ** btreeParseCellPtrIndex() => index btree nodes
74518 ** data area of the btree-page. The return number includes the cell
75335 BtShared *pBt; /* The main btree structure */
75421 ** the btree layer.
75448 BtShared *pBt, /* The btree */
75486 SQLITE_PRIVATE Pgno sqlite3BtreeLastPage(Btree *p){
75569 BtShared *pBt, /* The btree */
75605 /* pPage might not be a btree page; it might be an overflow page
75609 ** btreeInitPage() be called on every btree page so we make
75617 ** Invoke the busy handler for a btree.
75649 const char *zFilename, /* Name of the file containing the BTree database */
75651 Btree **ppBtree, /* Pointer to new Btree object written here */
75655 BtShared *pBt = 0; /* Shared part of btree structure */
75656 Btree *p; /* Handle to return */
75693 p = sqlite3MallocZero(sizeof(Btree));
75706 ** If this Btree is a candidate for shared cache, try to find an
75748 Btree *pExisting = db->aDb[iDb].pBt;
75779 ** The following asserts make sure that structures used by the btree are
75878 /* If the new Btree uses a sharable pBtShared, then link the new
75879 ** Btree into the list of all sharable Btrees for the same connection.
75884 Btree *pSib;
76036 SQLITE_PRIVATE int sqlite3BtreeClose(Btree *p){
76043 /* Verify that no other cursors have this Btree open */
76063 /* If there are still other outstanding references to the shared-btree
76065 ** up the shared-btree.
76102 SQLITE_PRIVATE int sqlite3BtreeSetCacheSize(Btree *p, int mxPage){
76121 SQLITE_PRIVATE int sqlite3BtreeSetSpillSize(Btree *p, int mxPage){
76136 SQLITE_PRIVATE int sqlite3BtreeSetMmapLimit(Btree *p, sqlite3_int64 szMmap){
76156 Btree *p, /* The btree to set the safety level on */
76188 SQLITE_PRIVATE int sqlite3BtreeSetPageSize(Btree *p, int pageSize, int nReserve, int iFix){
76224 SQLITE_PRIVATE int sqlite3BtreeGetPageSize(Btree *p){
76239 SQLITE_PRIVATE int sqlite3BtreeGetReserveNoMutex(Btree *p){
76255 SQLITE_PRIVATE int sqlite3BtreeGetRequestedReserve(Btree *p){
76270 SQLITE_PRIVATE Pgno sqlite3BtreeMaxPageCount(Btree *p, Pgno mxPage){
76296 SQLITE_PRIVATE int sqlite3BtreeSecureDelete(Btree *p, int newFlag){
76317 SQLITE_PRIVATE int sqlite3BtreeSetAutoVacuum(Btree *p, int autoVacuum){
76341 SQLITE_PRIVATE int sqlite3BtreeGetAutoVacuum(Btree *p){
76669 SQLITE_PRIVATE int sqlite3BtreeNewDb(Btree *p){
76714 Btree *p, /* The btree in which to start the transaction */
76725 /* If the btree is already in a write-transaction, or it
76750 ** on this shared-btree structure and a second write transaction is
76920 SQLITE_PRIVATE int sqlite3BtreeBeginTrans(Btree *p, int wrflag, int *pSchemaVersion){
76986 ** PTRMAP_BTREE: pPage is a btree-page. The pointer points at a child
76989 ** PTRMAP_OVERFLOW1: pPage is a btree-page. The pointer points at an overflow
77060 BtShared *pBt, /* Btree */
77087 /* If pDbPage was a btree-page, then it may have child pages and/or cells
77280 SQLITE_PRIVATE int sqlite3BtreeIncrVacuum(Btree *p){
77317 static int autoVacuumCommit(Btree *p){
77417 ** Otherwise, sync the database file for the btree pBt. zSuperJrnl points to
77428 SQLITE_PRIVATE int sqlite3BtreeCommitPhaseOne(Btree *p, const char *zSuperJrnl){
77455 static void btreeEndTransaction(Btree *p){
77471 ** transaction count of the shared btree. If the transaction count
77517 SQLITE_PRIVATE int sqlite3BtreeCommitPhaseTwo(Btree *p, int bCleanup){
77549 SQLITE_PRIVATE int sqlite3BtreeCommit(Btree *p){
77586 SQLITE_PRIVATE int sqlite3BtreeTripAllCursors(Btree *pBtree, int errCode, int writeOnly){
77637 SQLITE_PRIVATE int sqlite3BtreeRollback(Btree *p, int tripCode, int writeOnly){
77702 SQLITE_PRIVATE int sqlite3BtreeBeginStmt(Btree *p, int iStatement){
77733 SQLITE_PRIVATE int sqlite3BtreeSavepoint(Btree *p, int op, int iSavepoint){
77763 ** Create a new cursor for the BTree whose root is on the page
77805 Btree *p, /* The btree */
77851 /* If there are two or more cursors on the same btree, then all such
77872 Btree *p, /* The btree */
77885 Btree *p, /* The btree */
77912 ** Return true if and only if the Btree object will be automatically
77917 Btree *pBtree, /* the btree object */
77946 Btree *pBtree = pCur->pBtree;
78031 ** Return the value of the integer key or "rowid" for a table btree.
78033 ** ordinary table btree. If the cursor points to an index btree or
78250 MemPage *pPage = pCur->pPage; /* Btree page of current entry */
78251 BtShared *pBt = pCur->pBt; /* Btree this cursor belongs to */
78278 /* Check if data must be read/written to/from the btree page itself. */
78441 ** If pointing to a table btree, then the content section is read. If
78506 ** any btree routine is called.
78539 ** or be destroyed on the next call to any Btree routine,
78813 /* Set *pRes to 1 (true) if the BTree pointed to by cursor pCur contains zero
79403 ** the cursor will always be valid unless the btree is empty. */
79431 ** is a hint to the implement. SQLite btree implementation does not use
79525 ** hint to the implement. The native SQLite btree implementation does not
79619 BtShared *pBt, /* The btree */
80221 /* This is the common case where everything fits on the btree page
80495 ** a btree page has a value of 3 or less, the pCell value might point
80655 ** The order of cells is in the array is for an index btree is:
80663 ** For a table-btree (with rowids) the items 2 and 4 are empty because
80666 ** For an index btree, the apEnd[] array holds pointer to the end of page
80677 ** For a table-btree, the concept is similar, except only apEnd[0]..apEnd[2]
81562 ** offset section of the btree page will be overwritten and we will no
82157 BtShared *pBt = pRoot->pBt; /* The BTree */
82420 BtShared *pBt; /* Btree */
82484 ** Insert a new record into the BTree. The content of the new record
82489 ** For a table btree (used for rowid tables), only the pX.nKey value of
82494 ** For an index btree (used for indexes and WITHOUT ROWID tables), the
82524 Btree *p = pCur->pBtree;
82946 Btree *p = pCur->pBtree;
83148 ** Create a new BTree table. Write into *piTable the page
83158 static int btreeCreateTable(Btree *p, Pgno *piTable, int createTabFlags){
83303 SQLITE_PRIVATE int sqlite3BtreeCreateTable(Btree *p, Pgno *piTable, int flags){
83316 BtShared *pBt, /* The BTree that contains the table */
83382 SQLITE_PRIVATE int sqlite3BtreeClearTable(Btree *p, int iTable, i64 *pnChange){
83432 static int btreeDropTable(Btree *p, Pgno iTable, int *piMoved){
83517 SQLITE_PRIVATE int sqlite3BtreeDropTable(Btree *p, int iTable, int *piMoved){
83546 SQLITE_PRIVATE void sqlite3BtreeGetMeta(Btree *p, int idx, u32 *pMeta){
83576 SQLITE_PRIVATE int sqlite3BtreeUpdateMeta(Btree *p, int idx, u32 iMeta){
83674 ** Return the pager associated with a BTree. This routine is used for
83677 SQLITE_PRIVATE Pager *sqlite3BtreePager(Btree *p){
83909 ** entry represents the span of a cell or freeblock on a btree page.
84224 ** This routine does a complete check of the given BTree file. aRoot[] is
84247 Btree *p, /* The btree to be checked */
84403 SQLITE_PRIVATE const char *sqlite3BtreeGetFilename(Btree *p){
84416 SQLITE_PRIVATE const char *sqlite3BtreeGetJournalname(Btree *p){
84423 ** to describe the current transaction state of Btree p.
84425 SQLITE_PRIVATE int sqlite3BtreeTxnState(Btree *p){
84432 ** Run a checkpoint on the Btree passed as the first argument.
84435 ** transaction on the shared-cache the argument Btree is connected to.
84439 SQLITE_PRIVATE int sqlite3BtreeCheckpoint(Btree *p, int eMode, int *pnLog, int *pnCkpt){
84456 ** Return true if there is currently a backup running on Btree p.
84458 SQLITE_PRIVATE int sqlite3BtreeIsInBackup(Btree *p){
84466 ** a single shared-btree. The memory is used by client code for its own
84468 ** the shared-btree). The btree layer manages reference counting issues.
84470 ** The first time this is called on a shared-btree, nBytes bytes of memory
84479 ** Just before the shared-btree is closed, the function passed as the
84482 ** on the memory, the btree layer does that.
84484 SQLITE_PRIVATE void *sqlite3BtreeSchema(Btree *p, int nBytes, void(*xFree)(void *)){
84498 ** btree as the argument handle holds an exclusive lock on the
84501 SQLITE_PRIVATE int sqlite3BtreeSchemaLocked(Btree *p){
84519 SQLITE_PRIVATE int sqlite3BtreeLockTable(Btree *p, int iTab, u8 isWriteLock){
84608 SQLITE_PRIVATE int sqlite3BtreeSetVersion(Btree *pBtree, int iVersion){
84648 ** Return true if the given Btree is read-only.
84650 SQLITE_PRIVATE int sqlite3BtreeIsReadonly(Btree *p){
84663 SQLITE_PRIVATE void sqlite3BtreeClearCache(Btree *p){
84672 ** Return true if the Btree passed as the only argument is sharable.
84674 SQLITE_PRIVATE int sqlite3BtreeSharable(Btree *p){
84680 ** the Btree handle passed as the only argument. For private caches
84683 SQLITE_PRIVATE int sqlite3BtreeConnectionCount(Btree *p){
84689 /************** End of btree.c ***********************************************/
84713 Btree *pDest; /* Destination b-tree file */
84719 Btree *pSrc; /* Source b-tree file */
84758 ** the Btree objects may have their own mutexes that require locking.
84772 static Btree *findBtree(sqlite3 *pErrorDb, sqlite3 *pDb, const char *zDb){
84814 static int checkReadTransaction(sqlite3 *db, Btree *p){
84953 ** Then clear the Btree layer MemPage.isInit flag. Both this module
84955 ** of the page 'extra' space to invalidate the Btree layers
85235 ** no need to check the return values of the btree methods here, as
85289 /* If a transaction is still open on the Btree, roll it back. */
85408 SQLITE_PRIVATE int sqlite3BtreeCopyFile(Btree *pTo, Btree *pFrom){
85927 ** sqlite3_value_text()), or for ensuring that values to be used as btree
86908 ** Move data out of a btree key or data field and into a Mem structure.
86914 ** pMem->zMalloc to hold the content from the btree, if possible. New
86955 u32 available = 0; /* Number of bytes available on the local btree page */
89748 ** Declare to the Vdbe that the BTree object at db->aDb[i] is used.
90669 Btree *pBt = db->aDb[i].pBt;
90723 Btree *pBt = db->aDb[i].pBt;
90736 Btree *pBt = db->aDb[i].pBt;
90808 Btree *pBt = db->aDb[i].pBt;
90849 Btree *pBt = db->aDb[i].pBt;
90882 Btree *pBt = db->aDb[i].pBt;
90951 Btree *pBt = db->aDb[i].pBt;
91542 ** pointed to was deleted out from under it. Or maybe the btree was
94272 Btree *pBt = db->aDb[i].pBt;
97166 VdbeCursor *pC, /* The BTree cursor from which we are reading */
99218 ** Jump to P2 if the type of a column in a btree is one of the types specified
99221 ** P1 is normally a cursor on a btree for which the row decode cache is
99225 ** The the btree row has fewer than P3 columns, then use P4 as the
100240 ** every btree page of the table. But if P3 is non-zero, an estimate
100453 ** back any currently active btree transactions. If there are any active
100549 Btree *pBt;
100798 ** and subsequently delete entries in an index btree. This is a
100817 Btree *pX;
100904 ** since moved into the btree layer. */
100967 ** The cursor points to a BTree table if P4==0 and to a BTree index
100972 ** in btree.h. These flags control aspects of the operation of
100973 ** the btree. The BTREE_OMIT_JOURNAL and BTREE_SINGLE flags are
101198 ** OPFLAG_SEEKEQ flags is a hint to the btree layer to say that this
101265 ** OPFLAG_SEEKEQ flags is a hint to the btree layer to say that this
101486 ** unnecessary seeks on the btree, substituting steps to the next row
101532 ** btree) then jump to SeekGE.P2, ending the loop.
101535 ** (indicating that the target row does not exist in the btree) then
101711 ** Cursor P1 is on an index btree. If the record identified by P3 and P4
101728 ** Cursor P1 is on an index btree. If the record identified by P3 and P4
101744 ** record. Cursor P1 is an index btree. P2 is a jump destination.
101778 ** Cursor P1 is on an index btree. If the record identified by P3 and P4
101781 ** P1 index btree has a matching key prefix. If there are no matches, jump
101897 ** P1 is the index of a cursor open on an SQL table btree (with integer
101921 ** P1 is the index of a cursor open on an SQL table btree (with integer
102331 ** pre-update-hook for deletes is run, but the btree is otherwise unchanged.
102333 ** with the same key, causing the btree entry to be overwritten.
102679 ** Position cursor P1 at the end of the btree for the purpose of
102680 ** appending a new entry onto the btree.
102684 ** at the end of the btree and so no changes are made to
102893 ** The P3 value is a hint to the btree implementation. If P3==1, that
102918 ** The P3 value is a hint to the btree implementation. If P3==1, that
103398 /* All OP_Destroy operations occur on the same btree */
103567 ** on every btree. This is a prerequisite for invoking
104501 Btree *pBt; /* Btree to change journal mode of */
104621 Btree *pBt;
104666 ** Lock the btree to which cursor P1 is pointing so that the btree cannot be
104681 ** Unlock the btree to which cursor P1 is pointing so that it can be
105235 Btree *pBt;
106085 /* This VDBE program seeks a btree cursor to the identified
107353 Btree *pBt = db->aDb[0].pBt;
125532 Btree *pNewBt = 0;
125539 /* Both the Btree and the new Schema were allocated successfully.
125590 /* Open the database file. If the btree is successfully opened, use
128751 /* Bypass the creation of the PRIMARY KEY btree and the sqlite_schema
129551 ** used by SQLite when the btree layer moves a table root page. The
129594 ** if a root-page of another table is moved by the btree-layer whilst
129624 ** in case a root-page belonging to another table is moved by the btree layer
129730 ** at the btree level, in case the sqlite_sequence table needs to
130086 int iTab = pParse->nTab++; /* Btree cursor used for pTab */
130087 int iIdx = pParse->nTab++; /* Btree cursor used for pIndex */
131573 Btree *pBt = db->aDb[i].pBt;
131639 Btree *pBt;
132653 ** Find and return the schema associated with a BTree. Create
132656 SQLITE_PRIVATE Schema *sqlite3SchemaGet(sqlite3 *db, Btree *pBt){
133387 ** 1. iDataCur is an open cursor on the btree that is the canonical data
133564 ** btree for the table pTab. (This will be either the table itself
136806 Btree *pBtree;
141455 u8 pik_flags; /* flag values passed to the btree insert */
141862 return 0; /* Corrupt schema - two indexes on the same btree */
145154 Btree *pBt = pDb->pBt;
145180 Btree *pBt = pDb->pBt;
145358 Btree *pBt = pDb->pBt;
147305 Btree *pBt;
148165 Btree *pBt = db->aDb[iDb].pBt; /* Btree database to read cookie from */
148412 Btree *pBt = db->aDb[i].pBt;
159530 ** command. If the latter, then the row-records in the table btree on disk
159796 int iDataCur; /* Cursor for the canonical data btree
161338 Btree *pMain; /* The database being vacuumed */
161339 Btree *pTemp; /* The temporary database we vacuum into */
161557 /* Copy Btree meta values */
161597 ** was committed at the btree level). So it safe to end the transaction
163166 struct { /* Information for internal btree tables */
163173 } btree;
163673 #define WHERE_INDEXED 0x00000200 /* WhereLoop.u.btree.pIndex is valid */
163763 Index *pIndex = pLoop->u.btree.pIndex;
163764 u16 nEq = pLoop->u.btree.nEq;
163778 explainAppendTerm(pStr, pIndex, pLoop->u.btree.nBtm, j, i, ">");
163782 explainAppendTerm(pStr, pIndex, pLoop->u.btree.nTop, j, i, "<");
163821 || ((flags&WHERE_VIRTUALTABLE)==0 && (pLoop->u.btree.nEq>0))
163834 assert( pLoop->u.btree.pIndex!=0 );
163835 pIdx = pLoop->u.btree.pIndex;
163982 for(i=pLoop->nSkip; i<pLoop->u.btree.nEq; i++){
163983 const char *z = explainIndexColumnName(pLoop->u.btree.pIndex, i);
164020 if( (wsFlags & WHERE_VIRTUALTABLE)==0 && pLoop->u.btree.pIndex!=0 ){
164021 zObj = pLoop->u.btree.pIndex->zName;
164362 && pLoop->u.btree.pIndex!=0
164363 && pLoop->u.btree.pIndex->aSortOrder[iEq]
164588 nEq = pLoop->u.btree.nEq;
164590 pIdx = pLoop->u.btree.pIndex;
164844 sHint.pIdx = pLoop->u.btree.pIndex;
164893 if( pLoop->u.btree.nEq==0 && pTerm!=pEndRange ){
165098 u16 nEq = pLoop->u.btree.nEq;
165122 if( pLoop->u.btree.pIndex->onError
165124 && pLoop->u.btree.nEq==pLoop->u.btree.pIndex->nKeyCol
165127 for(ii=0; ii<pLoop->u.btree.nEq; ii++){
165367 assert( pLoop->u.btree.nEq==1 );
165543 u16 nEq = pLoop->u.btree.nEq; /* Number of == or IN terms */
165544 u16 nBtm = pLoop->u.btree.nBtm; /* Length of BTM vector */
165545 u16 nTop = pLoop->u.btree.nTop; /* Length of TOP vector */
165564 pIdx = pLoop->u.btree.pIndex;
165574 nExtraReg = MAX(nExtraReg, pLoop->u.btree.nBtm);
165581 nExtraReg = MAX(nExtraReg, pLoop->u.btree.nTop);
165726 ** on the estimated number of rows in the btree seems like a good
166190 && (ii==0 || pSubLoop->u.btree.pIndex==pCov)
166191 && (HasRowid(pTab) || !IsPrimaryKeyIndex(pSubLoop->u.btree.pIndex))
166194 pCov = pSubLoop->u.btree.pIndex;
169641 pLoop->u.btree.nEq = pLoop->nLTerm = nKeyCol;
169687 pLoop->u.btree.pIndex = pIdx;
169722 assert( (u32)n==pLoop->u.btree.nEq );
169789 regBase, pLoop->u.btree.nEq);
169921 Index *pIdx = pLoop->u.btree.pIndex;
169922 int n = pLoop->u.btree.nEq;
170557 Index *p = pLoop->u.btree.pIndex;
170558 int nEq = pLoop->u.btree.nEq;
170637 ** The value in (pBuilder->pNew->u.btree.nEq) is the number of the index
170674 Index *p = pLoop->u.btree.pIndex;
170675 int nEq = pLoop->u.btree.nEq;
170683 int nBtm = pLoop->u.btree.nBtm;
170684 int nTop = pLoop->u.btree.nTop;
170850 Index *p = pBuilder->pNew->u.btree.pIndex;
170851 int nEq = pBuilder->pNew->u.btree.nEq;
170914 Index *p = pBuilder->pNew->u.btree.pIndex;
171043 if( p->u.btree.pIndex && (zName = p->u.btree.pIndex->zName)!=0 ){
171049 sqlite3DebugPrintf(".%-16s %2d", zName, p->u.btree.nEq);
171113 }else if( (p->wsFlags & WHERE_AUTO_INDEX)!=0 && p->u.btree.pIndex!=0 ){
171114 sqlite3DbFree(db, p->u.btree.pIndex->zColAff);
171115 sqlite3DbFreeNN(db, p->u.btree.pIndex);
171116 p->u.btree.pIndex = 0;
171168 pFrom->u.btree.pIndex = 0;
171235 if( pX->u.btree.nEq < pY->u.btree.nEq /* (1b) */
171236 && pX->u.btree.pIndex==pY->u.btree.pIndex /* (1a) */
171502 Index *pIndex = p->u.btree.pIndex;
171504 p->u.btree.pIndex = 0;
171778 ** We have so far matched pBuilder->pNew->u.btree.nEq terms of the
171804 u16 saved_nEq; /* Original value of pNew->u.btree.nEq */
171805 u16 saved_nBtm; /* Original value of pNew->u.btree.nBtm */
171806 u16 saved_nTop; /* Original value of pNew->u.btree.nTop */
171822 pNew->u.btree.nEq, pNew->nSkip, pNew->rRun));
171829 assert( pNew->u.btree.nBtm==0 );
171836 assert( pNew->u.btree.nEq<pProbe->nColumn );
171837 assert( pNew->u.btree.nEq<pProbe->nKeyCol
171840 saved_nEq = pNew->u.btree.nEq;
171841 saved_nBtm = pNew->u.btree.nBtm;
171842 saved_nTop = pNew->u.btree.nTop;
171883 pNew->u.btree.nEq = saved_nEq;
171884 pNew->u.btree.nBtm = saved_nBtm;
171885 pNew->u.btree.nTop = saved_nTop;
171983 assert( saved_nEq==pNew->u.btree.nEq );
172006 pNew->u.btree.nBtm = nVecLen;
172019 pNew->u.btree.nTop = 1;
172026 pNew->u.btree.nTop = nVecLen;
172044 int nEq = ++pNew->u.btree.nEq;
172058 && ALWAYS(pNew->u.btree.nEq<=pProbe->nSampleCol)
172159 && pNew->u.btree.nEq<pProbe->nColumn
172160 && (pNew->u.btree.nEq<pProbe->nKeyCol ||
172163 if( pNew->u.btree.nEq>3 ){
172174 pNew->u.btree.nEq = saved_nEq;
172175 pNew->u.btree.nBtm = saved_nBtm;
172176 pNew->u.btree.nTop = saved_nTop;
172204 pNew->u.btree.nEq++;
172215 pNew->u.btree.nEq = saved_nEq;
172583 SrcItem *pSrc; /* The FROM clause btree term to add */
172652 pNew->u.btree.nEq = 1;
172654 pNew->u.btree.pIndex = 0;
172702 pNew->u.btree.nEq = 0;
172703 pNew->u.btree.nBtm = 0;
172704 pNew->u.btree.nTop = 0;
172705 pNew->u.btree.nDistinctCol = 0;
172712 pNew->u.btree.pIndex = pProbe;
172713 pNew->u.btree.pOrderBy = 0;
172745 /* Do not set btree.pOrderBy for a recursive CTE. In this case
172749 pNew->u.btree.pOrderBy = pSrc->u4.pSubq->pSelect->pOrderBy;
173663 pSubOB = pLoop->u.btree.pOrderBy;
173844 if( pLoop->u.btree.pOrderBy
173856 }else if( (pIndex = pLoop->u.btree.pIndex)==0 || pIndex->bUnordered ){
173880 assert( j>=pLoop->u.btree.nEq
173883 if( j<pLoop->u.btree.nEq && j>=pLoop->nSkip ){
173908 ** j<pLoop->u.btree.nEq constraint above. Any equality other
173912 for(i=j+1; i<pLoop->u.btree.nEq; i++){
173939 && j>=pLoop->u.btree.nEq
173975 pLoop->u.btree.nDistinctCol = j+1;
173996 if( j==pLoop->u.btree.nEq ){
174387 if( pCandidate->u.btree.pIndex->szIdxRow <
174388 pBaseline->u.btree.pIndex->szIdxRow ) return 0;
174955 pLoop->u.btree.nEq = 1;
174980 pLoop->u.btree.nEq = j;
174981 pLoop->u.btree.pIndex = pIdx;
175342 ** There are Btree cursors associated with each table. t1 uses cursor
175869 if( pLoop->u.btree.pIndex!=0 && (pTab->tabFlags & TF_WithoutRowid)==0 ){
175891 Index *pIx = pLoop->u.btree.pIndex;
176131 && (pIdx = pLoop->u.btree.pIndex)->hasStat1
176132 && (n = pLoop->u.btree.nDistinctCol)>0
176251 VdbeComment((v, "next skip-scan on %s", pLoop->u.btree.pIndex->zName));
176345 pIdx = pLoop->u.btree.pIndex;
188008 Btree *pBt = db->aDb[i].pBt;
188034 Btree *pBt = db->aDb[i].pBt;
188347 Btree *pBt = db->aDb[j].pBt;
188436 Btree *pBt = db->aDb[iDb].pBt;
188602 Btree *p = db->aDb[i].pBt;
188980 Btree *pBt = db->aDb[iDb].pBt;
191257 Btree *pBtree;
192058 ** Return the Btree pointer identified by zDbName. Return NULL if not found.
192060 SQLITE_PRIVATE Btree *sqlite3DbNameToBtree(sqlite3 *db, const char *zDbName){
192088 Btree *pBt;
192104 Btree *pBt;
192138 Btree *pBt = db->aDb[iDb].pBt;
192178 Btree *pBt = db->aDb[iDb].pBt;
192230 Btree *pBt = db->aDb[iDb].pBt;
221204 /* Unable to write to the btree while another cursor is reading from it,
224017 /* Unable to write to the btree while another cursor is reading from it,
231393 ** The pager and btree modules arrange objects in memory so that there are
231455 /* Size information for a single cell within a btree page */
231465 /* Size information for a single btree page */
231497 int nPage; /* Number of pages in current btree */
231731 ** For a single cell on a btree page, compute the number of bytes of
231760 static int statDecodePage(Btree *pBt, StatPage *p){
231877 Btree *pBt = pTab->db->aDb[pTab->iDb].pBt;
231903 Btree *pBt, /* Load page from this b-tree */
231932 ** the next entry is the next btree.
231940 Btree *pBt = pTab->db->aDb[pCsr->iDb].pBt;
231948 /* Start measuring space on the next btree */
231973 /* Continue analyzing the btree previously started */
232013 ** an entire btree, this is the exit point from this function */
232080 /* If computing aggregate space usage by btree, continue with the
232511 Btree *pBt;
232606 Btree *pBt = db->aDb[i].pBt;
232624 Btree *pBt;
232719 Btree *pBt = pTab->db->aDb[pTab->iDbTrunc].pBt;