From: drh Date: Thu, 7 May 2009 12:17:33 +0000 (+0000) Subject: Make sure the iteration counter on aggregate functions is reset each X-Git-Tag: version-3.6.15~134 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=cdd0376a555702563e482d667ec2d8b1ea8abf38;p=thirdparty%2Fsqlite.git Make sure the iteration counter on aggregate functions is reset each time the aggregate is used in an correlated subquery. Ticket #3841. (CVS 6616) FossilOrigin-Name: 4a86de35d57a0c8720772c29431c86cd9be1fb9b --- diff --git a/manifest b/manifest index 263a497173..d6c5ad619c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Version\s3.6.14\s(CVS\s6615) -D 2009-05-07T02:26:08 +C Make\ssure\sthe\siteration\scounter\son\saggregate\sfunctions\sis\sreset\seach\ntime\sthe\saggregate\sis\sused\sin\san\scorrelated\ssubquery.\s\sTicket\s#3841.\s(CVS\s6616) +D 2009-05-07T12:17:34 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in 583e87706abc3026960ed759aff6371faf84c211 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -203,7 +203,7 @@ F src/update.c deb930324dd67b7ad98234e1258a0ebcdd1ca0f9 F src/utf.c 9541d28f40441812c0b40f00334372a0542c00ff F src/util.c 71c2d9d6befc0405377744585461246c30a4474b F src/vacuum.c e8d178004377e97500c7ea87c8a3542976e3ea45 -F src/vdbe.c 3cecc2bb87192a0a425623bd530d67cc1b368ce5 +F src/vdbe.c b859cb274024e5755aa03625251ff859e3e95158 F src/vdbe.h 35a648bc3279a120da24f34d9a25213ec15daf8a F src/vdbeInt.h 43183a2a18654fa570219ab65e53a608057c48ae F src/vdbeapi.c 86aa27a5f3493aaffb8ac051782aa3b22670d7ed @@ -648,6 +648,7 @@ F test/tkt3793.test 3aa2efe55bc31fc9459618feea2016ea9a52b2af F test/tkt3824.test 3da2f5c81b057e3ff355f5dfc9aa0cf0a92e0206 F test/tkt3832.test 7ebd5ac82d1e430accd5eec9768044133a94c2aa F test/tkt3838.test 2a1525946bc9d3751e1d49ce95f3a2472f2b7408 +F test/tkt3841.test fe7451fb899bc31c5fbcee53362c621d0271e25f F test/tokenize.test ce430a7aed48fc98301611429595883fdfcab5d7 F test/trace.test 19ffbc09885c3321d56358a5738feae8587fb377 F test/trans.test d887cb07630dc39879a322d958ad8b006137485c @@ -728,7 +729,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81 F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e -P 93bdbc5e2f9771a30358cde03f0d3cb708d73d48 -R 069e745868418be8cf275b6c2785a5b7 +P 469ad1ded35f5ff8ab2f6e8f776d73a9cea73527 +R 14d435ec45cde23b6f0971f656f78d43 U drh -Z e1105c21d8149100fa62e58e0302b8e6 +Z a7e2bcfe217f4defe8fe1346f0212cfb diff --git a/manifest.uuid b/manifest.uuid index 995f205c1c..83bb4d331b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -469ad1ded35f5ff8ab2f6e8f776d73a9cea73527 \ No newline at end of file +4a86de35d57a0c8720772c29431c86cd9be1fb9b \ No newline at end of file diff --git a/src/vdbe.c b/src/vdbe.c index 56667f58c9..51a5e5b3e4 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -43,7 +43,7 @@ ** in this file for details. If in doubt, do not deviate from existing ** commenting and indentation practices when changing or adding code. ** -** $Id: vdbe.c,v 1.842 2009/05/06 18:57:10 shane Exp $ +** $Id: vdbe.c,v 1.843 2009/05/07 12:17:34 drh Exp $ */ #include "sqliteInt.h" #include "vdbeInt.h" @@ -676,6 +676,7 @@ int sqlite3VdbeExec( pOut = &p->aMem[pOp->p2]; sqlite3VdbeMemReleaseExternal(pOut); pOut->flags = MEM_Null; + pOut->n = 0; }else /* Do common setup for opcodes marked with one of the following diff --git a/test/tkt3841.test b/test/tkt3841.test new file mode 100644 index 0000000000..3ba5e0afc0 --- /dev/null +++ b/test/tkt3841.test @@ -0,0 +1,49 @@ +# 2009 May 7 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#*********************************************************************** +# +# Ticket #3841 +# +# The sqlite3_aggregate_count() is not being reset when an aggregate +# functio is used in a correlated subquery. +# +set testdir [file dirname $argv0] +source $testdir/tester.tcl + +ifcapable !subquery { + finish_test + return +} + +do_test tkt3841.1 { + execsql { + CREATE TABLE table2 (key TEXT, x TEXT); + CREATE TABLE list (key TEXT, value TEXT); + + INSERT INTO table2 VALUES ("a", "alist"); + INSERT INTO table2 VALUES ("b", "blist"); + INSERT INTO list VALUES ("a", 1); + INSERT INTO list VALUES ("a", 2); + INSERT INTO list VALUES ("a", 3); + INSERT INTO list VALUES ("b", 4); + INSERT INTO list VALUES ("b", 5); + INSERT INTO list VALUES ("b", 6); + +pragma vdbe_listing=on; pragma vdbe_trace=on; + SELECT + table2.x, + (SELECT group_concat(list.value) + FROM list + WHERE list.key = table2.key) + FROM table2; + } +} {alist 1,2,3 blist 4,5,6} + +finish_test