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

Re: jdbc1.AbstractJdbc1Statement.setBinaryStream bug and

From: Kris Jurka <books(at)ejurka(dot)com>
To: Martin Holz <holz(at)fiz-chemie(dot)de>
Cc: <pgsql-bugs(at)postgresql(dot)org>, <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: jdbc1.AbstractJdbc1Statement.setBinaryStream bug and
Date: 2004-01-09 08:46:04
Message-ID: Pine.LNX.4.33.0401090341280.6759-100000@leary.csoft.net (view raw or flat)
Thread:
Lists: pgsql-bugspgsql-jdbc

On Wed, 7 Jan 2004, Martin Holz wrote:

> Hello,
>
> org.postgresql.jdbc1.AbstractJdbc1Statement.setBinaryStream()
> in postgresql 7.4.1 wrongly assumes, that
> java.io.InputStream.read(byte[] b,int offset,int len )
> will always read len bytes. InputStream only guarantees to
> return at least 1 byte per call. The attached patch solves the bug.

Yes, it can even return 0 bytes if it feels like it.

> Btw. setBinaryStream() should really throw an SQLException, if
> in can not read as many bytes as expected from the InputStream.
> Otherwise the application might silently loss data.

The odd thing about the javadocs is that they say "The data will be read
from the stream as needed until end-of-file is reached."  The length
parameter's comment is "the number of bytes in the stream."

This is strange because it seems to imply that the length argument is just
for informational purposes and should not be used to limit the amount of
data actually read from the stream.

Kris Jurka


In response to

Responses

pgsql-bugs by date

Next:From: Kris JurkaDate: 2004-01-09 09:30:12
Subject: Re: JDBC driver doesn't handle NaN values
Previous:From: Denis N. StepanovDate: 2004-01-09 06:10:46
Subject: Re: BUG #1044: snprintf() shipped with PostgreSQL is not

pgsql-jdbc by date

Next:From: Antonio GallardoDate: 2004-01-09 09:17:53
Subject: Re: [BUG] - Invalid UNICODE character sequence found
Previous:From: Kris JurkaDate: 2004-01-09 08:33:02
Subject: Re: [BUG] - Invalid UNICODE character sequence found (0xc000)

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