Skip site navigation (1) Skip section navigation (2)

Re: patch: streaming of bytea parameter values

From: Kris Jurka <books(at)ejurka(dot)com>
To: Oliver Jowett <oliver(at)opencloud(dot)com>
Cc: "pgsql-jdbc(at)postgresql(dot)org" <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: patch: streaming of bytea parameter values
Date: 2004-05-22 17:49:34
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-jdbc

On Sat, 22 May 2004, Oliver Jowett wrote:

> > Fixing this is difficult
> > because you cannot simply throw an Exception if you hit the end of stream
> > before the specified length because you can't just bail out when streaming
> > data as that will leave the PGStream in a confused state.  You've got to 
> > get it back to a known state and do so without the query succeeding.
> > 
> > Another problem along this line is that the InputStream given could throw 
> > an IOException when being read and the same unknown state problem would 
> > result.
> My V3 patches handle these cases by closing the connection entirely & 
> throwing an exception (i.e. providing a short stream or throwing 
> IOException is a fatal error). This seemed better than silently padding 
> with bogus data.
> I don't see that either case is a "normal" case we should be supporting 
> -- we just need to be sure we clean up properly.

I don't consider abandoning the connection "cleaning up properly."  With
the V3 protocol we have a reasonable recovery method because we will
detect this error at Bind time and simply not issue the Execute.  In the
current code's case it seems the only way to do it is to deliberately
introduce a syntax error to make the query fail.

Another issue that just came to me is what is the desired behavior for

ByteArrayInputStream bais = new ByteArrayInputStream(new byte[1000]));
PreparedStatement ps = conn.prepareStatement("INSERT INTO t VALUES (?)");
ps.setBinaryStream(1, bais, 100);

Should each inserted row have the same values?  Should the second row get 
the second 100 bytes and the third row get the third 100?

Kris Jurka

In response to


pgsql-jdbc by date

Next:From: Oliver JowettDate: 2004-05-22 23:59:07
Subject: PreparedStatement & direct execution methods
Previous:From: Kris JurkaDate: 2004-05-22 07:34:03
Subject: Re: patch: streaming of bytea parameter values

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group