Fix overly-strict sanity check in BeginInternalSubTransaction that made it
authorTom Lane <[email protected]>
Wed, 30 May 2007 21:02:02 +0000 (21:02 +0000)
committerTom Lane <[email protected]>
Wed, 30 May 2007 21:02:02 +0000 (21:02 +0000)
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.

src/backend/access/transam/xact.c

index 2e5c27635ae6263dcb9509b6116eee5ec63ae9e9..f5a73caddba425aa61947b4ebc6f3f775534b9e6 100644 (file)
@@ -10,7 +10,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/access/transam/xact.c,v 1.195.4.2 2007/04/26 23:25:30 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/access/transam/xact.c,v 1.195.4.3 2007/05/30 21:02:02 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -2935,9 +2935,10 @@ 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
+ *     and TBLOCK_END 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 time.  Also, it
+ *     automatically does CommitTransactionCommand/StartTransactionCommand
  *     instead of expecting the caller to do it.
  */
 void
@@ -2949,6 +2950,7 @@ BeginInternalSubTransaction(char *name)
    {
        case TBLOCK_STARTED:
        case TBLOCK_INPROGRESS:
+       case TBLOCK_END:
        case TBLOCK_SUBINPROGRESS:
            /* Normal subtransaction start */
            PushTransaction();
@@ -2966,7 +2968,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: