/ Check-in [8c4cbdd0]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

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

Overview
Comment:In the VDBE, check to make sure a set has been initialized before using it. Ticket #185. (CVS 772)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 8c4cbdd05517e91879a0f2c4559d0f0518d2385b
User & Date: drh 2002-10-30 22:42:59
Context
2002-10-30
23:04
Bump the version number prior to the release of version 2.7.3. (CVS 773) check-in: bc7c7d87 user: drh tags: trunk
22:42
In the VDBE, check to make sure a set has been initialized before using it. Ticket #185. (CVS 772) check-in: 8c4cbdd0 user: drh tags: trunk
2002-10-27
19:35
Minimal support for oracle8 outer join syntax. (CVS 771) check-in: 31df3690 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/vdbe.c.

    32     32   **
    33     33   ** Various scripts scan this source file in order to generate HTML
    34     34   ** documentation, headers files, or other derived files.  The formatting
    35     35   ** of the code in this file is, therefore, important.  See other comments
    36     36   ** in this file for details.  If in doubt, do not deviate from existing
    37     37   ** commenting and indentation practices when changing or adding code.
    38     38   **
    39         -** $Id: vdbe.c,v 1.181 2002/10/22 15:04:34 drh Exp $
           39  +** $Id: vdbe.c,v 1.182 2002/10/30 22:42:59 drh Exp $
    40     40   */
    41     41   #include "sqliteInt.h"
    42     42   #include <ctype.h>
    43     43   
    44     44   /*
    45     45   ** The makefile scans this source file and creates the following
    46     46   ** array of string constants which are the names of all VDBE opcodes.
................................................................................
  5158   5158   ** then jump to P2.  Otherwise fall through.
  5159   5159   */
  5160   5160   case OP_SetFound: {
  5161   5161     int i = pOp->p1;
  5162   5162     int tos = p->tos;
  5163   5163     VERIFY( if( tos<0 ) goto not_enough_stack; )
  5164   5164     if( Stringify(p, tos) ) goto no_mem;
  5165         -  if( VERIFY( i>=0 && i<p->nSet &&) 
         5165  +  if( i>=0 && i<p->nSet &&
  5166   5166          sqliteHashFind(&p->aSet[i].hash, zStack[tos], aStack[tos].n)){
  5167   5167       pc = pOp->p2 - 1;
  5168   5168     }
  5169   5169     POPSTACK;
  5170   5170     break;
  5171   5171   }
  5172   5172   
................................................................................
  5177   5177   ** set P1, then jump to P2.  Otherwise fall through.
  5178   5178   */
  5179   5179   case OP_SetNotFound: {
  5180   5180     int i = pOp->p1;
  5181   5181     int tos = p->tos;
  5182   5182     VERIFY( if( tos<0 ) goto not_enough_stack; )
  5183   5183     if( Stringify(p, tos) ) goto no_mem;
  5184         -  if(VERIFY( i>=0 && i<p->nSet &&)
         5184  +  if( i<0 || i>=p->nSet ||
  5185   5185          sqliteHashFind(&p->aSet[i].hash, zStack[tos], aStack[tos].n)==0 ){
  5186   5186       pc = pOp->p2 - 1;
  5187   5187     }
  5188   5188     POPSTACK;
  5189   5189     break;
  5190   5190   }
  5191   5191   
................................................................................
  5201   5201   ** are no more elements in the set, do not do the push and fall through.
  5202   5202   ** Otherwise, jump to P2 after pushing the next set element.
  5203   5203   */
  5204   5204   case OP_SetFirst: 
  5205   5205   case OP_SetNext: {
  5206   5206     Set *pSet;
  5207   5207     int tos;
  5208         -  VERIFY( if( pOp->p1<0 || pOp->p1>=p->nSet ) goto bad_instruction; )
         5208  +  if( pOp->p1<0 || pOp->p1>=p->nSet ){
         5209  +    if( pOp->opcode==OP_SetFirst ) pc = pOp->p2 - 1;
         5210  +    break;
         5211  +  }
  5209   5212     pSet = &p->aSet[pOp->p1];
  5210   5213     if( pOp->opcode==OP_SetFirst ){
  5211   5214       pSet->prev = sqliteHashFirst(&pSet->hash);
  5212   5215       if( pSet->prev==0 ){
  5213   5216         pc = pOp->p2 - 1;
  5214   5217         break;
  5215   5218       }

Changes to test/in.test.

     7      7   #    May you find forgiveness for yourself and forgive others.
     8      8   #    May you share freely, never taking more than you give.
     9      9   #
    10     10   #***********************************************************************
    11     11   # This file implements regression tests for SQLite library.  The
    12     12   # focus of this file is testing the IN and BETWEEN operator.
    13     13   #
    14         -# $Id: in.test,v 1.7 2002/07/01 00:31:36 drh Exp $
           14  +# $Id: in.test,v 1.8 2002/10/30 22:42:59 drh Exp $
    15     15   
    16     16   set testdir [file dirname $argv0]
    17     17   source $testdir/tester.tcl
    18     18   
    19     19   # Generate the test data we will need for the first squences of tests.
    20     20   #
    21     21   do_test in-1.0 {
................................................................................
   222    222     }
   223    223   } {1 2 3}
   224    224   do_test in-6.10 {
   225    225     execsql {
   226    226       SELECT a FROM ta WHERE a NOT IN (SELECT b FROM tb);
   227    227     }
   228    228   } {4 6 8 10}
          229  +
          230  +# Tests of IN operator against empty sets.  (Ticket #185)
          231  +#
          232  +do_test in-7.1 {
          233  +  execsql {
          234  +    SELECT a FROM t1 WHERE a IN ();
          235  +  }
          236  +} {}
          237  +do_test in-7.2 {
          238  +  execsql {
          239  +    SELECT a FROM t1 WHERE a IN (5);
          240  +  }
          241  +} {5}
          242  +do_test in-7.3 {
          243  +  execsql {
          244  +    SELECT a FROM t1 WHERE a NOT IN () ORDER BY a;
          245  +  }
          246  +} {5 6 7 8 hello}
          247  +do_test in-7.4 {
          248  +  execsql {
          249  +    SELECT a FROM t1 WHERE a IN (5) AND b IN ();
          250  +  }
          251  +} {}
          252  +do_test in-7.5 {
          253  +  execsql {
          254  +    SELECT a FROM t1 WHERE a IN (5) AND b NOT IN ();
          255  +  }
          256  +} {5}
          257  +do_test in-7.6 {
          258  +  execsql {
          259  +    SELECT a FROM ta WHERE a IN ();
          260  +  }
          261  +} {}
          262  +do_test in-7.7 {
          263  +  execsql {
          264  +    SELECT a FROM ta WHERE a NOT IN ();
          265  +  }
          266  +} {1 2 3 4 6 8 10}
          267  +
   229    268   
   230    269   finish_test