diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2010-08-05 21:45:35 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2010-08-05 21:45:35 +0000 |
commit | 1e4c050b2415159aac782d727dbfd987571deab5 (patch) | |
tree | 256c2e3a561eb59fd37af865e5a25488a397d825 /src/backend/parser/parse_func.c | |
parent | 2e6dc5328ca2abb01b87e4e60aa325024c1d45c1 (diff) | |
download | postgresql-1e4c050b2415159aac782d727dbfd987571deab5.tar.gz postgresql-1e4c050b2415159aac782d727dbfd987571deab5.zip |
Add a very specific hint for the case that we're unable to locate a function
matching a call like f(x, ORDER BY y,z). It could be that what the user
really wants is f(x,z ORDER BY y). We now have pretty conclusive evidence
that many people won't understand this problem without concrete guidance,
so give it to them. Per further discussion of the string_agg() problem.
Diffstat (limited to 'src/backend/parser/parse_func.c')
-rw-r--r-- | src/backend/parser/parse_func.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/backend/parser/parse_func.c b/src/backend/parser/parse_func.c index 8e0f42fc427..88d31a34202 100644 --- a/src/backend/parser/parse_func.c +++ b/src/backend/parser/parse_func.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/parser/parse_func.c,v 1.225 2010/07/29 23:16:33 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/parser/parse_func.c,v 1.226 2010/08/05 21:45:35 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -284,6 +284,19 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs, errhint("Could not choose a best candidate function. " "You might need to add explicit type casts."), parser_errposition(pstate, location))); + else if (list_length(agg_order) > 1) + { + /* It's agg(x, ORDER BY y,z) ... perhaps misplaced ORDER BY */ + ereport(ERROR, + (errcode(ERRCODE_UNDEFINED_FUNCTION), + errmsg("function %s does not exist", + func_signature_string(funcname, nargs, argnames, + actual_arg_types)), + errhint("No aggregate function matches the given name and argument types. " + "Perhaps you misplaced ORDER BY; ORDER BY must appear " + "after all regular arguments of the aggregate."), + parser_errposition(pstate, location))); + } else ereport(ERROR, (errcode(ERRCODE_UNDEFINED_FUNCTION), |