drh | d820cb1 | 2002-02-18 03:21:45 +0000 | [diff] [blame^] | 1 | # 2001 September 15 |
| 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. The |
| 12 | # focus of this file is testing SELECT statements that contain |
| 13 | # subqueries in their FROM clause. |
| 14 | # |
| 15 | # $Id: select6.test,v 1.1 2002/02/18 03:21:47 drh Exp $ |
| 16 | |
| 17 | set testdir [file dirname $argv0] |
| 18 | source $testdir/tester.tcl |
| 19 | |
| 20 | # Build some test data |
| 21 | # |
| 22 | set fd [open data1.txt w] |
| 23 | for {set i 1} {$i<32} {incr i} { |
| 24 | for {set j 0} {pow(2,$j)<$i} {incr j} {} |
| 25 | puts $fd "[expr {32-$i}]\t[expr {10-$j}]" |
| 26 | } |
| 27 | close $fd |
| 28 | execsql { |
| 29 | CREATE TABLE t1(x int, y int); |
| 30 | COPY t1 FROM 'data1.txt' |
| 31 | } |
| 32 | file delete data1.txt |
| 33 | |
| 34 | do_test select6-1.0 { |
| 35 | execsql {SELECT DISTINCT y FROM t1 ORDER BY y} |
| 36 | } {5 6 7 8 9 10} |
| 37 | |
| 38 | do_test select6-1.1 { |
| 39 | execsql2 {SELECT * FROM (SELECT x, y FROM t1 ORDER BY x LIMIT 1)} |
| 40 | } {x 31 y 10} |
| 41 | do_test select6-1.2 { |
| 42 | execsql {SELECT count(*) FROM (SELECT y FROM t1)} |
| 43 | } {31} |
| 44 | do_test select6-1.3 { |
| 45 | execsql {SELECT count(*) FROM (SELECT DISTINCT y FROM t1)} |
| 46 | } {6} |
| 47 | do_test select6-1.4 { |
| 48 | execsql {SELECT count(*) FROM (SELECT DISTINCT * FROM (SELECT y FROM t1))} |
| 49 | } {6} |
| 50 | do_test select6-1.5 { |
| 51 | execsql {SELECT count(*) FROM (SELECT * FROM (SELECT DISTINCT y FROM t1))} |
| 52 | } {6} |
| 53 | |
| 54 | |
| 55 | |
| 56 | finish_test |