join3.test 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. # 2002 May 24
  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.
  12. #
  13. # This file implements tests for joins, including outer joins, where
  14. # there are a large number of tables involved in the join.
  15. #
  16. # $Id: join3.test,v 1.4 2005/01/19 23:24:51 drh Exp $
  17. set testdir [file dirname $argv0]
  18. source $testdir/tester.tcl
  19. # An unrestricted join
  20. #
  21. catch {unset ::result}
  22. set result {}
  23. for {set N 1} {$N<=$bitmask_size} {incr N} {
  24. lappend result $N
  25. do_test join3-1.$N {
  26. execsql "CREATE TABLE t${N}(x);"
  27. execsql "INSERT INTO t$N VALUES($N)"
  28. set sql "SELECT * FROM t1"
  29. for {set i 2} {$i<=$N} {incr i} {append sql ", t$i"}
  30. execsql $sql
  31. } $result
  32. }
  33. # Joins with a comparison
  34. #
  35. set result {}
  36. for {set N 1} {$N<=$bitmask_size} {incr N} {
  37. lappend result $N
  38. do_test join3-2.$N {
  39. set sql "SELECT * FROM t1"
  40. for {set i 2} {$i<=$N} {incr i} {append sql ", t$i"}
  41. set sep WHERE
  42. for {set i 1} {$i<$N} {incr i} {
  43. append sql " $sep t[expr {$i+1}].x==t$i.x+1"
  44. set sep AND
  45. }
  46. execsql $sql
  47. } $result
  48. }
  49. # Error of too many tables in the join
  50. #
  51. do_test join3-3.1 {
  52. set sql "SELECT * FROM t1 AS t0, t1"
  53. for {set i 2} {$i<=$bitmask_size} {incr i} {append sql ", t$i"}
  54. catchsql $sql
  55. } [list 1 "at most $bitmask_size tables in a join"]
  56. finish_test