Re: ResultSetMetaData.getColumnDisplaySize returns 2147483647 ? - Mailing list pgsql-jdbc

From Віталій Тимчишин
Subject Re: ResultSetMetaData.getColumnDisplaySize returns 2147483647 ?
Date
Msg-id 331e40660903030557l732b7976nebdf5e88d0eb32f1@mail.gmail.com
Whole thread Raw
In response to Re: ResultSetMetaData.getColumnDisplaySize returns 2147483647 ?  (DGPickett <DGPickett@aol.com>)
List pgsql-jdbc


2009/3/2 DGPickett <DGPickett@aol.com>
On Mar 2, 4:10 am, oli...@opencloud.com (Oliver Jowett) wrote:
> Or you could change the calling code to
> bounds-check the metadata results before it goes off and tries to
> allocate the entire heap for one column in one row ..

If you have to change calling code to access Postgres, it violates the
original promise of JDBC: use me and be portable.  If you want an 'I
don't know' response built into this API method, sell it to the JDBC
community, but until then, it is a requirement.  Most RDBMS have not
stumbled when delivering on the requirement, so selling it as a
hardship seems difficult.  As the real estate zoning lawyers say,
"This is, at best, a self-imposed hardship."

I'd say it works fairly well here. It is asked a maximum, it don't know - so it tells theoretical maximum possible and that is not precise, but correct value. And the jisql does have a bug - it tries to allocate memory equal to column maximum width. Imagine a varchar(1000000000) column I may use to store long descriptions without limits (or equal PostgreSQL "text" type). My values never larger then, say, 4KB, and jisql would try to allocate 1000000000 size buffer, that is stupid and would lead to problems. It should have some maximum limit (say, 1MB), because even for varchar(many) column, it usually do not have such a long values.

pgsql-jdbc by date:

Previous
From: Kris Jurka
Date:
Subject: Re: ResultSetMetaData.getColumnDisplaySize returns 2147483647 ?
Next
From: Thomas Kellerer
Date:
Subject: Inserting into a uuid column