Re: Precision and scale of numeric column reported as value - Mailing list pgsql-bugs

From Oliver Jowett
Subject Re: Precision and scale of numeric column reported as value
Date
Msg-id 4241E333.2070305@opencloud.com
Whole thread Raw
In response to Re: Precision and scale of numeric column reported as value  (Sergio Lob <Sergio_Lob@iwaysoftware.com>)
Responses Re: Precision and scale of numeric column reported as value  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
Sergio Lob wrote:
> Precision is the number of total digits in the number. Scale is the
> number of  fractional digits.
> For instance, a column defined as NUMERIC(10,3)  should return
> precision=10, scale=3.

Yes, I understand that.

> The error only occurs for a column defined as
> NUMERIC  (without precision or scale specified). Presumably, there is a
> default precision and scale assigned to the column by postgreSQL, which
> is not -1.

There appears to be no default, which is why we currently return -1.

Scale should default to 0 per the standard, but defaults to whatever the
precision is in PostgreSQL (see the docs for details).

The docs claim an implementation precision limit of 1000, but that
doesn't seem to correspond to the actual implementation -- I can insert
and retrieve 2000 digits NUMERICs (for example) just fine. I can't see
an obvious limit on precision in the backend code. There may be a
theoretical limit somewhere around 2^30 digits, I think (limited by the
backend's memory allocation sanity checks), but I have not tested that.

Given that there is effectively no default, do you have suggestions for
a better value to return?

-O

pgsql-bugs by date:

Previous
From: Andrew - Supernews
Date:
Subject: Re: BUG #1552: massive performance hit between 7.4 and 8.0.1
Next
From: Bruce Momjian
Date:
Subject: Re: BUG #1517: SQL interval syntax is accepted by the parser,