aboutsummaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
Diffstat (limited to 'contrib')
-rw-r--r--contrib/auto_explain/auto_explain.c8
-rw-r--r--contrib/dblink/dblink.c19
-rw-r--r--contrib/hstore_plpython/hstore_plpython.c5
-rw-r--r--contrib/jsonb_plpython/jsonb_plpython.c5
-rw-r--r--contrib/pg_stat_statements/pg_stat_statements.c12
-rw-r--r--contrib/pg_trgm/trgm_regexp.c5
-rw-r--r--contrib/postgres_fdw/connection.c5
-rw-r--r--contrib/postgres_fdw/postgres_fdw.c25
-rw-r--r--contrib/sepgsql/hooks.c4
-rw-r--r--contrib/sepgsql/label.c22
-rw-r--r--contrib/sepgsql/selinux.c4
-rw-r--r--contrib/sepgsql/uavc.c5
12 files changed, 24 insertions, 95 deletions
diff --git a/contrib/auto_explain/auto_explain.c b/contrib/auto_explain/auto_explain.c
index a9536c2de05..f118dbaedd7 100644
--- a/contrib/auto_explain/auto_explain.c
+++ b/contrib/auto_explain/auto_explain.c
@@ -320,12 +320,10 @@ explain_ExecutorRun(QueryDesc *queryDesc, ScanDirection direction,
prev_ExecutorRun(queryDesc, direction, count, execute_once);
else
standard_ExecutorRun(queryDesc, direction, count, execute_once);
- nesting_level--;
}
- PG_CATCH();
+ PG_FINALLY();
{
nesting_level--;
- PG_RE_THROW();
}
PG_END_TRY();
}
@@ -343,12 +341,10 @@ explain_ExecutorFinish(QueryDesc *queryDesc)
prev_ExecutorFinish(queryDesc);
else
standard_ExecutorFinish(queryDesc);
- nesting_level--;
}
- PG_CATCH();
+ PG_FINALLY();
{
nesting_level--;
- PG_RE_THROW();
}
PG_END_TRY();
}
diff --git a/contrib/dblink/dblink.c b/contrib/dblink/dblink.c
index 54b7bf952f3..7e225589a9b 100644
--- a/contrib/dblink/dblink.c
+++ b/contrib/dblink/dblink.c
@@ -776,19 +776,14 @@ dblink_record_internal(FunctionCallInfo fcinfo, bool is_async)
}
}
}
- PG_CATCH();
+ PG_FINALLY();
{
/* if needed, close the connection to the database */
if (freeconn)
PQfinish(conn);
- PG_RE_THROW();
}
PG_END_TRY();
- /* if needed, close the connection to the database */
- if (freeconn)
- PQfinish(conn);
-
return (Datum) 0;
}
@@ -952,14 +947,11 @@ materializeResult(FunctionCallInfo fcinfo, PGconn *conn, PGresult *res)
/* clean up and return the tuplestore */
tuplestore_donestoring(tupstore);
}
-
- PQclear(res);
}
- PG_CATCH();
+ PG_FINALLY();
{
/* be sure to release the libpq result */
PQclear(res);
- PG_RE_THROW();
}
PG_END_TRY();
}
@@ -1464,19 +1456,14 @@ dblink_exec(PG_FUNCTION_ARGS)
errmsg("statement returning results not allowed")));
}
}
- PG_CATCH();
+ PG_FINALLY();
{
/* if needed, close the connection to the database */
if (freeconn)
PQfinish(conn);
- PG_RE_THROW();
}
PG_END_TRY();
- /* if needed, close the connection to the database */
- if (freeconn)
- PQfinish(conn);
-
PG_RETURN_TEXT_P(sql_cmd_status);
}
diff --git a/contrib/hstore_plpython/hstore_plpython.c b/contrib/hstore_plpython/hstore_plpython.c
index 4dee5697403..39bad558023 100644
--- a/contrib/hstore_plpython/hstore_plpython.c
+++ b/contrib/hstore_plpython/hstore_plpython.c
@@ -180,14 +180,11 @@ plpython_to_hstore(PG_FUNCTION_ARGS)
pcount = hstoreUniquePairs(pairs, pcount, &buflen);
out = hstorePairs(pairs, pcount, buflen);
}
- PG_CATCH();
+ PG_FINALLY();
{
Py_DECREF(items);
- PG_RE_THROW();
}
PG_END_TRY();
- Py_DECREF(items);
-
PG_RETURN_POINTER(out);
}
diff --git a/contrib/jsonb_plpython/jsonb_plpython.c b/contrib/jsonb_plpython/jsonb_plpython.c
index ecaa4c6f92b..b41c738ad62 100644
--- a/contrib/jsonb_plpython/jsonb_plpython.c
+++ b/contrib/jsonb_plpython/jsonb_plpython.c
@@ -307,15 +307,12 @@ PLyMapping_ToJsonbValue(PyObject *obj, JsonbParseState **jsonb_state)
out = pushJsonbValue(jsonb_state, WJB_END_OBJECT, NULL);
}
- PG_CATCH();
+ PG_FINALLY();
{
Py_DECREF(items);
- PG_RE_THROW();
}
PG_END_TRY();
- Py_DECREF(items);
-
return out;
}
diff --git a/contrib/pg_stat_statements/pg_stat_statements.c b/contrib/pg_stat_statements/pg_stat_statements.c
index 221b47298ce..63b5888ebbc 100644
--- a/contrib/pg_stat_statements/pg_stat_statements.c
+++ b/contrib/pg_stat_statements/pg_stat_statements.c
@@ -892,12 +892,10 @@ pgss_ExecutorRun(QueryDesc *queryDesc, ScanDirection direction, uint64 count,
prev_ExecutorRun(queryDesc, direction, count, execute_once);
else
standard_ExecutorRun(queryDesc, direction, count, execute_once);
- nested_level--;
}
- PG_CATCH();
+ PG_FINALLY();
{
nested_level--;
- PG_RE_THROW();
}
PG_END_TRY();
}
@@ -915,12 +913,10 @@ pgss_ExecutorFinish(QueryDesc *queryDesc)
prev_ExecutorFinish(queryDesc);
else
standard_ExecutorFinish(queryDesc);
- nested_level--;
}
- PG_CATCH();
+ PG_FINALLY();
{
nested_level--;
- PG_RE_THROW();
}
PG_END_TRY();
}
@@ -1007,12 +1003,10 @@ pgss_ProcessUtility(PlannedStmt *pstmt, const char *queryString,
standard_ProcessUtility(pstmt, queryString,
context, params, queryEnv,
dest, completionTag);
- nested_level--;
}
- PG_CATCH();
+ PG_FINALLY();
{
nested_level--;
- PG_RE_THROW();
}
PG_END_TRY();
diff --git a/contrib/pg_trgm/trgm_regexp.c b/contrib/pg_trgm/trgm_regexp.c
index 7965a29c9f9..e65e6838230 100644
--- a/contrib/pg_trgm/trgm_regexp.c
+++ b/contrib/pg_trgm/trgm_regexp.c
@@ -555,15 +555,12 @@ createTrgmNFA(text *text_re, Oid collation,
{
trg = createTrgmNFAInternal(&regex, graph, rcontext);
}
- PG_CATCH();
+ PG_FINALLY();
{
pg_regfree(&regex);
- PG_RE_THROW();
}
PG_END_TRY();
- pg_regfree(&regex);
-
/* Clean up all the cruft we created */
MemoryContextSwitchTo(oldcontext);
MemoryContextDelete(tmpcontext);
diff --git a/contrib/postgres_fdw/connection.c b/contrib/postgres_fdw/connection.c
index 12f9dd35be8..7cd69cc7091 100644
--- a/contrib/postgres_fdw/connection.c
+++ b/contrib/postgres_fdw/connection.c
@@ -631,15 +631,12 @@ pgfdw_report_error(int elevel, PGresult *res, PGconn *conn,
message_context ? errcontext("%s", message_context) : 0,
sql ? errcontext("remote SQL command: %s", sql) : 0));
}
- PG_CATCH();
+ PG_FINALLY();
{
if (clear)
PQclear(res);
- PG_RE_THROW();
}
PG_END_TRY();
- if (clear)
- PQclear(res);
}
/*
diff --git a/contrib/postgres_fdw/postgres_fdw.c b/contrib/postgres_fdw/postgres_fdw.c
index 32366641a3e..fa142960eb5 100644
--- a/contrib/postgres_fdw/postgres_fdw.c
+++ b/contrib/postgres_fdw/postgres_fdw.c
@@ -3155,15 +3155,11 @@ get_remote_estimate(const char *sql, PGconn *conn,
startup_cost, total_cost, rows, width);
if (n != 4)
elog(ERROR, "could not interpret EXPLAIN output: \"%s\"", line);
-
- PQclear(res);
- res = NULL;
}
- PG_CATCH();
+ PG_FINALLY();
{
if (res)
PQclear(res);
- PG_RE_THROW();
}
PG_END_TRY();
}
@@ -3383,15 +3379,11 @@ fetch_more_data(ForeignScanState *node)
/* Must be EOF if we didn't get as many tuples as we asked for. */
fsstate->eof_reached = (numrows < fsstate->fetch_size);
-
- PQclear(res);
- res = NULL;
}
- PG_CATCH();
+ PG_FINALLY();
{
if (res)
PQclear(res);
- PG_RE_THROW();
}
PG_END_TRY();
@@ -4404,15 +4396,11 @@ postgresAnalyzeForeignTable(Relation relation,
if (PQntuples(res) != 1 || PQnfields(res) != 1)
elog(ERROR, "unexpected result from deparseAnalyzeSizeSql query");
*totalpages = strtoul(PQgetvalue(res, 0, 0), NULL, 10);
-
- PQclear(res);
- res = NULL;
}
- PG_CATCH();
+ PG_FINALLY();
{
if (res)
PQclear(res);
- PG_RE_THROW();
}
PG_END_TRY();
@@ -4925,16 +4913,11 @@ postgresImportForeignSchema(ImportForeignSchemaStmt *stmt, Oid serverOid)
commands = lappend(commands, pstrdup(buf.data));
}
-
- /* Clean up */
- PQclear(res);
- res = NULL;
}
- PG_CATCH();
+ PG_FINALLY();
{
if (res)
PQclear(res);
- PG_RE_THROW();
}
PG_END_TRY();
diff --git a/contrib/sepgsql/hooks.c b/contrib/sepgsql/hooks.c
index 992c70e8a06..49f32ac4d33 100644
--- a/contrib/sepgsql/hooks.c
+++ b/contrib/sepgsql/hooks.c
@@ -372,13 +372,11 @@ sepgsql_utility_command(PlannedStmt *pstmt,
context, params, queryEnv,
dest, completionTag);
}
- PG_CATCH();
+ PG_FINALLY();
{
sepgsql_context_info = saved_context_info;
- PG_RE_THROW();
}
PG_END_TRY();
- sepgsql_context_info = saved_context_info;
}
/*
diff --git a/contrib/sepgsql/label.c b/contrib/sepgsql/label.c
index d2505f7f343..d8a1d129d29 100644
--- a/contrib/sepgsql/label.c
+++ b/contrib/sepgsql/label.c
@@ -465,14 +465,11 @@ sepgsql_get_label(Oid classId, Oid objectId, int32 subId)
{
label = pstrdup(unlabeled);
}
- PG_CATCH();
+ PG_FINALLY();
{
freecon(unlabeled);
- PG_RE_THROW();
}
PG_END_TRY();
-
- freecon(unlabeled);
}
return label;
}
@@ -600,13 +597,11 @@ sepgsql_mcstrans_in(PG_FUNCTION_ARGS)
{
result = pstrdup(raw_label);
}
- PG_CATCH();
+ PG_FINALLY();
{
freecon(raw_label);
- PG_RE_THROW();
}
PG_END_TRY();
- freecon(raw_label);
PG_RETURN_TEXT_P(cstring_to_text(result));
}
@@ -640,13 +635,11 @@ sepgsql_mcstrans_out(PG_FUNCTION_ARGS)
{
result = pstrdup(qual_label);
}
- PG_CATCH();
+ PG_FINALLY();
{
freecon(qual_label);
- PG_RE_THROW();
}
PG_END_TRY();
- freecon(qual_label);
PG_RETURN_TEXT_P(cstring_to_text(result));
}
@@ -851,13 +844,11 @@ exec_object_restorecon(struct selabel_handle *sehnd, Oid catalogId)
SetSecurityLabel(&object, SEPGSQL_LABEL_TAG, context);
}
- PG_CATCH();
+ PG_FINALLY();
{
freecon(context);
- PG_RE_THROW();
}
PG_END_TRY();
- freecon(context);
}
else if (errno == ENOENT)
ereport(WARNING,
@@ -937,14 +928,11 @@ sepgsql_restorecon(PG_FUNCTION_ARGS)
exec_object_restorecon(sehnd, AttributeRelationId);
exec_object_restorecon(sehnd, ProcedureRelationId);
}
- PG_CATCH();
+ PG_FINALLY();
{
selabel_close(sehnd);
- PG_RE_THROW();
}
PG_END_TRY();
- selabel_close(sehnd);
-
PG_RETURN_BOOL(true);
}
diff --git a/contrib/sepgsql/selinux.c b/contrib/sepgsql/selinux.c
index 192aabea0b3..b7c489cc336 100644
--- a/contrib/sepgsql/selinux.c
+++ b/contrib/sepgsql/selinux.c
@@ -871,13 +871,11 @@ sepgsql_compute_create(const char *scontext,
{
result = pstrdup(ncontext);
}
- PG_CATCH();
+ PG_FINALLY();
{
freecon(ncontext);
- PG_RE_THROW();
}
PG_END_TRY();
- freecon(ncontext);
return result;
}
diff --git a/contrib/sepgsql/uavc.c b/contrib/sepgsql/uavc.c
index 8ce0bc631b7..f5279cc9b6e 100644
--- a/contrib/sepgsql/uavc.c
+++ b/contrib/sepgsql/uavc.c
@@ -181,14 +181,11 @@ sepgsql_avc_unlabeled(void)
{
avc_unlabeled = MemoryContextStrdup(avc_mem_cxt, unlabeled);
}
- PG_CATCH();
+ PG_FINALLY();
{
freecon(unlabeled);
- PG_RE_THROW();
}
PG_END_TRY();
-
- freecon(unlabeled);
}
return avc_unlabeled;
}