/ Check-in [5b0e6ba4]
Login

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

Overview
Comment:Fix a bug in rowid=? query handling. More problems remain.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | rtree-queue
Files: files | file ages | folders
SHA1: 5b0e6ba4a5050cf81cf41b977b28d714163569e0
User & Date: drh 2014-04-16 14:45:11
Context
2014-04-16
17:15
TCL tests now all pass. Closed-Leaf check-in: f864bacc user: drh tags: rtree-queue
14:45
Fix a bug in rowid=? query handling. More problems remain. check-in: 5b0e6ba4 user: drh tags: rtree-queue
13:00
Bug fixes to the priority-queue implementation for R-Trees. Improved tracing capability. Some queries work now, but still many problems. check-in: a439ddd6 user: drh tags: rtree-queue
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to ext/rtree/rtree.c.

  1226   1226       tracePoint(&pCur->sPoint, -1, pCur);
  1227   1227     }
  1228   1228     for(ii=0; ii<pCur->nPoint; ii++){
  1229   1229       if( ii>0 || pCur->bPoint ) printf("              ");
  1230   1230       tracePoint(&pCur->aPoint[ii], ii, pCur);
  1231   1231     }
  1232   1232   }
         1233  +# define RTREE_QUEUE_TRACE(A,B) traceQueue(A,B)
  1233   1234   #else
  1234   1235   # define RTREE_QUEUE_TRACE(A,B)   /* no-op */
  1235   1236   #endif
  1236   1237   
  1237   1238   /* Remove the search point with the lowest current score.
  1238   1239   */
  1239   1240   static void rtreeSearchPointPop(RtreeCursor *p){
................................................................................
  1280   1281   ** Continue the search on cursor pCur until the front of the queue
  1281   1282   ** contains an entry suitable for returning as a result-set row,
  1282   1283   ** or until the RtreeSearchPoint queue is empty, indicating that the
  1283   1284   ** query has completed.
  1284   1285   */
  1285   1286   static int rtreeStepToLeaf(RtreeCursor *pCur){
  1286   1287     RtreeSearchPoint *p;
  1287         -  RtreeSearchPoint *pNew;
  1288   1288     Rtree *pRtree = RTREE_OF_CURSOR(pCur);
  1289   1289     RtreeNode *pNode;
  1290   1290     int eWithin;
  1291   1291     int rc = SQLITE_OK;
  1292   1292     int nCell;
  1293   1293     RtreeCell cell;
  1294   1294     RtreeSearchPoint x;
................................................................................
  1309   1309         x = *p;
  1310   1310         p->iCell++;
  1311   1311         if( eWithin==NOT_WITHIN ) continue;
  1312   1312         if( p->iCell>=nCell ){
  1313   1313           RTREE_QUEUE_TRACE(pCur, "POP-S:");
  1314   1314           rtreeSearchPointPop(pCur);
  1315   1315         }
  1316         -      pNew = rtreeSearchPointNew(pCur, /*rScore*/0.0, x.iLevel-1);
  1317         -      if( pNew==0 ) return SQLITE_NOMEM;
  1318         -      pNew->eWithin = eWithin;
  1319         -      if( pNew->iLevel ){
  1320         -        pNew->id = cell.iRowid;
  1321         -        pNew->iCell = 0;
         1316  +      p = rtreeSearchPointNew(pCur, /*rScore*/0.0, x.iLevel-1);
         1317  +      if( p==0 ) return SQLITE_NOMEM;
         1318  +      p->eWithin = eWithin;
         1319  +      if( p->iLevel ){
         1320  +        p->id = cell.iRowid;
         1321  +        p->iCell = 0;
  1322   1322         }else{
  1323         -        pNew->id = x.id;
  1324         -        pNew->iCell = x.iCell;
         1323  +        p->id = x.id;
         1324  +        p->iCell = x.iCell;
  1325   1325         }
  1326         -      p = pNew;
  1327   1326         RTREE_QUEUE_TRACE(pCur, "PUSH-S:");
  1328   1327         break;
  1329   1328       }
  1330   1329       if( p->iCell>=nCell ){
  1331   1330         RTREE_QUEUE_TRACE(pCur, "POP-Se:");
  1332   1331         rtreeSearchPointPop(pCur);
  1333   1332       }
................................................................................
  1492   1491       RtreeSearchPoint *p;     /* Search point for the the leaf */
  1493   1492       i64 iRowid = sqlite3_value_int64(argv[0]);
  1494   1493       p = rtreeSearchPointNew(pCsr, 0.0, 0);
  1495   1494       if( p==0 ) return SQLITE_NOMEM;
  1496   1495       rc = findLeafNode(pRtree, iRowid, &pLeaf, &p->id);
  1497   1496       pCsr->aNode[0] = pLeaf;
  1498   1497       p->eWithin = PARTLY_WITHIN;
  1499         -    if( rc ) rc = nodeRowidIndex(pRtree, pLeaf, iRowid, &iCell);
         1498  +    if( rc==SQLITE_OK ){
         1499  +      rc = nodeRowidIndex(pRtree, pLeaf, iRowid, &iCell);
         1500  +    }
  1500   1501       p->iCell = iCell;
  1501   1502       RTREE_QUEUE_TRACE(pCsr, "PUSH-F1:");
  1502   1503     }else{
  1503   1504       /* Normal case - r-tree scan. Set up the RtreeCursor.aConstraint array 
  1504   1505       ** with the configured constraints. 
  1505   1506       */
  1506   1507       if( argc>0 ){