tkt3461.test 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. # 2008 October 25
  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 #3461 has been
  14. # fixed.
  15. #
  16. # $Id: tkt3461.test,v 1.4 2009/06/05 17:09:12 drh Exp $
  17. set testdir [file dirname $argv0]
  18. source $testdir/tester.tcl
  19. ####################################
  20. ####################################
  21. # REMOVE THESE TWO LINES:
  22. ####################################
  23. ####################################
  24. #finish_test
  25. #return
  26. do_test tkt3461-1.1 {
  27. execsql {
  28. CREATE TABLE t1(a, b);
  29. INSERT INTO t1 VALUES(1, 2);
  30. }
  31. } {}
  32. do_test tkt3461-1.2 {
  33. execsql { SELECT a, b+1 AS b_plus_one FROM t1 WHERE a=1 }
  34. } {1 3}
  35. do_test tkt3461-1.3 {
  36. # explain { SELECT a, b+1 AS b_plus_one FROM t1 WHERE a=1 OR b_plus_one }
  37. # execsql { PRAGMA vdbe_trace = 1; PRAGMA vdbe_listing=1 }
  38. execsql { SELECT a, b+1 AS b_plus_one FROM t1 WHERE a=1 OR b_plus_one }
  39. } {1 3}
  40. do_test tkt3461-2.1 {
  41. execsql {
  42. SELECT a, b+1 AS b_plus_one
  43. FROM t1
  44. WHERE CASE WHEN a=1 THEN 1 ELSE b_plus_one END
  45. }
  46. } {1 3}
  47. do_test tkt3461-3.1 {
  48. execsql {
  49. CREATE TABLE t2(c, d);
  50. INSERT INTO t2 VALUES(3, 4);
  51. }
  52. # execsql { PRAGMA vdbe_trace = 1; PRAGMA vdbe_listing=1 }
  53. execsql {
  54. SELECT a, b+1 AS b_plus_one, c, d
  55. FROM t1 LEFT JOIN t2
  56. ON (a=c AND d=b_plus_one)
  57. }
  58. } {1 3 {} {}}
  59. finish_test