Re: pg_typeof equivalent for numeric scale, numeric/timestamp precision?

From: Craig Ringer <ringerc(at)ringerc(dot)id(dot)au>
To: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: pg_typeof equivalent for numeric scale, numeric/timestamp precision?
Date: 2012-10-04 03:33:57
Message-ID: 506D03A5.1040307@ringerc.id.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 10/03/2012 05:50 AM, Martijn van Oosterhout wrote:
> On Tue, Oct 02, 2012 at 10:19:18AM +0800, Craig Ringer wrote:
>> Hi all
>>
>> While examining a reported issue with the JDBC driver I'm finding
>> myself wanting SQL-level functions to get the scale and precision of
>> a numeric result from an operation like:
>>
>> select NUMERIC(8,4) '1.9999'
>> union
>> select INTEGER 4;
>
> The typmod in postgres is not maintained very well. In the
> wire-protocol the typmod is provided if known (the C interface calls
> the function PQfmod) and if it's not there (which is very often,
> postgres doesn't try very hard) there's no way to "encourge" postgres
> to work it out for you.

OK, thanks for confirming that.

It seems the JDBC spec requires preservation of type qualifiers in ways
that PgJDBC just won't be able to do without that info. If the server
doesn't keep track of it I don't think there's anything PgJDBC can do to
be compliant on that topic :-(

--
Craig Ringer

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Craig Ringer 2012-10-04 03:34:53 Re: pros and cons of two security models
Previous Message Merlin Moncure 2012-10-04 03:15:17 Re: [PL/PGSQL] column name substitution in PG8.4