1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-29 08:01:23 +03:00

Be strict about type enforcement on rowid look-ups in the RTREE extension.

Ticket [30e2c183b6b356e4]

FossilOrigin-Name: d43e0efb9642037dd751cfed13438e71cfceb50e14a0ec603880c6c3be2e93b1
This commit is contained in:
drh
2019-12-05 13:34:13 +00:00
parent 674a9b3425
commit 348d7f64f2
5 changed files with 57 additions and 12 deletions

View File

@ -1817,7 +1817,15 @@ static int rtreeFilter(
RtreeSearchPoint *p; /* Search point for the leaf */
i64 iRowid = sqlite3_value_int64(argv[0]);
i64 iNode = 0;
rc = findLeafNode(pRtree, iRowid, &pLeaf, &iNode);
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 ){
p = rtreeSearchPointNew(pCsr, RTREE_ZERO, 0);
assert( p!=0 ); /* Always returns pCsr->sPoint */

View File

@ -601,15 +601,29 @@ do_execsql_test 14.5 {
1 0.0 0.0
2 52.0 81.0
}
do_execsql_test 14.6 {
INSERT INTO t10 VALUES(0,10,20);
SELECT * FROM t10 WHERE ii=NULL;
} {}
do_execsql_test 14.7 {
SELECT * FROM t10 WHERE ii='xyz';
} {}
do_execsql_test 14.8 {
SELECT * FROM t10 WHERE ii='0.0';
} {0 10.0 20.0}
do_execsql_test 14.9 {
SELECT * FROM t10 WHERE ii=0.0;
} {0 10.0 20.0}
do_execsql_test 14.4 {
do_execsql_test 14.104 {
DROP TABLE t10;
CREATE VIRTUAL TABLE t10 USING rtree_i32(ii, x1, x2);
INSERT INTO t10 VALUES(1, 'one', 'two');
INSERT INTO t10 VALUES(2, '52xyz', '81...');
INSERT INTO t10 VALUES(3, 42.3, 49.9);
}
do_execsql_test 14.5 {
do_execsql_test 14.105 {
SELECT * FROM t10;
} {
1 0 0

View File

@ -43,10 +43,33 @@ do_execsql_test rtreeH-101 {
do_execsql_test rtreeH-102 {
SELECT * FROM t1 WHERE rowid=5;
} {5 40.0 60.0 40.0 60.0 center {}}
do_execsql_test rtreeH-102b {
SELECT * FROM t1 WHERE rowid=5.0;
} {5 40.0 60.0 40.0 60.0 center {}}
do_execsql_test rtreeH-102c {
SELECT * FROM t1 WHERE rowid='5';
} {5 40.0 60.0 40.0 60.0 center {}}
do_execsql_test rtreeH-102d {
SELECT * FROM t1 WHERE rowid='0005';
} {5 40.0 60.0 40.0 60.0 center {}}
do_execsql_test rtreeH-102e {
SELECT * FROM t1 WHERE rowid='+5.0e+0';
} {5 40.0 60.0 40.0 60.0 center {}}
do_execsql_test rtreeH-103 {
SELECT * FROM t1 WHERE label='center';
} {5 40.0 60.0 40.0 60.0 center {}}
do_execsql_test rtreeH-104 {
SELECT * FROM t1 WHERE rowid='+5.0e+0x';
} {}
do_execsql_test rtreeH-105 {
SELECT * FROM t1 WHERE rowid=x'35';
} {}
do_execsql_test rtreeH-106 {
SELECT * FROM t1 WHERE rowid=null;
} {}
do_rtree_integrity_test rtreeH-110 t1
do_execsql_test rtreeH-120 {