1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/persistentdata/persistentstorage/sqlite3api/TEST/TclScript/join3.test Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,62 @@
1.4 +# 2002 May 24
1.5 +#
1.6 +# The author disclaims copyright to this source code. In place of
1.7 +# a legal notice, here is a blessing:
1.8 +#
1.9 +# May you do good and not evil.
1.10 +# May you find forgiveness for yourself and forgive others.
1.11 +# May you share freely, never taking more than you give.
1.12 +#
1.13 +#***********************************************************************
1.14 +# This file implements regression tests for SQLite library.
1.15 +#
1.16 +# This file implements tests for joins, including outer joins, where
1.17 +# there are a large number of tables involved in the join.
1.18 +#
1.19 +# $Id: join3.test,v 1.4 2005/01/19 23:24:51 drh Exp $
1.20 +
1.21 +set testdir [file dirname $argv0]
1.22 +source $testdir/tester.tcl
1.23 +
1.24 +# An unrestricted join
1.25 +#
1.26 +catch {unset ::result}
1.27 +set result {}
1.28 +for {set N 1} {$N<=$bitmask_size} {incr N} {
1.29 + lappend result $N
1.30 + do_test join3-1.$N {
1.31 + execsql "CREATE TABLE t${N}(x);"
1.32 + execsql "INSERT INTO t$N VALUES($N)"
1.33 + set sql "SELECT * FROM t1"
1.34 + for {set i 2} {$i<=$N} {incr i} {append sql ", t$i"}
1.35 + execsql $sql
1.36 + } $result
1.37 +}
1.38 +
1.39 +# Joins with a comparison
1.40 +#
1.41 +set result {}
1.42 +for {set N 1} {$N<=$bitmask_size} {incr N} {
1.43 + lappend result $N
1.44 + do_test join3-2.$N {
1.45 + set sql "SELECT * FROM t1"
1.46 + for {set i 2} {$i<=$N} {incr i} {append sql ", t$i"}
1.47 + set sep WHERE
1.48 + for {set i 1} {$i<$N} {incr i} {
1.49 + append sql " $sep t[expr {$i+1}].x==t$i.x+1"
1.50 + set sep AND
1.51 + }
1.52 + execsql $sql
1.53 + } $result
1.54 +}
1.55 +
1.56 +# Error of too many tables in the join
1.57 +#
1.58 +do_test join3-3.1 {
1.59 + set sql "SELECT * FROM t1 AS t0, t1"
1.60 + for {set i 2} {$i<=$bitmask_size} {incr i} {append sql ", t$i"}
1.61 + catchsql $sql
1.62 +} [list 1 "at most $bitmask_size tables in a join"]
1.63 +
1.64 +
1.65 +finish_test