Skip to content

Commit fa0e318

Browse files
committed
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.
1 parent 9b89c13 commit fa0e318

File tree

1 file changed

+8
-7
lines changed
  • src/backend/access/transam

1 file changed

+8
-7
lines changed

src/backend/access/transam/xact.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
*
1212
* IDENTIFICATION
13-
* $PostgreSQL: pgsql/src/backend/access/transam/xact.c,v 1.243 2007/05/27 03:50:39 tgl Exp $
13+
* $PostgreSQL: pgsql/src/backend/access/transam/xact.c,v 1.244 2007/05/30 21:01:39 tgl Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -3348,10 +3348,11 @@ RollbackToSavepoint(List *options)
33483348

33493349
/*
33503350
* BeginInternalSubTransaction
3351-
* This is the same as DefineSavepoint except it allows TBLOCK_STARTED
3352-
* state, and therefore it can safely be used in a function that might
3353-
* be called when not inside a BEGIN block. Also, we automatically
3354-
* cycle through CommitTransactionCommand/StartTransactionCommand
3351+
* This is the same as DefineSavepoint except it allows TBLOCK_STARTED,
3352+
* TBLOCK_END, and TBLOCK_PREPARE states, and therefore it can safely be
3353+
* used in functions that might be called when not inside a BEGIN block
3354+
* or when running deferred triggers at COMMIT/PREPARE time. Also, it
3355+
* automatically does CommitTransactionCommand/StartTransactionCommand
33553356
* instead of expecting the caller to do it.
33563357
*/
33573358
void
@@ -3363,6 +3364,8 @@ BeginInternalSubTransaction(char *name)
33633364
{
33643365
case TBLOCK_STARTED:
33653366
case TBLOCK_INPROGRESS:
3367+
case TBLOCK_END:
3368+
case TBLOCK_PREPARE:
33663369
case TBLOCK_SUBINPROGRESS:
33673370
/* Normal subtransaction start */
33683371
PushTransaction();
@@ -3380,7 +3383,6 @@ BeginInternalSubTransaction(char *name)
33803383
case TBLOCK_DEFAULT:
33813384
case TBLOCK_BEGIN:
33823385
case TBLOCK_SUBBEGIN:
3383-
case TBLOCK_END:
33843386
case TBLOCK_SUBEND:
33853387
case TBLOCK_ABORT:
33863388
case TBLOCK_SUBABORT:
@@ -3390,7 +3392,6 @@ BeginInternalSubTransaction(char *name)
33903392
case TBLOCK_SUBABORT_PENDING:
33913393
case TBLOCK_SUBRESTART:
33923394
case TBLOCK_SUBABORT_RESTART:
3393-
case TBLOCK_PREPARE:
33943395
elog(FATAL, "BeginInternalSubTransaction: unexpected state %s",
33953396
BlockStateAsString(s->blockState));
33963397
break;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy