summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTatsuo Ishii <ishii@postgresql.org>2025-10-14 19:15:24 +0900
committerTatsuo Ishii <ishii@postgresql.org>2025-10-14 19:15:24 +0900
commit5f3808646f67260d5dc0d95f2602886da5cf5c52 (patch)
tree0c0f6942ea7b4103d204ff04ff991652b425a4b6 /src
parent1206df04c2001868204f3f79c48173065f3b8231 (diff)
Use ereport rather than elog in WinCheckAndInitializeNullTreatment.
Previously WinCheckAndInitializeNullTreatment() used elog() to emit an error message. ereport() should be used instead because it's a user-facing error. Also use existing get_func_name() to get a function's name, rather than own implementation. Moreover add an assertion to validate winobj parameter, just like other window function API. Reported-by: Tom Lane <tgl@sss.pgh.pa.us> Author: Tatsuo Ishii <ishii@postgresql.org> Reviewed-by: Chao Li <lic@highgo.com> Discussion: https://postgr.es/m/2952409.1760023154%40sss.pgh.pa.us
Diffstat (limited to 'src')
-rw-r--r--src/backend/executor/nodeWindowAgg.c20
1 files changed, 8 insertions, 12 deletions
diff --git a/src/backend/executor/nodeWindowAgg.c b/src/backend/executor/nodeWindowAgg.c
index e6a53f95391..47e00be7b49 100644
--- a/src/backend/executor/nodeWindowAgg.c
+++ b/src/backend/executor/nodeWindowAgg.c
@@ -3538,24 +3538,20 @@ WinCheckAndInitializeNullTreatment(WindowObject winobj,
bool allowNullTreatment,
FunctionCallInfo fcinfo)
{
+ Assert(WindowObjectIsValid(winobj));
if (winobj->ignore_nulls != NO_NULLTREATMENT && !allowNullTreatment)
{
- HeapTuple proctup;
- Form_pg_proc procform;
- Oid funcid;
+ const char *funcname = get_func_name(fcinfo->flinfo->fn_oid);
- funcid = fcinfo->flinfo->fn_oid;
- proctup = SearchSysCache1(PROCOID,
- ObjectIdGetDatum(funcid));
- if (!HeapTupleIsValid(proctup))
- elog(ERROR, "cache lookup failed for function %u", funcid);
- procform = (Form_pg_proc) GETSTRUCT(proctup);
- elog(ERROR, "function %s does not allow RESPECT/IGNORE NULLS",
- NameStr(procform->proname));
+ if (!funcname)
+ elog(ERROR, "could not get function name");
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("function %s does not allow RESPECT/IGNORE NULLS",
+ funcname)));
}
else if (winobj->ignore_nulls == PARSER_IGNORE_NULLS)
winobj->ignore_nulls = IGNORE_NULLS;
-
}
/*