Lines Matching refs:pCur
6016 ** ^The current value of the requested parameter is written into *pCur
6026 SQLITE_API int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg);
45167 SQLITE_PRIVATE void sqlite3BtreeEnterCursor(BtCursor *pCur){
45168 sqlite3BtreeEnter(pCur->pBtree);
45170 SQLITE_PRIVATE void sqlite3BtreeLeaveCursor(BtCursor *pCur){
45171 sqlite3BtreeLeave(pCur->pBtree);
45799 ** Invalidate the overflow page-list cache for cursor pCur, if any.
45801 static void invalidateOverflowCache(BtCursor *pCur){
45802 assert( cursorHoldsMutex(pCur) );
45803 sqlite3_free(pCur->aOverflow);
45804 pCur->aOverflow = 0;
45932 static int saveCursorPosition(BtCursor *pCur){
45935 assert( CURSOR_VALID==pCur->eState );
45936 assert( 0==pCur->pKey );
45937 assert( cursorHoldsMutex(pCur) );
45939 rc = sqlite3BtreeKeySize(pCur, &pCur->nKey);
45943 ** stores the integer key in pCur->nKey. In this case this value is
45944 ** all that is required. Otherwise, if pCur is not open on an intKey
45945 ** table, then malloc space for and store the pCur->nKey bytes of key
45948 if( 0==pCur->apPage[0]->intKey ){
45949 void *pKey = sqlite3Malloc( (int)pCur->nKey );
45951 rc = sqlite3BtreeKey(pCur, 0, (int)pCur->nKey, pKey);
45953 pCur->pKey = pKey;
45961 assert( !pCur->apPage[0]->intKey || !pCur->pKey );
45965 for(i=0; i<=pCur->iPage; i++){
45966 releasePage(pCur->apPage[i]);
45967 pCur->apPage[i] = 0;
45969 pCur->iPage = -1;
45970 pCur->eState = CURSOR_REQUIRESEEK;
45973 invalidateOverflowCache(pCur);
46001 SQLITE_PRIVATE void sqlite3BtreeClearCursor(BtCursor *pCur){
46002 assert( cursorHoldsMutex(pCur) );
46003 sqlite3_free(pCur->pKey);
46004 pCur->pKey = 0;
46005 pCur->eState = CURSOR_INVALID;
46014 BtCursor *pCur, /* Cursor open on the btree to be searched */
46026 pIdxKey = sqlite3VdbeRecordUnpack(pCur->pKeyInfo, (int)nKey, pKey,
46032 rc = sqlite3BtreeMovetoUnpacked(pCur, pIdxKey, nKey, bias, pRes);
46046 static int btreeRestoreCursorPosition(BtCursor *pCur){
46048 assert( cursorHoldsMutex(pCur) );
46049 assert( pCur->eState>=CURSOR_REQUIRESEEK );
46050 if( pCur->eState==CURSOR_FAULT ){
46051 return pCur->skipNext;
46053 pCur->eState = CURSOR_INVALID;
46054 rc = btreeMoveto(pCur, pCur->pKey, pCur->nKey, 0, &pCur->skipNext);
46056 sqlite3_free(pCur->pKey);
46057 pCur->pKey = 0;
46058 assert( pCur->eState==CURSOR_VALID || pCur->eState==CURSOR_INVALID );
46076 SQLITE_PRIVATE int sqlite3BtreeCursorHasMoved(BtCursor *pCur, int *pHasMoved){
46079 rc = restoreCursorPosition(pCur);
46084 if( pCur->eState!=CURSOR_VALID || pCur->skipNext!=0 ){
47382 BtCursor *pCur;
47387 pCur = pBt->pCursor;
47388 while( pCur ){
47389 BtCursor *pTmp = pCur;
47390 pCur = pCur->pNext;
48588 BtCursor *pCur;
48590 for(pCur=pBt->pCursor; pCur; pCur=pCur->pNext){
48591 if( pCur->wrFlag && pCur->eState!=CURSOR_FAULT ) r++;
48791 ** on pCur to initialize the memory space prior to invoking this routine.
48798 BtCursor *pCur /* Space for new cursor */
48826 pCur->pgnoRoot = (Pgno)iTable;
48827 pCur->iPage = -1;
48828 pCur->pKeyInfo = pKeyInfo;
48829 pCur->pBtree = p;
48830 pCur->pBt = pBt;
48831 pCur->wrFlag = (u8)wrFlag;
48832 pCur->pNext = pBt->pCursor;
48833 if( pCur->pNext ){
48834 pCur->pNext->pPrev = pCur;
48836 pBt->pCursor = pCur;
48837 pCur->eState = CURSOR_INVALID;
48838 pCur->cachedRowid = 0;
48846 BtCursor *pCur /* Write new cursor here */
48850 rc = btreeCursor(p, iTable, wrFlag, pKeyInfo, pCur);
48881 ** as pCur and having the same root page number as pCur. The value is
48891 SQLITE_PRIVATE void sqlite3BtreeSetCachedRowid(BtCursor *pCur, sqlite3_int64 iRowid){
48893 for(p=pCur->pBt->pCursor; p; p=p->pNext){
48894 if( p->pgnoRoot==pCur->pgnoRoot ) p->cachedRowid = iRowid;
48896 assert( pCur->cachedRowid==iRowid );
48905 SQLITE_PRIVATE sqlite3_int64 sqlite3BtreeGetCachedRowid(BtCursor *pCur){
48906 return pCur->cachedRowid;
48913 SQLITE_PRIVATE int sqlite3BtreeCloseCursor(BtCursor *pCur){
48914 Btree *pBtree = pCur->pBtree;
48917 BtShared *pBt = pCur->pBt;
48919 sqlite3BtreeClearCursor(pCur);
48920 if( pCur->pPrev ){
48921 pCur->pPrev->pNext = pCur->pNext;
48923 pBt->pCursor = pCur->pNext;
48925 if( pCur->pNext ){
48926 pCur->pNext->pPrev = pCur->pPrev;
48928 for(i=0; i<=pCur->iPage; i++){
48929 releasePage(pCur->apPage[i]);
48932 invalidateOverflowCache(pCur);
48933 /* sqlite3_free(pCur); */
48955 static void assertCellInfo(BtCursor *pCur){
48957 int iPage = pCur->iPage;
48959 btreeParseCell(pCur->apPage[iPage], pCur->aiIdx[iPage], &info);
48960 assert( memcmp(&info, &pCur->info, sizeof(info))==0 );
48967 static void getCellInfo(BtCursor *pCur){
48968 if( pCur->info.nSize==0 ){
48969 int iPage = pCur->iPage;
48970 btreeParseCell(pCur->apPage[iPage],pCur->aiIdx[iPage],&pCur->info);
48971 pCur->validNKey = 1;
48973 assertCellInfo(pCur);
48978 #define getCellInfo(pCur) \
48979 if( pCur->info.nSize==0 ){ \
48980 int iPage = pCur->iPage; \
48981 btreeParseCell(pCur->apPage[iPage],pCur->aiIdx[iPage],&pCur->info); \
48982 pCur->validNKey = 1; \
48984 assertCellInfo(pCur); \
48994 SQLITE_PRIVATE int sqlite3BtreeCursorIsValid(BtCursor *pCur){
48995 return pCur && pCur->eState==CURSOR_VALID;
49011 SQLITE_PRIVATE int sqlite3BtreeKeySize(BtCursor *pCur, i64 *pSize){
49012 assert( cursorHoldsMutex(pCur) );
49013 assert( pCur->eState==CURSOR_INVALID || pCur->eState==CURSOR_VALID );
49014 if( pCur->eState!=CURSOR_VALID ){
49017 getCellInfo(pCur);
49018 *pSize = pCur->info.nKey;
49035 SQLITE_PRIVATE int sqlite3BtreeDataSize(BtCursor *pCur, u32 *pSize){
49036 assert( cursorHoldsMutex(pCur) );
49037 assert( pCur->eState==CURSOR_VALID );
49038 getCellInfo(pCur);
49039 *pSize = pCur->info.nData;
49153 ** for the entry that the pCur cursor is pointing to. If the eOp
49180 BtCursor *pCur, /* Cursor pointing to entry to read from */
49190 MemPage *pPage = pCur->apPage[pCur->iPage]; /* Btree page of current entry */
49191 BtShared *pBt = pCur->pBt; /* Btree this cursor belongs to */
49194 assert( pCur->eState==CURSOR_VALID );
49195 assert( pCur->aiIdx[pCur->iPage]<pPage->nCell );
49196 assert( cursorHoldsMutex(pCur) );
49198 getCellInfo(pCur);
49199 aPayload = pCur->info.pCell + pCur->info.nHeader;
49200 nKey = (pPage->intKey ? 0 : (int)pCur->info.nKey);
49202 if( NEVER(offset+amt > nKey+pCur->info.nData)
49203 || &aPayload[pCur->info.nLocal] > &pPage->aData[pBt->usableSize]
49210 if( offset<pCur->info.nLocal ){
49212 if( a+offset>pCur->info.nLocal ){
49213 a = pCur->info.nLocal - offset;
49220 offset -= pCur->info.nLocal;
49227 nextPage = get4byte(&aPayload[pCur->info.nLocal]);
49237 if( pCur->isIncrblobHandle && !pCur->aOverflow ){
49238 int nOvfl = (pCur->info.nPayload-pCur->info.nLocal+ovflSize-1)/ovflSize;
49239 pCur->aOverflow = (Pgno *)sqlite3MallocZero(sizeof(Pgno)*nOvfl);
49242 if( ALWAYS(nOvfl) && !pCur->aOverflow ){
49251 if( pCur->aOverflow && pCur->aOverflow[offset/ovflSize] ){
49253 nextPage = pCur->aOverflow[iIdx];
49262 if( pCur->aOverflow ){
49263 assert(!pCur->aOverflow[iIdx] || pCur->aOverflow[iIdx]==nextPage);
49264 pCur->aOverflow[iIdx] = nextPage;
49276 if( pCur->aOverflow && pCur->aOverflow[iIdx+1] ){
49277 nextPage = pCur->aOverflow[iIdx+1];
49312 ** Read part of the key associated with cursor pCur. Exactly
49316 ** The caller must ensure that pCur is pointing to a valid row
49323 SQLITE_PRIVATE int sqlite3BtreeKey(BtCursor *pCur, u32 offset, u32 amt, void *pBuf){
49324 assert( cursorHoldsMutex(pCur) );
49325 assert( pCur->eState==CURSOR_VALID );
49326 assert( pCur->iPage>=0 && pCur->apPage[pCur->iPage] );
49327 assert( pCur->aiIdx[pCur->iPage]<pCur->apPage[pCur->iPage]->nCell );
49328 return accessPayload(pCur, offset, amt, (unsigned char*)pBuf, 0);
49332 ** Read part of the data associated with cursor pCur. Exactly
49340 SQLITE_PRIVATE int sqlite3BtreeData(BtCursor *pCur, u32 offset, u32 amt, void *pBuf){
49344 if ( pCur->eState==CURSOR_INVALID ){
49349 assert( cursorHoldsMutex(pCur) );
49350 rc = restoreCursorPosition(pCur);
49352 assert( pCur->eState==CURSOR_VALID );
49353 assert( pCur->iPage>=0 && pCur->apPage[pCur->iPage] );
49354 assert( pCur->aiIdx[pCur->iPage]<pCur->apPage[pCur->iPage]->nCell );
49355 rc = accessPayload(pCur, offset, amt, pBuf, 0);
49362 ** pCur cursor is pointing to. The pointer is to the beginning of
49380 BtCursor *pCur, /* Cursor pointing to entry to read from */
49389 assert( pCur!=0 && pCur->iPage>=0 && pCur->apPage[pCur->iPage]);
49390 assert( pCur->eState==CURSOR_VALID );
49391 assert( cursorHoldsMutex(pCur) );
49392 pPage = pCur->apPage[pCur->iPage];
49393 assert( pCur->aiIdx[pCur->iPage]<pPage->nCell );
49394 if( NEVER(pCur->info.nSize==0) ){
49395 btreeParseCell(pCur->apPage[pCur->iPage], pCur->aiIdx[pCur->iPage],
49396 &pCur->info);
49398 aPayload = pCur->info.pCell;
49399 aPayload += pCur->info.nHeader;
49403 nKey = (int)pCur->info.nKey;
49407 nLocal = pCur->info.nLocal - nKey;
49409 nLocal = pCur->info.nLocal;
49418 ** For the entry that cursor pCur is point to, return as
49431 SQLITE_PRIVATE const void *sqlite3BtreeKeyFetch(BtCursor *pCur, int *pAmt){
49433 assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) );
49434 assert( cursorHoldsMutex(pCur) );
49435 if( ALWAYS(pCur->eState==CURSOR_VALID) ){
49436 p = (const void*)fetchPayload(pCur, pAmt, 0);
49440 SQLITE_PRIVATE const void *sqlite3BtreeDataFetch(BtCursor *pCur, int *pAmt){
49442 assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) );
49443 assert( cursorHoldsMutex(pCur) );
49444 if( ALWAYS(pCur->eState==CURSOR_VALID) ){
49445 p = (const void*)fetchPayload(pCur, pAmt, 1);
49460 static int moveToChild(BtCursor *pCur, u32 newPgno){
49462 int i = pCur->iPage;
49464 BtShared *pBt = pCur->pBt;
49466 assert( cursorHoldsMutex(pCur) );
49467 assert( pCur->eState==CURSOR_VALID );
49468 assert( pCur->iPage<BTCURSOR_MAX_DEPTH );
49469 if( pCur->iPage>=(BTCURSOR_MAX_DEPTH-1) ){
49474 pCur->apPage[i+1] = pNewPage;
49475 pCur->aiIdx[i+1] = 0;
49476 pCur->iPage++;
49478 pCur->info.nSize = 0;
49479 pCur->validNKey = 0;
49480 if( pNewPage->nCell<1 || pNewPage->intKey!=pCur->apPage[i]->intKey ){
49509 ** pCur->idx is set to the cell index that contains the pointer
49511 ** right-most child page then pCur->idx is set to one more than
49514 static void moveToParent(BtCursor *pCur){
49515 assert( cursorHoldsMutex(pCur) );
49516 assert( pCur->eState==CURSOR_VALID );
49517 assert( pCur->iPage>0 );
49518 assert( pCur->apPage[pCur->iPage] );
49520 pCur->apPage[pCur->iPage-1],
49521 pCur->aiIdx[pCur->iPage-1],
49522 pCur->apPage[pCur->iPage]->pgno
49524 releasePage(pCur->apPage[pCur->iPage]);
49525 pCur->iPage--;
49526 pCur->info.nSize = 0;
49527 pCur->validNKey = 0;
49551 static int moveToRoot(BtCursor *pCur){
49554 Btree *p = pCur->pBtree;
49557 assert( cursorHoldsMutex(pCur) );
49561 if( pCur->eState>=CURSOR_REQUIRESEEK ){
49562 if( pCur->eState==CURSOR_FAULT ){
49563 assert( pCur->skipNext!=SQLITE_OK );
49564 return pCur->skipNext;
49566 sqlite3BtreeClearCursor(pCur);
49569 if( pCur->iPage>=0 ){
49571 for(i=1; i<=pCur->iPage; i++){
49572 releasePage(pCur->apPage[i]);
49574 pCur->iPage = 0;
49576 rc = getAndInitPage(pBt, pCur->pgnoRoot, &pCur->apPage[0]);
49578 pCur->eState = CURSOR_INVALID;
49581 pCur->iPage = 0;
49583 /* If pCur->pKeyInfo is not NULL, then the caller that opened this cursor
49587 assert( pCur->apPage[0]->intKey==1 || pCur->apPage[0]->intKey==0 );
49588 if( (pCur->pKeyInfo==0)!=pCur->apPage[0]->intKey ){
49599 pRoot = pCur->apPage[0];
49600 assert( pRoot->pgno==pCur->pgnoRoot );
49601 assert( pRoot->isInit && (pCur->pKeyInfo==0)==pRoot->intKey );
49603 pCur->aiIdx[0] = 0;
49604 pCur->info.nSize = 0;
49605 pCur->atLast = 0;
49606 pCur->validNKey = 0;
49612 pCur->eState = CURSOR_VALID;
49613 rc = moveToChild(pCur, subpage);
49615 pCur->eState = ((pRoot->nCell>0)?CURSOR_VALID:CURSOR_INVALID);
49627 static int moveToLeftmost(BtCursor *pCur){
49632 assert( cursorHoldsMutex(pCur) );
49633 assert( pCur->eState==CURSOR_VALID );
49634 while( rc==SQLITE_OK && !(pPage = pCur->apPage[pCur->iPage])->leaf ){
49635 assert( pCur->aiIdx[pCur->iPage]<pPage->nCell );
49636 pgno = get4byte(findCell(pPage, pCur->aiIdx[pCur->iPage]));
49637 rc = moveToChild(pCur, pgno);
49652 static int moveToRightmost(BtCursor *pCur){
49657 assert( cursorHoldsMutex(pCur) );
49658 assert( pCur->eState==CURSOR_VALID );
49659 while( rc==SQLITE_OK && !(pPage = pCur->apPage[pCur->iPage])->leaf ){
49661 pCur->aiIdx[pCur->iPage] = pPage->nCell;
49662 rc = moveToChild(pCur, pgno);
49665 pCur->aiIdx[pCur->iPage] = pPage->nCell-1;
49666 pCur->info.nSize = 0;
49667 pCur->validNKey = 0;
49676 SQLITE_PRIVATE int sqlite3BtreeFirst(BtCursor *pCur, int *pRes){
49679 assert( cursorHoldsMutex(pCur) );
49680 assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) );
49681 rc = moveToRoot(pCur);
49683 if( pCur->eState==CURSOR_INVALID ){
49684 assert( pCur->apPage[pCur->iPage]->nCell==0 );
49687 assert( pCur->apPage[pCur->iPage]->nCell>0 );
49689 rc = moveToLeftmost(pCur);
49699 SQLITE_PRIVATE int sqlite3BtreeLast(BtCursor *pCur, int *pRes){
49702 assert( cursorHoldsMutex(pCur) );
49703 assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) );
49706 if( CURSOR_VALID==pCur->eState && pCur->atLast ){
49711 for(ii=0; ii<pCur->iPage; ii++){
49712 assert( pCur->aiIdx[ii]==pCur->apPage[ii]->nCell );
49714 assert( pCur->aiIdx[pCur->iPage]==pCur->apPage[pCur->iPage]->nCell-1 );
49715 assert( pCur->apPage[pCur->iPage]->leaf );
49720 rc = moveToRoot(pCur);
49722 if( CURSOR_INVALID==pCur->eState ){
49723 assert( pCur->apPage[pCur->iPage]->nCell==0 );
49726 assert( pCur->eState==CURSOR_VALID );
49728 rc = moveToRightmost(pCur);
49729 pCur->atLast = rc==SQLITE_OK ?1:0;
49764 BtCursor *pCur, /* The cursor to be moved */
49772 assert( cursorHoldsMutex(pCur) );
49773 assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) );
49775 assert( (pIdxKey==0)==(pCur->pKeyInfo==0) );
49779 if( pCur->eState==CURSOR_VALID && pCur->validNKey
49780 && pCur->apPage[0]->intKey
49782 if( pCur->info.nKey==intKey ){
49786 if( pCur->atLast && pCur->info.nKey<intKey ){
49792 rc = moveToRoot(pCur);
49796 assert( pCur->apPage[pCur->iPage] );
49797 assert( pCur->apPage[pCur->iPage]->isInit );
49798 assert( pCur->apPage[pCur->iPage]->nCell>0 || pCur->eState==CURSOR_INVALID );
49799 if( pCur->eState==CURSOR_INVALID ){
49801 assert( pCur->apPage[pCur->iPage]->nCell==0 );
49804 assert( pCur->apPage[0]->intKey || pIdxKey );
49808 MemPage *pPage = pCur->apPage[pCur->iPage];
49822 pCur->aiIdx[pCur->iPage] = (u16)upr;
49824 pCur->aiIdx[pCur->iPage] = (u16)((upr+lwr)/2);
49827 int idx = pCur->aiIdx[pCur->iPage]; /* Index of current cell in pPage */
49830 pCur->info.nSize = 0;
49847 pCur->validNKey = 1;
49848 pCur->info.nKey = nCellKey;
49877 btreeParseCellPtr(pPage, pCellBody, &pCur->info);
49878 nCell = (int)pCur->info.nKey;
49884 rc = accessPayload(pCur, 0, nCell, (unsigned char*)pCellKey, 0);
49912 pCur->aiIdx[pCur->iPage] = (u16)((lwr+upr)/2);
49924 assert( pCur->aiIdx[pCur->iPage]<pCur->apPage[pCur->iPage]->nCell );
49929 pCur->aiIdx[pCur->iPage] = (u16)lwr;
49930 pCur->info.nSize = 0;
49931 pCur->validNKey = 0;
49932 rc = moveToChild(pCur, chldPg);
49947 SQLITE_PRIVATE int sqlite3BtreeEof(BtCursor *pCur){
49952 return (CURSOR_VALID!=pCur->eState);
49961 SQLITE_PRIVATE int sqlite3BtreeNext(BtCursor *pCur, int *pRes){
49966 assert( cursorHoldsMutex(pCur) );
49967 rc = restoreCursorPosition(pCur);
49972 if( CURSOR_INVALID==pCur->eState ){
49976 if( pCur->skipNext>0 ){
49977 pCur->skipNext = 0;
49981 pCur->skipNext = 0;
49983 pPage = pCur->apPage[pCur->iPage];
49984 idx = ++pCur->aiIdx[pCur->iPage];
49988 pCur->info.nSize = 0;
49989 pCur->validNKey = 0;
49992 rc = moveToChild(pCur, get4byte(&pPage->aData[pPage->hdrOffset+8]));
49994 rc = moveToLeftmost(pCur);
49999 if( pCur->iPage==0 ){
50001 pCur->eState = CURSOR_INVALID;
50004 moveToParent(pCur);
50005 pPage = pCur->apPage[pCur->iPage];
50006 }while( pCur->aiIdx[pCur->iPage]>=pPage->nCell );
50009 rc = sqlite3BtreeNext(pCur, pRes);
50019 rc = moveToLeftmost(pCur);
50030 SQLITE_PRIVATE int sqlite3BtreePrevious(BtCursor *pCur, int *pRes){
50034 assert( cursorHoldsMutex(pCur) );
50035 rc = restoreCursorPosition(pCur);
50039 pCur->atLast = 0;
50040 if( CURSOR_INVALID==pCur->eState ){
50044 if( pCur->skipNext<0 ){
50045 pCur->skipNext = 0;
50049 pCur->skipNext = 0;
50051 pPage = pCur->apPage[pCur->iPage];
50054 int idx = pCur->aiIdx[pCur->iPage];
50055 rc = moveToChild(pCur, get4byte(findCell(pPage, idx)));
50059 rc = moveToRightmost(pCur);
50061 while( pCur->aiIdx[pCur->iPage]==0 ){
50062 if( pCur->iPage==0 ){
50063 pCur->eState = CURSOR_INVALID;
50067 moveToParent(pCur);
50069 pCur->info.nSize = 0;
50070 pCur->validNKey = 0;
50072 pCur->aiIdx[pCur->iPage]--;
50073 pPage = pCur->apPage[pCur->iPage];
50075 rc = sqlite3BtreePrevious(pCur, pRes);
51859 ** The page that pCur currently points to has just been modified in
51868 static int balance(BtCursor *pCur){
51870 const int nMin = pCur->pBt->usableSize * 2 / 3;
51878 int iPage = pCur->iPage;
51879 MemPage *pPage = pCur->apPage[iPage];
51889 rc = balance_deeper(pPage, &pCur->apPage[1]);
51891 pCur->iPage = 1;
51892 pCur->aiIdx[0] = 0;
51893 pCur->aiIdx[1] = 0;
51894 assert( pCur->apPage[1]->nOverflow );
51902 MemPage * const pParent = pCur->apPage[iPage-1];
51903 int const iIdx = pCur->aiIdx[iPage-1];
51949 u8 *pSpace = sqlite3PageMalloc(pCur->pBt->pageSize);
51970 pCur->iPage--;
51991 ** MovetoUnpacked() to seek cursor pCur to (pKey, nKey) has already
51993 ** number if pCur points at an entry that is smaller than (pKey, nKey), or
51994 ** a positive value if pCur points at an etry that is larger than
51998 ** cursor pCur is pointing at the existing copy of a row that is to be
51999 ** overwritten. If the seekResult parameter is 0, then cursor pCur may
52004 BtCursor *pCur, /* Insert data into the table of this cursor */
52016 Btree *p = pCur->pBtree;
52021 if( pCur->eState==CURSOR_FAULT ){
52022 assert( pCur->skipNext!=SQLITE_OK );
52023 return pCur->skipNext;
52026 assert( cursorHoldsMutex(pCur) );
52027 assert( pCur->wrFlag && pBt->inTransaction==TRANS_WRITE && !pBt->readOnly );
52028 assert( hasSharedCacheTableLock(p, pCur->pgnoRoot, pCur->pKeyInfo!=0, 2) );
52035 assert( (pKey==0)==(pCur->pKeyInfo==0) );
52040 if( pCur->pKeyInfo==0 ){
52055 pCur->pgnoRoot, pCur);
52058 rc = btreeMoveto(pCur, pKey, nKey, appendBias, &loc);
52061 assert( pCur->eState==CURSOR_VALID || (pCur->eState==CURSOR_INVALID && loc) );
52063 pPage = pCur->apPage[pCur->iPage];
52068 pCur->pgnoRoot, nKey, nData, pPage->pgno,
52078 idx = pCur->aiIdx[pCur->iPage];
52096 idx = ++pCur->aiIdx[pCur->iPage];
52123 pCur->info.nSize = 0;
52124 pCur->validNKey = 0;
52126 rc = balance(pCur);
52132 pCur->apPage[pCur->iPage]->nOverflow = 0;
52133 pCur->eState = CURSOR_INVALID;
52135 assert( pCur->apPage[pCur->iPage]->nOverflow==0 );
52145 SQLITE_PRIVATE int sqlite3BtreeDelete(BtCursor *pCur){
52146 Btree *p = pCur->pBtree;
52154 assert( cursorHoldsMutex(pCur) );
52157 assert( pCur->wrFlag );
52158 assert( hasSharedCacheTableLock(p, pCur->pgnoRoot, pCur->pKeyInfo!=0, 2) );
52159 assert( !hasReadConflicts(p, pCur->pgnoRoot) );
52161 if( NEVER(pCur->aiIdx[pCur->iPage]>=pCur->apPage[pCur->iPage]->nCell)
52162 || NEVER(pCur->eState!=CURSOR_VALID)
52169 if( pCur->pKeyInfo==0 ){
52170 invalidateIncrblobCursors(p, pCur->info.nKey, 0);
52173 iCellDepth = pCur->iPage;
52174 iCellIdx = pCur->aiIdx[iCellDepth];
52175 pPage = pCur->apPage[iCellDepth];
52187 rc = sqlite3BtreePrevious(pCur, ¬Used);
52196 rc = saveAllCursors(pBt, pCur->pgnoRoot, pCur);
52210 MemPage *pLeaf = pCur->apPage[pCur->iPage];
52212 Pgno n = pCur->apPage[iCellDepth+1]->pgno;
52234 ** pCur is pointing to the leaf page from which a cell was removed to
52243 rc = balance(pCur);
52244 if( rc==SQLITE_OK && pCur->iPage>iCellDepth ){
52245 while( pCur->iPage>iCellDepth ){
52246 releasePage(pCur->apPage[pCur->iPage--]);
52248 rc = balance(pCur);
52252 moveToRoot(pCur);
52687 ** The first argument, pCur, is a cursor opened on some b-tree. Count the
52694 SQLITE_PRIVATE int sqlite3BtreeCount(BtCursor *pCur, i64 *pnEntry){
52697 rc = moveToRoot(pCur);
52710 pPage = pCur->apPage[pCur->iPage];
52718 ** pCur->aiIdx[pCur->iPage] value is set to the index of the parent cell
52727 if( pCur->iPage==0 ){
52732 moveToParent(pCur);
52733 }while ( pCur->aiIdx[pCur->iPage]>=pCur->apPage[pCur->iPage]->nCell );
52735 pCur->aiIdx[pCur->iPage]++;
52736 pPage = pCur->apPage[pCur->iPage];
52742 iIdx = pCur->aiIdx[pCur->iPage];
52744 rc = moveToChild(pCur, get4byte(&pPage->aData[pPage->hdrOffset+8]));
52746 rc = moveToChild(pCur, get4byte(findCell(pPage, iIdx)));
53462 SQLITE_PRIVATE void sqlite3BtreeCacheOverflow(BtCursor *pCur){
53463 assert( cursorHoldsMutex(pCur) );
53464 assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) );
53465 invalidateOverflowCache(pCur);
53466 pCur->isIncrblobHandle = 1;
55052 ** The data or key is taken from the entry that pCur is currently pointing
55064 BtCursor *pCur, /* Cursor pointing at record to retrieve. */
55074 assert( sqlite3BtreeCursorIsValid(pCur) );
55080 zData = (char *)sqlite3BtreeKeyFetch(pCur, &available);
55082 zData = (char *)sqlite3BtreeDataFetch(pCur, &available);
55095 rc = sqlite3BtreeKey(pCur, offset, amt, pMem->z);
55097 rc = sqlite3BtreeData(pCur, offset, amt, pMem->z);
58278 ** pCur points at an index entry created using the OP_MakeRecord opcode.
58282 ** pCur might be pointing to text obtained from a corrupt database file.
58285 SQLITE_PRIVATE int sqlite3VdbeIdxRowid(sqlite3 *db, BtCursor *pCur, i64 *rowid){
58300 assert( sqlite3BtreeCursorIsValid(pCur) );
58301 rc = sqlite3BtreeKeySize(pCur, &nCellKey);
58302 assert( rc==SQLITE_OK ); /* pCur is always valid so KeySize cannot fail */
58307 rc = sqlite3VdbeMemFromBtree(pCur, 0, (int)nCellKey, 1, &m);
58372 BtCursor *pCur = pC->pCursor;
58375 assert( sqlite3BtreeCursorIsValid(pCur) );
58376 rc = sqlite3BtreeKeySize(pCur, &nCellKey);
58377 assert( rc==SQLITE_OK ); /* pCur is always valid so KeySize cannot fail */
60737 VdbeCursor *pCur;
60933 VdbeCursor *pCur;
60946 VdbeCursor *pCur;
60961 VdbeCursor *pCur;
63441 VdbeCursor *pCur;
63492 u.aw.pCur = allocateCursor(p, pOp->p1, u.aw.nField, u.aw.iDb, 1);
63493 if( u.aw.pCur==0 ) goto no_mem;
63494 u.aw.pCur->nullRow = 1;
63495 u.aw.pCur->isOrdered = 1;
63496 rc = sqlite3BtreeCursor(u.aw.pX, u.aw.p2, u.aw.wrFlag, u.aw.pKeyInfo, u.aw.pCur->pCursor);
63497 u.aw.pCur->pKeyInfo = u.aw.pKeyInfo;
63505 u.aw.pCur->pCursor = 0;
63513 u.aw.pCur->isTable = pOp->p4type!=P4_KEYINFO;
63514 u.aw.pCur->isIndex = !u.aw.pCur->isTable;
66016 VdbeCursor *pCur;
66022 u.cg.pCur = 0;
66034 u.cg.pCur = allocateCursor(p, pOp->p1, 0, -1, 0);
66035 if( u.cg.pCur ){
66036 u.cg.pCur->pVtabCursor = u.cg.pVtabCursor;
66037 u.cg.pCur->pModule = u.cg.pVtabCursor->pVtab->pModule;
66075 VdbeCursor *pCur;
66083 u.ch.pCur = p->apCsr[pOp->p1];
66086 assert( u.ch.pCur->pVtabCursor );
66087 u.ch.pVtabCursor = u.ch.pCur->pVtabCursor;
66117 u.ch.pCur->nullRow = 0;
66138 VdbeCursor *pCur = p->apCsr[pOp->p1];
66139 assert( pCur->pVtabCursor );
66143 if( pCur->nullRow ){
66147 u.ci.pVtab = pCur->pVtabCursor->pVtab;
66160 rc = u.ci.pModule->xColumn(pCur->pVtabCursor, &u.ci.sContext, pOp->p2);
66194 VdbeCursor *pCur;
66198 u.cj.pCur = p->apCsr[pOp->p1];
66199 assert( u.cj.pCur->pVtabCursor );
66200 if( u.cj.pCur->nullRow ){
66203 u.cj.pVtab = u.cj.pCur->pVtabCursor->pVtab;
66214 rc = u.cj.pModule->xNext(u.cj.pCur->pVtabCursor);
66218 u.cj.res = u.cj.pModule->xEof(u.cj.pCur->pVtabCursor);