diff options
| author | Peter Eisentraut | 2022-07-03 18:11:05 +0000 |
|---|---|---|
| committer | Peter Eisentraut | 2022-07-03 18:11:05 +0000 |
| commit | 5faef9d582012433db9ad05af27a77bd591508e1 (patch) | |
| tree | f3ace999fcaf45d69c3eb8428d3afc4819316530 /contrib | |
| parent | 02c408e21a6e78ff246ea7a1beb4669634fa9c4c (diff) | |
Remove redundant null pointer checks before PQclear and PQconninfoFree
These functions already had the free()-like behavior of handling null
pointers as a no-op. But it wasn't documented, so add it explicitly
to the documentation, too.
Discussion: https://www.postgresql.org/message-id/flat/dac5d2d0-98f5-94d9-8e69-46da2413593d%40enterprisedb.com
Diffstat (limited to 'contrib')
| -rw-r--r-- | contrib/dblink/dblink.c | 6 | ||||
| -rw-r--r-- | contrib/postgres_fdw/postgres_fdw.c | 24 |
2 files changed, 10 insertions, 20 deletions
diff --git a/contrib/dblink/dblink.c b/contrib/dblink/dblink.c index a561d1d6524..e323fdd0e67 100644 --- a/contrib/dblink/dblink.c +++ b/contrib/dblink/dblink.c @@ -157,8 +157,7 @@ dblink_res_internalerror(PGconn *conn, PGresult *res, const char *p2) { char *msg = pchomp(PQerrorMessage(conn)); - if (res) - PQclear(res); + PQclear(res); elog(ERROR, "%s: %s", p2, msg); } @@ -2756,8 +2755,7 @@ dblink_res_error(PGconn *conn, const char *conname, PGresult *res, * leaking all the strings too, but those are in palloc'd memory that will * get cleaned up eventually. */ - if (res) - PQclear(res); + PQclear(res); /* * Format the basic errcontext string. Below, we'll add on something diff --git a/contrib/postgres_fdw/postgres_fdw.c b/contrib/postgres_fdw/postgres_fdw.c index d56951153bb..955a428e3da 100644 --- a/contrib/postgres_fdw/postgres_fdw.c +++ b/contrib/postgres_fdw/postgres_fdw.c @@ -2790,8 +2790,7 @@ postgresEndDirectModify(ForeignScanState *node) return; /* Release PGresult */ - if (dmstate->result) - PQclear(dmstate->result); + PQclear(dmstate->result); /* Release remote connection */ ReleaseConnection(dmstate->conn); @@ -3604,8 +3603,7 @@ get_remote_estimate(const char *sql, PGconn *conn, } PG_FINALLY(); { - if (res) - PQclear(res); + PQclear(res); } PG_END_TRY(); } @@ -3853,8 +3851,7 @@ fetch_more_data(ForeignScanState *node) } PG_FINALLY(); { - if (res) - PQclear(res); + PQclear(res); } PG_END_TRY(); @@ -4338,8 +4335,7 @@ store_returning_result(PgFdwModifyState *fmstate, } PG_CATCH(); { - if (res) - PQclear(res); + PQclear(res); PG_RE_THROW(); } PG_END_TRY(); @@ -4627,8 +4623,7 @@ get_returning_data(ForeignScanState *node) } PG_CATCH(); { - if (dmstate->result) - PQclear(dmstate->result); + PQclear(dmstate->result); PG_RE_THROW(); } PG_END_TRY(); @@ -4957,8 +4952,7 @@ postgresAnalyzeForeignTable(Relation relation, } PG_FINALLY(); { - if (res) - PQclear(res); + PQclear(res); } PG_END_TRY(); @@ -5114,8 +5108,7 @@ postgresAcquireSampleRowsFunc(Relation relation, int elevel, } PG_CATCH(); { - if (res) - PQclear(res); + PQclear(res); PG_RE_THROW(); } PG_END_TRY(); @@ -5496,8 +5489,7 @@ postgresImportForeignSchema(ImportForeignSchemaStmt *stmt, Oid serverOid) } PG_FINALLY(); { - if (res) - PQclear(res); + PQclear(res); } PG_END_TRY(); |
