Lines Matching refs:pCur
135 RbtCursor* pCur,
141 static int memRbtreeNext(RbtCursor* pCur, int *pRes);
142 static int memRbtreeLast(RbtCursor* pCur, int *pRes);
143 static int memRbtreePrevious(RbtCursor* pCur, int *pRes);
160 static int checkReadLocks(RbtCursor *pCur){ in checkReadLocks() argument
162 assert( pCur->wrFlag ); in checkReadLocks()
163 for(p=pCur->pTree->pCursors; p; p=p->pShared){ in checkReadLocks()
164 if( p!=pCur ){ in checkReadLocks()
690 static int memRbtreeKeyCompare(RbtCursor* pCur, const void *pKey, int nKey, in memRbtreeKeyCompare() argument
693 assert(pCur); in memRbtreeKeyCompare()
695 if( !pCur->pNode ) { in memRbtreeKeyCompare()
698 if( (pCur->pNode->nKey - nIgnore) < 0 ){ in memRbtreeKeyCompare()
701 *pRes = key_compare(pCur->pNode->pKey, pCur->pNode->nKey-nIgnore, in memRbtreeKeyCompare()
720 RbtCursor *pCur; in memRbtreeCursor() local
722 pCur = *ppCur = sqliteMalloc(sizeof(RbtCursor)); in memRbtreeCursor()
724 pCur->pTree = sqliteHashFind(&tree->tblHash, 0, iTable); in memRbtreeCursor()
725 assert( pCur->pTree ); in memRbtreeCursor()
726 pCur->pRbtree = tree; in memRbtreeCursor()
727 pCur->iTree = iTable; in memRbtreeCursor()
728 pCur->pOps = &sqliteRbtreeCursorOps; in memRbtreeCursor()
729 pCur->wrFlag = wrFlag; in memRbtreeCursor()
730 pCur->pShared = pCur->pTree->pCursors; in memRbtreeCursor()
731 pCur->pTree->pCursors = pCur; in memRbtreeCursor()
746 RbtCursor* pCur, in memRbtreeInsert() argument
757 assert( pCur->pRbtree->eTransState != TRANS_NONE ); in memRbtreeInsert()
760 if( checkReadLocks(pCur) ){ in memRbtreeInsert()
781 memRbtreeMoveto( pCur, pKey, nKey, &match); in memRbtreeInsert()
791 if( pCur->pNode ){ in memRbtreeInsert()
794 assert( !pCur->pNode->pRight ); in memRbtreeInsert()
795 pNode->pParent = pCur->pNode; in memRbtreeInsert()
796 pCur->pNode->pRight = pNode; in memRbtreeInsert()
799 assert( !pCur->pNode->pLeft ); in memRbtreeInsert()
800 pNode->pParent = pCur->pNode; in memRbtreeInsert()
801 pCur->pNode->pLeft = pNode; in memRbtreeInsert()
807 pCur->pTree->pHead = pNode; in memRbtreeInsert()
811 pCur->pNode = pNode; in memRbtreeInsert()
814 do_insert_balancing(pCur->pTree, pNode); in memRbtreeInsert()
817 if( pCur->pRbtree->eTransState != TRANS_ROLLBACK ){ in memRbtreeInsert()
821 pOp->iTab = pCur->iTree; in memRbtreeInsert()
826 btreeLogRollbackOp(pCur->pRbtree, pOp); in memRbtreeInsert()
834 if( pCur->pRbtree->eTransState != TRANS_ROLLBACK ){ in memRbtreeInsert()
837 pOp->iTab = pCur->iTree; in memRbtreeInsert()
838 pOp->nKey = pCur->pNode->nKey; in memRbtreeInsert()
841 memcpy( pOp->pKey, pCur->pNode->pKey, pOp->nKey ); in memRbtreeInsert()
842 pOp->nData = pCur->pNode->nData; in memRbtreeInsert()
843 pOp->pData = pCur->pNode->pData; in memRbtreeInsert()
845 btreeLogRollbackOp(pCur->pRbtree, pOp); in memRbtreeInsert()
847 sqliteFree( pCur->pNode->pData ); in memRbtreeInsert()
851 pCur->pNode->pData = pData; in memRbtreeInsert()
852 pCur->pNode->nData = nData; in memRbtreeInsert()
872 RbtCursor* pCur, in memRbtreeMoveto() argument
879 pCur->pNode = pCur->pTree->pHead; in memRbtreeMoveto()
881 while( pCur->pNode && *pRes ) { in memRbtreeMoveto()
882 *pRes = key_compare(pCur->pNode->pKey, pCur->pNode->nKey, pKey, nKey); in memRbtreeMoveto()
883 pTmp = pCur->pNode; in memRbtreeMoveto()
886 pCur->pNode = pCur->pNode->pLeft; in memRbtreeMoveto()
889 pCur->pNode = pCur->pNode->pRight; in memRbtreeMoveto()
899 if( !pCur->pNode ) pCur->pNode = pTmp; in memRbtreeMoveto()
900 pCur->eSkip = SKIP_NONE; in memRbtreeMoveto()
920 static int memRbtreeDelete(RbtCursor* pCur) in memRbtreeDelete() argument
927 assert( pCur->pRbtree->eTransState != TRANS_NONE ); in memRbtreeDelete()
930 if( checkReadLocks(pCur) ){ in memRbtreeDelete()
934 pZ = pCur->pNode; in memRbtreeDelete()
941 if( pCur->pRbtree->eTransState != TRANS_ROLLBACK ){ in memRbtreeDelete()
944 pOp->iTab = pCur->iTree; in memRbtreeDelete()
950 btreeLogRollbackOp(pCur->pRbtree, pOp); in memRbtreeDelete()
962 pCur->eSkip = SKIP_NONE; in memRbtreeDelete()
963 memRbtreeNext(pCur, &dummy); in memRbtreeDelete()
965 if( pCur->pRbtree->eTransState == TRANS_ROLLBACK ){ in memRbtreeDelete()
969 pZ->pData = pCur->pNode->pData; in memRbtreeDelete()
970 pZ->nData = pCur->pNode->nData; in memRbtreeDelete()
971 pZ->pKey = pCur->pNode->pKey; in memRbtreeDelete()
972 pZ->nKey = pCur->pNode->nKey; in memRbtreeDelete()
974 pZ = pCur->pNode; in memRbtreeDelete()
975 pCur->pNode = pTmp; in memRbtreeDelete()
976 pCur->eSkip = SKIP_NEXT; in memRbtreeDelete()
979 pCur->eSkip = SKIP_NONE; in memRbtreeDelete()
980 memRbtreeNext(pCur, &res); in memRbtreeDelete()
981 pCur->eSkip = SKIP_NEXT; in memRbtreeDelete()
983 memRbtreeLast(pCur, &res); in memRbtreeDelete()
984 memRbtreePrevious(pCur, &res); in memRbtreeDelete()
985 pCur->eSkip = SKIP_PREV; in memRbtreeDelete()
987 if( pCur->pRbtree->eTransState == TRANS_ROLLBACK ){ in memRbtreeDelete()
1005 pCur->pTree->pHead = pChild; in memRbtreeDelete()
1016 do_delete_balancing(pCur->pTree, pChild, pZ->pParent); in memRbtreeDelete()
1071 static int memRbtreeFirst(RbtCursor* pCur, int *pRes) in memRbtreeFirst() argument
1073 if( pCur->pTree->pHead ){ in memRbtreeFirst()
1074 pCur->pNode = pCur->pTree->pHead; in memRbtreeFirst()
1075 while( pCur->pNode->pLeft ){ in memRbtreeFirst()
1076 pCur->pNode = pCur->pNode->pLeft; in memRbtreeFirst()
1079 if( pCur->pNode ){ in memRbtreeFirst()
1084 pCur->eSkip = SKIP_NONE; in memRbtreeFirst()
1088 static int memRbtreeLast(RbtCursor* pCur, int *pRes) in memRbtreeLast() argument
1090 if( pCur->pTree->pHead ){ in memRbtreeLast()
1091 pCur->pNode = pCur->pTree->pHead; in memRbtreeLast()
1092 while( pCur->pNode->pRight ){ in memRbtreeLast()
1093 pCur->pNode = pCur->pNode->pRight; in memRbtreeLast()
1096 if( pCur->pNode ){ in memRbtreeLast()
1101 pCur->eSkip = SKIP_NONE; in memRbtreeLast()
1111 static int memRbtreeNext(RbtCursor* pCur, int *pRes) in memRbtreeNext() argument
1113 if( pCur->pNode && pCur->eSkip != SKIP_NEXT ){ in memRbtreeNext()
1114 if( pCur->pNode->pRight ){ in memRbtreeNext()
1115 pCur->pNode = pCur->pNode->pRight; in memRbtreeNext()
1116 while( pCur->pNode->pLeft ) in memRbtreeNext()
1117 pCur->pNode = pCur->pNode->pLeft; in memRbtreeNext()
1119 BtRbNode * pX = pCur->pNode; in memRbtreeNext()
1120 pCur->pNode = pX->pParent; in memRbtreeNext()
1121 while( pCur->pNode && (pCur->pNode->pRight == pX) ){ in memRbtreeNext()
1122 pX = pCur->pNode; in memRbtreeNext()
1123 pCur->pNode = pX->pParent; in memRbtreeNext()
1127 pCur->eSkip = SKIP_NONE; in memRbtreeNext()
1129 if( !pCur->pNode ){ in memRbtreeNext()
1138 static int memRbtreePrevious(RbtCursor* pCur, int *pRes) in memRbtreePrevious() argument
1140 if( pCur->pNode && pCur->eSkip != SKIP_PREV ){ in memRbtreePrevious()
1141 if( pCur->pNode->pLeft ){ in memRbtreePrevious()
1142 pCur->pNode = pCur->pNode->pLeft; in memRbtreePrevious()
1143 while( pCur->pNode->pRight ) in memRbtreePrevious()
1144 pCur->pNode = pCur->pNode->pRight; in memRbtreePrevious()
1146 BtRbNode * pX = pCur->pNode; in memRbtreePrevious()
1147 pCur->pNode = pX->pParent; in memRbtreePrevious()
1148 while( pCur->pNode && (pCur->pNode->pLeft == pX) ){ in memRbtreePrevious()
1149 pX = pCur->pNode; in memRbtreePrevious()
1150 pCur->pNode = pX->pParent; in memRbtreePrevious()
1154 pCur->eSkip = SKIP_NONE; in memRbtreePrevious()
1156 if( !pCur->pNode ){ in memRbtreePrevious()
1165 static int memRbtreeKeySize(RbtCursor* pCur, int *pSize) in memRbtreeKeySize() argument
1167 if( pCur->pNode ){ in memRbtreeKeySize()
1168 *pSize = pCur->pNode->nKey; in memRbtreeKeySize()
1175 static int memRbtreeKey(RbtCursor* pCur, int offset, int amt, char *zBuf) in memRbtreeKey() argument
1177 if( !pCur->pNode ) return 0; in memRbtreeKey()
1178 if( !pCur->pNode->pKey || ((amt + offset) <= pCur->pNode->nKey) ){ in memRbtreeKey()
1179 memcpy(zBuf, ((char*)pCur->pNode->pKey)+offset, amt); in memRbtreeKey()
1181 memcpy(zBuf, ((char*)pCur->pNode->pKey)+offset, pCur->pNode->nKey-offset); in memRbtreeKey()
1182 amt = pCur->pNode->nKey-offset; in memRbtreeKey()
1187 static int memRbtreeDataSize(RbtCursor* pCur, int *pSize) in memRbtreeDataSize() argument
1189 if( pCur->pNode ){ in memRbtreeDataSize()
1190 *pSize = pCur->pNode->nData; in memRbtreeDataSize()
1197 static int memRbtreeData(RbtCursor *pCur, int offset, int amt, char *zBuf) in memRbtreeData() argument
1199 if( !pCur->pNode ) return 0; in memRbtreeData()
1200 if( (amt + offset) <= pCur->pNode->nData ){ in memRbtreeData()
1201 memcpy(zBuf, ((char*)pCur->pNode->pData)+offset, amt); in memRbtreeData()
1203 memcpy(zBuf, ((char*)pCur->pNode->pData)+offset ,pCur->pNode->nData-offset); in memRbtreeData()
1204 amt = pCur->pNode->nData-offset; in memRbtreeData()
1209 static int memRbtreeCloseCursor(RbtCursor* pCur) in memRbtreeCloseCursor() argument
1211 if( pCur->pTree->pCursors==pCur ){ in memRbtreeCloseCursor()
1212 pCur->pTree->pCursors = pCur->pShared; in memRbtreeCloseCursor()
1214 RbtCursor *p = pCur->pTree->pCursors; in memRbtreeCloseCursor()
1215 while( p && p->pShared!=pCur ){ p = p->pShared; } in memRbtreeCloseCursor()
1218 p->pShared = pCur->pShared; in memRbtreeCloseCursor()
1221 sqliteFree(pCur); in memRbtreeCloseCursor()
1416 static int memRbtreeCursorDump(RbtCursor* pCur, int* aRes) in memRbtreeCursorDump() argument