Re: BUG #18960: Mistake in test test_simple_pipeline (libpq_pipeline.c)

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: d(dot)kovalenko(at)postgrespro(dot)ru
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #18960: Mistake in test test_simple_pipeline (libpq_pipeline.c)
Date: 2025-06-18 21:09:03
Message-ID: 1181606.1750280943@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

PG Bug reporting form <noreply(at)postgresql(dot)org> writes:
> Please look at these test lines in
> src/test/modules/libpq_pipeline/libpq_pipeline.c 1657-1662:
> https://github.com/postgres/postgres/blob/c2e2589ab969eb802493191c79de844bf7dc3a6e/src/test/modules/libpq_pipeline/libpq_pipeline.c#L1657-L1662
> ---
> PQclear(res);
> res = NULL;
> if (PQgetResult(conn) != NULL)
> pg_fatal("PQgetResult returned something extra after
> pipeline end: %s",
> PQresStatus(PQresultStatus(res)));
> ---
> You forgot to assign res:
> ---
> PQclear(res);
> res = NULL;
> if ((res = PQgetResult(conn)) != NULL)
> pg_fatal("PQgetResult returned something extra after
> pipeline end: %s",
> PQresStatus(PQresultStatus(res)));

I agree that's wrong ... but looking around, there's a huge amount
of random inconsistency in this test script --- this same simple
task of checking for an expected NULL result is coded several
different ways with varying amounts of detail provided, and
some other places share this same outright bug.

I think it'd be better to make a helper function
"CheckNoMoreResults(conn)", or something along that line,
to shorten and standardize these places.

On the other side of the coin, the explicit tests for a result
*not* being NULL are mostly unnecessary; if the next step is
a check of PQresultStatus, we could just rely on the fact
that PQresultStatus(NULL) returns PGRES_FATAL_ERROR.

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2025-06-19 00:27:27 BUG #18961: Race scenario where max_standby_streaming_delay is not honored
Previous Message Tom Lane 2025-06-18 20:51:58 Re: PostgreSQL 17 Service Running but Not Listening on Network Port on Windows