Make group_concat() a 1- or 2-value function, as the documentation says it

should be.  Use the md5sum() function to verify ticket #3179, not
group_concat().  This undoes the ill-advised group_concat() change of
check-in (5233). (CVS 6233)

FossilOrigin-Name: f2ae82c4d46c2eca30fc60a50ab5064728f20739
This commit is contained in:
drh 2009-02-02 21:57:05 +00:00
parent bdb339ff73
commit 07d3117aed
4 changed files with 30 additions and 27 deletions

View File

@ -1,5 +1,5 @@
C Omit\sthe\sTEMP\skeyword\sfrom\sthe\sschema\sof\sTEMP\stables\screated\susing\nCREATE\sTEMP\sTABLE\sAS\sSELECT\s.....\s\sTicket\s#3630.\s(CVS\s6232)
D 2009-02-02T18:03:22
C Make\sgroup_concat()\sa\s1-\sor\s2-value\sfunction,\sas\sthe\sdocumentation\ssays\sit\nshould\sbe.\s\sUse\sthe\smd5sum()\sfunction\sto\sverify\sticket\s#3179,\snot\ngroup_concat().\s\sThis\sundoes\sthe\sill-advised\sgroup_concat()\schange\sof\ncheck-in\s(5233).\s(CVS\s6233)
D 2009-02-02T21:57:05
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
F Makefile.in 3871d308188cefcb7c5ab20da4c7b6aad023bc52
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@ -113,7 +113,7 @@ F src/date.c 870770dde3fb56772ab247dfb6a6eda44d16cfbc
F src/delete.c 6249005bdd8f85db6ec5f31ddb5c07de023693cc
F src/expr.c 76dc3dc83b56ab8db50a772714fac49def8bbf12
F src/fault.c dc88c821842157460750d2d61a8a8b4197d047ff
F src/func.c 4a837d75d6f46a9543bb2dd15cbf2ff32634415a
F src/func.c b4fe7d6b815044b0c1e8bcff15fa75da4a71b985
F src/global.c ab003581ea4ff193cfe17a00e1303bc51db619a5
F src/hash.c 5824e6ff7ba78cd34c8d6cd724367713583e5b55
F src/hash.h 28f38ebb1006a5beedcb013bcdfe31befe7437ae
@ -372,7 +372,7 @@ F test/fts3e.test 1f6c6ac9cc8b772ca256e6b22aaeed50c9350851
F test/fts3expr.test 000f05df771e203187ceac49ad21c303c720b783
F test/fts3expr2.test 8501de895a4c0631e7226c9bac055cd49c9f6646
F test/fts3near.test dc196dd17b4606f440c580d45b3d23aa975fd077
F test/func.test c98d620d6ecd10957896960da334540542a240fe
F test/func.test e40978f08973f5956cfd32a7f87ef427e39cf9d3
F test/fuzz.test 8bad3b9b09bad47c50f3433f9598707a70247ce1
F test/fuzz2.test ea38692ce2da99ad79fe0be5eb1a452c1c4d37bb
F test/fuzz3.test aec64345184d1662bd30e6a17851ff659d596dc5
@ -695,7 +695,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81
F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
P 92e5c27f20f150c1777c1b91d35207ade961319d
R ea477193cacfc00fd0ed1607f173f41d
P 3b0a25548c4c15c86aadcd9a6c3af0adafb85c17
R 3185b236f21f6eee6b41aaeb070f332d
U drh
Z d6cd04b7b570fe870dc266c2d4bae7bf
Z 44f9b42ab38c7b10fb63da33c391c0f2

View File

@ -1 +1 @@
3b0a25548c4c15c86aadcd9a6c3af0adafb85c17
f2ae82c4d46c2eca30fc60a50ab5064728f20739

View File

@ -16,7 +16,7 @@
** sqliteRegisterBuildinFunctions() found at the bottom of the file.
** All other code has file scope.
**
** $Id: func.c,v 1.217 2009/02/02 17:30:00 drh Exp $
** $Id: func.c,v 1.218 2009/02/02 21:57:05 drh Exp $
*/
#include "sqliteInt.h"
#include <stdlib.h>
@ -1213,8 +1213,9 @@ static void groupConcatStep(
const char *zVal;
StrAccum *pAccum;
const char *zSep;
int nVal, nSep, i;
if( argc==0 || sqlite3_value_type(argv[0])==SQLITE_NULL ) return;
int nVal, nSep;
assert( argc==1 || argc==2 );
if( sqlite3_value_type(argv[0])==SQLITE_NULL ) return;
pAccum = (StrAccum*)sqlite3_aggregate_context(context, sizeof(*pAccum));
if( pAccum ){
@ -1222,22 +1223,18 @@ static void groupConcatStep(
pAccum->useMalloc = 1;
pAccum->mxAlloc = db->aLimit[SQLITE_LIMIT_LENGTH];
if( pAccum->nChar ){
if( argc>1 ){
zSep = (char*)sqlite3_value_text(argv[argc-1]);
nSep = sqlite3_value_bytes(argv[argc-1]);
if( argc==2 ){
zSep = (char*)sqlite3_value_text(argv[1]);
nSep = sqlite3_value_bytes(argv[1]);
}else{
zSep = ",";
nSep = 1;
}
sqlite3StrAccumAppend(pAccum, zSep, nSep);
}
i = 0;
do{
zVal = (char*)sqlite3_value_text(argv[i]);
nVal = sqlite3_value_bytes(argv[i]);
sqlite3StrAccumAppend(pAccum, zVal, nVal);
i++;
}while( i<argc-1 );
zVal = (char*)sqlite3_value_text(argv[0]);
nVal = sqlite3_value_bytes(argv[0]);
sqlite3StrAccumAppend(pAccum, zVal, nVal);
}
}
static void groupConcatFinalize(sqlite3_context *context){
@ -1407,7 +1404,8 @@ void sqlite3RegisterGlobalFunctions(void){
AGGREGATE(avg, 1, 0, 0, sumStep, avgFinalize ),
AGGREGATE(count, 0, 0, 0, countStep, countFinalize ),
AGGREGATE(count, 1, 0, 0, countStep, countFinalize ),
AGGREGATE(group_concat, -1, 0, 0, groupConcatStep, groupConcatFinalize),
AGGREGATE(group_concat, 1, 0, 0, groupConcatStep, groupConcatFinalize),
AGGREGATE(group_concat, 2, 0, 0, groupConcatStep, groupConcatFinalize),
LIKEFUNC(glob, 2, &globInfo, SQLITE_FUNC_LIKE|SQLITE_FUNC_CASE),
#ifdef SQLITE_CASE_SENSITIVE_LIKE

View File

@ -11,7 +11,7 @@
# This file implements regression tests for SQLite library. The
# focus of this file is testing built-in functions.
#
# $Id: func.test,v 1.89 2009/02/01 18:08:41 drh Exp $
# $Id: func.test,v 1.90 2009/02/02 21:57:05 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@ -959,17 +959,22 @@ do_test func-24.6 {
SELECT 'BEGIN-'||group_concat(t1) FROM tbl1
}
} {BEGIN-this,program,is,free,software}
# Ticket #3179: Make sure aggregate functions can take many arguments.
# None of the built-in aggregates do this, so use the md5sum() from the
# test extensions.
#
unset -nocomplain midargs
set midargs {}
unset -nocomplain midres
set midres {}
unset -nocomplain result
for {set i 1} {$i<[sqlite3_limit db SQLITE_LIMIT_FUNCTION_ARG -1]-1} {incr i} {
for {set i 1} {$i<[sqlite3_limit db SQLITE_LIMIT_FUNCTION_ARG -1]} {incr i} {
append midargs ,'/$i'
append midres /$i
set result \
"this$midres:program$midres:is$midres:free$midres:software$midres"
set sql "SELECT group_concat(t1$midargs,':') FROM tbl1"
set result [md5 \
"this${midres}program${midres}is${midres}free${midres}software${midres}"]
set sql "SELECT md5sum(t1$midargs) FROM tbl1"
do_test func-24.7.$i {
db eval $::sql
} $result