Re: [PATCH] Add additional extended protocol commands to psql: \parse and \bindx

Peter Eisentraut <peter@eisentraut.org>

From: Peter Eisentraut <peter@eisentraut.org>
To: Michael Paquier <michael@paquier.xyz>
Cc: vignesh C <vignesh21@gmail.com>, Anthonin Bonnefoy <anthonin.bonnefoy@datadoghq.com>, Jelte Fennema-Nio <postgres@jeltef.nl>, PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Date: 2025-06-12T13:14:22Z
Lists: pgsql-hackers
On 24.07.24 07:04, Michael Paquier wrote:
> This commit introduces three additional commands: \parse, \bindx and
> \close.
> \parse creates a prepared statement using extended protocol.
> \bindx binds and execute an existing prepared statement using extended
> protocol.
> \close closes an existing prepared statement using extended protocol.

I'm wondering now if \close is a good name of this command.  I hadn't 
seen any discussion around the name choice in this thread.

On the SQL level, the CLOSE command operates on cursors.  I think it 
would be useful to keep SQL and psql aligned (e.g., COPY, \copy).  On 
the protocol level, the "Close" message operates on both cursors and 
statements, but those are actually two different message (sub-)types. 
And this is not something users ever see, so the connection would not be 
obvious.  Maybe this should be called something more specific like 
\close_stmt.




Commits

  1. psql: Rename meta-command \close to \close_prepared

  2. psql: Add tests for repeated calls of \bind[_named]

  3. psql: Fix memory leak with repeated calls of \bind

  4. psql: Clean up more aggressively state of \bind[_named], \parse and \close

  5. psql: Add more meta-commands able to use the extended protocol

  6. psql: Add ignore_slash_options in bind's inactive branch