Re: pgbench: using prepared BEGIN statement in a pipeline could cause an error - Mailing list pgsql-hackers

From Alvaro Herrera
Subject Re: pgbench: using prepared BEGIN statement in a pipeline could cause an error
Date
Msg-id 20220912150343.ds6myoqnwgaov5wy@alvherre.pgsql
Whole thread Raw
In response to Re: pgbench: using prepared BEGIN statement in a pipeline could cause an error  (Yugo NAGATA <nagata@sraoss.co.jp>)
List pgsql-hackers
On 2022-Mar-28, Yugo NAGATA wrote:

> On Fri, 25 Mar 2022 16:19:54 -0400
> Tom Lane <tgl@sss.pgh.pa.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(...);
> > DROP FUNCTION 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  —  https://www.EnterpriseDB.com/
"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)



pgsql-hackers by date:

Previous
From: Lev Kokotov
Date:
Subject: Re: Support for Rust
Next
From: Stephen Frost
Date:
Subject: Re: Add tracking of backend memory allocated to pg_stat_activity