PageRenderTime 42ms CodeModel.GetById 16ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/src/sqlite/test/tkt-31338dca7e.test

#
Unknown | 77 lines | 69 code | 8 blank | 0 comment | 0 complexity | 01cbd1bf45a95ddb1547ffe88e36d4c7 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. # 2009 December 16
  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 [31338dca7e] has been
  14. # fixed. Ticket [31338dca7e] demonstrates problems with the OR-clause
  15. # optimization in joins where the WHERE clause is of the form
  16. #
  17. # (x AND y) OR z
  18. #
  19. # And the x and y subterms from from different tables of the join.
  20. #
  21. set testdir [file dirname $argv0]
  22. source $testdir/tester.tcl
  23. do_test tkt-31338-1.1 {
  24. db eval {
  25. CREATE TABLE t1(x);
  26. CREATE TABLE t2(y);
  27. INSERT INTO t1 VALUES(111);
  28. INSERT INTO t1 VALUES(222);
  29. INSERT INTO t2 VALUES(333);
  30. INSERT INTO t2 VALUES(444);
  31. SELECT * FROM t1, t2
  32. WHERE (x=111 AND y!=444) OR x=222
  33. ORDER BY x, y;
  34. }
  35. } {111 333 222 333 222 444}
  36. do_test tkt-31338-1.2 {
  37. db eval {
  38. CREATE INDEX t1x ON t1(x);
  39. SELECT * FROM t1, t2
  40. WHERE (x=111 AND y!=444) OR x=222
  41. ORDER BY x, y;
  42. }
  43. } {111 333 222 333 222 444}
  44. do_test tkt-31338-2.1 {
  45. db eval {
  46. CREATE TABLE t3(v,w);
  47. CREATE TABLE t4(x,y);
  48. CREATE TABLE t5(z);
  49. INSERT INTO t3 VALUES(111,222);
  50. INSERT INTO t3 VALUES(333,444);
  51. INSERT INTO t4 VALUES(222,333);
  52. INSERT INTO t4 VALUES(444,555);
  53. INSERT INTO t5 VALUES(888);
  54. INSERT INTO t5 VALUES(999);
  55. SELECT * FROM t3, t4, t5
  56. WHERE (v=111 AND x=w AND z!=999) OR (v=333 AND x=444)
  57. ORDER BY v, w, x, y, z;
  58. }
  59. } {111 222 222 333 888 333 444 444 555 888 333 444 444 555 999}
  60. do_test tkt-31338-2.2 {
  61. db eval {
  62. CREATE INDEX t3v ON t3(v);
  63. CREATE INDEX t4x ON t4(x);
  64. SELECT * FROM t3, t4, t5
  65. WHERE (v=111 AND x=w AND z!=999) OR (v=333 AND x=444)
  66. ORDER BY v, w, x, y, z;
  67. }
  68. } {111 222 222 333 888 333 444 444 555 888 333 444 444 555 999}
  69. finish_test