Re: Add Pipelining support in psql
a.kozhemyakin <a.kozhemyakin@postgrespro.ru>
Hello, After commit 2cce0fe on master When executing query: psql postgres <<EOF CREATE TABLE psql_pipeline(); \startpipeline COPY psql_pipeline FROM STDIN; SELECT 'val1'; \syncpipeline \getresults EOF ERROR: unexpected message type 0x50 during COPY from stdin CONTEXT: COPY psql_pipeline, line 1 Pipeline aborted, command did not run psql: common.c:1510: discardAbortedPipelineResults: Assertion `res == ((void *)0) || result_status == PGRES_PIPELINE_ABORTED' failed. Aborted (core dumped) The psql crashes with the stack trace: (gdb) bt #0 __pthread_kill_implementation (no_tid=0, signo=6, threadid=<optimized out>) at ./nptl/pthread_kill.c:44 #1 __pthread_kill_internal (signo=6, threadid=<optimized out>) at ./nptl/pthread_kill.c:78 #2 __GI___pthread_kill (threadid=<optimized out>, signo=signo@entry=6) at ./nptl/pthread_kill.c:89 #3 0x0000760edd24527e in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26 #4 0x0000760edd2288ff in __GI_abort () at ./stdlib/abort.c:79 #5 0x0000760edd22881b in __assert_fail_base (fmt=0x760edd3d01e8 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=0x5ba46ab79850 "res == ((void *)0) || result_status == PGRES_PIPELINE_ABORTED", file=file@entry=0x5ba46ab6fcad "common.c", line=line@entry=1510, function=function@entry=0x5ba46ab9c780 <__PRETTY_FUNCTION__.3> "discardAbortedPipelineResults") at ./assert/assert.c:96 #6 0x0000760edd23b517 in __assert_fail (assertion=assertion@entry=0x5ba46ab79850 "res == ((void *)0) || result_status == PGRES_PIPELINE_ABORTED", file=file@entry=0x5ba46ab6fcad "common.c", line=line@entry=1510, function=function@entry=0x5ba46ab9c780 <__PRETTY_FUNCTION__.3> "discardAbortedPipelineResults") at ./assert/assert.c:105 #7 0x00005ba46ab2bd40 in discardAbortedPipelineResults () at common.c:1510 #8 ExecQueryAndProcessResults (query=query@entry=0x5ba4a2ec1e10 "SELECT 'val1';", elapsed_msec=elapsed_msec@entry=0x7ffeb07262a8, svpt_gone_p=svpt_gone_p@entry=0x7ffeb07262a7, is_watch=is_watch@entry=false, min_rows=min_rows@entry=0, opt=opt@entry=0x0, printQueryFout=0x0) at common.c:1811 #9 0x00005ba46ab2983f in SendQuery (query=0x5ba4a2ec1e10 "SELECT 'val1';") at common.c:1212 #10 0x00005ba46ab3f66a in MainLoop (source=source@entry=0x760edd4038e0 <_IO_2_1_stdin_>) at mainloop.c:515 #11 0x00005ba46ab23f2a in process_file (filename=0x0, use_relative_path=use_relative_path@entry=false) at command.c:4870 #12 0x00005ba46ab1e9d9 in main (argc=<optimized out>, argv=0x7ffeb07269d8) at startup.c:420 06.03.2025 11:20, Michael Paquier пишет: > On Wed, Mar 05, 2025 at 03:25:12PM +0100, Daniel Verite wrote: >> Anthonin Bonnefoy wrote: >>> I do see the idea to make it easier to convert existing scripts into >>> using pipelining. The main focus of the initial implementation was >>> more on protocol regression tests with psql, so that's not necessarily >>> something I had in mind. >> Understood. Yet pipelining can accelerate considerably certain scripts >> when client-server latency is an issue. We should expect end users to >> benefit from it too. > 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. > -- > Michael
Commits
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
psql: Fix assertion failures with pipeline mode
- 3631612eae9c 18.0 landed
-
psql: Rework TAP routine psql_fails_like() to define WAL sender context
- 0ff95e0a5be1 18.0 landed
-
psql: Split extended query protocol meta-commands in --help=commands
- 78231baaf967 18.0 landed
-
psql: Improve descriptions of \\flush[request] in --help
- 5743d122fcf3 18.0 landed
-
psql: Fix incorrect status code returned by \getresults
- 5ee7bd944ee8 18.0 landed
-
psql: Allow queries terminated by semicolons while in pipeline mode
- 2cce0fe440fb 18.0 landed
-
psql: Add \sendpipeline to send query buffers while in a pipeline
- 17caf6644546 18.0 landed
-
psql: Fix memory leak with \gx used within a pipeline
- 54d23601b978 18.0 landed
-
psql: Add pipeline status to prompt and some state variables
- 3ce357584e79 18.0 landed
-
Add more tests for utility commands in pipelines
- a4e986ef5a46 18.0 landed
-
psql: Add support for pipelines
- 41625ab8ea3d 18.0 landed
-
Add braces for if block with large comment in psql's common.c
- 40af897eb777 18.0 landed