From: drh Date: Thu, 21 Aug 2008 14:15:59 +0000 (+0000) Subject: Reinsert an SCopy operation that was removed in (5523) because coverage X-Git-Tag: version-3.6.10~599 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6a012f04d51268de5a066ae3bcd6253c5a85b842;p=thirdparty%2Fsqlite.git Reinsert an SCopy operation that was removed in (5523) because coverage testing indicated that it was dead code. Ticket #3324 shows that the code was not as dead as we thought it was. (CVS 5578) FossilOrigin-Name: 6855711595b58d4b6fbaf9480720b788904d0e2d --- diff --git a/manifest b/manifest index a4d1ddb8f0..8b87b5aa96 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Patch\sto\smkfunction\sto\stry\sand\sdetect\smiscompiles.\s\sAdd\san\sunimportant\nassert\sback\sto\spcache.c.\s(CVS\s5577) -D 2008-08-21T12:32:12 +C Reinsert\san\sSCopy\soperation\sthat\swas\sremoved\sin\s(5523)\sbecause\scoverage\ntesting\sindicated\sthat\sit\swas\sdead\scode.\s\sTicket\s#3324\sshows\sthat\sthe\ncode\swas\snot\sas\sdead\sas\swe\sthought\sit\swas.\s(CVS\s5578) +D 2008-08-21T14:15:59 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in 0b1c022000f55221454a7846022f11674d8024bf F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -145,7 +145,7 @@ F src/prepare.c c197041e0c4770672cda75e6bfe10242f885e510 F src/printf.c 2e984b2507291a7e16d89dc9bb60582904f6247d F src/random.c 5c754319d38abdd6acd74601ee0105504adc508a F src/resolve.c e688f240bdacf4003047c2b023c3a4ee3a3eca98 -F src/select.c 0a0ed2d14bfa216c1584fa8516e8820115b1047b +F src/select.c eed74c3d00c45a01808a16aaca8a676e222bf2fa F src/shell.c d83b578a8ccdd3e0e7fef4388a0887ce9f810967 F src/sqlite.h.in 54e51c22e2294c5989156b0aec87aa44168ac1f0 F src/sqlite3ext.h 1e3887c9bd3ae66cb599e922824b04cd0d0f2c3e @@ -465,7 +465,7 @@ F test/select1.test d0a4cad954fd41c030ec16ffbd2d08a4c0548742 F test/select2.test 272a3d3e35b1d3a0760168ababf555e656357fc4 F test/select3.test 2ce595f8fb8e2ac10071d3b4e424cadd4634a054 F test/select4.test b64d5d248d008e1dc365f451c76090bde907e665 -F test/select5.test 2c5464283438e06531a1e8801c674279dd01dd04 +F test/select5.test e758b8ef94f69b111df4cb819008856655dcd535 F test/select6.test faad87c6e691bf69a822b69cd6808137a34d19e8 F test/select7.test 7906735805cfbee4dddc0bed4c14e68d7f5f9c5f F test/select8.test 391de11bdd52339c30580dabbbbe97e3e9a3c79d @@ -623,7 +623,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81 F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 1dbced29de5f59ba2ebf877edcadf171540374d1 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e -P d025866b09352b32a6d35b97144eaad2fafb7165 -R b4969a898ecc1333175a9c194ed1293f +P a2f375fffb49b6f6adbfd59d24e9c6a170fd5ebb +R a28baeafe56f2cc5b7a4255743c38809 U drh -Z 4309b6f5bb92174f920621883fba8649 +Z 48f409680bd6268427d83dfae2ba5930 diff --git a/manifest.uuid b/manifest.uuid index 3753a45aaa..fba24c6f44 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a2f375fffb49b6f6adbfd59d24e9c6a170fd5ebb \ No newline at end of file +6855711595b58d4b6fbaf9480720b788904d0e2d \ No newline at end of file diff --git a/src/select.c b/src/select.c index e4eb186e74..790b958dfc 100644 --- a/src/select.c +++ b/src/select.c @@ -12,7 +12,7 @@ ** This file contains C code routines that are called by the parser ** to handle SELECT statements in SQLite. ** -** $Id: select.c,v 1.466 2008/08/20 16:35:10 drh Exp $ +** $Id: select.c,v 1.467 2008/08/21 14:15:59 drh Exp $ */ #include "sqliteInt.h" @@ -3773,20 +3773,14 @@ int sqlite3Select( struct AggInfo_col *pCol = &sAggInfo.aCol[i]; if( pCol->iSorterColumn>=j ){ int r1 = j + regBase; -#ifndef NDEBUG - int r2 = -#endif - sqlite3ExprCodeGetColumn(pParse, + int r2; + + r2 = sqlite3ExprCodeGetColumn(pParse, pCol->pTab, pCol->iColumn, pCol->iTable, r1, 0); + if( r1!=r2 ){ + sqlite3VdbeAddOp2(v, OP_SCopy, r2, r1); + } j++; - - /* sAggInfo.aCol[] only contains one entry per column. So - ** The reference to pCol->iColumn,pCol->iTable must have been - ** the first reference to that column. Hence, - ** sqliteExprCodeGetColumn is guaranteed to put the result in - ** the column requested. - */ - assert( r1==r2 ); } } regRecord = sqlite3GetTempReg(pParse); diff --git a/test/select5.test b/test/select5.test index f38efcf38f..3a787fc767 100644 --- a/test/select5.test +++ b/test/select5.test @@ -12,7 +12,7 @@ # focus of this file is testing aggregate functions and the # GROUP BY and HAVING clauses of SELECT statements. # -# $Id: select5.test,v 1.19 2008/08/20 16:35:10 drh Exp $ +# $Id: select5.test,v 1.20 2008/08/21 14:15:59 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -191,10 +191,67 @@ do_test select5-6.2 { } } {1 1 2 {} 2 1 3 {} 3 1 {} 5 4 2 {} 6 5 2 {} {} 6 1 7 8} -do_test select5.7.2 { +do_test select5-7.2 { execsql { SELECT count(*), count(x) as cnt FROM t4 GROUP BY y ORDER BY cnt; } } {1 1 1 1 1 1 5 5} + +# See ticket #3324. +# +do_test select5-8.1 { + execsql { + CREATE TABLE t8a(a,b); + CREATE TABLE t8b(x); + INSERT INTO t8a VALUES('one', 1); + INSERT INTO t8a VALUES('one', 2); + INSERT INTO t8a VALUES('two', 3); + INSERT INTO t8a VALUES('one', NULL); + INSERT INTO t8b(rowid,x) VALUES(1,111); + INSERT INTO t8b(rowid,x) VALUES(2,222); + INSERT INTO t8b(rowid,x) VALUES(3,333); + SELECT a, count(b) FROM t8a, t8b WHERE b=t8b.rowid GROUP BY a ORDER BY a; + } +} {one 2 two 1} +do_test select5-8.2 { + execsql { + SELECT a, count(b) FROM t8a, t8b WHERE b=+t8b.rowid GROUP BY a ORDER BY a; + } +} {one 2 two 1} +do_test select5-8.3 { + execsql { + SELECT t8a.a, count(t8a.b) FROM t8a, t8b WHERE t8a.b=t8b.rowid + GROUP BY 1 ORDER BY 1; + } +} {one 2 two 1} +do_test select5-8.4 { + execsql { + SELECT a, count(*) FROM t8a, t8b WHERE b=+t8b.rowid GROUP BY a ORDER BY a; + } +} {one 2 two 1} +do_test select5-8.5 { + execsql { + SELECT a, count(b) FROM t8a, t8b WHERE b