aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bin/pg_basebackup/streamutil.c6
-rw-r--r--src/bin/pg_dump/pg_dumpall.c3
-rw-r--r--src/bin/psql/command.c3
-rw-r--r--src/bin/psql/common.c3
-rw-r--r--src/bin/psql/describe.c3
-rw-r--r--src/fe_utils/query_utils.c3
-rw-r--r--src/interfaces/ecpg/ecpglib/descriptor.c3
-rw-r--r--src/interfaces/ecpg/ecpglib/execute.c3
-rw-r--r--src/interfaces/libpq/fe-connect.c6
-rw-r--r--src/interfaces/libpq/fe-exec.c9
10 files changed, 14 insertions, 28 deletions
diff --git a/src/bin/pg_basebackup/streamutil.c b/src/bin/pg_basebackup/streamutil.c
index 8e820c0c71c..919ec9c29c2 100644
--- a/src/bin/pg_basebackup/streamutil.c
+++ b/src/bin/pg_basebackup/streamutil.c
@@ -197,16 +197,14 @@ GetConnection(void)
PQfinish(tmpconn);
free(values);
free(keywords);
- if (conn_opts)
- PQconninfoFree(conn_opts);
+ PQconninfoFree(conn_opts);
return NULL;
}
/* Connection ok! */
free(values);
free(keywords);
- if (conn_opts)
- PQconninfoFree(conn_opts);
+ PQconninfoFree(conn_opts);
/*
* Set always-secure search path, so malicious users can't get control.
diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c
index da5cf85272c..26d3d53809b 100644
--- a/src/bin/pg_dump/pg_dumpall.c
+++ b/src/bin/pg_dump/pg_dumpall.c
@@ -1502,8 +1502,7 @@ connectDatabase(const char *dbname, const char *connection_string,
free(keywords);
free(values);
- if (conn_opts)
- PQconninfoFree(conn_opts);
+ PQconninfoFree(conn_opts);
/*
* Merge the connection info inputs given in form of connection string
diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c
index f3c5196c901..c562c04afee 100644
--- a/src/bin/psql/command.c
+++ b/src/bin/psql/command.c
@@ -3476,8 +3476,7 @@ do_connect(enum trivalue reuse_previous_specification,
/* Release locally allocated data, whether we succeeded or not */
pg_free(password);
- if (cinfo)
- PQconninfoFree(cinfo);
+ PQconninfoFree(cinfo);
if (!success)
{
diff --git a/src/bin/psql/common.c b/src/bin/psql/common.c
index 974959c5959..9f95869eca6 100644
--- a/src/bin/psql/common.c
+++ b/src/bin/psql/common.c
@@ -463,8 +463,7 @@ ClearOrSaveResult(PGresult *result)
{
case PGRES_NONFATAL_ERROR:
case PGRES_FATAL_ERROR:
- if (pset.last_error_result)
- PQclear(pset.last_error_result);
+ PQclear(pset.last_error_result);
pset.last_error_result = result;
break;
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index 2df95bc1654..88d92a08ae6 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -3492,8 +3492,7 @@ error_return:
free(view_def);
- if (res)
- PQclear(res);
+ PQclear(res);
return retval;
}
diff --git a/src/fe_utils/query_utils.c b/src/fe_utils/query_utils.c
index 2fc6e2405b4..6575b24c78f 100644
--- a/src/fe_utils/query_utils.c
+++ b/src/fe_utils/query_utils.c
@@ -85,8 +85,7 @@ executeMaintenanceCommand(PGconn *conn, const char *query, bool echo)
r = (res && PQresultStatus(res) == PGRES_COMMAND_OK);
- if (res)
- PQclear(res);
+ PQclear(res);
return r;
}
diff --git a/src/interfaces/ecpg/ecpglib/descriptor.c b/src/interfaces/ecpg/ecpglib/descriptor.c
index f1898dec6a6..649a71c286c 100644
--- a/src/interfaces/ecpg/ecpglib/descriptor.c
+++ b/src/interfaces/ecpg/ecpglib/descriptor.c
@@ -923,8 +923,7 @@ ECPGdescribe(int line, int compat, bool input, const char *connection_name, cons
if (!ecpg_check_PQresult(res, line, con->connection, compat))
break;
- if (desc->result != NULL)
- PQclear(desc->result);
+ PQclear(desc->result);
desc->result = res;
ret = true;
diff --git a/src/interfaces/ecpg/ecpglib/execute.c b/src/interfaces/ecpg/ecpglib/execute.c
index 2ebe6656d63..bd94bd4e6c6 100644
--- a/src/interfaces/ecpg/ecpglib/execute.c
+++ b/src/interfaces/ecpg/ecpglib/execute.c
@@ -1714,8 +1714,7 @@ ecpg_process_output(struct statement *stmt, bool clear_result)
status = false;
else
{
- if (desc->result)
- PQclear(desc->result);
+ PQclear(desc->result);
desc->result = stmt->results;
clear_result = false;
ecpg_log("ecpg_process_output on line %d: putting result (%d tuples) into descriptor %s\n",
diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c
index 057c9da0ede..dc49387d6c5 100644
--- a/src/interfaces/libpq/fe-connect.c
+++ b/src/interfaces/libpq/fe-connect.c
@@ -3766,8 +3766,7 @@ keep_going: /* We will come back to here until there is
}
/* Something went wrong with "SHOW transaction_read_only". */
- if (res)
- PQclear(res);
+ PQclear(res);
/* Append error report to conn->errorMessage. */
appendPQExpBuffer(&conn->errorMessage,
@@ -3818,8 +3817,7 @@ keep_going: /* We will come back to here until there is
}
/* Something went wrong with "SELECT pg_is_in_recovery()". */
- if (res)
- PQclear(res);
+ PQclear(res);
/* Append error report to conn->errorMessage. */
appendPQExpBuffer(&conn->errorMessage,
diff --git a/src/interfaces/libpq/fe-exec.c b/src/interfaces/libpq/fe-exec.c
index 1750d647a8d..51e9a362f6a 100644
--- a/src/interfaces/libpq/fe-exec.c
+++ b/src/interfaces/libpq/fe-exec.c
@@ -775,12 +775,10 @@ PQclear(PGresult *res)
void
pqClearAsyncResult(PGconn *conn)
{
- if (conn->result)
- PQclear(conn->result);
+ PQclear(conn->result);
conn->result = NULL;
conn->error_result = false;
- if (conn->next_result)
- PQclear(conn->next_result);
+ PQclear(conn->next_result);
conn->next_result = NULL;
}
@@ -2437,8 +2435,7 @@ PQexecFinish(PGconn *conn)
lastResult = NULL;
while ((result = PQgetResult(conn)) != NULL)
{
- if (lastResult)
- PQclear(lastResult);
+ PQclear(lastResult);
lastResult = result;
if (result->resultStatus == PGRES_COPY_IN ||
result->resultStatus == PGRES_COPY_OUT ||