Re: Implementing setBinaryStream(int, InputStream, long)
От | Dave Cramer |
---|---|
Тема | Re: Implementing setBinaryStream(int, InputStream, long) |
Дата | |
Msg-id | CADK3HHJ8ferutXUER9LhHKDEa4N=RgqZL7tZ+P=atp0XcG3JmA@mail.gmail.com обсуждение исходный текст |
Ответ на | Implementing setBinaryStream(int, InputStream, long) ("Johann 'Myrkraverk' Oskarsson" <johann@2ndquadrant.com>) |
Ответы |
Re: Implementing setBinaryStream(int, InputStream, long)
|
Список | 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@2ndquadrant.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@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-jdbc
В списке pgsql-jdbc по дате отправления: