pgjdbc/pgjdbc GitHub issues and pull requests (mirror)  
help / color / mirror / Atom feed
From: CTH57 (@CTH57) <[email protected]>
To: pgjdbc/pgjdbc <[email protected]>
Subject: Re: [pgjdbc/pgjdbc] PR #3897: fix: issue #3892, PGXAConnection.prepare(Xid) should return XA_RDONLY if the connection is read only
Date: Mon, 05 Jan 2026 15:53:57 +0000
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>

Proposition 👍 

    if (conn.isReadOnly()) {
      return XA_RDONLY;
    }
    
    state = State.IDLE;
    preparedXid = currentXid;
    currentXid = null;

    try {
      String s = RecoveredXid.xidToString(xid);

      try (Statement stmt = conn.createStatement()) {
        stmt.executeUpdate("PREPARE TRANSACTION '" + s + "'");
      }
      conn.setAutoCommit(localAutoCommitMode);
      
      return XA_OK;
    } catch (SQLException ex) {
      throw new PGXAException(GT.tr("Error preparing transaction. prepare xid={0}", xid), ex, mapSQLStateToXAErrorCode(ex));
    }

view thread (7+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: github://pgjdbc/pgjdbc
  Cc: [email protected], [email protected]
  Subject: Re: [pgjdbc/pgjdbc] PR #3897: fix: issue #3892, PGXAConnection.prepare(Xid) should return XA_RDONLY if the connection is read only
  In-Reply-To: <<[email protected]>>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox