improve comments on CreateFunction returnsSet

Started by Zshengbin91about 1 month ago2 messages
#1Zshengbin91
zshengbin91@gmail.com
1 attachment(s)

Hi hackers,

I'm using postgres, and I found a potentially ambiguous code comment in the
`CreateFunction` function. `returnsSet` is a boolean variable, and to be
consistent with the subsequent error message, I believe the comment should
be modified to match the error message. "reject ROWS if it's not
returnsSet" should be changed to "reject ROWS if it does not return a set"
Therefore, I've attached a patch to address this issue.

Thanks!
Br/Shengbin Zhao

Attachments:

improve_comments_on_CreateFunction_returnSet.patchtext/plain; charset=US-ASCII; name=improve_comments_on_CreateFunction_returnSet.patchDownload
diff --git a/src/backend/commands/functioncmds.c b/src/backend/commands/functioncmds.c
old mode 100644
new mode 100755
index 8a435cd93db..01d21098e06
--- a/src/backend/commands/functioncmds.c
+++ b/src/backend/commands/functioncmds.c
@@ -1245,7 +1245,7 @@ CreateFunction(ParseState *pstate, CreateFunctionStmt *stmt)
 
 	/*
 	 * Set default values for COST and ROWS depending on other parameters;
-	 * reject ROWS if it's not returnsSet.  NB: pg_dump knows these default
+	 * reject ROWS if it does not return a set.  NB: pg_dump knows these default
 	 * values, keep it in sync if you change them.
 	 */
 	if (procost < 0)
#2Andreas Karlsson
andreas.karlsson@percona.com
In reply to: Zshengbin91 (#1)
Re: improve comments on CreateFunction returnsSet

On 12/25/25 4:05 AM, Zshengbin91 wrote:

I'm using postgres, and I found a potentially ambiguous code comment in
the `CreateFunction` function. `returnsSet` is a boolean variable, and
to be consistent with the subsequent error message, I believe the
comment should be modified to match the error message. "reject ROWS if
it's not returnsSet" should be changed to "reject ROWS if it does not
return a set"  Therefore, I've attached a patch to address this issue.

Hm,

I personally don't really think your change improves anything. Either
version works just fine and I have a mild preferences for the original
comment. Honestly if it was me writing the comment I would probably have
entirely left out the part about rejecting since that is obvious from
just reading the code but now that it is there it might as well stay.

Andreas