diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2007-05-30 21:01:45 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2007-05-30 21:01:45 +0000 |
commit | 9a4c943747ebfcdc16c9869a7380b9805a9a0889 (patch) | |
tree | 1ac66f891c7ccf13c614fe28a9605b69502859bb /src/backend | |
parent | 75103cc2189d8455dfb6904b01c4a96449518ee9 (diff) | |
download | postgresql-9a4c943747ebfcdc16c9869a7380b9805a9a0889.tar.gz postgresql-9a4c943747ebfcdc16c9869a7380b9805a9a0889.zip |
Fix overly-strict sanity check in BeginInternalSubTransaction that made it
fail when used in a deferred trigger. Bug goes back to 8.0; no doubt the
reason it hadn't been noticed is that we've been discouraging use of
user-defined constraint triggers. Per report from Frank van Vugt.
Diffstat (limited to 'src/backend')
-rw-r--r-- | src/backend/access/transam/xact.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c index 1b5cfaa7cc1..f0442f5f9fa 100644 --- a/src/backend/access/transam/xact.c +++ b/src/backend/access/transam/xact.c @@ -10,7 +10,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/transam/xact.c,v 1.229.2.1 2007/04/26 23:24:56 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/transam/xact.c,v 1.229.2.2 2007/05/30 21:01:45 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -3306,10 +3306,11 @@ RollbackToSavepoint(List *options) /* * BeginInternalSubTransaction - * This is the same as DefineSavepoint except it allows TBLOCK_STARTED - * state, and therefore it can safely be used in a function that might - * be called when not inside a BEGIN block. Also, we automatically - * cycle through CommitTransactionCommand/StartTransactionCommand + * This is the same as DefineSavepoint except it allows TBLOCK_STARTED, + * TBLOCK_END, and TBLOCK_PREPARE states, and therefore it can safely be + * used in functions that might be called when not inside a BEGIN block + * or when running deferred triggers at COMMIT/PREPARE time. Also, it + * automatically does CommitTransactionCommand/StartTransactionCommand * instead of expecting the caller to do it. */ void @@ -3321,6 +3322,8 @@ BeginInternalSubTransaction(char *name) { case TBLOCK_STARTED: case TBLOCK_INPROGRESS: + case TBLOCK_END: + case TBLOCK_PREPARE: case TBLOCK_SUBINPROGRESS: /* Normal subtransaction start */ PushTransaction(); @@ -3338,7 +3341,6 @@ BeginInternalSubTransaction(char *name) case TBLOCK_DEFAULT: case TBLOCK_BEGIN: case TBLOCK_SUBBEGIN: - case TBLOCK_END: case TBLOCK_SUBEND: case TBLOCK_ABORT: case TBLOCK_SUBABORT: @@ -3348,7 +3350,6 @@ BeginInternalSubTransaction(char *name) case TBLOCK_SUBABORT_PENDING: case TBLOCK_SUBRESTART: case TBLOCK_SUBABORT_RESTART: - case TBLOCK_PREPARE: elog(FATAL, "BeginInternalSubTransaction: unexpected state %s", BlockStateAsString(s->blockState)); break; |