pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Kris Jurka <books@ejurka.com>
To: Peter Cooner <petriborg@gmail.com>
Cc: dmp <danap@ttc-cmc.net>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: Possible bug / regression from generated keys
Date: Thu, 8 Nov 2012 13:45:36 -0500 (EST)
Message-ID: <alpine.BSO.2.00.1211081338240.29600@leary.csoft.net> (raw)
In-Reply-To: <CAHVZnpHHfGncEfo9qM8VZvSmC+v5X0bt-aKttgR_3XBq1fSw1w@mail.gmail.com>
References: <CAHVZnpFRa2qp8s_=42MV8s6p1=3W6A-K0bv+XgO=JtfmTHrAzA@mail.gmail.com>
	<509A8FDC.6040403@ttc-cmc.net>
	<CAHVZnpHpGH3S_TDtfVYiQmmEqz3=ixbyRWTpTpdRC-EtmXBoVg@mail.gmail.com>
	<509A989D.5020108@ttc-cmc.net>
	<CADK3HHK60GdVAo-DDe8bbEhHJt==4_ZUbnvvWG-XLxY5EBZyXQ@mail.gmail.com>
	<CAHVZnpGQL2P_cQSdUqDOT9PohHPSE11ZbvSm9czj0isAagQpZw@mail.gmail.com>
	<CADK3HHKB9Z3+9R3dXen+cgJgDV7tXVdOotQo38i3bQ-oZ+1L8w@mail.gmail.com>
	<CAHVZnpHuZVQqebHcbyPAuLvTegd-ycpu043hLxDX0UfFBFje4A@mail.gmail.com>
	<CADK3HHKOfy3ODmOsy4bqL9mpcaicttCn6e8uNgrAmQS7jwYuAQ@mail.gmail.com>
	<509B0539.1050601@ttc-cmc.net>
	<CAHVZnpERodJFbT1AWJBFXcOsBCDtDp1DxsHg1pwd02eHkSiobw@mail.gmail.com>
	<CAHVZnpGjooaNCm9N9q10m+2ZxoeVnMKXhOv60tGLvOFdUUaWkw@mail.gmail.com>
	<509BD654.5030500@ttc-cmc.net>
	<CAHVZnpHHfGncEfo9qM8VZvSmC+v5X0bt-aKttgR_3XBq1fSw1w@mail.gmail.com>



On Thu, 8 Nov 2012, Peter Cooner wrote:

> I tried to write a test case for a few days before I mailed the list
> and was unable to produce the problem :(

Based on this description, I created a self contained test which is 
attached.

The problem is that the driver is splicing together a single 
generated keys ResultSet from each individual batch execution, but 
some results come back in text format and some come back in binary. 
 The combined result has a single per column format flag and it gets 
confused when trying to parse a text result that it thinks is in binary 
format.

The driver needs to be taught not to change the requested format mid batch 
execution, but this is a tricky area.

Kris Jurka

Attachments:

BinBatchPS.java (text/plain, 951B) download import java.sql.*; public class BinBatchPS { public static void main(String args[]) throws Exception { Class.forName("org.postgresql.Driver"); Connection conn = DriverManager.getConnection("jdbc:postgresql://localhost:5432/jurka?loglevel=2", "jurka", ""); Statement stmt = conn.createStatement(); stmt.execute("CREATE TEMP TABLE tmptab (id bigserial, val text)"); stmt.close(); PreparedStatement ps = conn.prepareStatement("INSERT INTO tmptab (val) VALUES (?)", Statement.RETURN_GENERATED_KEYS); ParameterMetaData pmd = ps.getParameterMetaData(); for (int i=0; i<5; i++) { ps.setString(1, "a"); ps.addBatch(); } ps.executeBatch(); ResultSet rs = ps.getGeneratedKeys(); ResultSetMetaData rsmd = rs.getMetaData(); while (rs.next()) { for (int j=1; j<=rsmd.getColumnCount(); j++) { System.out.println(rs.getString(j)); } } rs.close(); ps.close(); conn.close(); } }

view thread (19+ messages)  latest in thread

Message-ID: <alpine.BSO.2.00.1211081338240.29600@leary.csoft.net>
Permalink:  ../alpine.BSO.2.00.1211081338240.29600@leary.csoft.net/
Also on:    postgresql.org/message-id/alpine.BSO.2.00.1211081338240.29600@leary.csoft.net

 · 

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: books@ejurka.com, petriborg@gmail.com, danap@ttc-cmc.net
  Subject: Re: Possible bug / regression from generated keys
  In-Reply-To: <alpine.BSO.2.00.1211081338240.29600@leary.csoft.net>
  References: <CAHVZnpFRa2qp8s_=42MV8s6p1=3W6A-K0bv+XgO=JtfmTHrAzA@mail.gmail.com> <509A8FDC.6040403@ttc-cmc.net> <CAHVZnpHpGH3S_TDtfVYiQmmEqz3=ixbyRWTpTpdRC-EtmXBoVg@mail.gmail.com> <509A989D.5020108@ttc-cmc.net> <CADK3HHK60GdVAo-DDe8bbEhHJt==4_ZUbnvvWG-XLxY5EBZyXQ@mail.gmail.com> <CAHVZnpGQL2P_cQSdUqDOT9PohHPSE11ZbvSm9czj0isAagQpZw@mail.gmail.com> <CADK3HHKB9Z3+9R3dXen+cgJgDV7tXVdOotQo38i3bQ-oZ+1L8w@mail.gmail.com> <CAHVZnpHuZVQqebHcbyPAuLvTegd-ycpu043hLxDX0UfFBFje4A@mail.gmail.com> <CADK3HHKOfy3ODmOsy4bqL9mpcaicttCn6e8uNgrAmQS7jwYuAQ@mail.gmail.com> <509B0539.1050601@ttc-cmc.net> <CAHVZnpERodJFbT1AWJBFXcOsBCDtDp1DxsHg1pwd02eHkSiobw@mail.gmail.com> <CAHVZnpGjooaNCm9N9q10m+2ZxoeVnMKXhOv60tGLvOFdUUaWkw@mail.gmail.com> <509BD654.5030500@ttc-cmc.net> <CAHVZnpHHfGncEfo9qM8VZvSmC+v5X0bt-aKttgR_3XBq1fSw1w@mail.gmail.com> <alpine.BSO.2.00.1211081338240.29600@leary.csoft.net>

* 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