Skip to content

Commit

Permalink
Fix a problem triggered by DELETE statements with WHERE clauses that …
Browse files Browse the repository at this point in the history
…use the

OR-optimization on some virtual tables.
  • Loading branch information
danielk-1977 committed Jan 15, 2019
1 parent 91d8767 commit 4999660
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
10 changes: 10 additions & 0 deletions ext/rtree/rtree6.test
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ if {![info exists testdir]} {
set testdir [file join [file dirname [info script]] .. .. test]
}
source $testdir/tester.tcl
set testprefix rtree6

ifcapable {!rtree || rtree_int_only} {
finish_test
Expand Down Expand Up @@ -167,5 +168,14 @@ do_execsql_test rtree6-3.5 {
x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>1.1
} {}

#-------------------------------------------------------------------------
reset_db
do_execsql_test 4.0 {
CREATE VIRTUAL TABLE t1 USING rtree(id,x0,x1,y0,y1);
}
do_execsql_test 4.1 {
DELETE FROM t1 WHERE x0>1 AND x1<2 OR y0<92;
}

expand_all_sql db
finish_test
3 changes: 2 additions & 1 deletion src/where.c
Original file line number Diff line number Diff line change
Expand Up @@ -4919,9 +4919,10 @@ WhereInfo *sqlite3WhereBegin(
if( (wctrlFlags & WHERE_ONEPASS_DESIRED)!=0 ){
int wsFlags = pWInfo->a[0].pWLoop->wsFlags;
int bOnerow = (wsFlags & WHERE_ONEROW)!=0;
assert( !(wsFlags & WHERE_VIRTUALTABLE) || IsVirtual(pTabList->a[0].pTab) );
if( bOnerow || (
0!=(wctrlFlags & WHERE_ONEPASS_MULTIROW)
&& 0==(wsFlags & WHERE_VIRTUALTABLE)
&& !IsVirtual(pTabList->a[0].pTab)
&& (0==(wsFlags & WHERE_MULTI_OR) || (wctrlFlags & WHERE_DUPLICATES_OK))
)){
pWInfo->eOnePass = bOnerow ? ONEPASS_SINGLE : ONEPASS_MULTI;
Expand Down

0 comments on commit 4999660

Please sign in to comment.