SQLite

Check-in [027e5336]
Login

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

Overview
Comment:Fix handling of "id=?" corner cases in rtree when the value on the RHS is a real value. Problem reported by forum post 1bb055be17.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 027e5336acc26f57f21df4980928731026c30cf88688fa0b66f13ffa0b5da3a0
User & Date: dan 2024-03-06 11:35:36
Original Comment: Fix handling of "id=?" corner cases in rtree when the value on the RHS is a real value.
References
2024-03-08
03:24
Must use sqlite3IntFloatCompare() for accurate comparisons between very large integer and floating point values in RTREE. Otherwise the comparison does not work on all platforms. Further fix to [027e5336acc26f57]. (check-in: 820f106a user: drh tags: trunk)
Context
2024-03-06
12:28
Correction to the previous check-in. (check-in: 483fa296 user: drh tags: trunk)
11:35
Fix handling of "id=?" corner cases in rtree when the value on the RHS is a real value. Problem reported by forum post 1bb055be17. (check-in: 027e5336 user: dan tags: trunk)
2024-03-05
18:41
Remove code that added a P4 parameter to the OP_Variable opcode. This is no longer required. (check-in: dd5977c9 user: dan tags: trunk)
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to ext/rtree/rtree.c.

1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
    /* Special case - lookup by rowid. */
    RtreeNode *pLeaf;        /* Leaf on which the required cell resides */
    RtreeSearchPoint *p;     /* Search point for the leaf */
    i64 iRowid = sqlite3_value_int64(argv[0]);
    i64 iNode = 0;
    int eType = sqlite3_value_numeric_type(argv[0]);
    if( eType==SQLITE_INTEGER
     || (eType==SQLITE_FLOAT && sqlite3_value_double(argv[0])==iRowid)
    ){
      rc = findLeafNode(pRtree, iRowid, &pLeaf, &iNode);
    }else{
      rc = SQLITE_OK;
      pLeaf = 0;
    }
    if( rc==SQLITE_OK && pLeaf!=0 ){







|







1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
    /* Special case - lookup by rowid. */
    RtreeNode *pLeaf;        /* Leaf on which the required cell resides */
    RtreeSearchPoint *p;     /* Search point for the leaf */
    i64 iRowid = sqlite3_value_int64(argv[0]);
    i64 iNode = 0;
    int eType = sqlite3_value_numeric_type(argv[0]);
    if( eType==SQLITE_INTEGER
     || (eType==SQLITE_FLOAT && (i64)(sqlite3_value_double(argv[0]))==iRowid)
    ){
      rc = findLeafNode(pRtree, iRowid, &pLeaf, &iNode);
    }else{
      rc = SQLITE_OK;
      pLeaf = 0;
    }
    if( rc==SQLITE_OK && pLeaf!=0 ){

Changes to ext/rtree/rtree1.test.

792
793
794
795
796
797
798












799
800
#
reset_db
do_test 23.0 {
  db eval {CREATE TABLE t1(a,b,c);}
  catch {db eval {CREATE TABLE t2 AS SELECT rtreecheck('t1') AS y;}}
  db eval {PRAGMA integrity_check;}
} {ok}













finish_test







>
>
>
>
>
>
>
>
>
>
>
>


792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
#
reset_db
do_test 23.0 {
  db eval {CREATE TABLE t1(a,b,c);}
  catch {db eval {CREATE TABLE t2 AS SELECT rtreecheck('t1') AS y;}}
  db eval {PRAGMA integrity_check;}
} {ok}

reset_db
do_execsql_test 24.0 {
  CREATE VIRTUAL TABLE rt1 USING rtree_i32(rid, c1, c2);
  INSERT INTO rt1(rid, c1, c2) VALUES (9223372036854775807, 10, 18);
}

do_execsql_test 1.1 {
  SELECT (rid = (CAST (9223372036854775807 AS REAL)))
  FROM rt1 WHERE
         (rid = (CAST (9223372036854775807 AS REAL)));
}

finish_test