pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Allman <msa@allman.ms>
To: pgsql-jdbc@postgresql.org
Subject: prepare() method error
Date: Sun, 12 Feb 2006 03:51:50 -0500 (EST)
Message-ID: <20060212031201.V9299@yvyyl> (raw)

Hi all,

I've been testing the XA implementation and found a bug.  The 
PGXAConnection prepare(Xid) method may return a value of XA_OK when it 
should throw an XAException instead.  This can lead to an inconsistent TPC 
outcome.

For example, if you attempt to insert a row which violates a uniqueness 
constraint and then prepare the transaction branch, the prepare() method 
returns XA_OK erroneously because the PREPARE TRANSACTION statement 
executes without throwing an exception even though the transaction is not 
prepared.

As a workaround, I've added a query after the PREPARE TRANSACTION query in 
the prepare() method which searches the pg_prepared_xacts table for a row 
with the given gid just "prepared".  If it doesn't find the corresponding 
row, it throws an XAException with a suitable error code (I chose 
XA_RBROLLBACK).

It would be cleaner if the driver could determine the success/failure of 
the PREPARE TRANSACTION statement from the query itself.  For instance, 
have the executeUpdate("PREPARE TRANSACTION " ....) return normally if and 
only if it actually prepares a transaction.  If it doesn't prepare, throw 
a meaningful SQLException.

Michael



view thread (3+ messages)  latest in thread

Message-ID: <20060212031201.V9299@yvyyl>
Permalink:  ../20060212031201.V9299@yvyyl/
Also on:    postgresql.org/message-id/20060212031201.V9299@yvyyl

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: msa@allman.ms
  Subject: Re: prepare() method error
  In-Reply-To: <20060212031201.V9299@yvyyl>
  References: <20060212031201.V9299@yvyyl>

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

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