1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-30 19:03:16 +03:00

Test and documentation updates for sub-queries. (CVS 373)

FossilOrigin-Name: 607c0c49b2098771020514198cb1076de8245a62
This commit is contained in:
drh
2002-02-18 03:21:45 +00:00
parent 22f70c32f0
commit d820cb1b75
5 changed files with 104 additions and 38 deletions

56
test/select6.test Normal file
View File

@ -0,0 +1,56 @@
# 2001 September 15
#
# The author disclaims copyright to this source code. In place of
# a legal notice, here is a blessing:
#
# May you do good and not evil.
# May you find forgiveness for yourself and forgive others.
# May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library. The
# focus of this file is testing SELECT statements that contain
# subqueries in their FROM clause.
#
# $Id: select6.test,v 1.1 2002/02/18 03:21:47 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
# Build some test data
#
set fd [open data1.txt w]
for {set i 1} {$i<32} {incr i} {
for {set j 0} {pow(2,$j)<$i} {incr j} {}
puts $fd "[expr {32-$i}]\t[expr {10-$j}]"
}
close $fd
execsql {
CREATE TABLE t1(x int, y int);
COPY t1 FROM 'data1.txt'
}
file delete data1.txt
do_test select6-1.0 {
execsql {SELECT DISTINCT y FROM t1 ORDER BY y}
} {5 6 7 8 9 10}
do_test select6-1.1 {
execsql2 {SELECT * FROM (SELECT x, y FROM t1 ORDER BY x LIMIT 1)}
} {x 31 y 10}
do_test select6-1.2 {
execsql {SELECT count(*) FROM (SELECT y FROM t1)}
} {31}
do_test select6-1.3 {
execsql {SELECT count(*) FROM (SELECT DISTINCT y FROM t1)}
} {6}
do_test select6-1.4 {
execsql {SELECT count(*) FROM (SELECT DISTINCT * FROM (SELECT y FROM t1))}
} {6}
do_test select6-1.5 {
execsql {SELECT count(*) FROM (SELECT * FROM (SELECT DISTINCT y FROM t1))}
} {6}
finish_test