Index: ext/rtree/rtree.c ================================================================== --- ext/rtree/rtree.c +++ ext/rtree/rtree.c @@ -1228,10 +1228,11 @@ for(ii=0; iinPoint; ii++){ if( ii>0 || pCur->bPoint ) printf(" "); tracePoint(&pCur->aPoint[ii], ii, pCur); } } +# define RTREE_QUEUE_TRACE(A,B) traceQueue(A,B) #else # define RTREE_QUEUE_TRACE(A,B) /* no-op */ #endif /* Remove the search point with the lowest current score. @@ -1282,11 +1283,10 @@ ** or until the RtreeSearchPoint queue is empty, indicating that the ** query has completed. */ static int rtreeStepToLeaf(RtreeCursor *pCur){ RtreeSearchPoint *p; - RtreeSearchPoint *pNew; Rtree *pRtree = RTREE_OF_CURSOR(pCur); RtreeNode *pNode; int eWithin; int rc = SQLITE_OK; int nCell; @@ -1311,21 +1311,20 @@ if( eWithin==NOT_WITHIN ) continue; if( p->iCell>=nCell ){ RTREE_QUEUE_TRACE(pCur, "POP-S:"); rtreeSearchPointPop(pCur); } - pNew = rtreeSearchPointNew(pCur, /*rScore*/0.0, x.iLevel-1); - if( pNew==0 ) return SQLITE_NOMEM; - pNew->eWithin = eWithin; - if( pNew->iLevel ){ - pNew->id = cell.iRowid; - pNew->iCell = 0; + p = rtreeSearchPointNew(pCur, /*rScore*/0.0, x.iLevel-1); + if( p==0 ) return SQLITE_NOMEM; + p->eWithin = eWithin; + if( p->iLevel ){ + p->id = cell.iRowid; + p->iCell = 0; }else{ - pNew->id = x.id; - pNew->iCell = x.iCell; + p->id = x.id; + p->iCell = x.iCell; } - p = pNew; RTREE_QUEUE_TRACE(pCur, "PUSH-S:"); break; } if( p->iCell>=nCell ){ RTREE_QUEUE_TRACE(pCur, "POP-Se:"); @@ -1494,11 +1493,13 @@ p = rtreeSearchPointNew(pCsr, 0.0, 0); if( p==0 ) return SQLITE_NOMEM; rc = findLeafNode(pRtree, iRowid, &pLeaf, &p->id); pCsr->aNode[0] = pLeaf; p->eWithin = PARTLY_WITHIN; - if( rc ) rc = nodeRowidIndex(pRtree, pLeaf, iRowid, &iCell); + if( rc==SQLITE_OK ){ + rc = nodeRowidIndex(pRtree, pLeaf, iRowid, &iCell); + } p->iCell = iCell; RTREE_QUEUE_TRACE(pCsr, "PUSH-F1:"); }else{ /* Normal case - r-tree scan. Set up the RtreeCursor.aConstraint array ** with the configured constraints.