/ Check-in [a55f4ab9]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Make sure IS NOT NULL constraints work on virtual tables. Fix for ticket [6c14288a473ceff].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: a55f4ab99952a731e4cd8f6ef17389062e5ed4c5
User & Date: drh 2011-08-02 01:57:39
Context
2011-08-02
19:30
Omit backcompat.test from the journaltest permutation because it uses WAL mode which is incompatible with journaltest. check-in: 2bbf3150 user: drh tags: trunk
18:25
Merge all the latest trunk changes into the apple-osx branch. check-in: 77376b33 user: drh tags: apple-osx
01:57
Make sure IS NOT NULL constraints work on virtual tables. Fix for ticket [6c14288a473ceff]. check-in: a55f4ab9 user: drh tags: trunk
2011-07-30
23:50
Fix a (humorous) typo in the lemon documentation. check-in: ed630b01 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/where.c.

  2138   2138     ** to this virtual table */
  2139   2139     for(i=nTerm=0, pTerm=pWC->a; i<pWC->nTerm; i++, pTerm++){
  2140   2140       if( pTerm->leftCursor != pSrc->iCursor ) continue;
  2141   2141       assert( (pTerm->eOperator&(pTerm->eOperator-1))==0 );
  2142   2142       testcase( pTerm->eOperator==WO_IN );
  2143   2143       testcase( pTerm->eOperator==WO_ISNULL );
  2144   2144       if( pTerm->eOperator & (WO_IN|WO_ISNULL) ) continue;
         2145  +    if( pTerm->wtFlags & TERM_VNULL ) continue;
  2145   2146       nTerm++;
  2146   2147     }
  2147   2148   
  2148   2149     /* If the ORDER BY clause contains only columns in the current 
  2149   2150     ** virtual table then allocate space for the aOrderBy part of
  2150   2151     ** the sqlite3_index_info structure.
  2151   2152     */
................................................................................
  2188   2189   
  2189   2190     for(i=j=0, pTerm=pWC->a; i<pWC->nTerm; i++, pTerm++){
  2190   2191       if( pTerm->leftCursor != pSrc->iCursor ) continue;
  2191   2192       assert( (pTerm->eOperator&(pTerm->eOperator-1))==0 );
  2192   2193       testcase( pTerm->eOperator==WO_IN );
  2193   2194       testcase( pTerm->eOperator==WO_ISNULL );
  2194   2195       if( pTerm->eOperator & (WO_IN|WO_ISNULL) ) continue;
         2196  +    if( pTerm->wtFlags & TERM_VNULL ) continue;
  2195   2197       pIdxCons[j].iColumn = pTerm->u.leftColumn;
  2196   2198       pIdxCons[j].iTermOffset = i;
  2197   2199       pIdxCons[j].op = (u8)pTerm->eOperator;
  2198   2200       /* The direct assignment in the previous line is possible only because
  2199   2201       ** the WO_ and SQLITE_INDEX_CONSTRAINT_ codes are identical.  The
  2200   2202       ** following asserts verify this fact. */
  2201   2203       assert( WO_EQ==SQLITE_INDEX_CONSTRAINT_EQ );

Added test/vtabF.test.

            1  +# 2011 Aug 1
            2  +#
            3  +# The author disclaims copyright to this source code.  In place of
            4  +# a legal notice, here is a blessing:
            5  +#
            6  +#    May you do good and not evil.
            7  +#    May you find forgiveness for yourself and forgive others.
            8  +#    May you share freely, never taking more than you give.
            9  +#
           10  +#***********************************************************************
           11  +# This file implements regression tests for SQLite library. 
           12  +# This file checks to make sure IS NOT NULL constraints work on
           13  +# virtual tables.
           14  +#
           15  +
           16  +set testdir [file dirname $argv0]
           17  +source $testdir/tester.tcl
           18  +
           19  +ifcapable !vtab||!schema_pragmas { finish_test ; return }
           20  +
           21  +# Register the echo module
           22  +register_echo_module [sqlite3_connection_pointer db]
           23  +
           24  +do_test vtabE-1.1 {
           25  +  execsql {
           26  +    CREATE TABLE t1(a, b);
           27  +    CREATE INDEX i1 ON t1(a);
           28  +    CREATE INDEX i2 ON t1(b);
           29  +    INSERT INTO t1 VALUES(10,110);
           30  +    INSERT INTO t1 VALUES(11,111);
           31  +    INSERT INTO t1 SELECT a+2, b+2 FROM t1;
           32  +    INSERT INTO t1 SELECT null, b+4 FROM t1;
           33  +    INSERT INTO t1 SELECT null, b+8 FROM t1;
           34  +    INSERT INTO t1 SELECT null, b+16 FROM t1;
           35  +    ANALYZE;
           36  +    CREATE VIRTUAL TABLE tv1 USING echo(t1);
           37  +    SELECT b FROM t1 WHERE a IS NOT NULL;
           38  +  }
           39  +} {110 111 112 113}
           40  +do_test vtabE-1.2 {
           41  +  execsql {SELECT b FROM tv1 WHERE a IS NOT NULL}
           42  +} {110 111 112 113}
           43  +
           44  +
           45  +finish_test