Index: org/postgresql/test/xa/XADataSourceTest.java
===================================================================
RCS file: /usr/local/cvsroot/pgjdbc/pgjdbc/org/postgresql/test/xa/XADataSourceTest.java,v
retrieving revision 1.6
diff -c -r1.6 XADataSourceTest.java
*** org/postgresql/test/xa/XADataSourceTest.java	26 Apr 2006 18:58:59 -0000	1.6
--- org/postgresql/test/xa/XADataSourceTest.java	2 Oct 2006 11:32:27 -0000
***************
*** 217,222 ****
--- 217,232 ----
          xaRes.rollback(xid);
      }
  
+     public void testEndThenJoin() throws XAException {
+         Xid xid = new CustomXid(5);
+ 
+         xaRes.start(xid, XAResource.TMNOFLAGS);
+         xaRes.end(xid, XAResource.TMSUCCESS);
+         xaRes.start(xid, XAResource.TMJOIN);
+         xaRes.end(xid, XAResource.TMSUCCESS);
+         xaRes.commit(xid, true);
+     }
+ 
      /* We don't support transaction interleaving.
      public void testInterleaving1() throws Exception {
       Xid xid1 = new CustomXid(1);
Index: org/postgresql/xa/PGXAConnection.java
===================================================================
RCS file: /usr/local/cvsroot/pgjdbc/pgjdbc/org/postgresql/xa/PGXAConnection.java,v
retrieving revision 1.7
diff -c -r1.7 PGXAConnection.java
*** org/postgresql/xa/PGXAConnection.java	26 Apr 2006 18:58:59 -0000	1.7
--- org/postgresql/xa/PGXAConnection.java	2 Oct 2006 11:32:28 -0000
***************
*** 79,86 ****
       * 4. the TM hasn't seen the xid before
       *
       * Implementation deficiency preconditions:
!      * 1. flags must be TMNOFLAGS
!      * 2. Previous transaction using the connection must be committed or prepared or rolled back
       * 
       * Postconditions:
       * 1. Connection is associated with the transaction
--- 79,89 ----
       * 4. the TM hasn't seen the xid before
       *
       * Implementation deficiency preconditions:
!      * 1. TMRESUME not supported.
!      * 2. if flags is TMJOIN, we must be in ended state,
!      *    and xid must be the current transaction
!      * 3. unless flags is TMJOIN, previous transaction using the 
!      *    connection must be committed or prepared or rolled back
       * 
       * Postconditions:
       * 1. Connection is associated with the transaction
***************
*** 102,110 ****
          // We can't check precondition 4 easily, so we don't. Duplicate xid will be catched in prepare phase.
  
          // Check implementation deficiency preconditions
!         if (flags != TMNOFLAGS)
!             throw new PGXAException(GT.tr("suspend/resume and join not implemented"), XAException.XAER_RMERR);
!         if (state == STATE_ENDED)
              throw new PGXAException(GT.tr("Transaction interleaving not implemented"), XAException.XAER_RMERR);
  
          // Preconditions are met, Associate connection with the transaction
--- 105,122 ----
          // We can't check precondition 4 easily, so we don't. Duplicate xid will be catched in prepare phase.
  
          // Check implementation deficiency preconditions
!         if (flags == TMRESUME)
!             throw new PGXAException(GT.tr("suspend/resume not implemented"), XAException.XAER_RMERR);
! 
!         // It's ok to join an ended transaction. WebLogic does that.
!         if (flags == TMJOIN)
!         {
!             if (state != STATE_ENDED)
!                 throw new PGXAException(GT.tr("Transaction interleaving not implemented"), XAException.XAER_RMERR);
! 
!             if (!xid.equals(currentXid))
!                 throw new PGXAException(GT.tr("Transaction interleaving not implemented"), XAException.XAER_RMERR);
!         } else if(state == STATE_ENDED)
              throw new PGXAException(GT.tr("Transaction interleaving not implemented"), XAException.XAER_RMERR);
  
          // Preconditions are met, Associate connection with the transaction
