Re: patch: streaming of bytea parameter values - Mailing list pgsql-jdbc

From Kris Jurka
Subject Re: patch: streaming of bytea parameter values
Date
Msg-id Pine.BSO.4.56.0405220222030.20695@leary.csoft.net
Whole thread Raw
In response to patch: streaming of bytea parameter values  (Oliver Jowett <oliver@opencloud.com>)
List pgsql-jdbc

On Wed, 21 Apr 2004, Oliver Jowett wrote:

> This patch allows bytea parameters set via setBytes() /
> setBinaryStream() to be streamed to the backend. With the patch applied,
> the additional memory overhead for bytea parameters is small and
> independent of how large the parameter data is.

Taking another look, this patch makes the assumption that the length
parameter to setBinaryStream is correct.  It does not check that the calls
to the input stream's read method do not return -1 indicating the
exhaustion of the stream, so doing

setBinaryStream("col", new ByteArrayInputStream(new byte[0]), 1000);

will actually put 1000 values of -1 into col.  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.

Kris Jurka

pgsql-jdbc by date:

Previous
From: Kris Jurka
Date:
Subject: Re: Driver JDBC3 build 213 for postgreSQL 7.4
Next
From: Oliver Jowett
Date:
Subject: PreparedStatement & direct execution methods