sl@0: # 2002 May 24 sl@0: # sl@0: # The author disclaims copyright to this source code. In place of sl@0: # a legal notice, here is a blessing: sl@0: # sl@0: # May you do good and not evil. sl@0: # May you find forgiveness for yourself and forgive others. sl@0: # May you share freely, never taking more than you give. sl@0: # sl@0: #*********************************************************************** sl@0: # This file implements regression tests for SQLite library. sl@0: # sl@0: # This file implements tests for joins, including outer joins, where sl@0: # there are a large number of tables involved in the join. sl@0: # sl@0: # $Id: join3.test,v 1.4 2005/01/19 23:24:51 drh Exp $ sl@0: sl@0: set testdir [file dirname $argv0] sl@0: source $testdir/tester.tcl sl@0: sl@0: # An unrestricted join sl@0: # sl@0: catch {unset ::result} sl@0: set result {} sl@0: for {set N 1} {$N<=$bitmask_size} {incr N} { sl@0: lappend result $N sl@0: do_test join3-1.$N { sl@0: execsql "CREATE TABLE t${N}(x);" sl@0: execsql "INSERT INTO t$N VALUES($N)" sl@0: set sql "SELECT * FROM t1" sl@0: for {set i 2} {$i<=$N} {incr i} {append sql ", t$i"} sl@0: execsql $sql sl@0: } $result sl@0: } sl@0: sl@0: # Joins with a comparison sl@0: # sl@0: set result {} sl@0: for {set N 1} {$N<=$bitmask_size} {incr N} { sl@0: lappend result $N sl@0: do_test join3-2.$N { sl@0: set sql "SELECT * FROM t1" sl@0: for {set i 2} {$i<=$N} {incr i} {append sql ", t$i"} sl@0: set sep WHERE sl@0: for {set i 1} {$i<$N} {incr i} { sl@0: append sql " $sep t[expr {$i+1}].x==t$i.x+1" sl@0: set sep AND sl@0: } sl@0: execsql $sql sl@0: } $result sl@0: } sl@0: sl@0: # Error of too many tables in the join sl@0: # sl@0: do_test join3-3.1 { sl@0: set sql "SELECT * FROM t1 AS t0, t1" sl@0: for {set i 2} {$i<=$bitmask_size} {incr i} {append sql ", t$i"} sl@0: catchsql $sql sl@0: } [list 1 "at most $bitmask_size tables in a join"] sl@0: sl@0: sl@0: finish_test