From: Tom Lane <tgl@sss.pgh.pa.us>
To: Daniele Varrazzo <daniele.varrazzo@gmail.com>
Cc: Francisco Olarte <folarte@peoplecall.com>
Cc: pgsql-bugs <pgsql-bugs@postgresql.org>
Subject: Re: [PATCH] Fix segfault calling PQflush on invalid connection
Date: Mon, 15 Aug 2022 11:54:01 -0400
Message-ID: <920911.1660578841@sss.pgh.pa.us> (raw)
In-Reply-To: <CA+mi_8YiJ_F1L+73tCJCvpxvwhvyHtdhL6KuzMv8OV1DjnRu5g@mail.gmail.com>
References: <CA+mi_8Zm_mVVyW1iNFgyMd9Oh0Nv8-F+7Y3-BqwMgTMHuo_h2Q@mail.gmail.com>
<819197.1660527847@sss.pgh.pa.us>
<CA+bJJby2grMbH_GBhn0yscALoZ+VnOe=m-hGR2bFwGibakDSoQ@mail.gmail.com>
<CA+mi_8YiJ_F1L+73tCJCvpxvwhvyHtdhL6KuzMv8OV1DjnRu5g@mail.gmail.com>
Daniele Varrazzo <daniele.varrazzo@gmail.com> writes:
> After exercising most of the libpq API in psycopg 3, PQflush() seems
> the only one requiring a guard [1]. All the other functions seem to
> behave well when passed an "invalid connection" - aka either a NULL
> pointer or a connection in BAD status.
I went so far as to inspect every function listed in libpq/exports.txt.
All the ones that take a PGconn or PGresult check it for NULL except
PQflush
PQisnonblocking
PQdefaultSSLKeyPassHook_OpenSSL
PQisnonblocking is clearly an oversight, same as PQflush.
Maybe there is a case for not bothering to check in
PQdefaultSSLKeyPassHook_OpenSSL, on the grounds that you'd
not get that far without a connection, but I think for
consistency it should do so too.
There is not a lot of consistency about whether we insist on
the connection being in any particular "good" state. For
some of the functions I think it's intentional that they should
still work on a failed connection, but I wonder if any of those
are likewise oversights.
regards, tom lane
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-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, daniele.varrazzo@gmail.com, folarte@peoplecall.com
Subject: Re: [PATCH] Fix segfault calling PQflush on invalid connection
In-Reply-To: <920911.1660578841@sss.pgh.pa.us>
* 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