Add a test for the fixes on this branch.
[sqlite.git] / test / tkt3841.test
blob542c1bb5e7f014a8baf4e19f924379a3d8c6a366
1 # 2009 May 7
3 # The author disclaims copyright to this source code.  In place of
4 # a legal notice, here is a blessing:
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.
10 #***********************************************************************
12 # Ticket #3841
14 # The sqlite3_aggregate_count() is not being reset when an aggregate
15 # functio is used in a correlated subquery.
17 set testdir [file dirname $argv0]
18 source $testdir/tester.tcl
20 ifcapable !subquery {
21   finish_test
22   return
25 sqlite3_db_config db SQLITE_DBCONFIG_DQS_DML 1
26 do_test tkt3841.1 {
27   execsql {
28     CREATE TABLE table2 (key TEXT, x TEXT);
29     CREATE TABLE list (key TEXT, value TEXT);
30   
31     INSERT INTO table2 VALUES ("a", "alist");
32     INSERT INTO table2 VALUES ("b", "blist");
33     INSERT INTO list VALUES ("a", 1);
34     INSERT INTO list VALUES ("a", 2);
35     INSERT INTO list VALUES ("a", 3);
36     INSERT INTO list VALUES ("b", 4);
37     INSERT INTO list VALUES ("b", 5);
38     INSERT INTO list VALUES ("b", 6);
40     SELECT
41       table2.x,
42       (SELECT group_concat(list.value)
43         FROM list
44         WHERE list.key = table2.key)
45     FROM table2;
46   }
47 } {alist 1,2,3 blist 4,5,6}
49 finish_test