Re: pgbench: using prepared BEGIN statement in a pipeline could cause an error

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: Yugo NAGATA <nagata(at)sraoss(dot)co(dot)jp>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: pgbench: using prepared BEGIN statement in a pipeline could cause an error
Date: 2022-09-12 15:03:43
Message-ID: 20220912150343.ds6myoqnwgaov5wy@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 2022-Mar-28, Yugo NAGATA wrote:

> On Fri, 25 Mar 2022 16:19:54 -0400
> Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> > I am not convinced this is a great idea. The current behavior is that
> > a statement is not prepared until it's about to be executed, and I think
> > we chose that deliberately to avoid semantic differences between prepared
> > and not-prepared mode. For example, if a script looks like
> >
> > CREATE FUNCTION foo(...) ...;
> > SELECT foo(...);
> >
> > trying to prepare the SELECT in advance would lead to failure.
> >
> > We could perhaps get away with preparing the commands within a pipeline
> > just before we start to execute the pipeline, but it looks to me like
> > this patch tries to prepare the entire script in advance.

Maybe it would work to have one extra boolean in struct Command, indicating
that the i-th command in the script is inside a pipeline; in -M
prepared, issue PREPARE for each command marked with that flag ahead of
time, and for all other commands, do as today. That way, we don't
change behavior for anything except those commands that need the change.

Álvaro Herrera 48°01'N 7°57'E —
"Digital and video cameras have this adjustment and film cameras don't for the
same reason dogs and cats lick themselves: because they can." (Ken Rockwell)

In response to


Browse pgsql-hackers by date

  From Date Subject
Next Message Stephen Frost 2022-09-12 15:22:31 Re: Add tracking of backend memory allocated to pg_stat_activity
Previous Message Lev Kokotov 2022-09-12 14:57:31 Re: Support for Rust