aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands/sequence.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2017-10-11 17:43:50 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2017-10-11 17:44:09 -0400
commit5fa6b0d102eb8ccd15c4963ee9841baec50df45e (patch)
treef35515f23f5802fbf3f8506778ceb9363f7e33a3 /src/backend/commands/sequence.c
parentf676616651c83b14e1d879fbfabdd3ab2dc70bbe (diff)
downloadpostgresql-5fa6b0d102eb8ccd15c4963ee9841baec50df45e.tar.gz
postgresql-5fa6b0d102eb8ccd15c4963ee9841baec50df45e.zip
Remove unnecessary PG_TRY overhead for CurrentResourceOwner changes.
resowner/README contained advice to use a PG_TRY block to restore the old CurrentResourceOwner value anywhere that that variable is transiently changed. That advice was only inconsistently followed, however, and on reflection it seems like unnecessary overhead. We don't bother with such a convention for transient CurrentMemoryContext changes, on the grounds that any (sub)transaction abort will start out by resetting CurrentMemoryContext to what it wants. But the same is true of CurrentResourceOwner, so there seems no need to treat it differently. Hence, remove PG_TRY blocks that exist only to restore CurrentResourceOwner before re-throwing the error. There are a couple of places that restore it along with some other actions, and I left those alone; the restore is probably unnecessary but no noticeable gain will result from removing it. Discussion: https://postgr.es/m/5236.1507583529@sss.pgh.pa.us
Diffstat (limited to 'src/backend/commands/sequence.c')
-rw-r--r--src/backend/commands/sequence.c16
1 files changed, 4 insertions, 12 deletions
diff --git a/src/backend/commands/sequence.c b/src/backend/commands/sequence.c
index 5c2ce789468..5e1b0fe2897 100644
--- a/src/backend/commands/sequence.c
+++ b/src/backend/commands/sequence.c
@@ -1055,18 +1055,10 @@ lock_and_open_sequence(SeqTable seq)
ResourceOwner currentOwner;
currentOwner = CurrentResourceOwner;
- PG_TRY();
- {
- CurrentResourceOwner = TopTransactionResourceOwner;
- LockRelationOid(seq->relid, RowExclusiveLock);
- }
- PG_CATCH();
- {
- /* Ensure CurrentResourceOwner is restored on error */
- CurrentResourceOwner = currentOwner;
- PG_RE_THROW();
- }
- PG_END_TRY();
+ CurrentResourceOwner = TopTransactionResourceOwner;
+
+ LockRelationOid(seq->relid, RowExclusiveLock);
+
CurrentResourceOwner = currentOwner;
/* Flag that we have a lock in the current xact */