aboutsummaryrefslogtreecommitdiff
path: root/src/backend/storage/large_object/inv_api.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2004-07-31 00:45:57 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2004-07-31 00:45:57 +0000
commita393fbf93763709f90ba1f968e50a35bd4cabcfb (patch)
tree955d74e7181214688b575f31c243005fe470dfe1 /src/backend/storage/large_object/inv_api.c
parent94f8f63fdbcf61a56a23b8052d68fd78bec86a3b (diff)
downloadpostgresql-a393fbf93763709f90ba1f968e50a35bd4cabcfb.tar.gz
postgresql-a393fbf93763709f90ba1f968e50a35bd4cabcfb.zip
Restructure error handling as recently discussed. It is now really
possible to trap an error inside a function rather than letting it propagate out to PostgresMain. You still have to use AbortCurrentTransaction to clean up, but at least the error handling itself will cooperate.
Diffstat (limited to 'src/backend/storage/large_object/inv_api.c')
-rw-r--r--src/backend/storage/large_object/inv_api.c46
1 files changed, 32 insertions, 14 deletions
diff --git a/src/backend/storage/large_object/inv_api.c b/src/backend/storage/large_object/inv_api.c
index 470dcf11aa9..97e60a2fccf 100644
--- a/src/backend/storage/large_object/inv_api.c
+++ b/src/backend/storage/large_object/inv_api.c
@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/storage/large_object/inv_api.c,v 1.103 2004/07/28 14:23:29 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/storage/large_object/inv_api.c,v 1.104 2004/07/31 00:45:34 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -54,14 +54,23 @@ open_lo_relation(void)
/* Arrange for the top xact to own these relation references */
currentOwner = CurrentResourceOwner;
- CurrentResourceOwner = TopTransactionResourceOwner;
-
- /* Use RowExclusiveLock since we might either read or write */
- if (lo_heap_r == NULL)
- lo_heap_r = heap_openr(LargeObjectRelationName, RowExclusiveLock);
- if (lo_index_r == NULL)
- lo_index_r = index_openr(LargeObjectLOidPNIndex);
+ PG_TRY();
+ {
+ CurrentResourceOwner = TopTransactionResourceOwner;
+ /* Use RowExclusiveLock since we might either read or write */
+ if (lo_heap_r == NULL)
+ lo_heap_r = heap_openr(LargeObjectRelationName, RowExclusiveLock);
+ if (lo_index_r == NULL)
+ lo_index_r = index_openr(LargeObjectLOidPNIndex);
+ }
+ PG_CATCH();
+ {
+ /* Ensure CurrentResourceOwner is restored on error */
+ CurrentResourceOwner = currentOwner;
+ PG_RE_THROW();
+ }
+ PG_END_TRY();
CurrentResourceOwner = currentOwner;
}
@@ -82,13 +91,22 @@ close_lo_relation(bool isCommit)
ResourceOwner currentOwner;
currentOwner = CurrentResourceOwner;
- CurrentResourceOwner = TopTransactionResourceOwner;
-
- if (lo_index_r)
- index_close(lo_index_r);
- if (lo_heap_r)
- heap_close(lo_heap_r, NoLock);
+ PG_TRY();
+ {
+ CurrentResourceOwner = TopTransactionResourceOwner;
+ if (lo_index_r)
+ index_close(lo_index_r);
+ if (lo_heap_r)
+ heap_close(lo_heap_r, NoLock);
+ }
+ PG_CATCH();
+ {
+ /* Ensure CurrentResourceOwner is restored on error */
+ CurrentResourceOwner = currentOwner;
+ PG_RE_THROW();
+ }
+ PG_END_TRY();
CurrentResourceOwner = currentOwner;
}
lo_heap_r = NULL;