Re: Getting rid of "unknown error" in dblink and postgres_fdw
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Joe Conway <mail@joeconway.com>
Cc: pgsql-hackers@postgresql.org
Date: 2016-12-22T00:22:09Z
Lists: pgsql-hackers
Joe Conway <mail@joeconway.com> writes: > I did notice that postgres_fdw has the following stanza that I don't see > in dblink: > 8<------------------ > /* > * If we don't get a message from the PGresult, try the PGconn. This > * is needed because for connection-level failures, PQexec may just > * return NULL, not a PGresult at all. > */ > if (message_primary == NULL) > message_primary = PQerrorMessage(conn); > 8<------------------ > I wonder if the original issue on pgsql-bugs was a connection-level > failure rather than OOM? Seems like dblink ought to do the same. Oooh ... I had thought that code was in both, which was why I was having a hard time explaining the OP's failure. But I see you're right, which provides a very straightforward explanation for the report. I believe that if libpq is unable to malloc a PGresult, it will return NULL but put an "out of memory" message into the PGconn's error buffer. I had supposed that we'd capture and report the latter, but as the dblink code stands, it won't. In short, yes, please copy that bit into dblink. regards, tom lane
Commits
-
Make dblink try harder to form useful error messages
- 2f802d95b490 10.0 landed
- 51126ccdb1ce 9.6.2 landed
- 80ca22aa60a6 9.5.6 landed
- 76943f54a743 9.4.11 landed
- 9b8507bfae91 9.3.16 landed
- 44de099f89c2 9.2.20 landed
-
Improve dblink error message when remote does not provide it
- 88673c9d3bc7 9.6.2 landed
- 28c9b6be7f76 9.5.6 landed
- 0f5b1867c2e6 9.4.11 landed
- 3272be346895 9.3.16 landed
- fb0ab06dc4f4 9.2.20 landed
- ea0aa9698cfa 10.0 landed