Lines Matching refs:pCur

435 ** Invalidate the overflow page-list cache for cursor pCur, if any.
437 static void invalidateOverflowCache(BtCursor *pCur){
438 assert( cursorHoldsMutex(pCur) );
439 sqlite3_free(pCur->aOverflow);
440 pCur->aOverflow = 0;
568 static int saveCursorPosition(BtCursor *pCur){
571 assert( CURSOR_VALID==pCur->eState );
572 assert( 0==pCur->pKey );
573 assert( cursorHoldsMutex(pCur) );
575 rc = sqlite3BtreeKeySize(pCur, &pCur->nKey);
579 ** stores the integer key in pCur->nKey. In this case this value is
580 ** all that is required. Otherwise, if pCur is not open on an intKey
581 ** table, then malloc space for and store the pCur->nKey bytes of key
584 if( 0==pCur->apPage[0]->intKey ){
585 void *pKey = sqlite3Malloc( (int)pCur->nKey );
587 rc = sqlite3BtreeKey(pCur, 0, (int)pCur->nKey, pKey);
589 pCur->pKey = pKey;
597 assert( !pCur->apPage[0]->intKey || !pCur->pKey );
601 for(i=0; i<=pCur->iPage; i++){
602 releasePage(pCur->apPage[i]);
603 pCur->apPage[i] = 0;
605 pCur->iPage = -1;
606 pCur->eState = CURSOR_REQUIRESEEK;
609 invalidateOverflowCache(pCur);
637 void sqlite3BtreeClearCursor(BtCursor *pCur){
638 assert( cursorHoldsMutex(pCur) );
639 sqlite3_free(pCur->pKey);
640 pCur->pKey = 0;
641 pCur->eState = CURSOR_INVALID;
650 BtCursor *pCur, /* Cursor open on the btree to be searched */
662 pIdxKey = sqlite3VdbeRecordUnpack(pCur->pKeyInfo, (int)nKey, pKey,
668 rc = sqlite3BtreeMovetoUnpacked(pCur, pIdxKey, nKey, bias, pRes);
682 static int btreeRestoreCursorPosition(BtCursor *pCur){
684 assert( cursorHoldsMutex(pCur) );
685 assert( pCur->eState>=CURSOR_REQUIRESEEK );
686 if( pCur->eState==CURSOR_FAULT ){
687 return pCur->skipNext;
689 pCur->eState = CURSOR_INVALID;
690 rc = btreeMoveto(pCur, pCur->pKey, pCur->nKey, 0, &pCur->skipNext);
692 sqlite3_free(pCur->pKey);
693 pCur->pKey = 0;
694 assert( pCur->eState==CURSOR_VALID || pCur->eState==CURSOR_INVALID );
712 int sqlite3BtreeCursorHasMoved(BtCursor *pCur, int *pHasMoved){
715 rc = restoreCursorPosition(pCur);
720 if( pCur->eState!=CURSOR_VALID || pCur->skipNext!=0 ){
2013 BtCursor *pCur;
2018 pCur = pBt->pCursor;
2019 while( pCur ){
2020 BtCursor *pTmp = pCur;
2021 pCur = pCur->pNext;
3230 BtCursor *pCur;
3232 for(pCur=pBt->pCursor; pCur; pCur=pCur->pNext){
3233 if( pCur->wrFlag && pCur->eState!=CURSOR_FAULT ) r++;
3433 ** on pCur to initialize the memory space prior to invoking this routine.
3440 BtCursor *pCur /* Space for new cursor */
3468 pCur->pgnoRoot = (Pgno)iTable;
3469 pCur->iPage = -1;
3470 pCur->pKeyInfo = pKeyInfo;
3471 pCur->pBtree = p;
3472 pCur->pBt = pBt;
3473 pCur->wrFlag = (u8)wrFlag;
3474 pCur->pNext = pBt->pCursor;
3475 if( pCur->pNext ){
3476 pCur->pNext->pPrev = pCur;
3478 pBt->pCursor = pCur;
3479 pCur->eState = CURSOR_INVALID;
3480 pCur->cachedRowid = 0;
3488 BtCursor *pCur /* Write new cursor here */
3492 rc = btreeCursor(p, iTable, wrFlag, pKeyInfo, pCur);
3523 ** as pCur and having the same root page number as pCur. The value is
3533 void sqlite3BtreeSetCachedRowid(BtCursor *pCur, sqlite3_int64 iRowid){
3535 for(p=pCur->pBt->pCursor; p; p=p->pNext){
3536 if( p->pgnoRoot==pCur->pgnoRoot ) p->cachedRowid = iRowid;
3538 assert( pCur->cachedRowid==iRowid );
3547 sqlite3_int64 sqlite3BtreeGetCachedRowid(BtCursor *pCur){
3548 return pCur->cachedRowid;
3555 int sqlite3BtreeCloseCursor(BtCursor *pCur){
3556 Btree *pBtree = pCur->pBtree;
3559 BtShared *pBt = pCur->pBt;
3561 sqlite3BtreeClearCursor(pCur);
3562 if( pCur->pPrev ){
3563 pCur->pPrev->pNext = pCur->pNext;
3565 pBt->pCursor = pCur->pNext;
3567 if( pCur->pNext ){
3568 pCur->pNext->pPrev = pCur->pPrev;
3570 for(i=0; i<=pCur->iPage; i++){
3571 releasePage(pCur->apPage[i]);
3574 invalidateOverflowCache(pCur);
3575 /* sqlite3_free(pCur); */
3597 static void assertCellInfo(BtCursor *pCur){
3599 int iPage = pCur->iPage;
3601 btreeParseCell(pCur->apPage[iPage], pCur->aiIdx[iPage], &info);
3602 assert( memcmp(&info, &pCur->info, sizeof(info))==0 );
3609 static void getCellInfo(BtCursor *pCur){
3610 if( pCur->info.nSize==0 ){
3611 int iPage = pCur->iPage;
3612 btreeParseCell(pCur->apPage[iPage],pCur->aiIdx[iPage],&pCur->info);
3613 pCur->validNKey = 1;
3615 assertCellInfo(pCur);
3620 #define getCellInfo(pCur) \
3621 if( pCur->info.nSize==0 ){ \
3622 int iPage = pCur->iPage; \
3623 btreeParseCell(pCur->apPage[iPage],pCur->aiIdx[iPage],&pCur->info); \
3624 pCur->validNKey = 1; \
3626 assertCellInfo(pCur); \
3636 int sqlite3BtreeCursorIsValid(BtCursor *pCur){
3637 return pCur && pCur->eState==CURSOR_VALID;
3653 int sqlite3BtreeKeySize(BtCursor *pCur, i64 *pSize){
3654 assert( cursorHoldsMutex(pCur) );
3655 assert( pCur->eState==CURSOR_INVALID || pCur->eState==CURSOR_VALID );
3656 if( pCur->eState!=CURSOR_VALID ){
3659 getCellInfo(pCur);
3660 *pSize = pCur->info.nKey;
3677 int sqlite3BtreeDataSize(BtCursor *pCur, u32 *pSize){
3678 assert( cursorHoldsMutex(pCur) );
3679 assert( pCur->eState==CURSOR_VALID );
3680 getCellInfo(pCur);
3681 *pSize = pCur->info.nData;
3795 ** for the entry that the pCur cursor is pointing to. If the eOp
3822 BtCursor *pCur, /* Cursor pointing to entry to read from */
3832 MemPage *pPage = pCur->apPage[pCur->iPage]; /* Btree page of current entry */
3833 BtShared *pBt = pCur->pBt; /* Btree this cursor belongs to */
3836 assert( pCur->eState==CURSOR_VALID );
3837 assert( pCur->aiIdx[pCur->iPage]<pPage->nCell );
3838 assert( cursorHoldsMutex(pCur) );
3840 getCellInfo(pCur);
3841 aPayload = pCur->info.pCell + pCur->info.nHeader;
3842 nKey = (pPage->intKey ? 0 : (int)pCur->info.nKey);
3844 if( NEVER(offset+amt > nKey+pCur->info.nData)
3845 || &aPayload[pCur->info.nLocal] > &pPage->aData[pBt->usableSize]
3852 if( offset<pCur->info.nLocal ){
3854 if( a+offset>pCur->info.nLocal ){
3855 a = pCur->info.nLocal - offset;
3862 offset -= pCur->info.nLocal;
3869 nextPage = get4byte(&aPayload[pCur->info.nLocal]);
3879 if( pCur->isIncrblobHandle && !pCur->aOverflow ){
3880 int nOvfl = (pCur->info.nPayload-pCur->info.nLocal+ovflSize-1)/ovflSize;
3881 pCur->aOverflow = (Pgno *)sqlite3MallocZero(sizeof(Pgno)*nOvfl);
3884 if( ALWAYS(nOvfl) && !pCur->aOverflow ){
3893 if( pCur->aOverflow && pCur->aOverflow[offset/ovflSize] ){
3895 nextPage = pCur->aOverflow[iIdx];
3904 if( pCur->aOverflow ){
3905 assert(!pCur->aOverflow[iIdx] || pCur->aOverflow[iIdx]==nextPage);
3906 pCur->aOverflow[iIdx] = nextPage;
3918 if( pCur->aOverflow && pCur->aOverflow[iIdx+1] ){
3919 nextPage = pCur->aOverflow[iIdx+1];
3954 ** Read part of the key associated with cursor pCur. Exactly
3958 ** The caller must ensure that pCur is pointing to a valid row
3965 int sqlite3BtreeKey(BtCursor *pCur, u32 offset, u32 amt, void *pBuf){
3966 assert( cursorHoldsMutex(pCur) );
3967 assert( pCur->eState==CURSOR_VALID );
3968 assert( pCur->iPage>=0 && pCur->apPage[pCur->iPage] );
3969 assert( pCur->aiIdx[pCur->iPage]<pCur->apPage[pCur->iPage]->nCell );
3970 return accessPayload(pCur, offset, amt, (unsigned char*)pBuf, 0);
3974 ** Read part of the data associated with cursor pCur. Exactly
3982 int sqlite3BtreeData(BtCursor *pCur, u32 offset, u32 amt, void *pBuf){
3986 if ( pCur->eState==CURSOR_INVALID ){
3991 assert( cursorHoldsMutex(pCur) );
3992 rc = restoreCursorPosition(pCur);
3994 assert( pCur->eState==CURSOR_VALID );
3995 assert( pCur->iPage>=0 && pCur->apPage[pCur->iPage] );
3996 assert( pCur->aiIdx[pCur->iPage]<pCur->apPage[pCur->iPage]->nCell );
3997 rc = accessPayload(pCur, offset, amt, pBuf, 0);
4004 ** pCur cursor is pointing to. The pointer is to the beginning of
4022 BtCursor *pCur, /* Cursor pointing to entry to read from */
4031 assert( pCur!=0 && pCur->iPage>=0 && pCur->apPage[pCur->iPage]);
4032 assert( pCur->eState==CURSOR_VALID );
4033 assert( cursorHoldsMutex(pCur) );
4034 pPage = pCur->apPage[pCur->iPage];
4035 assert( pCur->aiIdx[pCur->iPage]<pPage->nCell );
4036 if( NEVER(pCur->info.nSize==0) ){
4037 btreeParseCell(pCur->apPage[pCur->iPage], pCur->aiIdx[pCur->iPage],
4038 &pCur->info);
4040 aPayload = pCur->info.pCell;
4041 aPayload += pCur->info.nHeader;
4045 nKey = (int)pCur->info.nKey;
4049 nLocal = pCur->info.nLocal - nKey;
4051 nLocal = pCur->info.nLocal;
4060 ** For the entry that cursor pCur is point to, return as
4073 const void *sqlite3BtreeKeyFetch(BtCursor *pCur, int *pAmt){
4075 assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) );
4076 assert( cursorHoldsMutex(pCur) );
4077 if( ALWAYS(pCur->eState==CURSOR_VALID) ){
4078 p = (const void*)fetchPayload(pCur, pAmt, 0);
4082 const void *sqlite3BtreeDataFetch(BtCursor *pCur, int *pAmt){
4084 assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) );
4085 assert( cursorHoldsMutex(pCur) );
4086 if( ALWAYS(pCur->eState==CURSOR_VALID) ){
4087 p = (const void*)fetchPayload(pCur, pAmt, 1);
4102 static int moveToChild(BtCursor *pCur, u32 newPgno){
4104 int i = pCur->iPage;
4106 BtShared *pBt = pCur->pBt;
4108 assert( cursorHoldsMutex(pCur) );
4109 assert( pCur->eState==CURSOR_VALID );
4110 assert( pCur->iPage<BTCURSOR_MAX_DEPTH );
4111 if( pCur->iPage>=(BTCURSOR_MAX_DEPTH-1) ){
4116 pCur->apPage[i+1] = pNewPage;
4117 pCur->aiIdx[i+1] = 0;
4118 pCur->iPage++;
4120 pCur->info.nSize = 0;
4121 pCur->validNKey = 0;
4122 if( pNewPage->nCell<1 || pNewPage->intKey!=pCur->apPage[i]->intKey ){
4151 ** pCur->idx is set to the cell index that contains the pointer
4153 ** right-most child page then pCur->idx is set to one more than
4156 static void moveToParent(BtCursor *pCur){
4157 assert( cursorHoldsMutex(pCur) );
4158 assert( pCur->eState==CURSOR_VALID );
4159 assert( pCur->iPage>0 );
4160 assert( pCur->apPage[pCur->iPage] );
4162 pCur->apPage[pCur->iPage-1],
4163 pCur->aiIdx[pCur->iPage-1],
4164 pCur->apPage[pCur->iPage]->pgno
4166 releasePage(pCur->apPage[pCur->iPage]);
4167 pCur->iPage--;
4168 pCur->info.nSize = 0;
4169 pCur->validNKey = 0;
4193 static int moveToRoot(BtCursor *pCur){
4196 Btree *p = pCur->pBtree;
4199 assert( cursorHoldsMutex(pCur) );
4203 if( pCur->eState>=CURSOR_REQUIRESEEK ){
4204 if( pCur->eState==CURSOR_FAULT ){
4205 assert( pCur->skipNext!=SQLITE_OK );
4206 return pCur->skipNext;
4208 sqlite3BtreeClearCursor(pCur);
4211 if( pCur->iPage>=0 ){
4213 for(i=1; i<=pCur->iPage; i++){
4214 releasePage(pCur->apPage[i]);
4216 pCur->iPage = 0;
4218 rc = getAndInitPage(pBt, pCur->pgnoRoot, &pCur->apPage[0]);
4220 pCur->eState = CURSOR_INVALID;
4223 pCur->iPage = 0;
4225 /* If pCur->pKeyInfo is not NULL, then the caller that opened this cursor
4229 assert( pCur->apPage[0]->intKey==1 || pCur->apPage[0]->intKey==0 );
4230 if( (pCur->pKeyInfo==0)!=pCur->apPage[0]->intKey ){
4241 pRoot = pCur->apPage[0];
4242 assert( pRoot->pgno==pCur->pgnoRoot );
4243 assert( pRoot->isInit && (pCur->pKeyInfo==0)==pRoot->intKey );
4245 pCur->aiIdx[0] = 0;
4246 pCur->info.nSize = 0;
4247 pCur->atLast = 0;
4248 pCur->validNKey = 0;
4254 pCur->eState = CURSOR_VALID;
4255 rc = moveToChild(pCur, subpage);
4257 pCur->eState = ((pRoot->nCell>0)?CURSOR_VALID:CURSOR_INVALID);
4269 static int moveToLeftmost(BtCursor *pCur){
4274 assert( cursorHoldsMutex(pCur) );
4275 assert( pCur->eState==CURSOR_VALID );
4276 while( rc==SQLITE_OK && !(pPage = pCur->apPage[pCur->iPage])->leaf ){
4277 assert( pCur->aiIdx[pCur->iPage]<pPage->nCell );
4278 pgno = get4byte(findCell(pPage, pCur->aiIdx[pCur->iPage]));
4279 rc = moveToChild(pCur, pgno);
4294 static int moveToRightmost(BtCursor *pCur){
4299 assert( cursorHoldsMutex(pCur) );
4300 assert( pCur->eState==CURSOR_VALID );
4301 while( rc==SQLITE_OK && !(pPage = pCur->apPage[pCur->iPage])->leaf ){
4303 pCur->aiIdx[pCur->iPage] = pPage->nCell;
4304 rc = moveToChild(pCur, pgno);
4307 pCur->aiIdx[pCur->iPage] = pPage->nCell-1;
4308 pCur->info.nSize = 0;
4309 pCur->validNKey = 0;
4318 int sqlite3BtreeFirst(BtCursor *pCur, int *pRes){
4321 assert( cursorHoldsMutex(pCur) );
4322 assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) );
4323 rc = moveToRoot(pCur);
4325 if( pCur->eState==CURSOR_INVALID ){
4326 assert( pCur->apPage[pCur->iPage]->nCell==0 );
4329 assert( pCur->apPage[pCur->iPage]->nCell>0 );
4331 rc = moveToLeftmost(pCur);
4341 int sqlite3BtreeLast(BtCursor *pCur, int *pRes){
4344 assert( cursorHoldsMutex(pCur) );
4345 assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) );
4348 if( CURSOR_VALID==pCur->eState && pCur->atLast ){
4353 for(ii=0; ii<pCur->iPage; ii++){
4354 assert( pCur->aiIdx[ii]==pCur->apPage[ii]->nCell );
4356 assert( pCur->aiIdx[pCur->iPage]==pCur->apPage[pCur->iPage]->nCell-1 );
4357 assert( pCur->apPage[pCur->iPage]->leaf );
4362 rc = moveToRoot(pCur);
4364 if( CURSOR_INVALID==pCur->eState ){
4365 assert( pCur->apPage[pCur->iPage]->nCell==0 );
4368 assert( pCur->eState==CURSOR_VALID );
4370 rc = moveToRightmost(pCur);
4371 pCur->atLast = rc==SQLITE_OK ?1:0;
4406 BtCursor *pCur, /* The cursor to be moved */
4414 assert( cursorHoldsMutex(pCur) );
4415 assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) );
4417 assert( (pIdxKey==0)==(pCur->pKeyInfo==0) );
4421 if( pCur->eState==CURSOR_VALID && pCur->validNKey
4422 && pCur->apPage[0]->intKey
4424 if( pCur->info.nKey==intKey ){
4428 if( pCur->atLast && pCur->info.nKey<intKey ){
4434 rc = moveToRoot(pCur);
4438 assert( pCur->apPage[pCur->iPage] );
4439 assert( pCur->apPage[pCur->iPage]->isInit );
4440 assert( pCur->apPage[pCur->iPage]->nCell>0 || pCur->eState==CURSOR_INVALID );
4441 if( pCur->eState==CURSOR_INVALID ){
4443 assert( pCur->apPage[pCur->iPage]->nCell==0 );
4446 assert( pCur->apPage[0]->intKey || pIdxKey );
4450 MemPage *pPage = pCur->apPage[pCur->iPage];
4464 pCur->aiIdx[pCur->iPage] = (u16)upr;
4466 pCur->aiIdx[pCur->iPage] = (u16)((upr+lwr)/2);
4469 int idx = pCur->aiIdx[pCur->iPage]; /* Index of current cell in pPage */
4472 pCur->info.nSize = 0;
4489 pCur->validNKey = 1;
4490 pCur->info.nKey = nCellKey;
4519 btreeParseCellPtr(pPage, pCellBody, &pCur->info);
4520 nCell = (int)pCur->info.nKey;
4526 rc = accessPayload(pCur, 0, nCell, (unsigned char*)pCellKey, 0);
4554 pCur->aiIdx[pCur->iPage] = (u16)((lwr+upr)/2);
4566 assert( pCur->aiIdx[pCur->iPage]<pCur->apPage[pCur->iPage]->nCell );
4571 pCur->aiIdx[pCur->iPage] = (u16)lwr;
4572 pCur->info.nSize = 0;
4573 pCur->validNKey = 0;
4574 rc = moveToChild(pCur, chldPg);
4589 int sqlite3BtreeEof(BtCursor *pCur){
4594 return (CURSOR_VALID!=pCur->eState);
4603 int sqlite3BtreeNext(BtCursor *pCur, int *pRes){
4608 assert( cursorHoldsMutex(pCur) );
4609 rc = restoreCursorPosition(pCur);
4614 if( CURSOR_INVALID==pCur->eState ){
4618 if( pCur->skipNext>0 ){
4619 pCur->skipNext = 0;
4623 pCur->skipNext = 0;
4625 pPage = pCur->apPage[pCur->iPage];
4626 idx = ++pCur->aiIdx[pCur->iPage];
4630 pCur->info.nSize = 0;
4631 pCur->validNKey = 0;
4634 rc = moveToChild(pCur, get4byte(&pPage->aData[pPage->hdrOffset+8]));
4636 rc = moveToLeftmost(pCur);
4641 if( pCur->iPage==0 ){
4643 pCur->eState = CURSOR_INVALID;
4646 moveToParent(pCur);
4647 pPage = pCur->apPage[pCur->iPage];
4648 }while( pCur->aiIdx[pCur->iPage]>=pPage->nCell );
4651 rc = sqlite3BtreeNext(pCur, pRes);
4661 rc = moveToLeftmost(pCur);
4672 int sqlite3BtreePrevious(BtCursor *pCur, int *pRes){
4676 assert( cursorHoldsMutex(pCur) );
4677 rc = restoreCursorPosition(pCur);
4681 pCur->atLast = 0;
4682 if( CURSOR_INVALID==pCur->eState ){
4686 if( pCur->skipNext<0 ){
4687 pCur->skipNext = 0;
4691 pCur->skipNext = 0;
4693 pPage = pCur->apPage[pCur->iPage];
4696 int idx = pCur->aiIdx[pCur->iPage];
4697 rc = moveToChild(pCur, get4byte(findCell(pPage, idx)));
4701 rc = moveToRightmost(pCur);
4703 while( pCur->aiIdx[pCur->iPage]==0 ){
4704 if( pCur->iPage==0 ){
4705 pCur->eState = CURSOR_INVALID;
4709 moveToParent(pCur);
4711 pCur->info.nSize = 0;
4712 pCur->validNKey = 0;
4714 pCur->aiIdx[pCur->iPage]--;
4715 pPage = pCur->apPage[pCur->iPage];
4717 rc = sqlite3BtreePrevious(pCur, pRes);
6496 ** The page that pCur currently points to has just been modified in
6505 static int balance(BtCursor *pCur){
6507 const int nMin = pCur->pBt->usableSize * 2 / 3;
6515 int iPage = pCur->iPage;
6516 MemPage *pPage = pCur->apPage[iPage];
6526 rc = balance_deeper(pPage, &pCur->apPage[1]);
6528 pCur->iPage = 1;
6529 pCur->aiIdx[0] = 0;
6530 pCur->aiIdx[1] = 0;
6531 assert( pCur->apPage[1]->nOverflow );
6539 MemPage * const pParent = pCur->apPage[iPage-1];
6540 int const iIdx = pCur->aiIdx[iPage-1];
6586 u8 *pSpace = sqlite3PageMalloc(pCur->pBt->pageSize);
6607 pCur->iPage--;
6628 ** MovetoUnpacked() to seek cursor pCur to (pKey, nKey) has already
6630 ** number if pCur points at an entry that is smaller than (pKey, nKey), or
6631 ** a positive value if pCur points at an etry that is larger than
6635 ** cursor pCur is pointing at the existing copy of a row that is to be
6636 ** overwritten. If the seekResult parameter is 0, then cursor pCur may
6641 BtCursor *pCur, /* Insert data into the table of this cursor */
6653 Btree *p = pCur->pBtree;
6658 if( pCur->eState==CURSOR_FAULT ){
6659 assert( pCur->skipNext!=SQLITE_OK );
6660 return pCur->skipNext;
6663 assert( cursorHoldsMutex(pCur) );
6664 assert( pCur->wrFlag && pBt->inTransaction==TRANS_WRITE && !pBt->readOnly );
6665 assert( hasSharedCacheTableLock(p, pCur->pgnoRoot, pCur->pKeyInfo!=0, 2) );
6672 assert( (pKey==0)==(pCur->pKeyInfo==0) );
6677 if( pCur->pKeyInfo==0 ){
6692 rc = saveAllCursors(pBt, pCur->pgnoRoot, pCur);
6695 rc = btreeMoveto(pCur, pKey, nKey, appendBias, &loc);
6698 assert( pCur->eState==CURSOR_VALID || (pCur->eState==CURSOR_INVALID && loc) );
6700 pPage = pCur->apPage[pCur->iPage];
6705 pCur->pgnoRoot, nKey, nData, pPage->pgno,
6715 idx = pCur->aiIdx[pCur->iPage];
6733 idx = ++pCur->aiIdx[pCur->iPage];
6760 pCur->info.nSize = 0;
6761 pCur->validNKey = 0;
6763 rc = balance(pCur);
6769 pCur->apPage[pCur->iPage]->nOverflow = 0;
6770 pCur->eState = CURSOR_INVALID;
6772 assert( pCur->apPage[pCur->iPage]->nOverflow==0 );
6782 int sqlite3BtreeDelete(BtCursor *pCur){
6783 Btree *p = pCur->pBtree;
6791 assert( cursorHoldsMutex(pCur) );
6794 assert( pCur->wrFlag );
6795 assert( hasSharedCacheTableLock(p, pCur->pgnoRoot, pCur->pKeyInfo!=0, 2) );
6796 assert( !hasReadConflicts(p, pCur->pgnoRoot) );
6798 if( NEVER(pCur->aiIdx[pCur->iPage]>=pCur->apPage[pCur->iPage]->nCell)
6799 || NEVER(pCur->eState!=CURSOR_VALID)
6806 if( pCur->pKeyInfo==0 ){
6807 invalidateIncrblobCursors(p, pCur->info.nKey, 0);
6810 iCellDepth = pCur->iPage;
6811 iCellIdx = pCur->aiIdx[iCellDepth];
6812 pPage = pCur->apPage[iCellDepth];
6824 rc = sqlite3BtreePrevious(pCur, &notUsed);
6833 rc = saveAllCursors(pBt, pCur->pgnoRoot, pCur);
6847 MemPage *pLeaf = pCur->apPage[pCur->iPage];
6849 Pgno n = pCur->apPage[iCellDepth+1]->pgno;
6871 ** pCur is pointing to the leaf page from which a cell was removed to
6880 rc = balance(pCur);
6881 if( rc==SQLITE_OK && pCur->iPage>iCellDepth ){
6882 while( pCur->iPage>iCellDepth ){
6883 releasePage(pCur->apPage[pCur->iPage--]);
6885 rc = balance(pCur);
6889 moveToRoot(pCur);
7324 ** The first argument, pCur, is a cursor opened on some b-tree. Count the
7331 int sqlite3BtreeCount(BtCursor *pCur, i64 *pnEntry){
7334 rc = moveToRoot(pCur);
7347 pPage = pCur->apPage[pCur->iPage];
7355 ** pCur->aiIdx[pCur->iPage] value is set to the index of the parent cell
7364 if( pCur->iPage==0 ){
7369 moveToParent(pCur);
7370 }while ( pCur->aiIdx[pCur->iPage]>=pCur->apPage[pCur->iPage]->nCell );
7372 pCur->aiIdx[pCur->iPage]++;
7373 pPage = pCur->apPage[pCur->iPage];
7379 iIdx = pCur->aiIdx[pCur->iPage];
7381 rc = moveToChild(pCur, get4byte(&pPage->aData[pPage->hdrOffset+8]));
7383 rc = moveToChild(pCur, get4byte(findCell(pPage, iIdx)));
8101 void sqlite3BtreeCacheOverflow(BtCursor *pCur){
8102 assert( cursorHoldsMutex(pCur) );
8103 assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) );
8104 invalidateOverflowCache(pCur);
8105 pCur->isIncrblobHandle = 1;