Re: JBoss w/int8 primary keys in postgres ... - Mailing list pgsql-jdbc

From Paul Thomas
Subject Re: JBoss w/int8 primary keys in postgres ...
Date
Msg-id 20030907114402.A21495@bacon
Whole thread Raw
In response to Re: JBoss w/int8 primary keys in postgres ...  (Oliver Jowett <oliver@opencloud.com>)
Responses Re: JBoss w/int8 primary keys in postgres ...  (James Robinson <jlrobins@socialserve.com>)
List pgsql-jdbc
On 06/09/2003 23:25 Oliver Jowett wrote:
> On Sat, Sep 06, 2003 at 02:38:40PM -0400, James Robinson wrote:
>
> > Is there any hope to get JBoss + PG JDBC to do this typecasting
> > automatically? Assuming JBoss is using PreparedStatements for its dirty
>
> > work, could the setLong() method on the JDBC driver's PreparedStatement
>
> >  implementation possibly always punch in the trailing '::int8' ?
>
> Something like this was tried without much success. See:
>
>   http://archives.postgresql.org/pgsql-jdbc/2002-10/msg00163.php
>
>
http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java#rev1.6
>
>
http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java#rev1.12
>
> Reading that thread, the change that was tried was quoting the value to
> get
> an implicit cast from 'text' to the expected type -- whatever it was --
> happening.
>
> Perhaps it's reasonable to have setLong() always append ::int8 since that
> does reflect the possible range of the parameter's type -- anyone more
> familiar with this area want to comment? I guess that you end up with the
> reverse problem of things that expect an int4 value but use setLong()
> will
> break, but maybe that is less common and is going to have other problems
> anyway if you try to use a java long that's larger than int4 can handle

Looking at the sources for the 7.3.4 driver, the code is almost there. It
looks like the type is carried across to org.postgresql.core.QueryExecutor
but is never send to the BE. I'm not familiar with the FE-BE protocol but
it just looks like we need to pass the m_bindTypes[] array across and
insert 2 lines of code to send :: followed by send m_bindTypes[i]. To
prevent breaking existing code, we would need make this the non-default
behavior. It would need to settable in the url string to be used in an EJB
container.

Comments?

--
Paul Thomas
+------------------------------+---------------------------------------------+
| Thomas Micro Systems Limited | Software Solutions for the Smaller
Business |
| Computer Consultants         |
http://www.thomas-micro-systems-ltd.co.uk   |
+------------------------------+---------------------------------------------+

pgsql-jdbc by date:

Previous
From: Oliver Jowett
Date:
Subject: Re: JBoss w/int8 primary keys in postgres ...
Next
From: James Robinson
Date:
Subject: Re: JBoss w/int8 primary keys in postgres ...