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
diff --git a/src/expr.c b/src/expr.c
index 9eb893d..0d2292e 100644
--- a/src/expr.c
+++ b/src/expr.c
@@ -2764,15 +2764,10 @@
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