Thread

  1. Re: Add Pipelining support in psql

    Anthonin Bonnefoy <anthonin.bonnefoy@datadoghq.com> — 2025-03-07T08:08:51Z

    On Thu, Mar 6, 2025 at 5:20 AM Michael Paquier <michael@paquier.xyz> wrote:
    > That was not a test case we had in mind originally here, but if it is
    > possible to keep the implementation simple while supporting your
    > demand, well, let's do it.  If it's not that straight-forward, let's
    > use the new meta-command, forbidding \g and \gx based on your
    > arguments from upthread.
    
    I think the new meta-command is a separate issue from allowing ';' to
    push in a pipeline. Any time there's a change or an additional format
    option added to \g, it will need to be forbidden for pipelining. The
    \sendpipeline meta-command will help keep those exceptions low since
    the whole \g will be forbidden.
    
    Another possible option would be to allow both \g and \gx, but send a
    warning like "printing options within a pipeline will be ignored" if
    those options are used, similar to "SET LOCAL" warning when done
    outside of a transaction block. That would have the benefit of making
    existing scripts using \g and \gx compatible.
    
    For using ';' to push commands in a pipeline, I think it should be
    fairly straightforward. I can try to work on that next week (I'm
    currently chasing a weird memory context bug that I need to finish
    first).
    
    On Fri, Mar 7, 2025 at 1:05 AM Jelte Fennema-Nio <postgres@jeltef.nl> wrote:
    > One thing I've noticed is that \startpipeline throws warnings when
    > copy pasting multiple lines. It seems to still execute everything as
    > expected though. As an example you can copy paste this tiny script:
    >
    > \startpipeline
    > select pg_sleep(5) \bind \g
    > \endpipeline
    >
    > And then it will show these "extra argument ... ignored" warnings
    >
    > \startpipeline: extra argument "select" ignored
    > \startpipeline: extra argument "pg_sleep(5)" ignored
    
    It looks like an issue with libreadline. At least, I've been able to
    reproduce the warnings and 'readline(prompt);' returns everything as a
    single line, with the \n inside the string. This explains why what is
    after \startpipeline is processed as arguments. This can also be done
    with:
    select 1 \bind \g
    select 2 \bind \g
    And somehow, I couldn't reproduce the issue anymore once I've compiled
    and installed libreadline with debug symbols.