tkt-fc7bd6358f.test 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. # 2013 March 05
  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. Specifically,
  12. # it tests that ticket [fc7bd6358f]:
  13. #
  14. # The following SQL yields an incorrect result (zero rows) in all
  15. # versions of SQLite between 3.6.14 and 3.7.15.2:
  16. #
  17. # CREATE TABLE t(textid TEXT);
  18. # INSERT INTO t VALUES('12');
  19. # INSERT INTO t VALUES('34');
  20. # CREATE TABLE i(intid INTEGER PRIMARY KEY);
  21. # INSERT INTO i VALUES(12);
  22. # INSERT INTO i VALUES(34);
  23. #
  24. # SELECT t1.textid AS a, i.intid AS b, t2.textid AS c
  25. # FROM t t1, i, t t2
  26. # WHERE t1.textid = i.intid
  27. # AND t1.textid = t2.textid;
  28. #
  29. # The correct result should be two rows, one with 12|12|12 and the other
  30. # with 34|34|34. With this bug, no rows are returned. Bisecting shows that
  31. # this bug was introduced with check-in [dd4d67a67454] on 2009-04-23.
  32. #
  33. set testdir [file dirname $argv0]
  34. source $testdir/tester.tcl
  35. do_test tkt-fc7bd6358f.100 {
  36. db eval {
  37. CREATE TABLE t(textid TEXT);
  38. INSERT INTO t VALUES('12');
  39. INSERT INTO t VALUES('34');
  40. CREATE TABLE i(intid INTEGER PRIMARY KEY);
  41. INSERT INTO i VALUES(12);
  42. INSERT INTO i VALUES(34);
  43. }
  44. } {}
  45. unset -nocomplain from
  46. unset -nocomplain where
  47. unset -nocomplain a
  48. unset -nocomplain b
  49. foreach {a from} {
  50. 1 {FROM t t1, i, t t2}
  51. 2 {FROM i, t t1, t t2}
  52. 3 {FROM t t1, t t2, i}
  53. } {
  54. foreach {b where} {
  55. 1 {WHERE t1.textid=i.intid AND t1.textid=t2.textid}
  56. 2 {WHERE i.intid=t1.textid AND t1.textid=t2.textid}
  57. 3 {WHERE t1.textid=i.intid AND i.intid=t2.textid}
  58. 4 {WHERE t1.textid=i.intid AND t2.textid=i.intid}
  59. 5 {WHERE i.intid=t1.textid AND i.intid=t2.textid}
  60. 6 {WHERE i.intid=t1.textid AND t2.textid=i.intid}
  61. 7 {WHERE t1.textid=t2.textid AND i.intid=t2.textid}
  62. 8 {WHERE t1.textid=t2.textid AND t2.textid=i.intid}
  63. } {
  64. do_test tkt-fc7bd6358f.110.$a.$b.1 {
  65. db eval {PRAGMA automatic_index=ON}
  66. db eval "SELECT t1.textid, i.intid, t2.textid $from $where"
  67. } {12 12 12 34 34 34}
  68. do_test tkt-fc7bd6358f.110.$a.$b.2 {
  69. db eval {PRAGMA automatic_index=OFF}
  70. db eval "SELECT t1.textid, i.intid, t2.textid $from $where"
  71. } {12 12 12 34 34 34}
  72. }
  73. }
  74. finish_test