Commit f7332e88 authored by Tom Lane's avatar Tom Lane

Remove duplicate PQclear(res) operations leading to double free() and

subsequent core dump.  It looks like at one time DBLINK_RES_ERROR_AS_NOTICE
didn't include a PQclear, but now it does and so these other ones are
duplicate.
parent 1ad68782
...@@ -345,7 +345,6 @@ dblink_open(PG_FUNCTION_ARGS) ...@@ -345,7 +345,6 @@ dblink_open(PG_FUNCTION_ARGS)
else else
{ {
DBLINK_RES_ERROR_AS_NOTICE("sql error"); DBLINK_RES_ERROR_AS_NOTICE("sql error");
PQclear(res);
PG_RETURN_TEXT_P(GET_TEXT("ERROR")); PG_RETURN_TEXT_P(GET_TEXT("ERROR"));
} }
} }
...@@ -419,7 +418,6 @@ dblink_close(PG_FUNCTION_ARGS) ...@@ -419,7 +418,6 @@ dblink_close(PG_FUNCTION_ARGS)
else else
{ {
DBLINK_RES_ERROR_AS_NOTICE("sql error"); DBLINK_RES_ERROR_AS_NOTICE("sql error");
PQclear(res);
PG_RETURN_TEXT_P(GET_TEXT("ERROR")); PG_RETURN_TEXT_P(GET_TEXT("ERROR"));
} }
} }
...@@ -531,8 +529,6 @@ dblink_fetch(PG_FUNCTION_ARGS) ...@@ -531,8 +529,6 @@ dblink_fetch(PG_FUNCTION_ARGS)
DBLINK_RES_ERROR("sql error"); DBLINK_RES_ERROR("sql error");
else else
{ {
if (res)
PQclear(res);
DBLINK_RES_ERROR_AS_NOTICE("sql error"); DBLINK_RES_ERROR_AS_NOTICE("sql error");
SRF_RETURN_DONE(funcctx); SRF_RETURN_DONE(funcctx);
} }
...@@ -720,11 +716,9 @@ dblink_record(PG_FUNCTION_ARGS) ...@@ -720,11 +716,9 @@ dblink_record(PG_FUNCTION_ARGS)
DBLINK_RES_ERROR("sql error"); DBLINK_RES_ERROR("sql error");
else else
{ {
if (res) DBLINK_RES_ERROR_AS_NOTICE("sql error");
PQclear(res);
if (freeconn) if (freeconn)
PQfinish(conn); PQfinish(conn);
DBLINK_RES_ERROR_AS_NOTICE("sql error");
SRF_RETURN_DONE(funcctx); SRF_RETURN_DONE(funcctx);
} }
} }
...@@ -938,13 +932,15 @@ dblink_exec(PG_FUNCTION_ARGS) ...@@ -938,13 +932,15 @@ dblink_exec(PG_FUNCTION_ARGS)
* result tuple * result tuple
*/ */
sql_cmd_status = GET_TEXT(PQcmdStatus(res)); sql_cmd_status = GET_TEXT(PQcmdStatus(res));
PQclear(res);
} }
else else
{
PQclear(res);
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_S_R_E_PROHIBITED_SQL_STATEMENT_ATTEMPTED), (errcode(ERRCODE_S_R_E_PROHIBITED_SQL_STATEMENT_ATTEMPTED),
errmsg("statement returning results not allowed"))); errmsg("statement returning results not allowed")));
}
PQclear(res);
/* if needed, close the connection to the database and cleanup */ /* if needed, close the connection to the database and cleanup */
if (freeconn) if (freeconn)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment