Re: Bug in pgbench prepared statements

From: Lev Kokotov <lev(dot)kokotov(at)gmail(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: Tristan Partin <tristan(at)neon(dot)tech>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Bug in pgbench prepared statements
Date: 2023-12-02 03:06:40
Message-ID: CAPwLVyKTTxCX43nSEXxo-B0T3DH81N+vZhr1JLW41pxYPOWJOw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> The patch you have sent does not apply cleanly on the master branch,
> could you rebase please?

Attached. PR against master also here
<https://github.com/postgres/postgres/pull/147>, just to make sure it's
mergeable <https://github.com/postgres/postgres/pull/147.patch>.

> Wouldn't it
> better to consume the errors from PQsendQueryPrepared() and
> PQsendQueryParams() when these fail?

The error is returned in PQPrepare(), which happens only in QUERY_PREPARED
mode, so PQsendQueryParams() does not apply, and before
PQsendQueryPrepared() is called, so catching the error from
PQsendQueryPrepared() is exactly what's causing the bug: ERROR: prepared
statement "P_0" does not exist.

Best,

Lev
postgresml.org

On Thu, Nov 30, 2023 at 11:19 PM Michael Paquier <michael(at)paquier(dot)xyz>
wrote:

> On Thu, Nov 30, 2023 at 07:15:54PM -0800, Lev Kokotov wrote:
> >> I see prepareCommand() is called one more time in
> >> prepareCommandsInPipeline(). Should you also check the return value
> >> there?
> >
> > Yes, good catch. New patch attached.
>
> Agreed that this is not really helpful as it stands
>
> >> It may also be useful to throw this patch on the January commitfest if
> >> no one else comes along to review/commit it.
> >
> > First time contributing, not familiar with the process here, but happy to
> > learn.
>
> The patch you have sent does not apply cleanly on the master branch,
> could you rebase please?
>
> FWIW, I am a bit confused by the state of sendCommand(). Wouldn't it
> better to consume the errors from PQsendQueryPrepared() and
> PQsendQueryParams() when these fail?
> --
> Michael
>

Attachment Content-Type Size
pgbench2.patch application/octet-stream 3.1 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Joe Conway 2023-12-02 03:10:54 Re: Emitting JSON to file using COPY TO
Previous Message Davin Shearer 2023-12-02 03:00:29 Re: Emitting JSON to file using COPY TO