Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uS02r-001vmP-M6 for pgsql-bugs@arkaria.postgresql.org; Wed, 18 Jun 2025 21:10:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1uS01r-0050iv-7n for pgsql-bugs@arkaria.postgresql.org; Wed, 18 Jun 2025 21:09:07 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uS01q-0050in-Vq for pgsql-bugs@lists.postgresql.org; Wed, 18 Jun 2025 21:09:07 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1uS01p-002kzr-04 for pgsql-bugs@lists.postgresql.org; Wed, 18 Jun 2025 21:09:06 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 55IL93go1181607; Wed, 18 Jun 2025 17:09:03 -0400 From: Tom Lane To: d.kovalenko@postgrespro.ru cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #18960: Mistake in test test_simple_pipeline (libpq_pipeline.c) In-reply-to: <18960-09cd4a5100152e58@postgresql.org> References: <18960-09cd4a5100152e58@postgresql.org> Comments: In-reply-to PG Bug reporting form message dated "Wed, 18 Jun 2025 19:25:04 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1181605.1750280943.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Wed, 18 Jun 2025 17:09:03 -0400 Message-ID: <1181606.1750280943@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk PG Bug reporting form writes: > Please look at these test lines in > src/test/modules/libpq_pipeline/libpq_pipeline.c 1657-1662: > https://github.com/postgres/postgres/blob/c2e2589ab969eb802493191c79de84= 4bf7dc3a6e/src/test/modules/libpq_pipeline/libpq_pipeline.c#L1657-L1662 > --- > PQclear(res); > res =3D NULL; > if (PQgetResult(conn) !=3D NULL) > pg_fatal("PQgetResult returned something extra after > pipeline end: %s", > PQresStatus(PQresultStatus(res))); > --- > You forgot to assign res: > --- > PQclear(res); > res =3D NULL; > if ((res =3D PQgetResult(conn)) !=3D 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