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

From: Anthonin Bonnefoy <anthonin(dot)bonnefoy(at)datadoghq(dot)com>
To: Alexander Lakhin <exclusion(at)gmail(dot)com>
Cc: Michael Paquier <michael(at)paquier(dot)xyz>, Jelte Fennema-Nio <postgres(at)jeltef(dot)nl>, Peter Eisentraut <peter(at)eisentraut(dot)org>, Tomas Vondra <tomas(dot)vondra(at)enterprisedb(dot)com>, vignesh C <vignesh21(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCH] Add additional extended protocol commands to psql: \parse and \bind
Date: 2024-09-18 07:42:43
Message-ID: CAO6_Xqr71LFGEYdwwsrm1RZCSgkia-5ZerTmi23Bsv180jpOMw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Sep 17, 2024 at 5:00 PM Alexander Lakhin <exclusion(at)gmail(dot)com> wrote:
>
> Please look at an assertion failure, caused by \bind_named:
> regression=# SELECT $1 \parse s
> \bind_named s
>
> regression=# \bind_named
> \bind_named: missing required argument
> regression=# 1 \g
> psql: common.c:1501: ExecQueryAndProcessResults: Assertion `pset.stmtName != ((void *)0)' failed.

Thanks for the report.

Looking at the failure, it seems like the issue was already present
with \bind, though there was no assertion failure: repeatedly calling
\bind would allocate new stmtName/bind_params and leak them at the
start of exec_command_bind.

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.

Attachment Content-Type Size
v1-0001-Clean-psql-extended-state-on-extended-command.patch application/octet-stream 5.8 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David Rowley 2024-09-18 07:50:15 Re: Remove useless GROUP BY columns considering unique index
Previous Message Peter Eisentraut 2024-09-18 07:28:30 Re: Remove useless GROUP BY columns considering unique index