tkt3841.test 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. # 2009 May 7
  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. # Ticket #3841
  13. #
  14. # The sqlite3_aggregate_count() is not being reset when an aggregate
  15. # functio is used in a correlated subquery.
  16. #
  17. set testdir [file dirname $argv0]
  18. source $testdir/tester.tcl
  19. ifcapable !subquery {
  20. finish_test
  21. return
  22. }
  23. do_test tkt3841.1 {
  24. execsql {
  25. CREATE TABLE table2 (key TEXT, x TEXT);
  26. CREATE TABLE list (key TEXT, value TEXT);
  27. INSERT INTO table2 VALUES ("a", "alist");
  28. INSERT INTO table2 VALUES ("b", "blist");
  29. INSERT INTO list VALUES ("a", 1);
  30. INSERT INTO list VALUES ("a", 2);
  31. INSERT INTO list VALUES ("a", 3);
  32. INSERT INTO list VALUES ("b", 4);
  33. INSERT INTO list VALUES ("b", 5);
  34. INSERT INTO list VALUES ("b", 6);
  35. SELECT
  36. table2.x,
  37. (SELECT group_concat(list.value)
  38. FROM list
  39. WHERE list.key = table2.key)
  40. FROM table2;
  41. }
  42. } {alist 1,2,3 blist 4,5,6}
  43. finish_test