Re: BUG #1712: JDBC column precision for bigint is 0

From: Gilles Dubochet <dubochet(at)urbanet(dot)ch>
To: Oliver Jowett <oliver(at)opencloud(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #1712: JDBC column precision for bigint is 0
Date: 2005-06-13 08:27:38
Message-ID: 445469A3-0EAA-48EC-A75F-61F2988F4E85@urbanet.ch
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

>> Whith the JDBC driver at least up to version 8.1dev-400, the
>> result of the
>> getPrecision method of ResultSetMetaData on a bigint column is 0
>> instead of
>> the expected 19.
>>
>
> This has been reported before but I haven't got to fixing it yet. This
> is partly because I haven't seen a good explanation of exactly what we
> should be returning here -- what spec says we should return 19?
>

Well, in PostgreSQL, BIGINT uses 8 bytes (that is what the
documentation says, at least). Now, with 8 bytes, the range of
numbers that can be represented is:

For 63 bits + 1 sign bit: [ (2^63/2)-1, -2^63/2] =
[9223372036854775807, -9223372036854775808]
For 64 bits (unsigned): [2^64, 0] = [18446744073709551616, 0]

If you count the number of digits in these numbers, you'll notice
that for the signed number, 19 decimal digits at most are required to
represent it (if the sign comes for free, which seems assumed for
other data types such as INT or SMALLINT).

For the unsigned number, 20 decimal digits are required. But as far
as I understand the PostgreSQL reference, integers are always signed,
except for serial data types, but where the range is that of a signed
number anyway (since they need to be compatible with "normal" integer
types to represent references).

This is why I believe 19 is the value the getPrecision method should
return. I don't think there is some kind of standard reference that
defines it, but it seems pretty clear what it should be really.

I hope this convinces you, if you still have any doubts, let me know:
I'll do my best to appease them ;)

Sincerely,
Gilles Dubochet.

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message tiejun feng 2005-06-13 11:33:47 BUG #1717: using PgOleDb-1.0.0.15 in delphi i can't edit the data in control
Previous Message Martin Pitt 2005-06-13 07:43:37 Re: Bug#311533: Invalid timestamp returned because of timezone