Re: [PATCH] Little refactoring of portalcmds.c - Mailing list pgsql-hackers

From Zizhuan Liu
Subject Re: [PATCH] Little refactoring of portalcmds.c
Date
Msg-id 177976656650.313758.11235594116976452461.pgcf@coridan.postgresql.org
Whole thread
In response to [PATCH] Little refactoring of portalcmds.c  (Aleksander Alekseev <aleksander@tigerdata.com>)
Responses Re: [PATCH] Little refactoring of portalcmds.c
List pgsql-hackers
The newly introduced check_cursor_name() implements the logic to reject empty cursor names, which matches the existing
checksin PerformCursorOpen() and PerformPortalFetch().
 

However, this helper function is not a good fit for PerformPortalClose(). At the start of this
function(PerformPortalClose),there is a check for name == NULL — a NULL name corresponds to the CLOSE ALL command — and
thischeck 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
futurereaders. This approach also fails to achieve truly consistent cursor name validation across all three functions,
andmay 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
ratherminimal.
 

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

pgsql-hackers by date:

Previous
From: jian he
Date:
Subject: Re: Row pattern recognition
Next
From: Zizhuan Liu
Date:
Subject: Re: [PATCH] Little refactoring of portalcmds.c