Re:[PATCH] Little refactoring of portalcmds.c

From: Zizhuan Liu <44973863(at)qq(dot)com>
To: aleksander <aleksander(at)tigerdata(dot)com>, pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Cc: quanzongliang <quanzongliang(at)yeah(dot)net>, qiuwenhuifx <qiuwenhuifx(at)gmail(dot)com>
Subject: Re:[PATCH] Little refactoring of portalcmds.c
Date: 2026-05-26 07:05:37
Message-ID: tencent_149BDBB2851AA69104BEAC8D84566722F005@qq.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi all,

I have reviewed patch 6113 on CommitFest.
CommitFest page: https://commitfest.postgresql.org/patch/6113/

The newly introduced check_cursor_name() implements the logic to reject empty cursor names, which matches the existing checks in PerformCursorOpen() and PerformPortalFetch().

However, this helper function is not a good fit for PerformPortalClose(). At the start of this function, there is a check for name == NULL — a NULL name corresponds to the CLOSE ALL command — and this check runs prior to validating whether the name is an empty string.

While calling check_cursor_name() inside PerformPortalClose() would keep the current behavior intact, it could confuse future readers. This approach also fails to achieve truly consistent cursor name validation across all three functions, and may add extra maintenance burdens in the long term.

On the other hand, if we only refactor PerformCursorOpen() and PerformPortalFetch(), the change would end up being rather minimal.

Considering all these factors, I'd suggest leaving the code as it is.

(Sorry, I tried but still cannot post this to the original thread.)

Thanks,
--
X-MAN (Zizhuan Liu)&nbsp;
44973863(at)QQ(dot)COM

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Chao Li 2026-05-26 07:14:25 Re: Avoid leaking system path from pg_available_extensions
Previous Message Japin Li 2026-05-26 06:56:09 Re: pg_rewind does not rewind diverging timelines