Re: "Fix" for INT8 literals being parsed as INT4 disqualifying index scan problem in JBoss ...

From: James Robinson <jlrobins(at)socialserve(dot)com>
To: Oliver Jowett <oliver(at)opencloud(dot)com>, Barry Lind <blind(at)xythos(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: "Fix" for INT8 literals being parsed as INT4 disqualifying index scan problem in JBoss ...
Date: 2003-11-07 14:11:53
Message-ID: 567D39D4-112C-11D8-A127-000A9566A412@socialserve.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc


On Nov 6, 2003, at 6:09 PM, Oliver Jowett wrote:

> There's a patch pending that should fix this problem .. it adds an
> explicit
> typecast to all literals that reflects the type provided to JDBC
> (either
> implied by the method used, or from the java.sql.Types value for
> setObject()). So the above query actually turns into:
>
> SELECT COUNT(*) FROM foo WHERE (id=1234::int8)
>
> if you use setLong() or setObject(..., Types.BIGINT) to set the
> parameter.
>
> This does break other cases (e.g. using setLong() when you actually
> want an
> int4 value) but it's necessary to get consistency between the PREPARE
> and
> non-PREPARE paths.. and it's almost an application error in this case
> anyway.
>

This sounds like a good fix. It was unfortunate that the additional
type info that the PreparedStatement knew was evaporating before it
could be used by the backend to stop some maddness. JBoss does indeed
use the setObject(..., Types.BIGINT) (see line 1278 of
org.jboss.ejb.plugins.cmp.jdbc.JDBCUtil -- that was fun to ultimately
track down), so that should keep it happy.

Thanks!

----
James Robinson
Socialserve.com

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Gupta, Sahil 2003-11-07 17:42:18 Accessing PG DB using jdbc
Previous Message Binh Nguyen Thanh 2003-11-07 09:25:49 Question