From 61b4393bd12ad286e735a3bdf793443ecbf3b1aa Mon Sep 17 00:00:00 2001 From: Tatsuo Ishii Date: Sat, 11 Oct 2025 14:31:12 +0900 Subject: [PATCH v1] 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 fix WinCheckAndInitializeNullTreatment() to use existing get_func_name() to get a function's name, rather than own implementation. Reported-by: Tom Lane Author: Tatsuo Ishii Discussion: https://postgr.es/m/2952409.1760023154%40sss.pgh.pa.us --- src/backend/executor/nodeWindowAgg.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/src/backend/executor/nodeWindowAgg.c b/src/backend/executor/nodeWindowAgg.c index e6a53f95391..892bdbd5ef5 100644 --- a/src/backend/executor/nodeWindowAgg.c +++ b/src/backend/executor/nodeWindowAgg.c @@ -3540,22 +3540,15 @@ WinCheckAndInitializeNullTreatment(WindowObject winobj, { if (winobj->ignore_nulls != NO_NULLTREATMENT && !allowNullTreatment) { - HeapTuple proctup; - Form_pg_proc procform; - Oid funcid; - - 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)); + char *funcname = get_func_name(fcinfo->flinfo->fn_oid); + + 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; - } /* -- 2.43.0