Re: getColumnDisplayWidth() returns 0x7fffffff for char varying

From: Dan Evans <devans(at)invores(dot)com>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: getColumnDisplayWidth() returns 0x7fffffff for char varying
Date: 2009-06-08 14:41:05
Message-ID: 4A2D2301.60703@invores.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Oliver Jowett wrote:
> Dan Evans wrote:
>
>> My problem is that getColumnDisplayWidth() returns the widths
>>
>> column(1) uname(2147483647)
>
> This has been discussed at some length previously, check the list archives.
>
> (quick summary from memory: for an unbounded character varying type,
> there's nothing really sensible we can return - that column could have a
> gigabyte of text for all we know. We originally returned -1 but that
> broke some common RowSet implementations. Now we return Integer.MAX_VALUE)
>
> -O
>

I did check the archives before posting, but the hits on getColumnDisplayWidth() did not seem relevant. If you can point to the approximate date, I'd appreciate it.

For any ResultSet that is completely contained in the address space of the requestor, the return value can be the maximum length of the values for the requested column in the result set. If the ResultSet is not complete in the requestor's address space at the time of the getColumnDisplayWidth() call, that might be the time to return Integer.MAX_VALUE signifying no useful information. Most ResultSet's are reasonably small, so I would hope that doesn't happen often. But even then, some useful information can be provided to the caller. The maximum length across the received rows can be returned, with a negative value indicating that this is only an estimate based on the received rows. However, if negative values break some implementations, then that is precluded.

Dan

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Gaël BOUGANNE 2009-06-09 11:53:32 Getting views' metadata
Previous Message Oliver Jowett 2009-06-07 22:53:26 Re: getColumnDisplayWidth() returns 0x7fffffff for char varying