Message-ID: From: "CTH57 (@CTH57)" To: "pgjdbc/pgjdbc" Date: Mon, 05 Jan 2026 15:53:57 +0000 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: References: List-Id: X-GitHub-Author-Login: CTH57 X-GitHub-Comment-Id: 3711007574 X-GitHub-Comment-Type: issue_comment X-GitHub-Issue: 3897 X-GitHub-Repo: pgjdbc/pgjdbc X-GitHub-Type: comment X-GitHub-Url: https://github.com/pgjdbc/pgjdbc/pull/3897#issuecomment-3711007574 Content-Type: text/plain; charset=utf-8 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)); }