Re: Implementing setBinaryStream(int, InputStream, long)

From: Dave Cramer <pg(at)fastcrypt(dot)com>
To: "Johann 'Myrkraverk' Oskarsson" <johann(at)2ndquadrant(dot)com>
Cc: PostgreSQL JDBC <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: Implementing setBinaryStream(int, InputStream, long)
Date: 2012-05-30 10:08:10
Message-ID: CADK3HHJ8ferutXUER9LhHKDEa4N=RgqZL7tZ+P=atp0XcG3JmA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

First of all thanks for the effort, and secondly welcome to the
ambiguity of JDBC.

Looking at QueryExecutorImpl.java PSQLException is thrown for errors
in executing the protocol.
Integer.MAX_VALUE seems like a very large number but if the protocol
supports it we should use it. The user on the other hand may want to
reconsider.

Thanks,

Dave Cramer

dave.cramer(at)credativ(dot)ca
http://www.credativ.ca

On Tue, May 29, 2012 at 9:45 AM, Johann 'Myrkraverk' Oskarsson
<johann(at)2ndquadrant(dot)com> wrote:
> Hi all,
>
> I have implemented the JDBC 4 function setBinaryStream(int, InputStream,
> long) in the PreparedStatement.  It is a bit of a hack since I added
> long to the ParameterList interface and StreamWrapper.  I suppose that
> was a bit of an overkill.
>
> PostgreSQL doesn't support field values larger than 1GB according to
> http://www.postgresql.org/about/ so I suppose a check if the length
> given is larger than Integer.MAX_VALUE and throw an exception is
> reasonable.  What exception makes sense?  The Integer.MAX_VALUE is
> chosen based on the underlying protocol using length values in int32.
>
> Is there any sense in choosing a smaller value for this?
>
> With the appropriate check, the implementation is trivial:
>
>  preparedParameters.setBytea( parameterIndex, value, (int) length );
>
> The V3 protocol does not allow piecewise transmission of data, so
> implementing setBinaryStream( int, InputStream ) makes no sense.  Notice
> the absense of the length field.
>
> I can submit a patch once I know to deal with values that don't fit in
> an int.
>
>
> --
>   Johann Oskarsson                http://www.2ndquadrant.com/    |[]
>   PostgreSQL Development, 24x7 Support, Training and Services  --+--
>                                                                  |
>   Blog: http://my.opera.com/myrkraverk/blog/
>
> --
> Sent via pgsql-jdbc mailing list (pgsql-jdbc(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-jdbc

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Dave Cramer 2012-05-30 14:04:49 building site
Previous Message Dave Cramer 2012-05-29 18:17:09 Re: a difference of version information 9.1-902 jar and source