pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix missed cases in libpq's error handling.
Date: Thu, 21 Apr 2022 21:12:57 +0000
Message-ID: <E1nhe6j-000UBk-Ad@gemulon.postgresql.org> (raw)

Fix missed cases in libpq's error handling.

Commit 618c16707 invented an "error_result" flag in PGconn, which
intends to represent the state that we have an error condition and
need to build a PGRES_FATAL_ERROR PGresult from the message text in
conn->errorMessage, but have not yet done so.  (Postponing construction
of the error object simplifies dealing with out-of-memory conditions
and with concatenation of messages for multiple errors.)  For nearly all
purposes, this "virtual" PGresult object should act the same as if it
were already materialized.  But a couple of places in fe-protocol3.c
didn't get that memo, and were only testing conn->result as they used
to, without also checking conn->error_result.

In hopes of reducing the probability of similar mistakes in future,
I invented a pgHavePendingResult() macro that includes both tests.

Per report from Peter Eisentraut.

Discussion: https://postgr.es/m/b52277b9-fa66-b027-4a37-fb8989c73ff8@enterprisedb.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/914611ea738a3601717990faff0f5d71a0f14a3d

Modified Files
--------------
src/interfaces/libpq/fe-exec.c      |  5 +++--
src/interfaces/libpq/fe-protocol3.c | 10 +++++-----
src/interfaces/libpq/libpq-int.h    |  8 ++++++++
3 files changed, 16 insertions(+), 7 deletions(-)



Message-ID: <E1nhe6j-000UBk-Ad@gemulon.postgresql.org>
Permalink:  ../E1nhe6j-000UBk-Ad@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1nhe6j-000UBk-Ad@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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Fix missed cases in libpq's error handling.
  In-Reply-To: <E1nhe6j-000UBk-Ad@gemulon.postgresql.org>
  References: <E1nhe6j-000UBk-Ad@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