| From: | Fujii Masao <fujii(at)postgresql(dot)org> |
|---|---|
| To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
| Subject: | pgsql: psql: Do not let invalid \getresults affect the next query |
| Date: | 2026-08-21 03:38:03 |
| Message-ID: | E1wxG4v-00000001SIF-46TP@gemulon.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-committers |
psql: Do not let invalid \getresults affect the next query
In pipeline mode, an invalid \getresults argument could previously
affect the next SQL command in the same pipeline. For example, after
reporting an error for \getresults -1, psql could treat the following
SQL command as a request to read pending pipeline results instead of
sending it to the server, making the command appear to be skipped or
causing missing results.
This happened because psql marked \getresults as a request to read
pipeline results before validating its optional argument. When
validation failed, psql reported the error without running the normal
cleanup path that clears the request.
Fix this by validating the \getresults argument before marking the
command as a request to read pipeline results. After an invalid
argument, psql now reports the error and sends the following SQL command
normally.
Backpatch to v18, where psql pipeline meta-commands were introduced.
Author: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Reviewed-by: Anthonin Bonnefoy <anthonin(dot)bonnefoy(at)datadoghq(dot)com>
Discussion: https://postgr.es/m/CAHGQGwGkgM2HKZeig5hobEgUCjn7MMJux4UCcN=OfOzOEvRT0A@mail.gmail.com
Backpatch-through: 18
Branch
------
REL_18_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/fd9bb365db5b83249b97b788df4af4e7877fc1e0
Modified Files
--------------
src/bin/psql/command.c | 9 +++++----
src/test/regress/expected/psql_pipeline.out | 21 +++++++++++++++++++++
src/test/regress/sql/psql_pipeline.sql | 11 +++++++++++
3 files changed, 37 insertions(+), 4 deletions(-)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Richard Guo | 2026-08-21 06:52:25 | pgsql: Collect quals for outer-join reduction on demand |
| Previous Message | Fujii Masao | 2026-08-21 03:37:52 | pgsql: psql: Do not let invalid \getresults affect the next query |