Re: BackendKeyData is mandatory?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
Cc: Jelte Fennema-Nio <postgres(at)jeltef(dot)nl>, Jacob Champion <jacob(dot)champion(at)enterprisedb(dot)com>, Tatsuo Ishii <ishii(at)postgresql(dot)org>, peter(at)eisentraut(dot)org, pgsql-hackers(at)postgresql(dot)org, Dave Cramer <davecramer(at)gmail(dot)com>
Subject: Re: BackendKeyData is mandatory?
Date: 2025-08-08 14:01:05
Message-ID: 1846938.1754661665@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Heikki Linnakangas <hlinnaka(at)iki(dot)fi> writes:
> I noticed that there's a similar, existing case in getNotify(), where
> libpq just hangs if an allocation fails. To simulate that, apply this
> change and use LISTEN/NOTIFY:

> --- a/src/interfaces/libpq/fe-protocol3.c
> +++ b/src/interfaces/libpq/fe-protocol3.c
> @@ -1587,7 +1587,7 @@ getNotify(PGconn *conn)
> if (pqGets(&conn->workBuffer, conn))
> return EOF;
> /* must save name while getting extra string */
> - svname = strdup(conn->workBuffer.data);
> + svname = NULL;
> if (!svname)
> return EOF;
> if (pqGets(&conn->workBuffer, conn))

> Returning EOF means "not enough data", which is wrong here just like in
> getBackendKeyData().

The implication of "return EOF" is "try again later", which seems like
about the best thing we can do. If memory serves, other places that
construct query results do likewise.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2025-08-08 15:50:27 Re: BackendKeyData is mandatory?
Previous Message Fabrice Chapuis 2025-08-08 13:30:57 Re: Issue with logical replication slot during switchover