pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: psql: Do not let invalid \getresults affect the next query
3+ messages / 1 participants
[nested] [flat]

* pgsql: psql: Do not let invalid \getresults affect the next query
@ 2026-08-21 03:37 Fujii Masao <fujii@postgresql.org>
  0 siblings, 0 replies; 3+ messages in thread

From: Fujii Masao @ 2026-08-21 03:37 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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.fujii@gmail.com>
Reviewed-by: Anthonin Bonnefoy <anthonin.bonnefoy@datadoghq.com>
Discussion: https://postgr.es/m/CAHGQGwGkgM2HKZeig5hobEgUCjn7MMJux4UCcN=OfOzOEvRT0A@mail.gmail.com
Backpatch-through: 18

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/d2ba580475ce5af8e5d07b922964e6206333af2c

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(-)



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* pgsql: psql: Do not let invalid \getresults affect the next query
@ 2026-08-21 03:37 Fujii Masao <fujii@postgresql.org>
  0 siblings, 0 replies; 3+ messages in thread

From: Fujii Masao @ 2026-08-21 03:37 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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.fujii@gmail.com>
Reviewed-by: Anthonin Bonnefoy <anthonin.bonnefoy@datadoghq.com>
Discussion: https://postgr.es/m/CAHGQGwGkgM2HKZeig5hobEgUCjn7MMJux4UCcN=OfOzOEvRT0A@mail.gmail.com
Backpatch-through: 18

Branch
------
REL_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/2b0d50e39c58e14b69de76aae2a1c73877de52a6

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(-)



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* pgsql: psql: Do not let invalid \getresults affect the next query
@ 2026-08-21 03:38 Fujii Masao <fujii@postgresql.org>
  0 siblings, 0 replies; 3+ messages in thread

From: Fujii Masao @ 2026-08-21 03:38 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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.fujii@gmail.com>
Reviewed-by: Anthonin Bonnefoy <anthonin.bonnefoy@datadoghq.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(-)



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2026-08-21 03:38 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-08-21 03:37 pgsql: psql: Do not let invalid \getresults affect the next query Fujii Masao <fujii@postgresql.org>
2026-08-21 03:37 pgsql: psql: Do not let invalid \getresults affect the next query Fujii Masao <fujii@postgresql.org>
2026-08-21 03:38 pgsql: psql: Do not let invalid \getresults affect the next query Fujii Masao <fujii@postgresql.org>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox