PageRenderTime 41ms CodeModel.GetById 15ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/src/sqlite/test/join2.test

#
Unknown | 75 lines | 71 code | 4 blank | 0 comment | 0 complexity | 4add97f8e8653bdb129b8f58c7251d55 MD5 | raw file
Possible License(s): BSD-3-Clause
  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.
  14. #
  15. # $Id: join2.test,v 1.2 2005/01/21 03:12:16 danielk1977 Exp $
  16. set testdir [file dirname $argv0]
  17. source $testdir/tester.tcl
  18. do_test join2-1.1 {
  19. execsql {
  20. CREATE TABLE t1(a,b);
  21. INSERT INTO t1 VALUES(1,11);
  22. INSERT INTO t1 VALUES(2,22);
  23. INSERT INTO t1 VALUES(3,33);
  24. SELECT * FROM t1;
  25. }
  26. } {1 11 2 22 3 33}
  27. do_test join2-1.2 {
  28. execsql {
  29. CREATE TABLE t2(b,c);
  30. INSERT INTO t2 VALUES(11,111);
  31. INSERT INTO t2 VALUES(33,333);
  32. INSERT INTO t2 VALUES(44,444);
  33. SELECT * FROM t2;
  34. }
  35. } {11 111 33 333 44 444};
  36. do_test join2-1.3 {
  37. execsql {
  38. CREATE TABLE t3(c,d);
  39. INSERT INTO t3 VALUES(111,1111);
  40. INSERT INTO t3 VALUES(444,4444);
  41. INSERT INTO t3 VALUES(555,5555);
  42. SELECT * FROM t3;
  43. }
  44. } {111 1111 444 4444 555 5555}
  45. do_test join2-1.4 {
  46. execsql {
  47. SELECT * FROM
  48. t1 NATURAL JOIN t2 NATURAL JOIN t3
  49. }
  50. } {1 11 111 1111}
  51. do_test join2-1.5 {
  52. execsql {
  53. SELECT * FROM
  54. t1 NATURAL JOIN t2 NATURAL LEFT OUTER JOIN t3
  55. }
  56. } {1 11 111 1111 3 33 333 {}}
  57. do_test join2-1.6 {
  58. execsql {
  59. SELECT * FROM
  60. t1 NATURAL LEFT OUTER JOIN t2 NATURAL JOIN t3
  61. }
  62. } {1 11 111 1111}
  63. ifcapable subquery {
  64. do_test join2-1.7 {
  65. execsql {
  66. SELECT * FROM
  67. t1 NATURAL LEFT OUTER JOIN (t2 NATURAL JOIN t3)
  68. }
  69. } {1 11 111 1111 2 22 {} {} 3 33 {} {}}
  70. }
  71. finish_test