Home | History | Annotate | Download | only in dist

Lines Matching refs:pBt

6874 ** are placed in aBtree[] in order of aBtree[]->pBt.  That way,
8182 Btree *pBt; /* The B*Tree structure for this database file */
12894 void **pBt;
12908 pBt = (void**)&z[mem.nTitle];
12909 pHdr = (struct MemBlockHdr*)&pBt[mem.nBacktrace];
12924 memcpy(pBt, &aAddr[1], pHdr->nBacktrace*sizeof(void*));
12925 assert(pBt[0]);
12952 void **pBt;
12956 pBt = (void**)pHdr;
12957 pBt -= pHdr->nBacktraceSlots;
12973 z = (char*)pBt;
13057 void **pBt = (void**)pHdr;
13058 pBt -= pHdr->nBacktraceSlots;
13059 mem.xBacktrace(pHdr->iSize, pHdr->nBacktrace-1, &pBt[1]);
13070 void **pBt;
13085 pBt = (void**)pHdr;
13086 pBt -= pHdr->nBacktraceSlots;
13087 backtrace_symbols_fd(pBt, pHdr->nBacktrace, fileno(out));
17582 Btree *pBt; /* Separate file holding temporary table */
37021 #define MX_CELL_SIZE(pBt) (pBt->pageSize-8)
37028 #define MX_CELL(pBt) ((pBt->pageSize-8)/6)
37070 ** stored in MemPage.pBt->mutex.
37090 BtShared *pBt
37137 ** The pBt pointer itself may not be changed while there exists cursors
37144 BtShared *pBt; /* Sharable content of this btree */
37146 u8 sharable; /* True if we can share pBt with another db */
37147 u8 locked; /* True if db currently has pBt locked */
37277 ** found at self->pBt->mutex.
37281 BtShared *pBt; /* The BtShared this cursor points to */
37336 # define PENDING_BYTE_PAGE(pBt) PAGER_MJ_PGNO(pBt)
37353 #define PTRMAP_PAGENO(pBt, pgno) ptrmapPageno(pBt, pgno)
37355 #define PTRMAP_ISPAGE(pBt, pgno) (PTRMAP_PAGENO((pBt),(pgno))==(pgno))
37398 assert( p->pBt->inTransaction!=TRANS_NONE || p->pBt->nTransaction==0 ); \
37399 assert( p->pBt->inTransaction>=p->inTrans );
37410 #define ISAUTOVACUUM (pBt->autoVacuum)
37422 BtShared *pBt; /* The tree being checked out */
37423 Pager *pPager; /* The associated pager. Also accessible by pBt->pPager */
37452 assert( sqlite3_mutex_notheld(p->pBt->mutex) );
37455 sqlite3_mutex_enter(p->pBt->mutex);
37456 p->pBt->db = p->db;
37466 assert( sqlite3_mutex_held(p->pBt->mutex) );
37468 assert( p->db==p->pBt->db );
37470 sqlite3_mutex_leave(p->pBt->mutex);
37495 ** Btree.pBt value. All elements of the list should belong to
37497 assert( p->pNext==0 || p->pNext->pBt>p->pBt );
37498 assert( p->pPrev==0 || p->pPrev->pBt<p->pBt );
37512 assert( (p->locked==0 && p->sharable) || p->pBt->db==p->db );
37522 if( sqlite3_mutex_try(p->pBt->mutex)==SQLITE_OK ){
37523 p->pBt->db = p->db;
37535 assert( pLater->pNext==0 || pLater->pNext->pBt>pLater->pBt );
37571 assert( p->sharable==0 || p->locked==0 || p->db==p->pBt->db );
37572 assert( p->sharable==0 || p->locked==0 || sqlite3_mutex_held(p->pBt->mutex) );
37614 p = db->aDb[i].pBt;
37615 assert( !p || (p->locked==0 && p->sharable) || p->pBt->db==p->db );
37642 p = db->aDb[i].pBt;
37667 p = db->aDb[i].pBt;
37669 (p->wantToLock==0 || !sqlite3_mutex_held(p->pBt->mutex)) ){
37682 ** The pointers are kept in sorted order by pBtree->pBt. That
37692 BtShared *pBt;
37703 pBt = pBtree->pBt;
37706 if( pArray->aBtree[i]->pBt>pBt ){
37728 assert( i==0 || pArray->aBtree[i-1]->pBt<p->pBt );
37753 assert( i==0 || pArray->aBtree[i-1]->pBt<p->pBt );
37769 p->pBt->db = p->db;
37774 Btree *p = db->aDb[i].pBt;
37776 p->pBt->db = p->db;
37901 Schema *pSchema = (Schema *)pBtree->pBt->pSchema;
37943 for(pLock=pBtree->pBt->pLock; pLock; pLock=pLock->pNext){
37978 for(p=pBtree->pBt->pCursor; p; p=p->pNext){
37997 BtShared *pBt = p->pBt;
38009 assert( eLock==READ_LOCK || (p==pBt->pWriter && p->inTrans==TRANS_WRITE) );
38010 assert( eLock==READ_LOCK || pBt->inTransaction==TRANS_WRITE );
38020 if( pBt->pWriter!=p && pBt->isExclusive ){
38021 sqlite3ConnectionBlocked(p->db, pBt->pWriter->db);
38025 for(pIter=pBt->pLock; pIter; pIter=pIter->pNext){
38040 assert( p==pBt->pWriter );
38041 pBt->isPending = 1;
38069 BtShared *pBt = p->pBt;
38089 for(pIter=pBt->pLock; pIter; pIter=pIter->pNext){
38106 pLock->pNext = pBt->pLock;
38107 pBt->pLock = pLock;
38133 BtShared *pBt = p->pBt;
38134 BtLock **ppIter = &pBt->pLock;
38142 assert( pBt->isExclusive==0 || pBt->pWriter==pLock->pBtree );
38155 assert( pBt->isPending==0 || pBt->pWriter );
38156 if( pBt->pWriter==p ){
38157 pBt->pWriter = 0;
38158 pBt->isExclusive = 0;
38159 pBt->isPending = 0;
38160 }else if( pBt->nTransaction==2 ){
38170 pBt->isPending = 0;
38178 BtShared *pBt = p->pBt;
38179 if( pBt->pWriter==p ){
38181 pBt->pWriter = 0;
38182 pBt->isExclusive = 0;
38183 pBt->isPending = 0;
38184 for(pLock=pBt->pLock; pLock; pLock=pLock->pNext){
38202 return sqlite3_mutex_held(p->pBt->mutex);
38219 ** on the shared btree structure pBt.
38221 static void invalidateAllOverflowCache(BtShared *pBt){
38223 assert( sqlite3_mutex_held(pBt->mutex) );
38224 for(p=pBt->pCursor; p; p=p->pNext){
38248 BtShared *pBt = pBtree->pBt;
38250 for(p=pBt->pCursor; p; p=p->pNext){
38299 static int btreeSetHasContent(BtShared *pBt, Pgno pgno){
38301 if( !pBt->pHasContent ){
38303 sqlite3PagerPagecount(pBt->pPager, &nPage);
38306 pBt->pHasContent = sqlite3BitvecCreate((u32)nPage);
38307 if( !pBt->pHasContent ){
38311 if( rc==SQLITE_OK && pgno<=sqlite3BitvecSize(pBt->pHasContent) ){
38312 rc = sqlite3BitvecSet(pBt->pHasContent, pgno);
38324 static int btreeGetHasContent(BtShared *pBt, Pgno pgno){
38325 Bitvec *p = pBt->pHasContent;
38333 static void btreeClearHasContent(BtShared *pBt){
38334 sqlite3BitvecDestroy(pBt->pHasContent);
38335 pBt->pHasContent = 0;
38395 static int saveAllCursors(BtShared *pBt, Pgno iRoot, BtCursor *pExcept){
38397 assert( sqlite3_mutex_held(pBt->mutex) );
38398 assert( pExcept==0 || pExcept->pBt==pBt );
38399 for(p=pBt->pCursor; p; p=p->pNext){
38511 static Pgno ptrmapPageno(BtShared *pBt, Pgno pgno){
38514 assert( sqlite3_mutex_held(pBt->mutex) );
38515 nPagesPerMapPage = (pBt->usableSize/5)+1;
38518 if( ret==PENDING_BYTE_PAGE(pBt) ){
38534 static void ptrmapPut(BtShared *pBt, Pgno key, u8 eType, Pgno parent, int *pRC){
38543 assert( sqlite3_mutex_held(pBt->mutex) );
38545 assert( 0==PTRMAP_ISPAGE(pBt, PENDING_BYTE_PAGE(pBt)) );
38547 assert( pBt->autoVacuum );
38552 iPtrmap = PTRMAP_PAGENO(pBt, key);
38553 rc = sqlite3PagerGet(pBt->pPager, iPtrmap, &pDbPage);
38585 static int ptrmapGet(BtShared *pBt, Pgno key, u8 *pEType, Pgno *pPgno){
38592 assert( sqlite3_mutex_held(pBt->mutex) );
38594 iPtrmap = PTRMAP_PAGENO(pBt, key);
38595 rc = sqlite3PagerGet(pBt->pPager, iPtrmap, &pDbPage);
38633 assert( sqlite3_mutex_held(pPage->pBt->mutex) );
38666 assert( sqlite3_mutex_held(pPage->pBt->mutex) );
38717 surplus = minLocal + (nPayload - minLocal)%(pPage->pBt->usableSize - 4);
38779 nSize = minLocal + (nSize - minLocal) % (pPage->pBt->usableSize - 4);
38820 ptrmapPut(pPage->pBt, ovfl, PTRMAP_OVERFLOW1, pPage->pgno, pRC);
38848 assert( pPage->pBt!=0 );
38849 assert( pPage->pBt->usableSize <= SQLITE_MAX_PAGE_SIZE );
38851 assert( sqlite3_mutex_held(pPage->pBt->mutex) );
38852 temp = sqlite3PagerTempSpace(pPage->pBt->pPager);
38858 usableSize = pPage->pBt->usableSize;
38932 assert( pPage->pBt );
38933 assert( sqlite3_mutex_held(pPage->pBt->mutex) );
38937 usableSize = pPage->pBt->usableSize;
39008 assert( top+nByte <= pPage->pBt->usableSize );
39026 assert( pPage->pBt!=0 );
39029 assert( (start + size)<=pPage->pBt->usableSize );
39030 assert( sqlite3_mutex_held(pPage->pBt->mutex) );
39050 iLast = pPage->pBt->usableSize - 4;
39072 assert( pbegin<=pPage->pBt->usableSize-4 );
39115 BtShared *pBt; /* A copy of pPage->pBt */
39118 assert( sqlite3_mutex_held(pPage->pBt->mutex) );
39122 pBt = pPage->pBt;
39126 pPage->maxLocal = pBt->maxLeaf;
39127 pPage->minLocal = pBt->minLeaf;
39131 pPage->maxLocal = pBt->maxLocal;
39132 pPage->minLocal = pBt->minLocal;
39150 assert( pPage->pBt!=0 );
39151 assert( sqlite3_mutex_held(pPage->pBt->mutex) );
39160 BtShared *pBt; /* The main btree structure */
39168 pBt = pPage->pBt;
39173 assert( pBt->pageSize>=512 && pBt->pageSize<=32768 );
39174 pPage->maskPage = pBt->pageSize - 1;
39176 usableSize = pBt->usableSize;
39180 if( pPage->nCell>MX_CELL(pBt) ){
39184 testcase( pPage->nCell==MX_CELL(pBt) );
39260 BtShared *pBt = pPage->pBt;
39268 assert( sqlite3_mutex_held(pBt->mutex) );
39270 memset(&data[hdr], 0, pBt->usableSize - hdr);
39276 put2byte(&data[hdr+5], pBt->usableSize);
39277 pPage->nFree = pBt->usableSize - first;
39282 assert( pBt->pageSize>=512 && pBt->pageSize<=32768 );
39283 pPage->maskPage = pBt->pageSize - 1;
39293 static MemPage *btreePageFromDbPage(DbPage *pDbPage, Pgno pgno, BtShared *pBt){
39297 pPage->pBt = pBt;
39304 ** Get a page from the pager. Initialize the MemPage.pBt and
39315 BtShared *pBt, /* The btree */
39323 assert( sqlite3_mutex_held(pBt->mutex) );
39324 rc = sqlite3PagerAcquire(pBt->pPager, pgno, (DbPage**)&pDbPage, noContent);
39326 *ppPage = btreePageFromDbPage(pDbPage, pgno, pBt);
39332 ** already in the pager cache return NULL. Initialize the MemPage.pBt and
39335 static MemPage *btreePageLookup(BtShared *pBt, Pgno pgno){
39337 assert( sqlite3_mutex_held(pBt->mutex) );
39338 pDbPage = sqlite3PagerLookup(pBt->pPager, pgno);
39340 return btreePageFromDbPage(pDbPage, pgno, pBt);
39349 static Pgno pagerPagecount(BtShared *pBt){
39352 assert( pBt->pPage1 );
39353 rc = sqlite3PagerPagecount(pBt->pPager, &nPage);
39367 BtShared *pBt, /* The database file */
39372 TESTONLY( Pgno iLastPg = pagerPagecount(pBt); )
39373 assert( sqlite3_mutex_held(pBt->mutex) );
39375 rc = btreeGetPage(pBt, pgno, ppPage, 0);
39401 assert( pPage->pBt );
39404 assert( sqlite3_mutex_held(pPage->pBt->mutex) );
39422 assert( sqlite3_mutex_held(pPage->pBt->mutex) );
39440 BtShared *pBt = (BtShared*)pArg;
39441 assert( pBt->db );
39442 assert( sqlite3_mutex_held(pBt->db->mutex) );
39443 return sqlite3InvokeBusyHandler(&pBt->db->busyHandler);
39469 BtShared *pBt = 0; /* Shared part of btree structure */
39524 for(pBt=GLOBAL(BtShared*,sqlite3SharedCacheList); pBt; pBt=pBt->pNext){
39525 assert( pBt->nRef>0 );
39526 if( 0==strcmp(zFullPathname, sqlite3PagerFilename(pBt->pPager))
39527 && sqlite3PagerVfs(pBt->pPager)==pVfs ){
39530 Btree *pExisting = db->aDb[iDb].pBt;
39531 if( pExisting && pExisting->pBt==pBt ){
39539 p->pBt = pBt;
39540 pBt->nRef++;
39559 if( pBt==0 ){
39571 pBt = sqlite3MallocZero( sizeof(*pBt) );
39572 if( pBt==0 ){
39576 rc = sqlite3PagerOpen(pVfs, &pBt->pPager, zFilename,
39579 rc = sqlite3PagerReadFileheader(pBt->pPager,sizeof(zDbHeader),zDbHeader);
39584 pBt->db = db;
39585 sqlite3PagerSetBusyhandler(pBt->pPager, btreeInvokeBusyHandler, pBt);
39586 p->pBt = pBt;
39588 pBt->pCursor = 0;
39589 pBt->pPage1 = 0;
39590 pBt->readOnly = sqlite3PagerIsreadonly(pBt->pPager);
39591 pBt->pageSize = get2byte(&zDbHeader[16]);
39592 if( pBt->pageSize<512 || pBt->pageSize>SQLITE_MAX_PAGE_SIZE
39593 || ((pBt->pageSize-1)&pBt->pageSize)!=0 ){
39594 pBt->pageSize = 0;
39603 pBt->autoVacuum = (SQLITE_DEFAULT_AUTOVACUUM ? 1 : 0);
39604 pBt->incrVacuum = (SQLITE_DEFAULT_AUTOVACUUM==2 ? 1 : 0);
39610 pBt->pageSizeFixed = 1;
39612 pBt->autoVacuum = (get4byte(&zDbHeader[36 + 4*4])?1:0);
39613 pBt->incrVacuum = (get4byte(&zDbHeader[36 + 7*4])?1:0);
39616 rc = sqlite3PagerSetPagesize(pBt->pPager, &pBt->pageSize, nReserve);
39618 pBt->usableSize = pBt->pageSize - nReserve;
39619 assert( (pBt->pageSize & 7)==0 ); /* 8-byte alignment of pageSize */
39626 pBt->nRef = 1;
39629 pBt->mutex = sqlite3MutexAlloc(SQLITE_MUTEX_FAST);
39630 if( pBt->mutex==0 ){
39637 pBt->pNext = GLOBAL(BtShared*,sqlite3SharedCacheList);
39638 GLOBAL(BtShared*,sqlite3SharedCacheList) = pBt;
39647 ** The list is kept in ascending order by pBt address.
39653 if( (pSib = db->aDb[i].pBt)!=0 && pSib->sharable ){
39655 if( p->pBt<pSib->pBt ){
39660 while( pSib->pNext && pSib->pNext->pBt<p->pBt ){
39679 if( pBt && pBt->pPager ){
39680 sqlite3PagerClose(pBt->pPager);
39682 sqlite3_free(pBt);
39699 static int removeFromSharingList(BtShared *pBt){
39705 assert( sqlite3_mutex_notheld(pBt->mutex) );
39708 pBt->nRef--;
39709 if( pBt->nRef<=0 ){
39710 if( GLOBAL(BtShared*,sqlite3SharedCacheList)==pBt ){
39711 GLOBAL(BtShared*,sqlite3SharedCacheList) = pBt->pNext;
39714 while( ALWAYS(pList) && pList->pNext!=pBt ){
39718 pList->pNext = pBt->pNext;
39722 sqlite3_mutex_free(pBt->mutex);
39734 ** Make sure pBt->pTmpSpace points to an allocation of
39735 ** MX_CELL_SIZE(pBt) bytes.
39737 static void allocateTempSpace(BtShared *pBt){
39738 if( !pBt->pTmpSpace ){
39739 pBt->pTmpSpace = sqlite3PageMalloc( pBt->pageSize );
39744 ** Free the pBt->pTmpSpace allocation
39746 static void freeTempSpace(BtShared *pBt){
39747 sqlite3PageFree( pBt->pTmpSpace);
39748 pBt->pTmpSpace = 0;
39755 BtShared *pBt = p->pBt;
39761 pCur = pBt->pCursor;
39782 if( !p->sharable || removeFromSharingList(pBt) ){
39783 /* The pBt is no longer on the sharing list, so we can access
39788 assert( !pBt->pCursor );
39789 sqlite3PagerClose(pBt->pPager);
39790 if( pBt->xFreeSchema && pBt->pSchema ){
39791 pBt->xFreeSchema(pBt->pSchema);
39793 sqlite3_free(pBt->pSchema);
39794 freeTempSpace(pBt);
39795 sqlite3_free(pBt);
39825 BtShared *pBt = p->pBt;
39828 sqlite3PagerSetCachesize(pBt->pPager, mxPage);
39843 BtShared *pBt = p->pBt;
39846 sqlite3PagerSetSafetyLevel(pBt->pPager, level, fullSync);
39857 BtShared *pBt = p->pBt;
39861 assert( pBt && pBt->pPager );
39862 rc = sqlite3PagerNosync(pBt->pPager);
39890 BtShared *pBt = p->pBt;
39893 if( pBt->pageSizeFixed ){
39898 nReserve = pBt->pageSize - pBt->usableSize;
39904 assert( !pBt->pPage1 && !pBt->pCursor );
39905 pBt->pageSize = (u16)pageSize;
39906 freeTempSpace(pBt);
39908 rc = sqlite3PagerSetPagesize(pBt->pPager, &pBt->pageSize, nReserve);
39909 pBt->usableSize = pBt->pageSize - (u16)nReserve;
39910 if( iFix ) pBt->pageSizeFixed = 1;
39919 return p->pBt->pageSize;
39930 n = p->pBt->pageSize - p->pBt->usableSize;
39943 n = sqlite3PagerMaxPageCount(p->pBt->pPager, mxPage);
39959 BtShared *pBt = p->pBt;
39964 if( pBt->pageSizeFixed && (av ?1:0)!=pBt->autoVacuum ){
39967 pBt->autoVacuum = av ?1:0;
39968 pBt->incrVacuum = av==2 ?1:0;
39986 (!p->pBt->autoVacuum)?BTREE_AUTOVACUUM_NONE:
39987 (!p->pBt->incrVacuum)?BTREE_AUTOVACUUM_FULL:
40005 static int lockBtree(BtShared *pBt){
40010 assert( sqlite3_mutex_held(pBt->mutex) );
40011 assert( pBt->pPage1==0 );
40012 rc = sqlite3PagerSharedLock(pBt->pPager);
40014 rc = btreeGetPage(pBt, 1, &pPage1, 0);
40020 rc = sqlite3PagerPagecount(pBt->pPager, &nPage);
40032 pBt->readOnly = 1;
40054 if( pageSize!=pBt->pageSize ){
40057 ** actually pageSize. Unlock the database, leave pBt->pPage1 at
40062 pBt->usableSize = (u16)usableSize;
40063 pBt->pageSize = (u16)pageSize;
40064 freeTempSpace(pBt);
40065 rc = sqlite3PagerSetPagesize(pBt->pPager, &pBt->pageSize,
40072 pBt->pageSize = (u16)pageSize;
40073 pBt->usableSize = (u16)usableSize;
40075 pBt->autoVacuum = (get4byte(&page1[36 + 4*4])?1:0);
40076 pBt->incrVacuum = (get4byte(&page1[36 + 7*4])?1:0);
40093 pBt->maxLocal = (pBt->usableSize-12)*64/255 - 23;
40094 pBt->minLocal = (pBt->usableSize-12)*32/255 - 23;
40095 pBt->maxLeaf = pBt->usableSize - 35;
40096 pBt->minLeaf = (pBt->usableSize-12)*32/255 - 23;
40097 assert( pBt->maxLeaf + 23 <= MX_CELL_SIZE(pBt) );
40098 pBt->pPage1 = pPage1;
40103 pBt->pPage1 = 0;
40121 static void unlockBtreeIfUnused(BtShared *pBt){
40122 assert( sqlite3_mutex_held(pBt->mutex) );
40123 assert( pBt->pCursor==0 || pBt->inTransaction>TRANS_NONE );
40124 if( pBt->inTransaction==TRANS_NONE && pBt->pPage1!=0 ){
40125 assert( pBt->pPage1->aData );
40126 assert( sqlite3PagerRefcount(pBt->pPager)==1 );
40127 assert( pBt->pPage1->aData );
40128 releasePage(pBt->pPage1);
40129 pBt->pPage1 = 0;
40134 ** If pBt points to an empty file then convert that empty file
40138 static int newDatabase(BtShared *pBt){
40144 assert( sqlite3_mutex_held(pBt->mutex) );
40145 rc = sqlite3PagerPagecount(pBt->pPager, &nPage);
40149 pP1 = pBt->pPage1;
40156 put2byte(&data[16], pBt->pageSize);
40159 assert( pBt->usableSize<=pBt->pageSize && pBt->usableSize+255>=pBt->pageSize);
40160 data[20] = (u8)(pBt->pageSize - pBt->usableSize);
40166 pBt->pageSizeFixed = 1;
40168 assert( pBt->autoVacuum==1 || pBt->autoVacuum==0 );
40169 assert( pBt->incrVacuum==1 || pBt->incrVacuum==0 );
40170 put4byte(&data[36 + 4*4], pBt->autoVacuum);
40171 put4byte(&data[36 + 7*4], pBt->incrVacuum);
40213 BtShared *pBt = p->pBt;
40228 if( pBt->readOnly && wrflag ){
40238 if( (wrflag && pBt->inTransaction==TRANS_WRITE) || pBt->isPending ){
40239 pBlock = pBt->pWriter->db;
40242 for(pIter=pBt->pLock; pIter; pIter=pIter->pNext){
40263 /* Call lockBtree() until either pBt->pPage1 is populated or
40265 ** may return SQLITE_OK but leave pBt->pPage1 set to 0 if after
40267 ** file is not pBt->pageSize. In this case lockBtree() will update
40268 ** pBt->pageSize to the page-size of the file on disk.
40270 while( pBt->pPage1==0 && SQLITE_OK==(rc = lockBtree(pBt)) );
40273 if( pBt->readOnly ){
40276 rc = sqlite3PagerBegin(pBt->pPager,wrflag>1,sqlite3TempInMemory(p->db));
40278 rc = newDatabase(pBt);
40284 unlockBtreeIfUnused(pBt);
40286 }while( rc==SQLITE_BUSY && pBt->inTransaction==TRANS_NONE &&
40287 btreeInvokeBusyHandler(pBt) );
40291 pBt->nTransaction++;
40296 p->lock.pNext = pBt->pLock;
40297 pBt->pLock = &p->lock;
40302 if( p->inTrans>pBt->inTransaction ){
40303 pBt->inTransaction = p->inTrans;
40307 assert( !pBt->pWriter );
40308 pBt->pWriter = p;
40309 pBt->isExclusive = (u8)(wrflag>1);
40321 rc = sqlite3PagerOpenSavepoint(pBt->pPager, p->db->nSavepoint);
40340 BtShared *pBt = pPage->pBt;
40344 assert( sqlite3_mutex_held(pPage->pBt->mutex) );
40358 ptrmapPut(pBt, childPgno, PTRMAP_BTREE, pgno, &rc);
40364 ptrmapPut(pBt, childPgno, PTRMAP_BTREE, pgno, &rc);
40387 assert( sqlite3_mutex_held(pPage->pBt->mutex) );
40446 BtShared *pBt, /* Btree */
40455 Pager *pPager = pBt->pPager;
40460 assert( sqlite3_mutex_held(pBt->mutex) );
40461 assert( pDbPage->pBt==pBt );
40488 ptrmapPut(pBt, nextOvfl, PTRMAP_OVERFLOW2, iFreePage, &rc);
40500 rc = btreeGetPage(pBt, iPtrPage, &pPtrPage, 0);
40512 ptrmapPut(pBt, iFreePage, eType, iPtrPage, &rc);
40539 static int incrVacuumStep(BtShared *pBt, Pgno nFin, Pgno iLastPg){
40542 assert( sqlite3_mutex_held(pBt->mutex) );
40545 if( !PTRMAP_ISPAGE(pBt, iLastPg) && iLastPg!=PENDING_BYTE_PAGE(pBt) ){
40550 nFreeList = get4byte(&pBt->pPage1->aData[36]);
40555 rc = ptrmapGet(pBt, iLastPg, &eType, &iPtrPage);
40572 rc = allocateBtreePage(pBt, &pFreePg, &iFreePg, iLastPg, 1);
40583 rc = btreeGetPage(pBt, iLastPg, &pLastPg, 0);
40597 rc = allocateBtreePage(pBt, &pFreePg, &iFreePg, 0, 0);
40608 rc = relocatePage(pBt, pLastPg, eType, iPtrPage, iFreePg, nFin!=0);
40619 while( iLastPg==PENDING_BYTE_PAGE(pBt)||PTRMAP_ISPAGE(pBt, iLastPg) ){
40620 if( PTRMAP_ISPAGE(pBt, iLastPg) ){
40622 int rc = btreeGetPage(pBt, iLastPg, &pPg, 0);
40634 sqlite3PagerTruncateImage(pBt->pPager, iLastPg);
40649 BtShared *pBt = p->pBt;
40652 assert( pBt->inTransaction==TRANS_WRITE && p->inTrans==TRANS_WRITE );
40653 if( !pBt->autoVacuum ){
40656 invalidateAllOverflowCache(pBt);
40657 rc = incrVacuumStep(pBt, 0, pagerPagecount(pBt));
40672 static int autoVacuumCommit(BtShared *pBt){
40674 Pager *pPager = pBt->pPager;
40677 assert( sqlite3_mutex_held(pBt->mutex) );
40678 invalidateAllOverflowCache(pBt);
40679 assert(pBt->autoVacuum);
40680 if( !pBt->incrVacuum ){
40688 nOrig = pagerPagecount(pBt);
40689 if( PTRMAP_ISPAGE(pBt, nOrig) || nOrig==PENDING_BYTE_PAGE(pBt) ){
40697 nFree = get4byte(&pBt->pPage1->aData[36]);
40698 nEntry = pBt->usableSize/5;
40699 nPtrmap = (nFree-nOrig+PTRMAP_PAGENO(pBt, nOrig)+nEntry)/nEntry;
40701 if( nOrig>PENDING_BYTE_PAGE(pBt) && nFin<PENDING_BYTE_PAGE(pBt) ){
40704 while( PTRMAP_ISPAGE(pBt, nFin) || nFin==PENDING_BYTE_PAGE(pBt) ){
40710 rc = incrVacuumStep(pBt, nFin, iFree);
40714 rc = sqlite3PagerWrite(pBt->pPage1->pDbPage);
40715 put4byte(&pBt->pPage1->aData[32], 0);
40716 put4byte(&pBt->pPage1->aData[36], 0);
40717 sqlite3PagerTruncateImage(pBt->pPager, nFin);
40745 ** This call is a no-op if no write-transaction is currently active on pBt.
40747 ** Otherwise, sync the database file for the btree pBt. zMaster points to
40761 BtShared *pBt = p->pBt;
40764 if( pBt->autoVacuum ){
40765 rc = autoVacuumCommit(pBt);
40772 rc = sqlite3PagerCommitPhaseOne(pBt->pPager, zMaster, 0);
40783 BtShared *pBt = p->pBt;
40786 btreeClearHasContent(pBt);
40800 pBt->nTransaction--;
40801 if( 0==pBt->nTransaction ){
40802 pBt->inTransaction = TRANS_NONE;
40809 unlockBtreeIfUnused(pBt);
40831 BtShared *pBt = p->pBt;
40841 assert( pBt->inTransaction==TRANS_WRITE );
40842 assert( pBt->nTransaction>0 );
40843 rc = sqlite3PagerCommitPhaseTwo(pBt->pPager);
40848 pBt->inTransaction = TRANS_READ;
40881 static int countWriteCursors(BtShared *pBt){
40884 for(pCur=pBt->pCursor; pCur; pCur=pCur->pNext){
40911 for(p=pBtree->pBt->pCursor; p; p=p->pNext){
40935 BtShared *pBt = p->pBt;
40939 rc = saveAllCursors(pBt, 0, 0);
40957 assert( TRANS_WRITE==pBt->inTransaction );
40958 rc2 = sqlite3PagerRollback(pBt->pPager);
40966 if( btreeGetPage(pBt, 1, &pPage1, 0)==SQLITE_OK ){
40969 assert( countWriteCursors(pBt)==0 );
40970 pBt->inTransaction = TRANS_READ;
40998 BtShared *pBt = p->pBt;
41001 assert( pBt->readOnly==0 );
41004 if( NEVER(p->inTrans!=TRANS_WRITE || pBt->readOnly) ){
41007 assert( pBt->inTransaction==TRANS_WRITE );
41013 rc = sqlite3PagerOpenSavepoint(pBt->pPager, iStatement);
41034 BtShared *pBt = p->pBt;
41038 rc = sqlite3PagerSavepoint(pBt->pPager, op, iSavepoint);
41040 rc = newDatabase(pBt);
41086 BtShared *pBt = p->pBt; /* Shared b-tree handle */
41101 assert( pBt->pPage1 && pBt->pPage1->aData );
41103 if( NEVER(wrFlag && pBt->readOnly) ){
41106 if( iTable==1 && pagerPagecount(pBt)==0 ){
41116 pCur->pBt = pBt;
41118 pCur->pNext = pBt->pCursor;
41122 pBt->pCursor = pCur;
41179 for(p=pCur->pBt->pCursor; p; p=p->pNext){
41203 BtShared *pBt = pCur->pBt;
41209 pBt->pCursor = pCur->pNext;
41217 unlockBtreeIfUnused(pBt);
41349 BtShared *pBt, /* The database file */
41358 assert( sqlite3_mutex_held(pBt->mutex) );
41368 if( pBt->autoVacuum ){
41373 while( PTRMAP_ISPAGE(pBt, iGuess) || iGuess==PENDING_BYTE_PAGE(pBt) ){
41377 if( iGuess<=pagerPagecount(pBt) ){
41378 rc = ptrmapGet(pBt, iGuess, &eType, &pgno);
41389 rc = btreeGetPage(pBt, ovfl, &pPage, 0);
41477 BtShared *pBt = pCur->pBt; /* Btree this cursor belongs to */
41489 || &aPayload[pCur->info.nLocal] > &pPage->aData[pBt->usableSize]
41510 const u32 ovflSize = pBt->usableSize - 4; /* Bytes content per ovfl page */
41566 rc = getOverflowPage(pBt, nextPage, 0, &nextPage);
41574 rc = sqlite3PagerGet(pBt->pPager, nextPage, &pDbPage);
41750 BtShared *pBt = pCur->pBt;
41758 rc = getAndInitPage(pBt, newPgno, &pNewPage);
41841 BtShared *pBt = p->pBt;
41862 rc = getAndInitPage(pBt, pCur->pgnoRoot, &pCur->apPage[0]);
42393 BtShared *pBt,
42407 assert( sqlite3_mutex_held(pBt->mutex) );
42408 pPage1 = pBt->pPage1;
42409 mxPage = pagerPagecount(pBt);
42428 assert( pBt->autoVacuum );
42429 rc = ptrmapGet(pBt, nearby, &eType, 0);
42460 rc = btreeGetPage(pBt, iTrunk, &pTrunk, 0);
42482 }else if( k>(u32)(pBt->usableSize/4 - 2) ){
42516 rc = btreeGetPage(pBt, iNewTrunk, &pNewTrunk, 0);
42588 noContent = !btreeGetHasContent(pBt, *pPgno);
42589 rc = btreeGetPage(pBt, *pPgno, ppPage, noContent);
42605 int nPage = pagerPagecount(pBt);
42608 if( *pPgno==PENDING_BYTE_PAGE(pBt) ){
42613 if( pBt->autoVacuum && PTRMAP_ISPAGE(pBt, *pPgno) ){
42620 assert( *pPgno!=PENDING_BYTE_PAGE(pBt) );
42621 rc = btreeGetPage(pBt, *pPgno, &pPg, 0);
42628 if( *pPgno==PENDING_BYTE_PAGE(pBt) ){ (*pPgno)++; }
42632 assert( *pPgno!=PENDING_BYTE_PAGE(pBt) );
42633 rc = btreeGetPage(pBt, *pPgno, ppPage, 0);
42642 assert( *pPgno!=PENDING_BYTE_PAGE(pBt) );
42671 static int freePage2(BtShared *pBt, MemPage *pMemPage, Pgno iPage){
42674 MemPage *pPage1 = pBt->pPage1; /* Local reference to page 1 */
42679 assert( sqlite3_mutex_held(pBt->mutex) );
42687 pPage = btreePageLookup(pBt, iPage);
42700 if( (!pPage && (rc = btreeGetPage(pBt, iPage, &pPage, 0)))
42705 memset(pPage->aData, 0, pPage->pBt->pageSize);
42712 ptrmapPut(pBt, iPage, PTRMAP_FREEPAGE, 0, &rc);
42727 rc = btreeGetPage(pBt, iTrunk, &pTrunk, 0);
42733 assert( pBt->usableSize>32 );
42734 if( nLeaf > (u32)pBt->usableSize/4 - 2 ){
42738 if( nLeaf < (u32)pBt->usableSize/4 - 8 ){
42762 rc = btreeSetHasContent(pBt, iPage);
42775 if( pPage==0 && SQLITE_OK!=(rc = btreeGetPage(pBt, iPage, &pPage, 0)) ){
42797 *pRC = freePage2(pPage->pBt, pPage, pPage->pgno);
42805 BtShared *pBt = pPage->pBt;
42812 assert( sqlite3_mutex_held(pPage->pBt->mutex) );
42818 assert( pBt->usableSize > 4 );
42819 ovflPageSize = pBt->usableSize - 4;
42825 if( ovflPgno<2 || ovflPgno>pagerPagecount(pBt) ){
42832 rc = getOverflowPage(pBt, ovflPgno, &pOvfl, &iNext);
42835 rc = freePage2(pBt, pOvfl, ovflPgno);
42873 BtShared *pBt = pPage->pBt;
42878 assert( sqlite3_mutex_held(pPage->pBt->mutex) );
42882 assert( pCell<pPage->aData || pCell>=&pPage->aData[pBt->pageSize]
42924 if( pBt->autoVacuum ){
42928 PTRMAP_ISPAGE(pBt, pgnoOvfl) || pgnoOvfl==PENDING_BYTE_PAGE(pBt)
42932 rc = allocateBtreePage(pBt, &pOvfl, &pgnoOvfl, pgnoOvfl, 0);
42944 if( pBt->autoVacuum && rc==SQLITE_OK ){
42946 ptrmapPut(pBt, pgnoOvfl, eType, pgnoPtrmap, &rc);
42963 assert( pPrior<pPage->aData || pPrior>=&pPage->aData[pBt->pageSize]
42972 spaceLeft = pBt->usableSize - 4;
42983 assert( pPayload<pPage->aData || pPayload>=&pPage->aData[pBt->pageSize]
43028 assert( sqlite3_mutex_held(pPage->pBt->mutex) );
43034 testcase( pc+sz==pPage->pBt->usableSize );
43035 if( pc < get2byte(&data[hdr+5]) || pc+sz > pPage->pBt->usableSize ){
43092 assert( pPage->nCell<=MX_CELL(pPage->pBt) && MX_CELL(pPage->pBt)<=5460 );
43094 assert( sqlite3_mutex_held(pPage->pBt->mutex) );
43129 assert( idx+sz <= pPage->pBt->usableSize );
43143 if( pPage->pBt->autoVacuum ){
43168 const int nUsable = pPage->pBt->usableSize; /* Usable size of page */
43171 assert( sqlite3_mutex_held(pPage->pBt->mutex) );
43172 assert( nCell>=0 && nCell<=MX_CELL(pPage->pBt) && MX_CELL(pPage->pBt)<=5460 );
43234 BtShared *const pBt = pPage->pBt; /* B-Tree Database */
43239 assert( sqlite3_mutex_held(pPage->pBt->mutex) );
43249 rc = allocateBtreePage(pBt, &pNew, &pgnoNew, 0, 0);
43273 ptrmapPut(pBt, pgnoNew, PTRMAP_BTREE, pParent->pgno, &rc);
43325 BtShared *pBt = pPage->pBt;
43336 ptrmapGet(pBt, ovfl, &e, &n);
43341 ptrmapGet(pBt, child, &e, &n);
43347 ptrmapGet(pBt, child, &e, &n);
43374 BtShared * const pBt = pFrom->pBt;
43385 assert( get2byte(&aFrom[iFromHdr+5])<=pBt->usableSize );
43389 memcpy(&aTo[iData], &aFrom[iData], pBt->usableSize-iData);
43459 BtShared *pBt; /* The whole database */
43487 pBt = pParent->pBt;
43488 assert( sqlite3_mutex_held(pBt->mutex) );
43540 rc = getAndInitPage(pBt, pgno, &apOld[i]);
43585 k = pBt->pageSize + ROUND8(sizeof(MemPage));
43589 + pBt->pageSize /* aSpace1 */
43625 MemPage *pOld = apCopy[i] = (MemPage*)&aSpace1[pBt->pageSize + k*i];
43628 memcpy(pOld->aData, apOld[i]->aData, pBt->pageSize);
43644 assert( sz<=pBt->pageSize/4 );
43645 assert( iSpace1<=pBt->pageSize );
43683 usableSpace = pBt->usableSize - 12 + leafCorrection;
43761 rc = allocateBtreePage(pBt, &pNew, &pgno, pgno, 0);
43768 ptrmapPut(pBt, pNew->pgno, PTRMAP_BTREE, pParent->pgno, &rc);
43890 assert( sz<=pBt->pageSize/4 );
43891 assert( iOvflSpace<=pBt->pageSize );
44009 ptrmapPut(pBt, get4byte(apCell[i]), PTRMAP_BTREE, pNew->pgno, &rc);
44020 ptrmapPut(pBt, key, PTRMAP_BTREE, apNew[i]->pgno, &rc);
44077 BtShared *pBt = pRoot->pBt; /* The BTree */
44080 assert( sqlite3_mutex_held(pBt->mutex) );
44088 rc = allocateBtreePage(pBt,&pChild,&pgnoChild,pRoot->pgno,0);
44091 ptrmapPut(pBt, pgnoChild, PTRMAP_BTREE, pRoot->pgno, &rc);
44129 const int nMin = pCur->pBt->usableSize * 2 / 3;
44208 u8 *pSpace = sqlite3PageMalloc(pCur->pBt->pageSize);
44276 BtShared *pBt = p->pBt;
44286 assert( pCur->wrFlag && pBt->inTransaction==TRANS_WRITE && !pBt->readOnly );
44314 rc = saveAllCursors(pBt, pCur->pgnoRoot, pCur);
44330 allocateTempSpace(pBt);
44331 newCell = pBt->pTmpSpace;
44336 assert( szNew<=MX_CELL_SIZE(pBt) );
44406 BtShared *pBt = p->pBt;
44414 assert( pBt->inTransaction==TRANS_WRITE );
44415 assert( !pBt->readOnly );
44455 rc = saveAllCursors(pBt, pCur->pgnoRoot, pCur);
44476 assert( MX_CELL_SIZE(pBt)>=nCell );
44478 allocateTempSpace(pBt);
44479 pTmp = pBt->pTmpSpace;
44528 BtShared *pBt = p->pBt;
44534 assert( pBt->inTransaction==TRANS_WRITE );
44535 assert( !pBt->readOnly );
44538 rc = allocateBtreePage(pBt, &pRoot, &pgnoRoot, 1, 0);
44543 if( pBt->autoVacuum ){
44552 invalidateAllOverflowCache(pBt);
44564 while( pgnoRoot==PTRMAP_PAGENO(pBt, pgnoRoot) ||
44565 pgnoRoot==PENDING_BYTE_PAGE(pBt) ){
44574 rc = allocateBtreePage(pBt, &pPageMove, &pgnoMove, pgnoRoot, 1);
44592 rc = btreeGetPage(pBt, pgnoRoot, &pRoot, 0);
44596 rc = ptrmapGet(pBt, pgnoRoot, &eType, &iPtrPage);
44606 rc = relocatePage(pBt, pRoot, eType, iPtrPage, pgnoMove, 0);
44613 rc = btreeGetPage(pBt, pgnoRoot, &pRoot, 0);
44627 ptrmapPut(pBt, pgnoRoot, PTRMAP_ROOTPAGE, 0, &rc);
44639 rc = allocateBtreePage(pBt, &pRoot, &pgnoRoot, 1, 0);
44662 BtShared *pBt, /* The BTree that contains the table */
44672 assert( sqlite3_mutex_held(pBt->mutex) );
44673 if( pgno>pagerPagecount(pBt) ){
44677 rc = getAndInitPage(pBt, pgno, &pPage);
44682 rc = clearDatabasePage(pBt, get4byte(pCell), 1, pnChange);
44689 rc = clearDatabasePage(pBt, get4byte(&pPage->aData[8]), 1, pnChange);
44721 BtShared *pBt = p->pBt;
44730 rc = saveAllCursors(pBt, (Pgno)iTable, 0);
44732 rc = clearDatabasePage(pBt, (Pgno)iTable, 0, pnChange);
44761 BtShared *pBt = p->pBt;
44774 if( NEVER(pBt->pCursor) ){
44775 sqlite3ConnectionBlocked(p->db, pBt->pCursor->pBtree->db);
44779 rc = btreeGetPage(pBt, (Pgno)iTable, &pPage, 0);
44794 if( pBt->autoVacuum ){
44814 rc = btreeGetPage(pBt, maxRootPgno, &pMove, 0);
44818 rc = relocatePage(pBt, pMove, PTRMAP_ROOTPAGE, 0, iTable, 0);
44824 rc = btreeGetPage(pBt, maxRootPgno, &pMove, 0);
44839 while( maxRootPgno==PENDING_BYTE_PAGE(pBt)
44840 || PTRMAP_ISPAGE(pBt, maxRootPgno) ){
44843 assert( maxRootPgno!=PENDING_BYTE_PAGE(pBt) );
44884 BtShared *pBt = p->pBt;
44889 assert( pBt->pPage1 );
44892 *pMeta = get4byte(&pBt->pPage1->aData[36 + idx*4]);
44897 if( idx==BTREE_LARGEST_ROOT_PAGE && *pMeta>0 ) pBt->readOnly = 1;
44908 BtShared *pBt = p->pBt;
44914 assert( pBt->pPage1!=0 );
44915 pP1 = pBt->pPage1->aData;
44916 rc = sqlite3PagerWrite(pBt->pPage1->pDbPage);
44921 assert( pBt->autoVacuum || iMeta==0 );
44923 pBt->incrVacuum = (u8)iMeta;
45006 return p->pBt->pPager;
45077 rc = ptrmapGet(pCheck->pBt, iChild, &ePtrmapType, &iPtrmapParent);
45124 if( pCheck->pBt->autoVacuum ){
45128 if( n>pCheck->pBt->usableSize/4-2 ){
45136 if( pCheck->pBt->autoVacuum ){
45151 if( pCheck->pBt->autoVacuum && N>0 ){
45194 BtShared *pBt;
45205 pBt = pCheck->pBt;
45206 usableSize = pBt->usableSize;
45209 if( (rc = btreeGetPage(pBt, (Pgno)iPage, &pPage, 0))!=0 ){
45254 && (&pCell[info.iOverflow]<=&pPage->aData[pBt->usableSize])
45259 if( pBt->autoVacuum ){
45271 if( pBt->autoVacuum ){
45288 if( pBt->autoVacuum ){
45335 hit = sqlite3PageMalloc( pBt->pageSize );
45416 BtShared *pBt = p->pBt;
45420 assert( p->inTrans>TRANS_NONE && pBt->inTransaction>TRANS_NONE );
45421 nRef = sqlite3PagerRefcount(pBt->pPager);
45422 sCheck.pBt = pBt;
45423 sCheck.pPager = pBt->pPager;
45424 sCheck.nPage = pagerPagecount(sCheck.pBt);
45440 i = PENDING_BYTE_PAGE(pBt);
45448 checkList(&sCheck, 1, get4byte(&pBt->pPage1->aData[32]),
45449 get4byte(&pBt->pPage1->aData[36]), "Main freelist: ");
45456 if( pBt->autoVacuum && aRoot[i]>1 ){
45475 (PTRMAP_PAGENO(pBt, i)!=i || !pBt->autoVacuum) ){
45479 (PTRMAP_PAGENO(pBt, i)==i && pBt->autoVacuum) ){
45489 if( NEVER(nRef != sqlite3PagerRefcount(pBt->pPager)) ){
45492 nRef, sqlite3PagerRefcount(pBt->pPager)
45518 assert( p->pBt->pPager!=0 );
45519 return sqlite3PagerFilename(p->pBt->pPager);
45531 assert( p->pBt->pPager!=0 );
45532 return sqlite3PagerJournalname(p->pBt->pPager);
45579 BtShared *pBt = p->pBt;
45581 if( !pBt->pSchema && nBytes ){
45582 pBt->pSchema = sqlite3MallocZero(nBytes);
45583 pBt->xFreeSchema = xFree;
45586 return pBt->pSchema;
45666 assert( !pCsr->pBt->readOnly && pCsr->pBt->inTransaction==TRANS_WRITE );
45809 return pDb->aDb[i].pBt;
45906 assert( iSrcPg!=PENDING_BYTE_PAGE(p->pSrc->pBt) );
45923 if( iDest==PENDING_BYTE_PAGE(p->pDest->pBt) ) continue;
46000 if( p->pDestDb && p->pSrc->pBt->inTransaction==TRANS_WRITE ){
46031 if( iSrcPg!=PENDING_BYTE_PAGE(p->pSrc->pBt) ){
46082 if( nDestTruncate==(int)PENDING_BYTE_PAGE(p->pDest->pBt) ){
46105 nDestTruncate==(int)(PENDING_BYTE_PAGE(p->pDest->pBt)-1)
46242 assert( sqlite3_mutex_held(p->pSrc->pBt->mutex) );
46271 assert( sqlite3_mutex_held(p->pSrc->pBt->mutex) );
46313 pTo->pBt->pageSizeFixed = 0;
48384 sqlite3BtreeMutexArrayInsert(&p->aMutex, p->db->aDb[i].pBt);
48894 if( pCx->pBt ){
48895 sqlite3BtreeClose(pCx->pBt);
49078 Btree *pBt = db->aDb[i].pBt;
49079 if( sqlite3BtreeIsInTrans(pBt) ){
49102 if( 0==sqlite3Strlen30(sqlite3BtreeGetFilename(db->aDb[0].pBt))
49106 Btree *pBt = db->aDb[i].pBt;
49107 if( pBt ){
49108 rc = sqlite3BtreeCommitPhaseOne(pBt, 0);
49118 Btree *pBt = db->aDb[i].pBt;
49119 if( pBt ){
49120 rc = sqlite3BtreeCommitPhaseTwo(pBt);
49137 char const *zMainFile = sqlite3BtreeGetFilename(db->aDb[0].pBt);
49172 Btree *pBt = db->aDb[i].pBt;
49173 if( sqlite3BtreeIsInTrans(pBt) ){
49174 char const *zFile = sqlite3BtreeGetJournalname(pBt);
49178 if( !needSync && !sqlite3BtreeSyncDisabled(pBt) ){
49216 Btree *pBt = db->aDb[i].pBt;
49217 if( pBt ){
49218 rc = sqlite3BtreeCommitPhaseOne(pBt, zMaster);
49248 Btree *pBt = db->aDb[i].pBt;
49249 if( pBt ){
49250 sqlite3BtreeCommitPhaseTwo(pBt);
49311 Btree *p = db->aDb[i].pBt;
49347 Btree *pBt = db->aDb[i].pBt;
49348 if( pBt ){
49350 rc2 = sqlite3BtreeSavepoint(pBt, SAVEPOINT_ROLLBACK, iSavepoint);
49353 rc2 = sqlite3BtreeSavepoint(pBt, SAVEPOINT_RELEASE, iSavepoint);
52722 Btree *pBt;
52734 Btree *pBt;
52926 Btree *pBt;
55063 rc = sqlite3BtreeSavepoint(db->aDb[u.aq.ii].pBt, u.aq.p1, u.aq.iSavepoint);
55209 Btree *pBt;
55214 u.as.pBt = db->aDb[pOp->p1].pBt;
55216 if( u.as.pBt ){
55217 rc = sqlite3BtreeBeginTrans(u.as.pBt, pOp->p2);
55230 assert( sqlite3BtreeIsInTrans(u.as.pBt) );
55236 rc = sqlite3BtreeBeginStmt(u.as.pBt, p->iStatement);
55270 assert( db->aDb[u.at.iDb].pBt!=0 );
55273 sqlite3BtreeGetMeta(db->aDb[u.at.iDb].pBt, u.at.iCookie, (u32 *)&u.at.iMeta);
55296 assert( u.au.pDb->pBt!=0 );
55300 rc = sqlite3BtreeUpdateMeta(u.au.pDb->pBt, pOp->p2, (int)pIn3->u.i);
55337 Btree *pBt;
55341 u.av.pBt = db->aDb[pOp->p1].pBt;
55342 if( u.av.pBt ){
55343 sqlite3BtreeGetMeta(u.av.pBt, BTREE_SCHEMA_VERSION, (u32 *)&u.av.iMeta);
55447 u.aw.pX = u.aw.pDb->pBt;
55539 &u.ax.pCx->pBt);
55541 rc = sqlite3BtreeBeginTrans(u.ax.pCx->pBt, 1);
55552 rc = sqlite3BtreeCreateTable(u.ax.pCx->pBt, &pgno, BTREE_ZERODATA);
55555 rc = sqlite3BtreeCursor(u.ax.pCx->pBt, pgno, 1,
55562 rc = sqlite3BtreeCursor(u.ax.pCx->pBt, MASTER_ROOT, 1, 0, u.ax.pCx->pCursor);
56939 rc = sqlite3BtreeDropTable(db->aDb[u.br.iDb].pBt, pOp->p1, &u.br.iMoved);
56978 db->aDb[pOp->p2].pBt, pOp->p1, (pOp->p3 ? &u.bs.nChange : 0)
57023 assert( u.bt.pDb->pBt!=0 );
57030 rc = sqlite3BtreeCreateTable(u.bt.pDb->pBt, &u.bt.pgno, u.bt.flags);
57079 assert( sqlite3BtreeHoldsMutex(db->aDb[u.bu.iDb].pBt) );
57206 u.bv.z = sqlite3BtreeIntegrityCheck(db->aDb[pOp->p5].pBt, u.bv.aRoot, u.bv.nRoot,
57699 Btree *pBt;
57704 u.cd.pBt = db->aDb[pOp->p1].pBt;
57705 rc = sqlite3BtreeIncrVacuum(u.cd.pBt);
57754 rc = sqlite3BtreeLockTable(db->aDb[p1].pBt, pOp->p2, isWriteLock);
58144 u.cl.pPager = sqlite3BtreePager(db->aDb[u.cl.p1].pBt);
65585 assert( db->aDb[iDb].pBt!=0 );
65586 assert( sqlite3BtreeHoldsMutex(db->aDb[iDb].pBt) );
65822 &aNew->pBt);
65829 aNew->pSchema = sqlite3SchemaGet(db, aNew->pBt);
65837 pPager = sqlite3BtreePager(aNew->pBt);
65891 if( db->aDb[iDb].pBt ){
65892 sqlite3BtreeClose(db->aDb[iDb].pBt);
65893 db->aDb[iDb].pBt = 0;
65943 if( pDb->pBt==0 ) continue;
65960 if( sqlite3BtreeIsInReadTrans(pDb->pBt) || sqlite3BtreeIsInBackup(pDb->pBt) ){
65965 sqlite3BtreeClose(pDb->pBt);
65966 pDb->pBt = 0;
66910 assert(i==1 || (pDb->pBt && sqlite3BtreeHoldsMutex(pDb->pBt)));
66928 if( pDb->pBt==0 ){
69804 /* if( db->aDb[0].pBt==0 ) return; */
69829 /* if( db->aDb[0].pBt==0 ) return; */
69849 /* if( db->aDb[0].pBt==0 ) return; */
69885 if( db->aDb[1].pBt==0 && !pParse->explain ){
69895 &db->aDb[1].pBt);
69903 sqlite3PagerJournalMode(sqlite3BtreePager(db->aDb[1].pBt),
69944 assert( db->aDb[iDb].pBt!=0 || iDb==1 );
70621 SQLITE_PRIVATE Schema *sqlite3SchemaGet(sqlite3 *db, Btree *pBt){
70623 if( pBt ){
70624 p = (Schema *)sqlite3BtreeSchema(pBt, sizeof(Schema), sqlite3SchemaFree);
77060 if( db->aDb[1].pBt!=0 ){
77061 if( !db->autoCommit || sqlite3BtreeIsInReadTrans(db->aDb[1].pBt) ){
77066 sqlite3BtreeClose(db->aDb[1].pBt);
77067 db->aDb[1].pBt = 0;
77318 sqlite3BtreeSetCacheSize(pDb->pBt, pDb->pSchema->cache_size);
77332 Btree *pBt = pDb->pBt;
77333 assert( pBt!=0 );
77335 int size = ALWAYS(pBt) ? sqlite3BtreeGetPageSize(pBt) : 0;
77342 if( SQLITE_NOMEM==sqlite3BtreeSetPageSize(pBt, db->nextPagesize, -1, 0) ){
77358 Btree *pBt = pDb->pBt;
77360 assert( pBt!=0 );
77364 if( ALWAYS(pBt) ){
77365 newMax = sqlite3BtreeMaxPageCount(pBt, newMax);
77414 pPager = sqlite3BtreePager(db->aDb[ii].pBt);
77419 pPager = sqlite3BtreePager(pDb->pBt);
77472 if( db->aDb[ii].pBt ){
77473 pPager = sqlite3BtreePager(db->aDb[ii].pBt);
77479 pPager = sqlite3BtreePager(pDb->pBt);
77501 Pager *pPager = sqlite3BtreePager(pDb->pBt);
77522 Btree *pBt = pDb->pBt;
77523 assert( pBt!=0 );
77529 if( ALWAYS(pBt) ){
77530 auto_vacuum = sqlite3BtreeGetAutoVacuum(pBt);
77545 int rc = sqlite3BtreeSetAutoVacuum(pBt, eAuto);
77621 sqlite3BtreeSetCacheSize(pDb->pBt, pDb->pSchema->cache_size);
77708 Pager *pPager = sqlite3BtreePager(pDb->pBt);
77722 Pager *pPager = sqlite3BtreePager(pDb->pBt);
77882 if( db->aDb[i].pBt==0 ) continue;
77887 sqlite3BtreeGetFilename(db->aDb[i].pBt), 0);
78302 Btree *pBt;
78308 pBt = db->aDb[i].pBt;
78309 if( pBt==0 || (pPager = sqlite3BtreePager(pBt))==0 ){
78371 sqlite3BtreeSetSafetyLevel(pDb->pBt, pDb->safety_level,
78555 assert( iDb==1 || sqlite3BtreeHoldsMutex(db->aDb[iDb].pBt) );
78590 if( pDb->pBt==0 ){
78600 sqlite3BtreeEnter(pDb->pBt);
78601 if( !sqlite3BtreeIsInReadTrans(pDb->pBt) ){
78602 rc = sqlite3BtreeBeginTrans(pDb->pBt, 0);
78628 sqlite3BtreeGetMeta(pDb->pBt, i+1, (u32 *)&meta[i]);
78664 sqlite3BtreeSetCacheSize(pDb->pBt, pDb->pSchema->cache_size);
78742 sqlite3BtreeCommit(pDb->pBt);
78744 sqlite3BtreeLeave(pDb->pBt);
78834 Btree *pBt = db->aDb[iDb].pBt; /* Btree database to read cookie from */
78835 if( pBt==0 ) continue;
78840 if( !sqlite3BtreeIsInReadTrans(pBt) ){
78841 rc = sqlite3BtreeBeginTrans(pBt, 0);
78852 sqlite3BtreeGetMeta(pBt, BTREE_SCHEMA_VERSION, (u32 *)&cookie);
78859 sqlite3BtreeCommit(pBt);
78948 Btree *pBt = db->aDb[i].pBt;
78949 if( pBt ){
78950 assert( sqlite3BtreeHoldsMutex(pBt) );
78951 rc = sqlite3BtreeSchemaLocked(pBt);
85607 pMain = db->aDb[0].pBt;
85633 pTemp = db->aDb[db->nDb-1].pBt;
85801 sqlite3BtreeClose(pDb->pBt);
85802 pDb->pBt = 0;
85962 sqlite3BtreeHoldsMutex(db->aDb[sqlite3SchemaToIndex(db, p->pSchema)].pBt)
96085 Btree *pBt = db->aDb[j].pBt;
96086 if( pBt && sqlite3BtreeIsInBackup(pBt) ){
96099 if( pDb->pBt ){
96100 sqlite3BtreeClose(pDb->pBt);
96101 pDb->pBt = 0;
96184 if( db->aDb[i].pBt ){
96185 if( sqlite3BtreeIsInTrans(db->aDb[i].pBt) ){
96188 sqlite3BtreeRollback(db->aDb[i].pBt);
97111 &db->aDb[0].pBt);
97119 db->aDb[0].pSchema = sqlite3SchemaGet(db, db->aDb[0].pBt);
97213 sqlite3PagerLockingMode(sqlite3BtreePager(db->aDb[0].pBt),
97614 Btree *pBtree = db->aDb[iDb].pBt;
97782 sqlite3BtreeSetPageSize(db->aDb[0].pBt, 0, x, 0);