Re: JBoss w/int8 primary keys in postgres ...

From: Paul Thomas <paul(at)tmsl(dot)demon(dot)co(dot)uk>
To: Oliver Jowett <oliver(at)opencloud(dot)com>
Cc: James Robinson <jlrobins(at)socialserve(dot)com>, pgsql-jdbc(at)postgresql(dot)org
Subject: Re: JBoss w/int8 primary keys in postgres ...
Date: 2003-09-07 10:44:02
Message-ID: 20030907114402.A21495@bacon
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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 |
+------------------------------+---------------------------------------------+

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message James Robinson 2003-09-07 19:09:23 Re: JBoss w/int8 primary keys in postgres ...
Previous Message Oliver Jowett 2003-09-06 22:25:30 Re: JBoss w/int8 primary keys in postgres ...