blob: 305066eeb4eb140c8f93050b9f2a79add72afe3b [file] [log] [blame]
drhd820cb12002-02-18 03:21:45 +00001# 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
17set testdir [file dirname $argv0]
18source $testdir/tester.tcl
19
20# Build some test data
21#
22set fd [open data1.txt w]
23for {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}
27close $fd
28execsql {
29 CREATE TABLE t1(x int, y int);
30 COPY t1 FROM 'data1.txt'
31}
32file delete data1.txt
33
34do_test select6-1.0 {
35 execsql {SELECT DISTINCT y FROM t1 ORDER BY y}
36} {5 6 7 8 9 10}
37
38do_test select6-1.1 {
39 execsql2 {SELECT * FROM (SELECT x, y FROM t1 ORDER BY x LIMIT 1)}
40} {x 31 y 10}
41do_test select6-1.2 {
42 execsql {SELECT count(*) FROM (SELECT y FROM t1)}
43} {31}
44do_test select6-1.3 {
45 execsql {SELECT count(*) FROM (SELECT DISTINCT y FROM t1)}
46} {6}
47do_test select6-1.4 {
48 execsql {SELECT count(*) FROM (SELECT DISTINCT * FROM (SELECT y FROM t1))}
49} {6}
50do_test select6-1.5 {
51 execsql {SELECT count(*) FROM (SELECT * FROM (SELECT DISTINCT y FROM t1))}
52} {6}
53
54
55
56finish_test