transitive1.test 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. # 2013 April 17
  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. The
  12. # focus of this script is testing of transitive WHERE clause constraints
  13. #
  14. set testdir [file dirname $argv0]
  15. source $testdir/tester.tcl
  16. do_execsql_test transitive1-100 {
  17. CREATE TABLE t1(a TEXT, b TEXT, c TEXT COLLATE NOCASE);
  18. INSERT INTO t1 VALUES('abc','abc','Abc');
  19. INSERT INTO t1 VALUES('def','def','def');
  20. INSERT INTO t1 VALUES('ghi','ghi','GHI');
  21. CREATE INDEX t1a1 ON t1(a);
  22. CREATE INDEX t1a2 ON t1(a COLLATE nocase);
  23. SELECT * FROM t1 WHERE a=b AND c=b AND c='DEF';
  24. } {def def def}
  25. do_execsql_test transitive1-110 {
  26. SELECT * FROM t1 WHERE a=b AND c=b AND c>='DEF' ORDER BY +a;
  27. } {def def def ghi ghi GHI}
  28. do_execsql_test transitive1-120 {
  29. SELECT * FROM t1 WHERE a=b AND c=b AND c<='DEF' ORDER BY +a;
  30. } {abc abc Abc def def def}
  31. do_execsql_test transitive1-200 {
  32. CREATE TABLE t2(a INTEGER, b INTEGER, c TEXT);
  33. INSERT INTO t2 VALUES(100,100,100);
  34. INSERT INTO t2 VALUES(20,20,20);
  35. INSERT INTO t2 VALUES(3,3,3);
  36. SELECT * FROM t2 WHERE a=b AND c=b AND c=20;
  37. } {20 20 20}
  38. do_execsql_test transitive1-210 {
  39. SELECT * FROM t2 WHERE a=b AND c=b AND c>=20 ORDER BY +a;
  40. } {3 3 3 20 20 20}
  41. do_execsql_test transitive1-220 {
  42. SELECT * FROM t2 WHERE a=b AND c=b AND c<=20 ORDER BY +a;
  43. } {20 20 20 100 100 100}
  44. # Test cases for ticket [[d805526eae253103] 2013-07-08
  45. # "Incorrect join result or assertion fault due to transitive constraints"
  46. #
  47. do_execsql_test transitive1-300 {
  48. CREATE TABLE t301(w INTEGER PRIMARY KEY, x);
  49. CREATE TABLE t302(y INTEGER UNIQUE, z);
  50. INSERT INTO t301 VALUES(1,2),(3,4),(5,6);
  51. INSERT INTO t302 VALUES(1,3),(3,6),(5,7);
  52. SELECT *
  53. FROM t301 CROSS JOIN t302
  54. WHERE w=y AND y IS NOT NULL
  55. ORDER BY +w;
  56. } {1 2 1 3 3 4 3 6 5 6 5 7}
  57. do_execsql_test transitive1-301 {
  58. SELECT *
  59. FROM t301 CROSS JOIN t302
  60. WHERE w=y AND y IS NOT NULL
  61. ORDER BY w;
  62. } {1 2 1 3 3 4 3 6 5 6 5 7}
  63. do_execsql_test transitive1-310 {
  64. SELECT *
  65. FROM t301 CROSS JOIN t302 ON w=y
  66. WHERE y>1
  67. ORDER BY +w
  68. } {3 4 3 6 5 6 5 7}
  69. do_execsql_test transitive1-311 {
  70. SELECT *
  71. FROM t301 CROSS JOIN t302 ON w=y
  72. WHERE y>1
  73. ORDER BY w
  74. } {3 4 3 6 5 6 5 7}
  75. do_execsql_test transitive1-312 {
  76. SELECT *
  77. FROM t301 CROSS JOIN t302 ON w=y
  78. WHERE y>1
  79. ORDER BY w DESC
  80. } {5 6 5 7 3 4 3 6}
  81. do_execsql_test transitive1-320 {
  82. SELECT *
  83. FROM t301 CROSS JOIN t302 ON w=y
  84. WHERE y BETWEEN 2 AND 4;
  85. } {3 4 3 6}
  86. do_execsql_test transitive1-331 {
  87. SELECT *
  88. FROM t301 CROSS JOIN t302 ON w=y
  89. WHERE y BETWEEN 1 AND 4
  90. ORDER BY w;
  91. } {1 2 1 3 3 4 3 6}
  92. do_execsql_test transitive1-332 {
  93. SELECT *
  94. FROM t301 CROSS JOIN t302 ON w=y
  95. WHERE y BETWEEN 1 AND 4
  96. ORDER BY w DESC;
  97. } {3 4 3 6 1 2 1 3}
  98. finish_test