pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: psql: Set variables from query result on failure when printing t
Date: Mon, 02 Oct 2023 02:06:58 +0000
Message-ID: <E1qn8Ko-0074Cw-K2@gemulon.postgresql.org> (raw)

psql: Set variables from query result on failure when printing tuples

SetResultVariables() was not getting called when "printing" a result
that failed (see around PrintQueryResult), which would cause some
variables to not be set, like ROW_COUNT, SQLSTATE or ERROR.  This can be
confusing as a previous result would be retained.

This state could be reached when failing to process tuples in a few
commands, like \gset when it returns no tuples, or \crosstabview.  A
test is added, based on \gset.

This is arguably a bug fix, but no backpatch is done as there is a risk
of breaking scripts that rely on the previous behavior, even if they do
so accidentally.

Reported-by: amutu
Author: Japin Li
Reviewed-by: Tom Lane, Michael Paquier
Discussion: https://postgr.es/m/18134-87126d90cb4dd049@postgresql.org

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/2940f1c8373cb3b43b3b42d40786b05d6e901de1

Modified Files
--------------
src/bin/psql/common.c              | 6 +++---
src/test/regress/expected/psql.out | 5 +++++
src/test/regress/sql/psql.sql      | 4 ++++
3 files changed, 12 insertions(+), 3 deletions(-)



Message-ID: <E1qn8Ko-0074Cw-K2@gemulon.postgresql.org>
Permalink:  ../E1qn8Ko-0074Cw-K2@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1qn8Ko-0074Cw-K2@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: michael@paquier.xyz, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: psql: Set variables from query result on failure when printing t
  In-Reply-To: <E1qn8Ko-0074Cw-K2@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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