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: Make libpq_pipeline.c shorter and more uniform via helper functi
Date: Wed, 03 Sep 2025 20:08:03 +0000
Message-ID: <E1uttlz-000Lyd-2u@gemulon.postgresql.org> (raw)

Make libpq_pipeline.c shorter and more uniform via helper functions.

There are many places in this test program that need to consume a
PGresult while checking that its PQresultStatus is as-expected, or
related tasks such as checking that PQgetResult has nothing more to
return.  These tasks were open-coded in a rather inconsistent way,
leading to some outright bugs, some memory leakage, and frequent
inconsistencies about what would be reported in event of an error.
Invent a few helper functions to standardize the behavior and
reduce code duplication.  Also, rename the one pre-existing helper
function from confirm_query_canceled to consume_query_cancel, per
Álvaro's suggestion that "confirm" is a poor choice of verb for a
function that will discard the PGresult.

While at it, clean up assorted other places that were leaking
PGresults or even server connections.  This is pure neatnik-ism,
since the test doesn't run long enough for those leaks to be of
any real-world concern.

While this fixes some things that are clearly bugs, it's only
a test program, and none of the bugs seem serious enough to
justify back-patching.

Bug: #18960
Reported-by: Dmitry Kovalenko <d.kovalenko@postgrespro.ru>
Author: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de>
Discussion: https://postgr.es/m/18960-09cd4a5100152e58@postgresql.org

Branch
------
master

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

Modified Files
--------------
src/test/modules/libpq_pipeline/libpq_pipeline.c | 549 +++++++++--------------
1 file changed, 201 insertions(+), 348 deletions(-)



Message-ID: <E1uttlz-000Lyd-2u@gemulon.postgresql.org>
Permalink:  ../E1uttlz-000Lyd-2u@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1uttlz-000Lyd-2u@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: tgl@sss.pgh.pa.us, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Make libpq_pipeline.c shorter and more uniform via helper functi
  In-Reply-To: <E1uttlz-000Lyd-2u@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