Skip to content

Commit dd5e3d0

Browse files
committed
Fix a problem with queries that use "IN(...) ORDER BY ... NULLS LAST" or similar introduced by [d7648e21605a0b38].
1 parent ed83c14 commit dd5e3d0

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/wherecode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2106,7 +2106,7 @@ Bitmask sqlite3WhereCodeOneLoopStart(
21062106

21072107
/* Record the instruction used to terminate the loop. */
21082108
if( (pLoop->wsFlags & WHERE_ONEROW)
2109-
|| (pLevel->u.in.nIn && whereLoopIsOneRow(pLoop))
2109+
|| (pLevel->u.in.nIn && regBignull==0 && whereLoopIsOneRow(pLoop))
21102110
){
21112111
pLevel->op = OP_Noop;
21122112
}else if( bRev ){

test/in7.test

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,5 +103,18 @@ foreach {tn nNext idx sql} {
103103
} $nNext
104104
}
105105

106+
#-------------------------------------------------------------------------
107+
reset_db
108+
do_execsql_test 2.0 {
109+
CREATE TABLE t1(a TEXT PRIMARY KEY, b TEXT) WITHOUT ROWID;
110+
INSERT INTO t1 VALUES('1', 'one');
111+
INSERT INTO t1 VALUES('2', NULL);
112+
INSERT INTO t1 VALUES('3', 'three');
113+
}
114+
115+
do_execsql_test 2.1 {
116+
SELECT b FROM t1 WHERE a IN (1,2,3) ORDER BY b ASC NULLS LAST;
117+
} {one three {}}
118+
106119

107120
finish_test

0 commit comments

Comments
 (0)