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

jdbc1.AbstractJdbc1Statement.setBinaryStream bug and patch

From: Martin Holz <holz(at)fiz-chemie(dot)de>
To: pgsql-bugs(at)postgresql(dot)org
Subject: jdbc1.AbstractJdbc1Statement.setBinaryStream bug and patch
Date: 2004-01-07 18:28:17
Message-ID: 200401071928.17842.holz@fiz-chemie.de (view raw or flat)
Thread:
Lists: pgsql-bugspgsql-jdbc
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.

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.

Regards
        Martin

-- 
Martin Holz     <holz(at)fiz-chemie(dot)de>

Softwareentwicklung / Vernetztes Studium - Chemie
FIZ CHEMIE Berlin
Franklin Str. 11
D-10587 Berlin     
  

Attachment: AbstractJdbc1Statement.java.diff
Description: text/x-diff (1.1 KB)

Responses

pgsql-bugs by date

Next:From: Seum-Lim GanDate: 2004-01-07 19:51:23
Subject: Re: dyntest.pgc not working in 7.4 ?
Previous:From: Tom LaneDate: 2004-01-07 15:19:52
Subject: Re: Crash while recovering database index relation

pgsql-jdbc by date

Next:From: Conor BeverlandDate: 2004-01-07 18:39:51
Subject: getBytes() returning too much data
Previous:From: Barry LindDate: 2004-01-07 17:25:53
Subject: Re: PreparedStatement parameters and mutable objects

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