Re: Out-of-memory error reports in libpq

Michael Paquier <michael@paquier.xyz>

From: Michael Paquier <michael@paquier.xyz>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: "Bossart, Nathan" <bossartn@amazon.com>, "pgsql-hackers@lists.postgresql.org" <pgsql-hackers@lists.postgresql.org>, Alvaro Herrera <alvherre@alvh.no-ip.org>, Peter Geoghegan <pg@bowt.ie>
Date: 2021-07-28T03:32:53Z
Lists: pgsql-hackers
On Tue, Jul 27, 2021 at 10:31:25PM -0400, Tom Lane wrote:
> Yeah, there are half a dozen places that currently print something
> more specific than "out of memory".  I judged that the value of this
> was not worth the complexity it'd add to support it in this scheme.
> Different opinions welcome of course.

I don't mind either that this removes a bit of context.  For
unlikely-going-to-happen errors that's not worth the extra translation
cost.  No objections from me for an integration into 14 as that's
straight-forward, and that would minimize conflicts between HEAD and 
14 in the event of a back-patch

+pqReportOOM(PGconn *conn)
+{
+   pqReportOOMBuffer(&conn->errorMessage);
+}
+
+/*
+ * As above, but work with a bare error-message-buffer pointer.
+ */
+void
+pqReportOOMBuffer(PQExpBuffer errorMessage)
+{
Not much a fan of having two routines to do this job though.  I would
vote for keeping the one named pqReportOOM() with PQExpBuffer as
argument.
--
Michael

Commits

  1. Improve libpq's handling of OOM during error message construction.

  2. In libpq, always append new error messages to conn->errorMessage.