1
0
mirror of https://github.com/sqlite/sqlite.git synced 2026-01-06 08:01:16 +03:00

Handle "IS NULL" constraints on virtual table scans. IS NULL constraints are not passed to the virtual table layer. Ticket #2759. (CVS 4523)

FossilOrigin-Name: 7027368c15b3270a139bea5612d7c03c2288dcc4
This commit is contained in:
danielk1977
2007-11-05 05:12:53 +00:00
parent 3b1a9881e7
commit 6d64307b03
4 changed files with 43 additions and 11 deletions

View File

@@ -1,5 +1,5 @@
C Add\sthe\s".timer"\scommand\sto\sthe\sCLI.\s(CVS\s4522)
D 2007-11-02T12:53:04
C Handle\s"IS\sNULL"\sconstraints\son\svirtual\stable\sscans.\sIS\sNULL\sconstraints\sare\snot\spassed\sto\sthe\svirtual\stable\slayer.\sTicket\s#2759.\s(CVS\s4523)
D 2007-11-05T05:12:53
F Makefile.in 30c7e3ba426ddb253b8ef037d1873425da6009a8
F Makefile.linux-gcc 65241babba6faf1152bf86574477baab19190499
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
@@ -174,7 +174,7 @@ F src/vdbeblob.c 82f51cdf9b0c0af729732fde48c824e498c0a1ca
F src/vdbefifo.c 334c838c8f42d61a94813d136019ee566b5dc2f6
F src/vdbemem.c 123994fcd344993d2fb050a83b91b341bbbd08b4
F src/vtab.c f819d55ef638d45e09ce00009d435da8bf16f528
F src/where.c 44042c8b9d0d054cc318c3a0df052215ebf49d2d
F src/where.c ddcbc5c419e9851906c9a9e76839086c98e7cea4
F tclinstaller.tcl 4356d9d94d2b5ed5e68f9f0c80c4df3048dd7617
F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
F test/all.test b59d1bd8b0c1d4a08b845e8af48fd43926f01f11
@@ -486,7 +486,7 @@ F test/vacuum.test cf839fc3ff24d601057319bbb5c700ce9c8e0fb0
F test/vacuum2.test e198d81a1cbc3f3f6b8aeee27cadfffea8995d42
F test/varint.test ab7b110089a08b9926ed7390e7e97bdefeb74102
F test/view.test 7e15fa1ba3267ddaa9ae96b6daf519f23f95b43e
F test/vtab1.test 3271e7c5128f17a16fee795f273c4658da97c168
F test/vtab1.test 3573ad5045c44e8e2d2b6451122bcf2ee2a4f688
F test/vtab2.test 94bb3bf691ac10e34cf7dad46b1cf94b861d513c
F test/vtab3.test f38d6d7d19f08bffdadce4d5b8cba078f8118587
F test/vtab4.test a9d7104d41a787754a734740d7aa61c807a69f87
@@ -584,7 +584,7 @@ F www/tclsqlite.tcl 8be95ee6dba05eabcd27a9d91331c803f2ce2130
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
P a616b6cb646a35a68bebc7d013c13185a9a6f47d
R 3c475471a85720fe0d75e54f60c99bbc
U drh
Z c5d9d02a9879c0e073ce1cae0bcfc7b6
P 56680360d3b14a66a077ebb735f4594ed524a4bb
R c2385fbfbf468f6a65082faa2df6e19b
U danielk1977
Z b4b52c4ef3717f88e5ea0d2790947f26

View File

@@ -1 +1 @@
56680360d3b14a66a077ebb735f4594ed524a4bb
7027368c15b3270a139bea5612d7c03c2288dcc4

View File

@@ -16,7 +16,7 @@
** so is applicable. Because this module is responsible for selecting
** indices, you might also think of this module as the "query optimizer".
**
** $Id: where.c,v 1.261 2007/09/13 17:54:40 drh Exp $
** $Id: where.c,v 1.262 2007/11/05 05:12:53 danielk1977 Exp $
*/
#include "sqliteInt.h"
@@ -1239,6 +1239,7 @@ static double bestVirtualIndex(
for(i=nTerm=0, pTerm=pWC->a; i<pWC->nTerm; i++, pTerm++){
if( pTerm->leftCursor != pSrc->iCursor ) continue;
if( pTerm->eOperator==WO_IN ) continue;
if( pTerm->eOperator==WO_ISNULL ) continue;
nTerm++;
}
@@ -1286,6 +1287,7 @@ static double bestVirtualIndex(
for(i=j=0, pTerm=pWC->a; i<pWC->nTerm; i++, pTerm++){
if( pTerm->leftCursor != pSrc->iCursor ) continue;
if( pTerm->eOperator==WO_IN ) continue;
if( pTerm->eOperator==WO_ISNULL ) continue;
pIdxCons[j].iColumn = pTerm->leftColumn;
pIdxCons[j].iTermOffset = i;
pIdxCons[j].op = pTerm->eOperator;

View File

@@ -11,7 +11,7 @@
# This file implements regression tests for SQLite library. The
# focus of this file is creating and dropping virtual tables.
#
# $Id: vtab1.test,v 1.47 2007/10/09 08:29:33 danielk1977 Exp $
# $Id: vtab1.test,v 1.48 2007/11/05 05:12:53 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@@ -946,5 +946,35 @@ do_test vtab1.12-6 {
execsql { SELECT * FROM c }
} {3 G H}
# At one point (ticket #2759), a WHERE clause of the form "<column> IS NULL"
# on a virtual table was causing an assert() to fail in the compiler.
#
# "IS NULL" clauses should not be passed through to the virtual table
# implementation. They are handled by SQLite after the vtab returns it's
# data.
#
do_test vtab1.13-1 {
execsql {
SELECT * FROM echo_c WHERE a IS NULL
}
} {}
do_test vtab1.13-2 {
execsql {
INSERT INTO c VALUES(NULL, 15, 16);
SELECT * FROM echo_c WHERE a IS NULL
}
} {{} 15 16}
do_test vtab1.13-3 {
execsql {
INSERT INTO c VALUES(15, NULL, 16);
SELECT * FROM echo_c WHERE b IS NULL
}
} {15 {} 16}
do_test vtab1.13-3 {
execsql {
SELECT * FROM echo_c WHERE b IS NULL AND a = 15;
}
} {15 {} 16}
unset -nocomplain echo_module_begin_fail
finish_test