Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | When a floating-point RTREE is presented with large integer constraints - integers that are too big to be represented exactly by a float - then take extra steps to ensure that all possibly relevant entries in the RTREE are returned, even in boundary cases. Fix for the problem identified by forum post da70ee0d0d. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
bfd8d9100015f3e3fb011698963d670b |
User & Date: | drh 2023-05-22 16:35:21 |
Context
2023-05-22
| ||
20:36 | Avoid duplicate WIN32_LEAN_AND_MEAN #define. Fix a trivial nit likely never observed. (check-in: 81ffcf41 user: larrybr tags: trunk) | |
16:35 | When a floating-point RTREE is presented with large integer constraints - integers that are too big to be represented exactly by a float - then take extra steps to ensure that all possibly relevant entries in the RTREE are returned, even in boundary cases. Fix for the problem identified by forum post da70ee0d0d. (check-in: bfd8d910 user: drh tags: trunk) | |
11:02 | Fix a buffer overrun that could occur in fts5 when processing corrupt records. dbsqlfuzz 0c6d3451d115974bc27ebed9b14b7a8e13ea05f3. (check-in: 4891dbd9 user: dan tags: trunk) | |
Changes
Changes to ext/rtree/rtree.c.
︙ | ︙ | |||
1903 1904 1905 1906 1907 1908 1909 | rc = deserializeGeometry(argv[ii], p); if( rc!=SQLITE_OK ){ break; } p->pInfo->nCoord = pRtree->nDim2; p->pInfo->anQueue = pCsr->anQueue; p->pInfo->mxLevel = pRtree->iDepth + 1; | | > > > > > > > > > > > > > | 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 | rc = deserializeGeometry(argv[ii], p); if( rc!=SQLITE_OK ){ break; } p->pInfo->nCoord = pRtree->nDim2; p->pInfo->anQueue = pCsr->anQueue; p->pInfo->mxLevel = pRtree->iDepth + 1; }else if( eType==SQLITE_INTEGER ){ sqlite3_int64 iVal = sqlite3_value_int64(argv[ii]); #ifdef SQLITE_RTREE_INT_ONLY p->u.rValue = iVal; #else p->u.rValue = (double)iVal; if( iVal>=((sqlite3_int64)1)<<48 || -iVal>=((sqlite3_int64)1)<<48 ){ if( p->op==RTREE_LT ) p->op = RTREE_LE; if( p->op==RTREE_GT ) p->op = RTREE_GE; } #endif }else if( eType==SQLITE_FLOAT ){ #ifdef SQLITE_RTREE_INT_ONLY p->u.rValue = sqlite3_value_int64(argv[ii]); #else p->u.rValue = sqlite3_value_double(argv[ii]); #endif }else{ p->u.rValue = RTREE_ZERO; |
︙ | ︙ | |||
2034 2035 2036 2037 2038 2039 2040 2041 | } if( p->usable && ((p->iColumn>0 && p->iColumn<=pRtree->nDim2) || p->op==SQLITE_INDEX_CONSTRAINT_MATCH) ){ u8 op; switch( p->op ){ | > | | | | | 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 | } if( p->usable && ((p->iColumn>0 && p->iColumn<=pRtree->nDim2) || p->op==SQLITE_INDEX_CONSTRAINT_MATCH) ){ u8 op; u8 doOmit = 1; switch( p->op ){ case SQLITE_INDEX_CONSTRAINT_EQ: op = RTREE_EQ; doOmit = 0; break; case SQLITE_INDEX_CONSTRAINT_GT: op = RTREE_GT; doOmit = 0; break; case SQLITE_INDEX_CONSTRAINT_LE: op = RTREE_LE; break; case SQLITE_INDEX_CONSTRAINT_LT: op = RTREE_LT; doOmit = 0; break; case SQLITE_INDEX_CONSTRAINT_GE: op = RTREE_GE; break; case SQLITE_INDEX_CONSTRAINT_MATCH: op = RTREE_MATCH; break; default: op = 0; break; } if( op ){ zIdxStr[iIdx++] = op; zIdxStr[iIdx++] = (char)(p->iColumn - 1 + '0'); pIdxInfo->aConstraintUsage[ii].argvIndex = (iIdx/2); pIdxInfo->aConstraintUsage[ii].omit = doOmit; } } } pIdxInfo->idxNum = 2; pIdxInfo->needToFreeIdxStr = 1; if( iIdx>0 && 0==(pIdxInfo->idxStr = sqlite3_mprintf("%s", zIdxStr)) ){ |
︙ | ︙ |
Changes to ext/rtree/rtree1.test.
︙ | ︙ | |||
765 766 767 768 769 770 771 772 773 | CREATE VIRTUAL TABLE t1 USING rtree(id, x0, x1); INSERT INTO t1 VALUES(0, 1, 9223372036854775807); SELECT count(*) FROM t1 WHERE x1=9223372036854775807; } {0} do_execsql_test 21.1 { SELECT x1=9223372036854775807 FROM t1; } {0} finish_test | > > > > > > > > > > > > > > | 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 | CREATE VIRTUAL TABLE t1 USING rtree(id, x0, x1); INSERT INTO t1 VALUES(0, 1, 9223372036854775807); SELECT count(*) FROM t1 WHERE x1=9223372036854775807; } {0} do_execsql_test 21.1 { SELECT x1=9223372036854775807 FROM t1; } {0} # 2023-05-22 https://sqlite.org/forum/forumpost/da70ee0d0d # Round-off error associated with using large integer constraints on # a rtree search. # reset_db do_execsql_test 22.0 { CREATE VIRTUAL TABLE t1 USING rtree ( id, x0, x1 ); INSERT INTO t1 VALUES (123, 9223372036854775799, 9223372036854775800); SELECT id FROM t1 WHERE x0 > 9223372036854775807; } {123} do_execsql_test 22.1 { SELECT id, x0 > 9223372036854775807 AS 'a0' FROM t1; } {123 1} finish_test |