pipelining in psql, commit 41625ab
Noah Misch <noah@leadboat.com>
On Fri, Feb 21, 2025 at 11:33:41AM +0900, Michael Paquier wrote:
> So let's take one step here, I have applied the main patch.
commit 41625ab wrote:
> * \syncpipeline queues a synchronisation request, without flushing the
> commands to the server, equivalent of PQsendPipelineSync().
libpq has both PQpipelineSync() and PQsendPipelineSync(), so I find it odd
that the psql command for PQsendPipelineSync() is \syncpipeline. I would have
expected the word "send" somewhere in its name. That said, maybe having
PQpipelineSync() was a mistake, since I think it's just PQsendPipelineSync() +
PQflush(). In that light, it's reasonable not to spread the extra "send" word
into psql. \syncpipeline is fine with me, but it's worth others taking a
second look.
> + pg_log_error("\\getresults: invalid number of requested results");
> + return PSQL_CMD_SKIP_LINE;
This should be PSQL_CMD_ERROR. That matters under ON_ERROR_STOP=1.
> --- a/src/bin/psql/help.c
> +++ b/src/bin/psql/help.c
> @@ -167,15 +167,22 @@ slashUsage(unsigned short int pager)
> HELP0(" \\close STMT_NAME close an existing prepared statement\n");
> HELP0(" \\copyright show PostgreSQL usage and distribution terms\n");
> HELP0(" \\crosstabview [COLUMNS] execute query and display result in crosstab\n");
> + HELP0(" \\endpipeline exit pipeline mode\n");
> HELP0(" \\errverbose show most recent error message at maximum verbosity\n");
> + HELP0(" \\flush push unsent data to the server\n");
> + HELP0(" \\flushrequest send a flushrequest command\n");
protocol.sgml calls it a "Flush command".
> HELP0(" \\g [(OPTIONS)] [FILE] execute query (and send result to file or |pipe);\n"
> " \\g with no arguments is equivalent to a semicolon\n");
> HELP0(" \\gdesc describe result of query, without executing it\n");
> + HELP0(" \\getresults [NUM_RES] read NUM_RES pending results. All pending results are\n"
> + " read if no argument is provided\n");
> HELP0(" \\gexec execute query, then execute each value in its result\n");
> HELP0(" \\gset [PREFIX] execute query and store result in psql variables\n");
> HELP0(" \\gx [(OPTIONS)] [FILE] as \\g, but forces expanded output mode\n");
> HELP0(" \\parse STMT_NAME create a prepared statement\n");
> HELP0(" \\q quit psql\n");
> + HELP0(" \\startpipeline enter pipeline mode\n");
> + HELP0(" \\syncpipeline add a synchronisation point to an ongoing pipeline\n");
v17 "\?" has a 14-line "General" section:
General
\bind [PARAM]... set query parameters
\copyright show PostgreSQL usage and distribution terms
\crosstabview [COLUMNS] execute query and display result in crosstab
\errverbose show most recent error message at maximum verbosity
\g [(OPTIONS)] [FILE] execute query (and send result to file or |pipe);
\g with no arguments is equivalent to a semicolon
\gdesc describe result of query, without executing it
\gexec execute query, then execute each value in its result
\gset [PREFIX] execute query and store result in psql variables
\gx [(OPTIONS)] [FILE] as \g, but forces expanded output mode
\q quit psql
\watch [[i=]SEC] [c=N] [m=MIN]
execute query every SEC seconds, up to N times,
stop if less than MIN rows are returned
v18 has raised that to 26 lines via $SUBJECT and other additions. I think a
new "Extended Query Protocol" section should house \bind and all the v18
additions. Beginners should ignore the new section. The section may as well
appear last. What do you think?
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