*** src/backend/access/transam/xact.c
--- src/backend/access/transam/xact.c
***************
*** 404,419 **** AssignTransactionId(TransactionState s)
  		AssignTransactionId(s->parent);
  
  	/*
! 	 * Generate a new Xid and record it in PG_PROC and pg_subtrans.
! 	 *
! 	 * NB: we must make the subtrans entry BEFORE the Xid appears anywhere in
! 	 * shared storage other than PG_PROC; because if there's no room for it in
! 	 * PG_PROC, the subtrans entry is needed to ensure that other backends see
! 	 * the Xid as "running".  See GetNewTransactionId.
  	 */
  	s->transactionId = GetNewTransactionId(isSubXact);
  
! 	if (isSubXact)
  		SubTransSetParent(s->transactionId, s->parent->transactionId);
  
  	/*
--- 404,418 ----
  		AssignTransactionId(s->parent);
  
  	/*
! 	 * Generate a new Xid and record it in PG_PROC. If there's no room
! 	 * in MyProc-> in MyProc->subxids, we must make the pg_subtrans
! 	 * entry BEFORE the Xid appears anywhere in shared storage other than
! 	 * PG_PROC, because the subtrans entry is needed to ensure that other
! 	 * backends see the Xid as "running".
  	 */
  	s->transactionId = GetNewTransactionId(isSubXact);
  
! 	if (isSubXact && MyProc->subxids.overflowed)
  		SubTransSetParent(s->transactionId, s->parent->transactionId);
  
  	/*
