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.
This commit is contained in:
Tom Lane 2007-05-30 21:01:39 +00:00
parent 9b89c13ab5
commit fa0e318f94
1 changed files with 8 additions and 7 deletions

View File

@ -10,7 +10,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/access/transam/xact.c,v 1.243 2007/05/27 03:50:39 tgl Exp $ * $PostgreSQL: pgsql/src/backend/access/transam/xact.c,v 1.244 2007/05/30 21:01:39 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -3348,10 +3348,11 @@ RollbackToSavepoint(List *options)
/* /*
* BeginInternalSubTransaction * BeginInternalSubTransaction
* This is the same as DefineSavepoint except it allows TBLOCK_STARTED * This is the same as DefineSavepoint except it allows TBLOCK_STARTED,
* state, and therefore it can safely be used in a function that might * TBLOCK_END, and TBLOCK_PREPARE states, and therefore it can safely be
* be called when not inside a BEGIN block. Also, we automatically * used in functions that might be called when not inside a BEGIN block
* cycle through CommitTransactionCommand/StartTransactionCommand * or when running deferred triggers at COMMIT/PREPARE time. Also, it
* automatically does CommitTransactionCommand/StartTransactionCommand
* instead of expecting the caller to do it. * instead of expecting the caller to do it.
*/ */
void void
@ -3363,6 +3364,8 @@ BeginInternalSubTransaction(char *name)
{ {
case TBLOCK_STARTED: case TBLOCK_STARTED:
case TBLOCK_INPROGRESS: case TBLOCK_INPROGRESS:
case TBLOCK_END:
case TBLOCK_PREPARE:
case TBLOCK_SUBINPROGRESS: case TBLOCK_SUBINPROGRESS:
/* Normal subtransaction start */ /* Normal subtransaction start */
PushTransaction(); PushTransaction();
@ -3380,7 +3383,6 @@ BeginInternalSubTransaction(char *name)
case TBLOCK_DEFAULT: case TBLOCK_DEFAULT:
case TBLOCK_BEGIN: case TBLOCK_BEGIN:
case TBLOCK_SUBBEGIN: case TBLOCK_SUBBEGIN:
case TBLOCK_END:
case TBLOCK_SUBEND: case TBLOCK_SUBEND:
case TBLOCK_ABORT: case TBLOCK_ABORT:
case TBLOCK_SUBABORT: case TBLOCK_SUBABORT:
@ -3390,7 +3392,6 @@ BeginInternalSubTransaction(char *name)
case TBLOCK_SUBABORT_PENDING: case TBLOCK_SUBABORT_PENDING:
case TBLOCK_SUBRESTART: case TBLOCK_SUBRESTART:
case TBLOCK_SUBABORT_RESTART: case TBLOCK_SUBABORT_RESTART:
case TBLOCK_PREPARE:
elog(FATAL, "BeginInternalSubTransaction: unexpected state %s", elog(FATAL, "BeginInternalSubTransaction: unexpected state %s",
BlockStateAsString(s->blockState)); BlockStateAsString(s->blockState));
break; break;