tkt3334.test 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. # 2008 August 26
  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. #
  12. # This file implements regression tests for SQLite library.
  13. # Specifically, it tests that bug #3334 has been fixed by the
  14. # addition of restriction (19) to the subquery flattener optimization.
  15. #
  16. # $Id: tkt3334.test,v 1.1 2008/08/26 12:56:14 drh Exp $
  17. set testdir [file dirname $argv0]
  18. source $testdir/tester.tcl
  19. do_test tkt3334-1.0 {
  20. execsql {
  21. CREATE TABLE t1(a,b);
  22. INSERT INTO t1 VALUES(1,934);
  23. INSERT INTO t1 VALUES(2,221);
  24. INSERT INTO t1 VALUES(1,372);
  25. INSERT INTO t1 VALUES(3,552);
  26. INSERT INTO t1 VALUES(1,719);
  27. INSERT INTO t1 VALUES(4,102);
  28. SELECT * FROM t1 ORDER BY b;
  29. }
  30. } {4 102 2 221 1 372 3 552 1 719 1 934}
  31. do_test tkt3334-1.1 {
  32. execsql {
  33. SELECT a FROM (SELECT a FROM t1 ORDER BY b LIMIT 2) WHERE a=1;
  34. }
  35. } {}
  36. do_test tkt3334-1.2 {
  37. execsql {
  38. SELECT count(*) FROM (SELECT a FROM t1 ORDER BY b LIMIT 2) WHERE a=1;
  39. }
  40. } {0}
  41. do_test tkt3334-1.3 {
  42. execsql {
  43. SELECT a FROM (SELECT a FROM t1 ORDER BY b LIMIT 3) WHERE a=1;
  44. }
  45. } {1}
  46. do_test tkt3334-1.4 {
  47. execsql {
  48. SELECT count(*) FROM (SELECT a FROM t1 ORDER BY b LIMIT 3) WHERE a=1;
  49. }
  50. } {1}
  51. do_test tkt3334-1.5 {
  52. execsql {
  53. SELECT a FROM (SELECT a FROM t1 ORDER BY b LIMIT 99) WHERE a=1;
  54. }
  55. } {1 1 1}
  56. do_test tkt3334-1.6 {
  57. execsql {
  58. SELECT count(*) FROM (SELECT a FROM t1 ORDER BY b LIMIT 99) WHERE a=1;
  59. }
  60. } {3}
  61. do_test tkt3334-1.7 {
  62. execsql {
  63. SELECT a FROM (SELECT a FROM t1 ORDER BY b) WHERE a=1;
  64. }
  65. } {1 1 1}
  66. do_test tkt3334-1.8 {
  67. execsql {
  68. SELECT count(*) FROM (SELECT a FROM t1 ORDER BY b) WHERE a=1;
  69. }
  70. } {3}
  71. do_test tkt3334-1.9 {
  72. execsql {
  73. SELECT a FROM (SELECT a FROM t1) WHERE a=1;
  74. }
  75. } {1 1 1}
  76. do_test tkt3334-1.10 {
  77. execsql {
  78. SELECT count(*) FROM (SELECT a FROM t1) WHERE a=1;
  79. }
  80. } {3}