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

Michael Paquier <michael@paquier.xyz>

From: Michael Paquier <michael@paquier.xyz>
To: Anthonin Bonnefoy <anthonin.bonnefoy@datadoghq.com>
Cc: Alexander Lakhin <exclusion@gmail.com>, Jelte Fennema-Nio <postgres@jeltef.nl>, Peter Eisentraut <peter@eisentraut.org>, Tomas Vondra <tomas.vondra@enterprisedb.com>, vignesh C <vignesh21@gmail.com>, PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Date: 2024-09-19T07:30:11Z
Lists: pgsql-hackers
On Wed, Sep 18, 2024 at 06:08:54PM +0900, Michael Paquier wrote:
> On Wed, Sep 18, 2024 at 09:42:43AM +0200, Anthonin Bonnefoy wrote:
>> I've joined a patch to clean the psql extended state at the start of
>> every extended protocol backslash command, freeing the allocated
>> variables and resetting the send_mode. Another possible approach would
>> be to return an error when there's already an existing state instead
>> of overwriting it.
> 
> I'll double-check all that tomorrow, but you have looks like it is
> going in the right direction.

And done down to v16, with one logic for HEAD and something simpler
for \bind in v16 and v17.

Issuing an error if there is a state does not sound like a good idea
at this stage because it would suddenly break scripts that expect
multiple commands of \bind to prioritize the last one.  If that was
something only on HEAD, I would have considered that as a serious
option, but not with v16 in mind for \bind.
--
Michael

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