diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2014-02-03 21:30:05 -0500 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2014-02-03 21:30:28 -0500 |
commit | eb3d350db3fe89e9f58aa82f6b490e2aa457028f (patch) | |
tree | a923a5c713ca599667ef67d2dfa753fb62c21222 /contrib/postgres_fdw/postgres_fdw.h | |
parent | 5203b6a752fedb771edc78e6b7b6b8f548de3032 (diff) | |
download | postgresql-eb3d350db3fe89e9f58aa82f6b490e2aa457028f.tar.gz postgresql-eb3d350db3fe89e9f58aa82f6b490e2aa457028f.zip |
Improve connection-failure error handling in contrib/postgres_fdw.
postgres_fdw tended to say "unknown error" if it tried to execute a command
on an already-dead connection, because some paths in libpq just return a
null PGresult for such cases. Out-of-memory might result in that, too.
To fix, pass the PGconn to pgfdw_report_error, and look at its
PQerrorMessage() string if we can't get anything out of the PGresult.
Also, fix the transaction-exit logic to reliably drop a dead connection.
It was attempting to do that already, but it assumed that only connection
cache entries with xact_depth > 0 needed to be examined. The folly in that
is that if we fail while issuing START TRANSACTION, we'll not have bumped
xact_depth. (At least for the case I was testing, this fix masks the
other problem; but it still seems like a good idea to have the PGconn
fallback logic.)
Per investigation of bug #9087 from Craig Lucas. Backpatch to 9.3 where
this code was introduced.
Diffstat (limited to 'contrib/postgres_fdw/postgres_fdw.h')
-rw-r--r-- | contrib/postgres_fdw/postgres_fdw.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/contrib/postgres_fdw/postgres_fdw.h b/contrib/postgres_fdw/postgres_fdw.h index c782d4fea12..cd0fab17417 100644 --- a/contrib/postgres_fdw/postgres_fdw.h +++ b/contrib/postgres_fdw/postgres_fdw.h @@ -30,8 +30,8 @@ extern PGconn *GetConnection(ForeignServer *server, UserMapping *user, extern void ReleaseConnection(PGconn *conn); extern unsigned int GetCursorNumber(PGconn *conn); extern unsigned int GetPrepStmtNumber(PGconn *conn); -extern void pgfdw_report_error(int elevel, PGresult *res, bool clear, - const char *sql); +extern void pgfdw_report_error(int elevel, PGresult *res, PGconn *conn, + bool clear, const char *sql); /* in option.c */ extern int ExtractConnectionOptions(List *defelems, |