SQLite

Check-in [5b0e6ba4a5]
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
Timelines: family | ancestors | descendants | both | rtree-queue
Files: files | file ages | folders
SHA1: 5b0e6ba4a5050cf81cf41b977b28d714163569e0
User & Date: drh 2014-04-16 14:45:11.945
Context
2014-04-16
17:15
TCL tests now all pass. (Closed-Leaf check-in: f864baccd3 user: drh tags: rtree-queue)
14:45
Fix a bug in rowid=? query handling. More problems remain. (check-in: 5b0e6ba4a5 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: a439ddd629 user: drh tags: rtree-queue)
Changes
Side-by-Side Diff Ignore Whitespace Patch
Changes to ext/rtree/rtree.c.
1226
1227
1228
1229
1230
1231
1232

1233
1234
1235
1236
1237
1238
1239
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240







+







    tracePoint(&pCur->sPoint, -1, pCur);
  }
  for(ii=0; ii<pCur->nPoint; 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.
*/
static void rtreeSearchPointPop(RtreeCursor *p){
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1281
1282
1283
1284
1285
1286
1287

1288
1289
1290
1291
1292
1293
1294







-







** Continue the search on cursor pCur until the front of the queue
** contains an entry suitable for returning as a result-set row,
** 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;
  RtreeCell cell;
  RtreeSearchPoint x;
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321






1322
1323
1324


1325
1326
1327
1328
1329
1330
1331
1332
1333
1309
1310
1311
1312
1313
1314
1315






1316
1317
1318
1319
1320
1321
1322


1323
1324
1325

1326
1327
1328
1329
1330
1331
1332







-
-
-
-
-
-
+
+
+
+
+
+

-
-
+
+

-







      x = *p;
      p->iCell++;
      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:");
      rtreeSearchPointPop(pCur);
    }
1492
1493
1494
1495
1496
1497
1498

1499


1500
1501
1502
1503
1504
1505
1506
1491
1492
1493
1494
1495
1496
1497
1498

1499
1500
1501
1502
1503
1504
1505
1506
1507







+
-
+
+







    RtreeSearchPoint *p;     /* Search point for the the leaf */
    i64 iRowid = sqlite3_value_int64(argv[0]);
    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==SQLITE_OK ){
    if( rc ) rc = nodeRowidIndex(pRtree, pLeaf, iRowid, &iCell);
      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. 
    */
    if( argc>0 ){