tkt-a7b7803e.test 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. # 2012 December 19
  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 [a7b7803e8d1e8699cd8a460a38133b98892d2e17] has
  13. # been fixed.
  14. #
  15. set testdir [file dirname $argv0]
  16. source $testdir/tester.tcl
  17. source $testdir/lock_common.tcl
  18. source $testdir/malloc_common.tcl
  19. do_test tkt-a7b7803e.1 {
  20. db eval {
  21. CREATE TABLE t1(a,b);
  22. INSERT INTO t1 VALUES(0,'first'),(99,'fuzzy');
  23. SELECT (t1.a==0) AS x, b
  24. FROM t1
  25. WHERE a=0 OR x;
  26. }
  27. } {1 first}
  28. do_test tkt-a7b7803e.2 {
  29. db eval {
  30. SELECT a, (t1.b='fuzzy') AS x
  31. FROM t1
  32. WHERE x
  33. }
  34. } {99 1}
  35. do_test tkt-a7b7803e.3 {
  36. db eval {
  37. SELECT (a=99) AS x, (t1.b='fuzzy') AS y, *
  38. FROM t1
  39. WHERE x AND y
  40. }
  41. } {1 1 99 fuzzy}
  42. do_test tkt-a7b7803e.4 {
  43. db eval {
  44. SELECT (a=99) AS x, (t1.b='first') AS y, *
  45. FROM t1
  46. WHERE x OR y
  47. ORDER BY a
  48. }
  49. } {0 1 0 first 1 0 99 fuzzy}
  50. do_test tkt-a7b7803e.5 {
  51. db eval {
  52. SELECT (M.a=99) AS x, M.b, (N.b='first') AS y, N.b
  53. FROM t1 M, t1 N
  54. WHERE x OR y
  55. ORDER BY M.a, N.a
  56. }
  57. } {0 first 1 first 1 fuzzy 1 first 1 fuzzy 0 fuzzy}
  58. do_test tkt-a7b7803e.6 {
  59. db eval {
  60. SELECT (M.a=99) AS x, M.b, (N.b='first') AS y, N.b
  61. FROM t1 M, t1 N
  62. WHERE x AND y
  63. ORDER BY M.a, N.a
  64. }
  65. } {1 fuzzy 1 first}
  66. do_test tkt-a7b7803e.7 {
  67. db eval {
  68. SELECT (M.a=99) AS x, M.b, (N.b='first') AS y, N.b
  69. FROM t1 M JOIN t1 N ON x AND y
  70. ORDER BY M.a, N.a
  71. }
  72. } {1 fuzzy 1 first}
  73. do_test tkt-a7b7803e.8 {
  74. db eval {
  75. SELECT (M.a=99) AS x, M.b, (N.b='first') AS y, N.b
  76. FROM t1 M JOIN t1 N ON x
  77. ORDER BY M.a, N.a
  78. }
  79. } {1 fuzzy 1 first 1 fuzzy 0 fuzzy}
  80. finish_test