tkt-54844eea3f.test 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. # 2011 July 8
  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. The
  12. # focus of this file is testing that bug [54844eea3f] has been fixed.
  13. #
  14. set testdir [file dirname $argv0]
  15. source $testdir/tester.tcl
  16. set ::testprefix tkt-54844eea3f
  17. do_test 1.0 {
  18. execsql {
  19. CREATE TABLE t1(a INTEGER PRIMARY KEY);
  20. INSERT INTO t1 VALUES(1);
  21. INSERT INTO t1 VALUES(4);
  22. CREATE TABLE t2(b INTEGER PRIMARY KEY);
  23. INSERT INTO t2 VALUES(1);
  24. INSERT INTO t2 VALUES(2);
  25. INSERT INTO t2 SELECT b+2 FROM t2;
  26. INSERT INTO t2 SELECT b+4 FROM t2;
  27. INSERT INTO t2 SELECT b+8 FROM t2;
  28. INSERT INTO t2 SELECT b+16 FROM t2;
  29. CREATE TABLE t3(c INTEGER PRIMARY KEY);
  30. INSERT INTO t3 VALUES(1);
  31. INSERT INTO t3 VALUES(2);
  32. INSERT INTO t3 VALUES(3);
  33. }
  34. } {}
  35. do_test 1.1 {
  36. execsql {
  37. SELECT 'test-2', t3.c, (
  38. SELECT count(*)
  39. FROM t1 JOIN (SELECT DISTINCT t3.c AS p FROM t2) AS x ON t1.a=x.p
  40. )
  41. FROM t3;
  42. }
  43. } {test-2 1 1 test-2 2 0 test-2 3 0}
  44. do_test 1.2 {
  45. execsql {
  46. CREATE TABLE t4(a, b, c);
  47. INSERT INTO t4 VALUES('a', 1, 'one');
  48. INSERT INTO t4 VALUES('a', 2, 'two');
  49. INSERT INTO t4 VALUES('b', 1, 'three');
  50. INSERT INTO t4 VALUES('b', 2, 'four');
  51. SELECT (
  52. SELECT c FROM (
  53. SELECT * FROM t4 WHERE a=out.a ORDER BY b LIMIT 10 OFFSET 1
  54. ) WHERE b=out.b
  55. ) FROM t4 AS out;
  56. }
  57. } {{} two {} four}
  58. finish_test