/ Check-in [79544fc2]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Remove sqlite3_log() and abort() calls added to this branch to debug the pointer-map problem ([fda22108]).
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | begin-concurrent
Files: files | file ages | folders
SHA3-256:79544fc2856f30cac8b0962d00698974e8918562f09769a68264d17e1e1176fe
User & Date: dan 2017-06-10 17:23:20
Wiki:begin-concurrent
Context
2017-07-20
17:47
Merge all the latest trunk enhancements. check-in: 213c61cb user: drh tags: begin-concurrent
2017-06-10
17:23
Remove sqlite3_log() and abort() calls added to this branch to debug the pointer-map problem ([fda22108]). check-in: 79544fc2 user: dan tags: begin-concurrent
2017-06-08
16:23
Update the recent auto-vacuum fix so that it works for the in-memory pointer-map structure used by this branch. check-in: 8e311a6d user: dan tags: begin-concurrent
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/btree.c.

   625    625       sqlite3_free(pMap->aRollback);
   626    626       sqlite3_free(pMap->aPtr);
   627    627       sqlite3_free(pMap->aSvpt);
   628    628       sqlite3_free(pMap);
   629    629       pBt->pMap = 0;
   630    630     }
   631    631   }
   632         -
   633         -static void btreeCheckPtrmap(BtShared *p, int nPage, const char *zLog){
   634         -  BtreePtrmap *pMap = p->pMap;
   635         -  if( pMap ){
   636         -    int n = MIN(1 + nPage - (int)pMap->iFirst, 5);
   637         -    int i;
   638         -    for(i=0; i<n; i++){
   639         -      int eType = pMap->aPtr[i].eType;
   640         -      if( (eType==PTRMAP_OVERFLOW1 || 
   641         -            eType==PTRMAP_OVERFLOW2 || 
   642         -            eType==PTRMAP_BTREE) && pMap->aPtr[i].parent==0 
   643         -        ){
   644         -        sqlite3_log(SQLITE_ERROR, 
   645         -            "Bitvec: error at (%s) - (%d/%d %d/%d %d/%d %d/%d %d/%d)",
   646         -            zLog,
   647         -            (int)pMap->aPtr[0].eType, (int)pMap->aPtr[0].parent,
   648         -            (n>1 ? (int)pMap->aPtr[1].eType : -1),
   649         -            (n>1 ? (int)pMap->aPtr[1].parent : -1),
   650         -
   651         -            (n>2 ? (int)pMap->aPtr[2].eType : -1),
   652         -            (n>2 ? (int)pMap->aPtr[2].parent : -1),
   653         -
   654         -            (n>3 ? (int)pMap->aPtr[3].eType : -1),
   655         -            (n>3 ? (int)pMap->aPtr[3].parent : -1),
   656         -
   657         -            (n>4 ? (int)pMap->aPtr[4].eType : -1),
   658         -            (n>4 ? (int)pMap->aPtr[4].parent : -1)
   659         -            );
   660         -        abort();
   661         -        break;
   662         -      }
   663         -    }
   664         -  }
   665         -}
   666    632   #else  /* SQLITE_OMIT_CONCURRENT */
   667    633   # define btreePtrmapAllocate(x) SQLITE_OK
   668    634   # define btreePtrmapDelete(x) 
   669    635   # define btreePtrmapBegin(x,y)  SQLITE_OK
   670    636   # define btreePtrmapEnd(x,y,z) 
   671         -# define btreeCheckPtrmap(a,b,c)
   672    637   #endif /* SQLITE_OMIT_CONCURRENT */
   673    638   
   674    639   static void releasePage(MemPage *pPage);  /* Forward reference */
   675    640   
   676    641   /*
   677    642   ***** This routine is used inside of assert() only ****
   678    643   **
................................................................................
  4119   4084     ** or freed by this transaction. In this case no special handling is 
  4120   4085     ** required. Otherwise, if page 1 is dirty, proceed.  */
  4121   4086     BtreePtrmap *pMap = pBt->pMap;
  4122   4087     Pgno iTrunk = get4byte(&p1[32]);
  4123   4088     Pgno nPage = btreePagecount(pBt);
  4124   4089     u32 nFree = get4byte(&p1[36]);
  4125   4090   
  4126         -  btreeCheckPtrmap(pBt, nPage, "btreeFixUnlocked(1)");
  4127         -
  4128   4091     assert( pBt->pMap );
  4129   4092     rc = sqlite3PagerUpgradeSnapshot(pPager, pPage1->pDbPage);
  4130   4093     assert( p1==pPage1->aData );
  4131   4094   
  4132   4095     if( rc==SQLITE_OK ){
  4133   4096       Pgno nHPage = get4byte(&p1[28]);
  4134   4097       Pgno nFin = nHPage;         /* Size of db after transaction merge */
................................................................................
  8713   8676         pCur->eState = CURSOR_REQUIRESEEK;
  8714   8677         pCur->nKey = pX->nKey;
  8715   8678       }
  8716   8679     }
  8717   8680     assert( pCur->apPage[pCur->iPage]->nOverflow==0 );
  8718   8681   
  8719   8682   end_insert:
  8720         -  btreeCheckPtrmap(pBt, pBt->nPage, "sqlite3BtreeInsert()");
  8721   8683     return rc;
  8722   8684   }
  8723   8685   
  8724   8686   /*
  8725   8687   ** Delete the entry that the cursor is pointing to. 
  8726   8688   **
  8727   8689   ** If the BTREE_SAVEPOSITION bit of the flags parameter is zero, then
................................................................................
  8809   8771   
  8810   8772     /* If this is a delete operation to remove a row from a table b-tree,
  8811   8773     ** invalidate any incrblob cursors open on the row being deleted.  */
  8812   8774     if( pCur->pKeyInfo==0 ){
  8813   8775       invalidateIncrblobCursors(p, pCur->pgnoRoot, pCur->info.nKey, 0);
  8814   8776     }
  8815   8777   
  8816         -  btreeCheckPtrmap(pBt, pBt->nPage, "sqlite3BtreeDelete(0)");
  8817         -
  8818   8778     /* Make the page containing the entry to be deleted writable. Then free any
  8819   8779     ** overflow pages associated with the entry and finally remove the cell
  8820   8780     ** itself from within the page.  */
  8821   8781     rc = sqlite3PagerWrite(pPage->pDbPage);
  8822   8782     if( rc ) return rc;
  8823   8783     rc = clearCell(pPage, pCell, &info);
  8824   8784     dropCell(pPage, iCellIdx, info.nSize, &rc);
  8825   8785     if( rc ) return rc;
  8826   8786   
  8827         -  btreeCheckPtrmap(pBt, pBt->nPage, "sqlite3BtreeDelete(1)");
  8828         -
  8829   8787     /* If the cell deleted was not located on a leaf page, then the cursor
  8830   8788     ** is currently pointing to the largest entry in the sub-tree headed
  8831   8789     ** by the child-page of the cell that was just deleted from an internal
  8832   8790     ** node. The cell from the leaf node needs to be moved to the internal
  8833   8791     ** node to replace the deleted cell.  */
  8834   8792     if( !pPage->leaf ){
  8835   8793       MemPage *pLeaf = pCur->apPage[pCur->iPage];
................................................................................
  8847   8805       if( rc==SQLITE_OK ){
  8848   8806         insertCell(pPage, iCellIdx, pCell-4, nCell+4, pTmp, n, &rc);
  8849   8807       }
  8850   8808       dropCell(pLeaf, pLeaf->nCell-1, nCell, &rc);
  8851   8809       if( rc ) return rc;
  8852   8810     }
  8853   8811   
  8854         -  btreeCheckPtrmap(pBt, pBt->nPage, "sqlite3BtreeDelete(2)");
  8855         -
  8856   8812     /* Balance the tree. If the entry deleted was located on a leaf page,
  8857   8813     ** then the cursor still points to that page. In this case the first
  8858   8814     ** call to balance() repairs the tree, and the if(...) condition is
  8859   8815     ** never true.
  8860   8816     **
  8861   8817     ** Otherwise, if the entry deleted was on an internal node page, then
  8862   8818     ** pCur is pointing to the leaf page from which a cell was removed to
................................................................................
  8872   8828     if( rc==SQLITE_OK && pCur->iPage>iCellDepth ){
  8873   8829       while( pCur->iPage>iCellDepth ){
  8874   8830         releasePage(pCur->apPage[pCur->iPage--]);
  8875   8831       }
  8876   8832       rc = balance(pCur);
  8877   8833     }
  8878   8834   
  8879         -  btreeCheckPtrmap(pBt, pBt->nPage, "sqlite3BtreeDelete(3)");
  8880         -
  8881   8835     if( rc==SQLITE_OK ){
  8882   8836       if( bSkipnext ){
  8883   8837         assert( bPreserve && (pCur->iPage==iCellDepth || CORRUPT_DB) );
  8884   8838         assert( pPage==pCur->apPage[pCur->iPage] || CORRUPT_DB );
  8885   8839         assert( (pPage->nCell>0 || CORRUPT_DB) && iCellIdx<=pPage->nCell );
  8886   8840         pCur->eState = CURSOR_SKIPNEXT;
  8887   8841         if( iCellIdx>=pPage->nCell ){