From 7bfc6e71dbdacae1f287c5a3832fafb81dc7cdf5 Mon Sep 17 00:00:00 2001
From: Henson Choi <assam258@gmail.com>
Date: Sun, 28 Jun 2026 15:09:22 +0900
Subject: [PATCH] Remove unreachable function-name guard in null-treatment
 check

In WinCheckAndInitializeNullTreatment() the window function is being
executed, so its OID always resolves and get_func_name() never returns
NULL; the "could not get function name" guard is unreachable.  Drop it
and fall back to "?" inline instead.
---
 src/backend/executor/nodeWindowAgg.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/backend/executor/nodeWindowAgg.c b/src/backend/executor/nodeWindowAgg.c
index f1c524d00df..0ee6059932f 100644
--- a/src/backend/executor/nodeWindowAgg.c
+++ b/src/backend/executor/nodeWindowAgg.c
@@ -3657,12 +3657,11 @@ WinCheckAndInitializeNullTreatment(WindowObject winobj,
 	{
 		const char *funcname = get_func_name(fcinfo->flinfo->fn_oid);
 
-		if (!funcname)
-			elog(ERROR, "could not get function name");
+		/* the executing function's name always resolves; stay safe regardless */
 		ereport(ERROR,
 				(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
 				 errmsg("function %s does not allow RESPECT/IGNORE NULLS",
-						funcname)));
+						funcname ? funcname : "?")));
 	}
 	else if (winobj->ignore_nulls == PARSER_IGNORE_NULLS)
 		winobj->ignore_nulls = IGNORE_NULLS;
-- 
2.50.1 (Apple Git-155)

