/ Check-in [4f10f19d]
Login

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

Overview
Comment:Additional test cases for nested subqueries in a WHERE clause. (CVS 5999)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 4f10f19dd1e66cd29b0e1e26506154d670c3bc46
User & Date: drh 2008-12-09 13:12:57
Context
2008-12-09
14:03
Finish incomplete edit of resolve.c from check-in (5998). (CVS 6000) check-in: 0d7e150e user: drh tags: trunk
13:12
Additional test cases for nested subqueries in a WHERE clause. (CVS 5999) check-in: 4f10f19d user: drh tags: trunk
13:04
A subquery in the result set of a SELECT should be able to look into outer queries to find variable references. But a subquery in the FROM clause should not be able to do this. Ticket #3530. (CVS 5998) check-in: be03fa05 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Show Whitespace Changes Patch

Changes to test/tkt3346.test.

     8      8   #    May you share freely, never taking more than you give.
     9      9   #
    10     10   #***********************************************************************
    11     11   #
    12     12   # This file implements regression tests for SQLite library.  The
    13     13   # focus of this file is testing the fix for ticket #3346
    14     14   #
    15         -# $Id: tkt3346.test,v 1.2 2008/12/09 13:04:29 drh Exp $
           15  +# $Id: tkt3346.test,v 1.3 2008/12/09 13:12:57 drh Exp $
    16     16   
    17     17   set testdir [file dirname $argv0]
    18     18   source $testdir/tester.tcl
    19     19   
    20     20   do_test tkt3346-1.1 {
    21     21     db eval {
    22     22      CREATE TABLE t1(a,b);
................................................................................
    23     23      INSERT INTO t1 VALUES(2,'bob');
    24     24      INSERT INTO t1 VALUES(1,'alice');
    25     25      INSERT INTO t1 VALUES(3,'claire');
    26     26      SELECT *, ( SELECT y FROM (SELECT x.b='alice' AS y) )
    27     27        FROM ( SELECT * FROM t1 ) AS x;
    28     28     }
    29     29   } {2 bob 0 1 alice 1 3 claire 0}
           30  +do_test tkt3346-1.2 {
           31  +  db eval {
           32  +    SELECT b FROM (SELECT * FROM t1) AS x
           33  +     WHERE (SELECT y FROM (SELECT x.b='alice' AS y))=0
           34  +  }
           35  +} {bob claire}
           36  +do_test tkt3346-1.3 {
           37  +  db eval {
           38  +    SELECT b FROM (SELECT * FROM t1 ORDER BY a) AS x
           39  +     WHERE (SELECT y FROM (SELECT a||b y FROM t1 WHERE t1.b=x.b))=(x.a||x.b)
           40  +  }
           41  +} {alice bob claire}
           42  +do_test tkt3346-1.4 {
           43  +  db eval {
           44  +    SELECT b FROM (SELECT * FROM t1 ORDER BY a) AS x
           45  +     WHERE (SELECT y FROM (SELECT a||b y FROM t1 WHERE t1.b=x.b))=('2'||x.b)
           46  +  }
           47  +} {bob}
    30     48   
    31     49   # Ticket #3530
    32     50   #
    33     51   # As shown by ticket #3346 above (see also ticket #3298) it is important
    34     52   # that a subquery in the result-set be able to look up through multiple
    35     53   # FROM levels in order to view tables in the FROM clause at the top level.
    36     54   #