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

From Alexander Lakhin
Subject Re: pgbench: using prepared BEGIN statement in a pipeline could cause an error
Date
Msg-id bcf802a6-afc1-95b9-7bf4-c5dd868ec144@gmail.com
Whole thread Raw
In response to Re: pgbench: using prepared BEGIN statement in a pipeline could cause an error  (Alvaro Herrera <alvherre@alvh.no-ip.org>)
Responses Re: pgbench: using prepared BEGIN statement in a pipeline could cause an error  (Alvaro Herrera <alvherre@alvh.no-ip.org>)
List pgsql-hackers
Hello Alvaro,

21.02.2023 19:32, Alvaro Herrera wrote:
> On 2023-Feb-20, Alvaro Herrera wrote:
>
>> Found one last problem: if you do "-f foobar.sql -M prepared" in that
>> order, then the prepare fails because the statement names would not be
>> assigned when the file is parsed.  This coding only supported doing
>> "-M prepared -f foobar.sql", which funnily enough is the only one that
>> PostgreSQL/Cluster.pm->pgbench() supports.  So I moved the prepared
>> statement name generation to the postprocess step.
> Pushed to all three branches -- thanks, Nagata-san, for diagnosing the
> issue.

Starting from 038f586d5, the following script:
echo "
\startpipeline
\endpipeline
" >test.sql
pgbench -n -M prepared -f test.sql

leads to the pgbench's segfault:
Core was generated by `pgbench -n -M prepared -f test.sql'.
Program terminated with signal SIGSEGV, Segmentation fault.

warning: Section `.reg-xstate/2327306' in core file too small.
#0  0x0000555a402546b4 in prepareCommandsInPipeline (st=st@entry=0x555a409d62e0) at pgbench.c:3130
3130            st->prepared[st->use_file][st->command] = true;
(gdb) bt
#0  0x0000555a402546b4 in prepareCommandsInPipeline (st=st@entry=0x555a409d62e0) at pgbench.c:3130
#1  0x0000555a40257fca in executeMetaCommand (st=st@entry=0x555a409d62e0, now=now@entry=0x7ffdd46eff58)
     at pgbench.c:4413
#2  0x0000555a402585ce in advanceConnectionState (thread=thread@entry=0x555a409d6580, st=st@entry=0x555a409d62e0,
     agg=agg@entry=0x7ffdd46f0090) at pgbench.c:3807
#3  0x0000555a40259564 in threadRun (arg=arg@entry=0x555a409d6580) at pgbench.c:7535
#4  0x0000555a4025ca40 in main (argc=<optimized out>, argv=<optimized out>) at pgbench.c:7253

Best regards,
Alexander



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Assert failure of the cross-check for nullingrels
Next
From: Jeff Davis
Date:
Subject: Re: ICU locale validation / canonicalization