diff options
-rw-r--r-- | src/backend/access/transam/xact.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c index b34b418fd98..184fe28f5c5 100644 --- a/src/backend/access/transam/xact.c +++ b/src/backend/access/transam/xact.c @@ -3802,7 +3802,24 @@ AbortOutOfAnyTransaction(void) switch (s->blockState) { case TBLOCK_DEFAULT: - /* Not in a transaction, do nothing */ + if (s->state == TRANS_DEFAULT) + { + /* Not in a transaction, do nothing */ + } + else + { + /* + * We can get here after an error during transaction start + * (state will be TRANS_START). Need to clean up the + * incompletely started transaction. First, adjust the + * low-level state to suppress warning message from + * AbortTransaction. + */ + if (s->state == TRANS_START) + s->state = TRANS_INPROGRESS; + AbortTransaction(); + CleanupTransaction(); + } break; case TBLOCK_STARTED: case TBLOCK_BEGIN: |