/ Check-in [a7015625]
Login

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

Overview
Comment:Fix a problem in the WHERE clause generator when the FROM clause is empty. (CVS 6114)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: a7015625610624be1645e918d0a62cf85bec86ce
User & Date: drh 2009-01-06 00:08:02
Context
2009-01-06
00:11
Remove leftover "breakpoint" from the fuzz.test script. (CVS 6115) check-in: c2482d88 user: drh tags: trunk
00:08
Fix a problem in the WHERE clause generator when the FROM clause is empty. (CVS 6114) check-in: a7015625 user: drh tags: trunk
2009-01-05
22:30
The fix in (6111) was not quite right. This version works better. (CVS 6113) check-in: 5f80140a user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/where.c.

    12     12   ** This module contains C code that generates VDBE code used to process
    13     13   ** the WHERE clause of SQL statements.  This module is responsible for
    14     14   ** generating the code that loops through a table looking for applicable
    15     15   ** rows.  Indices are selected and used to speed the search when doing
    16     16   ** so is applicable.  Because this module is responsible for selecting
    17     17   ** indices, you might also think of this module as the "query optimizer".
    18     18   **
    19         -** $Id: where.c,v 1.355 2008/12/30 17:55:00 drh Exp $
           19  +** $Id: where.c,v 1.356 2009/01/06 00:08:02 drh Exp $
    20     20   */
    21     21   #include "sqliteInt.h"
    22     22   
    23     23   /*
    24     24   ** Trace output macros
    25     25   */
    26     26   #if defined(SQLITE_TEST) || defined(SQLITE_DEBUG)
................................................................................
  3247   3247     /* Generate the code to do the search.  Each iteration of the for
  3248   3248     ** loop below generates code for a single nested loop of the VM
  3249   3249     ** program.
  3250   3250     */
  3251   3251     notReady = ~(Bitmask)0;
  3252   3252     for(i=0; i<pTabList->nSrc; i++){
  3253   3253       notReady = codeOneLoopStart(pWInfo, i, wctrlFlags, notReady);
         3254  +    pWInfo->iContinue = pWInfo->a[i].addrCont;
  3254   3255     }
  3255         -  pWInfo->iContinue = pWInfo->a[i-1].addrCont;
  3256   3256   
  3257   3257   #ifdef SQLITE_TEST  /* For testing and debugging use only */
  3258   3258     /* Record in the query plan information about the current table
  3259   3259     ** and the index used to access it (if any).  If the table itself
  3260   3260     ** is not used, its name is just '{}'.  If no index is used
  3261   3261     ** the index is listed as "{}".  If the primary key is used the
  3262   3262     ** index name is '*'.

Changes to test/fuzz.test.

    15     15   #
    16     16   # The tests in this file are really about testing fuzzily generated
    17     17   # SQL parse-trees. The majority of the fuzzily generated SQL is 
    18     18   # valid as far as the parser is concerned. 
    19     19   #
    20     20   # The most complicated trees are for SELECT statements.
    21     21   #
    22         -# $Id: fuzz.test,v 1.16 2009/01/05 22:30:39 drh Exp $
           22  +# $Id: fuzz.test,v 1.17 2009/01/06 00:08:02 drh Exp $
    23     23   
    24     24   set testdir [file dirname $argv0]
    25     25   source $testdir/tester.tcl
    26     26   
    27     27   set ::REPEATS 5000
    28     28   
    29     29   # If running quick.test, don't do so many iterations.
................................................................................
   186    186     execsql {
   187    187       CREATE TABLE abc(a, b, c);
   188    188       CREATE TABLE def(a, b, c);
   189    189       CREATE TABLE ghi(a, b, c);
   190    190     }
   191    191   } {}
   192    192   do_test fuzz-1.16.2 {
   193         -breakpoint
   194    193     catchsql {
   195    194       SELECT DISTINCT EXISTS(
   196    195          SELECT 1
   197    196          FROM (
   198    197            SELECT C FROM (SELECT 1)
   199    198          )
   200    199          WHERE (SELECT c)
................................................................................
   260    259            FROM (SELECT ALL 2147483647, typeof(2147483649))
   261    260          )
   262    261       )
   263    262       GROUP BY CAST(CAST('experiments' AS blob) AS blob)
   264    263       HAVING random()
   265    264     }
   266    265   } {0 {hardware 1 0}}
          266  +
          267  +do_test fuzz-1.18 {
          268  +breakpoint
          269  +  catchsql {
          270  +     SELECT -2147483649 << upper('fault' NOT IN (
          271  +        SELECT ALL (
          272  +           SELECT ALL -1
          273  +           ORDER BY -2147483649
          274  +           LIMIT (
          275  +              SELECT ALL (
          276  +                 SELECT 0 EXCEPT SELECT DISTINCT 'experiments' ORDER BY 1 ASC
          277  +              )
          278  +           )
          279  +           OFFSET EXISTS (
          280  +              SELECT ALL 
          281  +                  (SELECT ALL -2147483648) NOT IN (
          282  +                     SELECT ALL 123456789.1234567899
          283  +                  ) IN (SELECT 2147483649) 
          284  +              FROM sqlite_master
          285  +           ) NOT IN (SELECT ALL 'The')
          286  +        )
          287  +     ))
          288  +  }
          289  +} {0 -4294967298}
   267    290   
   268    291   #----------------------------------------------------------------
   269    292   # Test some fuzzily generated expressions.
   270    293   #
   271    294   do_fuzzy_test fuzz-2 -template  { SELECT [Expr] }
   272    295   
   273    296   do_test fuzz-3.1 {