A simpler fix for ticket [3a88d85f36704eebe1] - one that uses less code.

The error message is not quite as good, but as this error has apparently
not previously occurred in over 8 years of heavy use, that is not seen as
a serious problem.

FossilOrigin-Name: 0ad1ed8ef0b5fb5d8db44479373b2b93d8fcfd66
This commit is contained in:
drh 2014-08-06 00:29:06 +00:00
parent 1cfc9aa993
commit 0c4de2d96d
4 changed files with 16 additions and 20 deletions

View File

@ -1,5 +1,5 @@
C Ensure\sthat\saggregate\sfunctions\sare\snot\sused\swhen\sevaluating\sa\sdefault\nvalue\sfor\sa\stable\scolumn.\nCandidate\sfix\sfor\sticket\s[3a88d85f36704eebe134f7].
D 2014-08-05T21:31:08.768
C A\ssimpler\sfix\sfor\sticket\s[3a88d85f36704eebe1]\s-\sone\sthat\suses\sless\scode.\nThe\serror\smessage\sis\snot\squite\sas\sgood,\sbut\sas\sthis\serror\shas\sapparently\nnot\spreviously\soccurred\sin\sover\s8\syears\sof\sheavy\suse,\sthat\sis\snot\sseen\sas\na\sserious\sproblem.
D 2014-08-06T00:29:06.807
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in 5eb79e334a5de69c87740edd56af6527dd219308
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@ -176,7 +176,7 @@ F src/complete.c dc1d136c0feee03c2f7550bafc0d29075e36deac
F src/ctime.c 0231df905e2c4abba4483ee18ffc05adc321df2a
F src/date.c 593c744b2623971e45affd0bde347631bdfa4625
F src/delete.c bcf8f72126cea80fc3d5bc5494cf19b3f8935aaf
F src/expr.c 94d26c8e47bb25957e3963cc3d116b09ed8e12cd
F src/expr.c f749009cf4a8534efb5e0d5cd7c9fb1fb0f2836c
F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb
F src/fkey.c 8545f3b36da47473e10800ea4fb0810fd4062514
F src/func.c 3bc223ea36cd29a91c481485343d0ee4257ab8dc
@ -856,7 +856,7 @@ F test/superlock.test 1cde669f68d2dd37d6c9bd35eee1d95491ae3fc2
F test/sync.test a34cd43e98b7fb84eabbf38f7ed8f7349b3f3d85
F test/syscall.test d2fdaad713f103ac611fe7ef9b724c7b69f8149c
F test/sysfault.test fa776e60bf46bdd3ae69f0b73e46ee3977a58ae6
F test/table.test 5b985827973a7b7b24ce155c8bda5fe3544e8442
F test/table.test 2a1d2fa52c531de5915f28023747d9a8c27b6f31
F test/tableapi.test 2674633fa95d80da917571ebdd759a14d9819126
F test/tableopts.test dba698ba97251017b7c80d738c198d39ab747930
F test/tclsqlite.test 37a61c2da7e3bfe3b8c1a2867199f6b860df5d43
@ -1185,7 +1185,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
P 952868216854e8355edf57af62bd1a6bcb70ce61
R cc49bc1b5436eaa2e754c5d5e9ba9fd5
P 29ba812825bf06ef230f2480bba0579653f0a52d
R f634869bc839ef6a8575d1173c369416
U drh
Z 79f28300cbbdd20d7d6bedff33de2779
Z 8e016893764edede1871bf058b88fac4

View File

@ -1 +1 @@
29ba812825bf06ef230f2480bba0579653f0a52d
0ad1ed8ef0b5fb5d8db44479373b2b93d8fcfd66

View File

@ -2764,15 +2764,10 @@ int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target){
zId = pExpr->u.zToken;
nId = sqlite3Strlen30(zId);
pDef = sqlite3FindFunction(db, zId, nId, nFarg, enc, 0);
if( pDef==0 ){
if( pDef==0 || pDef->xFunc==0 ){
sqlite3ErrorMsg(pParse, "unknown function: %.*s()", nId, zId);
break;
}
if( pDef->xFunc==0 ){
sqlite3ErrorMsg(pParse, "misuse of aggregate function: %.*s()",
nId, zId);
break;
}
/* Attempt a direct implementation of the built-in COALESCE() and
** IFNULL() functions. This avoids unnecessary evalation of

View File

@ -744,7 +744,7 @@ do_execsql_test table-16.1 {
} {1 123}
do_catchsql_test table-16.2 {
INSERT INTO t16(rowid) VALUES(4);
} {1 {misuse of aggregate function: max()}}
} {1 {unknown function: max()}}
do_execsql_test table-16.3 {
DROP TABLE t16;
CREATE TABLE t16(x DEFAULT(abs(1)));
@ -756,20 +756,21 @@ do_catchsql_test table-16.4 {
CREATE TABLE t16(x DEFAULT(avg(1)));
INSERT INTO t16(rowid) VALUES(123);
SELECT rowid, x FROM t16;
} {1 {misuse of aggregate function: avg()}}
} {1 {unknown function: avg()}}
do_catchsql_test table-16.5 {
DROP TABLE t16;
CREATE TABLE t16(x DEFAULT(count()));
INSERT INTO t16(rowid) VALUES(123);
SELECT rowid, x FROM t16;
} {1 {misuse of aggregate function: count()}}
} {1 {unknown function: count()}}
do_catchsql_test table-16.6 {
DROP TABLE t16;
CREATE TABLE t16(x DEFAULT(group_concat('x',',')));
INSERT INTO t16(rowid) VALUES(123);
SELECT rowid, x FROM t16;
} {1 {misuse of aggregate function: group_concat()}}
} {1 {unknown function: group_concat()}}
do_catchsql_test table-16.7 {
INSERT INTO t16 DEFAULT VALUES;
} {1 {unknown function: group_concat()}}
finish_test