tkt1537.test 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. # 2005 November 26
  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 to verify that ticket #1537 is
  14. # fixed.
  15. #
  16. set testdir [file dirname $argv0]
  17. source $testdir/tester.tcl
  18. do_test tkt1537-1.1 {
  19. execsql {
  20. CREATE TABLE t1(id, a1, a2);
  21. INSERT INTO t1 VALUES(1, NULL, NULL);
  22. INSERT INTO t1 VALUES(2, 1, 3);
  23. CREATE TABLE t2(id, b);
  24. INSERT INTO t2 VALUES(3, 1);
  25. INSERT INTO t2 VALUES(4, NULL);
  26. SELECT * FROM t1 LEFT JOIN t2 ON a1=b OR a2=+b;
  27. }
  28. } {1 {} {} {} {} 2 1 3 3 1}
  29. do_test tkt1537-1.2 {
  30. execsql {
  31. SELECT * FROM t1 LEFT JOIN t2 ON a1=b OR a2=b;
  32. }
  33. } {1 {} {} {} {} 2 1 3 3 1}
  34. do_test tkt1537-1.3 {
  35. execsql {
  36. SELECT * FROM t2 LEFT JOIN t1 ON a1=b OR a2=b;
  37. }
  38. } {3 1 2 1 3 4 {} {} {} {}}
  39. ifcapable subquery {
  40. do_test tkt1537-1.4 {
  41. execsql {
  42. SELECT * FROM t1 LEFT JOIN t2 ON b IN (a1,a2);
  43. }
  44. } {1 {} {} {} {} 2 1 3 3 1}
  45. do_test tkt1537-1.5 {
  46. execsql {
  47. SELECT * FROM t2 LEFT JOIN t1 ON b IN (a2,a1);
  48. }
  49. } {3 1 2 1 3 4 {} {} {} {}}
  50. }
  51. do_test tkt1537-1.6 {
  52. execsql {
  53. CREATE INDEX t1a1 ON t1(a1);
  54. CREATE INDEX t1a2 ON t1(a2);
  55. CREATE INDEX t2b ON t2(b);
  56. SELECT * FROM t1 LEFT JOIN t2 ON a1=b OR a2=b;
  57. }
  58. } {1 {} {} {} {} 2 1 3 3 1}
  59. do_test tkt1537-1.7 {
  60. execsql {
  61. SELECT * FROM t2 LEFT JOIN t1 ON a1=b OR a2=b;
  62. }
  63. } {3 1 2 1 3 4 {} {} {} {}}
  64. ifcapable subquery {
  65. do_test tkt1537-1.8 {
  66. execsql {
  67. SELECT * FROM t1 LEFT JOIN t2 ON b IN (a1,a2);
  68. }
  69. } {1 {} {} {} {} 2 1 3 3 1}
  70. do_test tkt1537-1.9 {
  71. execsql {
  72. SELECT * FROM t2 LEFT JOIN t1 ON b IN (a2,a1);
  73. }
  74. } {3 1 2 1 3 4 {} {} {} {}}
  75. }
  76. execsql {
  77. DROP INDEX t1a1;
  78. DROP INDEX t1a2;
  79. DROP INDEX t2b;
  80. }
  81. do_test tkt1537-2.1 {
  82. execsql {
  83. SELECT * FROM t1 LEFT JOIN t2 ON b BETWEEN a1 AND a2;
  84. }
  85. } {1 {} {} {} {} 2 1 3 3 1}
  86. do_test tkt1537-2.2 {
  87. execsql {
  88. CREATE INDEX t2b ON t2(b);
  89. SELECT * FROM t1 LEFT JOIN t2 ON b BETWEEN a1 AND a2;
  90. }
  91. } {1 {} {} {} {} 2 1 3 3 1}
  92. do_test tkt1537-2.3 {
  93. execsql {
  94. SELECT * FROM t2 LEFT JOIN t1 ON b BETWEEN a1 AND a2;
  95. }
  96. } {3 1 2 1 3 4 {} {} {} {}}
  97. do_test tkt1537-2.4 {
  98. execsql {
  99. CREATE INDEX t1a1 ON t1(a1);
  100. CREATE INDEX t1a2 ON t1(a2);
  101. SELECT * FROM t2 LEFT JOIN t1 ON b BETWEEN a1 AND a2;
  102. }
  103. } {3 1 2 1 3 4 {} {} {} {}}
  104. do_test tkt1537-3.1 {
  105. execsql {
  106. SELECT * FROM t1 LEFT JOIN t2 ON b GLOB 'abc*' WHERE t1.id=1;
  107. }
  108. } {1 {} {} {} {}}
  109. do_test tkt1537-3.2 {
  110. execsql {
  111. SELECT * FROM t2 LEFT JOIN t1 ON a1 GLOB 'abc*' WHERE t2.id=3;
  112. }
  113. } {3 1 {} {} {}}
  114. finish_test