Re: [PATCH] Fix segfault calling PQflush on invalid connection

From: Daniele Varrazzo <daniele(dot)varrazzo(at)gmail(dot)com>
To: Francisco Olarte <folarte(at)peoplecall(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-bugs <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: [PATCH] Fix segfault calling PQflush on invalid connection
Date: 2022-08-15 14:57:58
Message-ID: CA+mi_8YiJ_F1L+73tCJCvpxvwhvyHtdhL6KuzMv8OV1DjnRu5g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Mon, 15 Aug 2022 at 13:21, Francisco Olarte <folarte(at)peoplecall(dot)com> wrote:

> Is there any place in the docs which states libpq just errors out ( as
> opposed to dump core ) on null PGconn? I could not find it easily, and
> I have always assumed the worst ( normally I use it wrapped, use
> nullptr as invalid marked in my data and check that (and either do
> nothing or intentionally SEGV for easier debugging ).

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.

[1] https://github.com/psycopg/psycopg/blob/923bb834ce7601f2743d10bff7e007698429933a/psycopg/psycopg/pq/pq_ctypes.py#L541-L548

-- Daniele

-- Daniele

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Alvaro Herrera 2022-08-15 15:24:37 Re: Regression in pipeline mode in libpq 14.5
Previous Message Sergei Kornilov 2022-08-15 14:02:38 Re:BUG #17568: unexpected zero page at block 0 during REINDEX CONCURRENTLY