pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
oid int issue with CachedRowSet upgrading from JDBC 8.4 to 9.1
7+ messages / 4 participants
[nested] [flat]

* oid int issue with CachedRowSet upgrading from JDBC 8.4 to 9.1
@ 2012-03-09 21:25 otran <otran@switchfly.com>
  2012-03-09 22:06 ` Re: oid int issue with CachedRowSet upgrading from JDBC 8.4 to 9.1 Dave Cramer <pg@fastcrypt.com>
  2012-03-13 00:39 ` Re: oid int issue with CachedRowSet upgrading from JDBC 8.4 to 9.1 Kris Jurka <books@ejurka.com>
  0 siblings, 2 replies; 7+ messages in thread

From: otran @ 2012-03-09 21:25 UTC (permalink / raw)
  To: pgsql-jdbc

Hi,

We are in the process of upgrading from Postgres JDBC 8.4 to 9.1-901-1.jdbc4
and discovered that CacheRowSet now call the methods isAutoIncrement() and
fetchFieldMetaData(), which will fail converting a OID to an int.

The following code works with the 8.4 driver, but fails with 9.1:

    public static void main(String[] args) throws Exception {
        Properties connectionProperties = new Properties();
        connectionProperties.put("user", "otran");
        connectionProperties.put("pass", "”);

        Class.forName("org.postgresql.Driver");
        Connection connection =
            DriverManager.getConnection("jdbc:postgresql://postgres-9.1",
connectionProperties);
        Statement statement = connection.createStatement();
        ResultSet resultSet = statement.executeQuery("select * from
airports");
       CachedRowSet cachedRowSet = new CachedRowSetImpl();
        cachedRowSet.populate(resultSet);
    }

$ export CLASSPATH=postgresql-8.4-702.jdbc4.jar:.
$ java Test

$ export CLASSPATH=postgresql-9.1-901-1.jdbc4.jar:.
$ java Test

Exception in thread "main" org.postgresql.util.PSQLException: Bad value for
type int : 3090704121
        at
org.postgresql.jdbc2.AbstractJdbc2ResultSet.toInt(AbstractJdbc2ResultSet.java:2731)
        at
org.postgresql.jdbc2.AbstractJdbc2ResultSet.getInt(AbstractJdbc2ResultSet.java:1983)
        at
org.postgresql.jdbc2.AbstractJdbc2ResultSetMetaData.fetchFieldMetaData(AbstractJdbc2ResultSetMetaData.java:242)
        at
org.postgresql.jdbc2.AbstractJdbc2ResultSetMetaData.isAutoIncrement(AbstractJdbc2ResultSetMetaData.java:61)
        at
com.sun.rowset.CachedRowSetImpl.initMetaData(CachedRowSetImpl.java:701)
        at
com.sun.rowset.CachedRowSetImpl.populate(CachedRowSetImpl.java:621)
        at Test.main(Test.java:22)

It only affects our production environments where the oids are larger than
an int, but many of our tables have that issue. We can try ripping out
CachedRowSets, but wonder if someone has a fix.


Seems related to:

RELEASE NOTE... 

With Version 89.3-dev600 (2007-04-18). Make the default object return type
of oids to be a Java Long instead of Integer because oids are unsigned and
exceed the range of Integer. (jurka)

http://postgresql.1045698.n5.nabble.com/oid-as-long-type-td2169988.html

Thanks,
Owen




--
View this message in context: http://postgresql.1045698.n5.nabble.com/oid-int-issue-with-CachedRowSet-upgrading-from-JDBC-8-4-to-9...
Sent from the PostgreSQL - jdbc mailing list archive at Nabble.com.



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: oid int issue with CachedRowSet upgrading from JDBC 8.4 to 9.1
  2012-03-09 21:25 oid int issue with CachedRowSet upgrading from JDBC 8.4 to 9.1 otran <otran@switchfly.com>
@ 2012-03-09 22:06 ` Dave Cramer <pg@fastcrypt.com>
  2012-03-09 22:59   ` Re: oid int issue with CachedRowSet upgrading from JDBC 8.4 to 9.1 otran <otran@switchfly.com>
  1 sibling, 1 reply; 7+ messages in thread

From: Dave Cramer @ 2012-03-09 22:06 UTC (permalink / raw)
  To: otran <otran@switchfly.com>; +Cc: pgsql-jdbc

On Fri, Mar 9, 2012 at 4:25 PM, otran <otran@switchfly.com> wrote:
> Hi,
>
> We are in the process of upgrading from Postgres JDBC 8.4 to 9.1-901-1.jdbc4
> and discovered that CacheRowSet now call the methods isAutoIncrement() and
> fetchFieldMetaData(), which will fail converting a OID to an int.
>
> The following code works with the 8.4 driver, but fails with 9.1:
>
>    public static void main(String[] args) throws Exception {
>        Properties connectionProperties = new Properties();
>        connectionProperties.put("user", "otran");
>        connectionProperties.put("pass", "”);
>
>        Class.forName("org.postgresql.Driver");
>        Connection connection =
>            DriverManager.getConnection("jdbc:postgresql://postgres-9.1",
> connectionProperties);
>        Statement statement = connection.createStatement();
>        ResultSet resultSet = statement.executeQuery("select * from
> airports");
>       CachedRowSet cachedRowSet = new CachedRowSetImpl();
>        cachedRowSet.populate(resultSet);
>    }
>
> $ export CLASSPATH=postgresql-8.4-702.jdbc4.jar:.
> $ java Test
>
> $ export CLASSPATH=postgresql-9.1-901-1.jdbc4.jar:.
> $ java Test
>
> Exception in thread "main" org.postgresql.util.PSQLException: Bad value for
> type int : 3090704121
>        at
> org.postgresql.jdbc2.AbstractJdbc2ResultSet.toInt(AbstractJdbc2ResultSet.java:2731)
>        at
> org.postgresql.jdbc2.AbstractJdbc2ResultSet.getInt(AbstractJdbc2ResultSet.java:1983)
>        at
> org.postgresql.jdbc2.AbstractJdbc2ResultSetMetaData.fetchFieldMetaData(AbstractJdbc2ResultSetMetaData.java:242)
>        at
> org.postgresql.jdbc2.AbstractJdbc2ResultSetMetaData.isAutoIncrement(AbstractJdbc2ResultSetMetaData.java:61)
>        at
> com.sun.rowset.CachedRowSetImpl.initMetaData(CachedRowSetImpl.java:701)
>        at
> com.sun.rowset.CachedRowSetImpl.populate(CachedRowSetImpl.java:621)
>        at Test.main(Test.java:22)
>
> It only affects our production environments where the oids are larger than
> an int, but many of our tables have that issue. We can try ripping out
> CachedRowSets, but wonder if someone has a fix.
>

If your oid's exceed an int, then I don't see how CachedRowSets could
possibly work ?


Dave Cramer

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



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: oid int issue with CachedRowSet upgrading from JDBC 8.4 to 9.1
  2012-03-09 21:25 oid int issue with CachedRowSet upgrading from JDBC 8.4 to 9.1 otran <otran@switchfly.com>
  2012-03-09 22:06 ` Re: oid int issue with CachedRowSet upgrading from JDBC 8.4 to 9.1 Dave Cramer <pg@fastcrypt.com>
@ 2012-03-09 22:59   ` otran <otran@switchfly.com>
  2012-03-12 20:19     ` Re: oid int issue with CachedRowSet upgrading from JDBC 8.4 to 9.1 Dave Cramer <pg@fastcrypt.com>
  0 siblings, 1 reply; 7+ messages in thread

From: otran @ 2012-03-09 22:59 UTC (permalink / raw)
  To: pgsql-jdbc

Hi Dave,

This did work when we were using the 8.4 jdbc driver. With 9.1, we see a
call com.sun.rowset.CachedRowSetImpl.initMetaData(CachedRowSetImpl.java:701)
that is trying to read the OID now when building this metadata.

So CacheRowSetImpl is just highlighting a difference between the 8.4 and 9.1
jdbc drivers in terms of the implementation of grabbing the initMetaData.

Thanks,
Owen




--
View this message in context: http://postgresql.1045698.n5.nabble.com/oid-int-issue-with-CachedRowSet-upgrading-from-JDBC-8-4-to-9...
Sent from the PostgreSQL - jdbc mailing list archive at Nabble.com.



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: oid int issue with CachedRowSet upgrading from JDBC 8.4 to 9.1
  2012-03-09 21:25 oid int issue with CachedRowSet upgrading from JDBC 8.4 to 9.1 otran <otran@switchfly.com>
  2012-03-09 22:06 ` Re: oid int issue with CachedRowSet upgrading from JDBC 8.4 to 9.1 Dave Cramer <pg@fastcrypt.com>
  2012-03-09 22:59   ` Re: oid int issue with CachedRowSet upgrading from JDBC 8.4 to 9.1 otran <otran@switchfly.com>
@ 2012-03-12 20:19     ` Dave Cramer <pg@fastcrypt.com>
  2012-03-28 21:16       ` Re: oid int issue with CachedRowSet upgrading from JDBC 8.4 to 9.1 Maciek Sakrejda <msakrejda@truviso.com>
  0 siblings, 1 reply; 7+ messages in thread

From: Dave Cramer @ 2012-03-12 20:19 UTC (permalink / raw)
  To: otran <otran@switchfly.com>; +Cc: pgsql-jdbc

Owen,

So did I miss something ? You said that your OID's were larger than an
int didn't you ?

If so even if the signature of the method is correct how do you expect
it to work ?

Dave Cramer

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



On Fri, Mar 9, 2012 at 5:59 PM, otran <otran@switchfly.com> wrote:
> Hi Dave,
>
> This did work when we were using the 8.4 jdbc driver. With 9.1, we see a
> call com.sun.rowset.CachedRowSetImpl.initMetaData(CachedRowSetImpl.java:701)
> that is trying to read the OID now when building this metadata.
>
> So CacheRowSetImpl is just highlighting a difference between the 8.4 and 9.1
> jdbc drivers in terms of the implementation of grabbing the initMetaData.
>
> Thanks,
> Owen
>
>
>
>
> --
> View this message in context: http://postgresql.1045698.n5.nabble.com/oid-int-issue-with-CachedRowSet-upgrading-from-JDBC-8-4-to-9...
> Sent from the PostgreSQL - jdbc mailing list archive at Nabble.com.
>
> --
> Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-jdbc



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: oid int issue with CachedRowSet upgrading from JDBC 8.4 to 9.1
  2012-03-09 21:25 oid int issue with CachedRowSet upgrading from JDBC 8.4 to 9.1 otran <otran@switchfly.com>
  2012-03-09 22:06 ` Re: oid int issue with CachedRowSet upgrading from JDBC 8.4 to 9.1 Dave Cramer <pg@fastcrypt.com>
  2012-03-09 22:59   ` Re: oid int issue with CachedRowSet upgrading from JDBC 8.4 to 9.1 otran <otran@switchfly.com>
  2012-03-12 20:19     ` Re: oid int issue with CachedRowSet upgrading from JDBC 8.4 to 9.1 Dave Cramer <pg@fastcrypt.com>
@ 2012-03-28 21:16       ` Maciek Sakrejda <msakrejda@truviso.com>
  2012-03-28 21:18         ` Re: oid int issue with CachedRowSet upgrading from JDBC 8.4 to 9.1 Maciek Sakrejda <msakrejda@truviso.com>
  0 siblings, 1 reply; 7+ messages in thread

From: Maciek Sakrejda @ 2012-03-28 21:16 UTC (permalink / raw)
  To: Dave Cramer <pg@fastcrypt.com>; +Cc: otran <otran@switchfly.com>; pgsql-jdbc

On Mon, Mar 12, 2012 at 1:19 PM, Dave Cramer <pg@fastcrypt.com> wrote:
> Owen,
>
> So did I miss something ? You said that your OID's were larger than an
> int didn't you ?
>
> If so even if the signature of the method is correct how do you expect
> it to work ?
>
> Dave Cramer
>
> dave.cramer(at)credativ(dot)ca
> http://www.credativ.ca

For anyone interested, I think the issue was that while OIDs are
32-bit entities, they are unsigned, so they could not be treated as
Java (signed) ints beyond 2^31-1.

The nature of Kris' patch [1] seems to support that.

[1]: https://github.com/pgjdbc/pgjdbc/commit/4d60ea616eff61262721176db6e77819a23f6dc2

---
Maciek Sakrejda | System Architect | Truviso

1065 E. Hillsdale Blvd., Suite 215
Foster City, CA 94404
(650) 242-3500 Main
www.truviso.com



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: oid int issue with CachedRowSet upgrading from JDBC 8.4 to 9.1
  2012-03-09 21:25 oid int issue with CachedRowSet upgrading from JDBC 8.4 to 9.1 otran <otran@switchfly.com>
  2012-03-09 22:06 ` Re: oid int issue with CachedRowSet upgrading from JDBC 8.4 to 9.1 Dave Cramer <pg@fastcrypt.com>
  2012-03-09 22:59   ` Re: oid int issue with CachedRowSet upgrading from JDBC 8.4 to 9.1 otran <otran@switchfly.com>
  2012-03-12 20:19     ` Re: oid int issue with CachedRowSet upgrading from JDBC 8.4 to 9.1 Dave Cramer <pg@fastcrypt.com>
  2012-03-28 21:16       ` Re: oid int issue with CachedRowSet upgrading from JDBC 8.4 to 9.1 Maciek Sakrejda <msakrejda@truviso.com>
@ 2012-03-28 21:18         ` Maciek Sakrejda <msakrejda@truviso.com>
  0 siblings, 0 replies; 7+ messages in thread

From: Maciek Sakrejda @ 2012-03-28 21:18 UTC (permalink / raw)
  To: Dave Cramer <pg@fastcrypt.com>; +Cc: otran <otran@switchfly.com>; pgsql-jdbc

And I guess the commit comment supports that even more. Apologies for
the list noise.
---
Maciek Sakrejda | System Architect | Truviso

1065 E. Hillsdale Blvd., Suite 215
Foster City, CA 94404
(650) 242-3500 Main
www.truviso.com



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: oid int issue with CachedRowSet upgrading from JDBC 8.4 to 9.1
  2012-03-09 21:25 oid int issue with CachedRowSet upgrading from JDBC 8.4 to 9.1 otran <otran@switchfly.com>
@ 2012-03-13 00:39 ` Kris Jurka <books@ejurka.com>
  1 sibling, 0 replies; 7+ messages in thread

From: Kris Jurka @ 2012-03-13 00:39 UTC (permalink / raw)
  To: otran <otran@switchfly.com>; +Cc: pgsql-jdbc



On Fri, 9 Mar 2012, otran wrote:

> We are in the process of upgrading from Postgres JDBC 8.4 to 9.1-901-1.jdbc4
> and discovered that CacheRowSet now call the methods isAutoIncrement() and
> fetchFieldMetaData(), which will fail converting a OID to an int.
> 

I have pushed a fix for this to git for 9.1 and master.  Thanks for the 
report.

I've found another problem with master for binary transfer setup with high 
OIDs.  If people want to test this situation and don't have a high 
oid use database handy, you can set the oid counter to an arbitrary 
value with pg_resetxlog.


Kris Jurka



^ permalink  raw  reply  [nested|flat] 7+ messages in thread


end of thread, other threads:[~2012-03-28 21:18 UTC | newest]

Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2012-03-09 21:25 oid int issue with CachedRowSet upgrading from JDBC 8.4 to 9.1 otran <otran@switchfly.com>
2012-03-09 22:06 ` Dave Cramer <pg@fastcrypt.com>
2012-03-09 22:59   ` otran <otran@switchfly.com>
2012-03-12 20:19     ` Dave Cramer <pg@fastcrypt.com>
2012-03-28 21:16       ` Maciek Sakrejda <msakrejda@truviso.com>
2012-03-28 21:18         ` Maciek Sakrejda <msakrejda@truviso.com>
2012-03-13 00:39 ` Kris Jurka <books@ejurka.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox