Thread: NumericShort vs NumericLong format

NumericShort vs NumericLong format

From
Amin
Date:
Hi,

- How can I determine which format will be used for a numeric type?
- What the precision and scale values should be for pgsql to use the long format? Is there a threshold?

Re: NumericShort vs NumericLong format

From
"David G. Johnston"
Date:
I'll give this a go as a learning exercise for myself...

On Mon, Mar 6, 2023 at 8:47 PM Amin <amin.fallahi@gmail.com> wrote:

- How can I determine which format will be used for a numeric type?


(the three constants are decimal 63, 63, and -64 respectively)
- What the precision and scale values should be for pgsql to use the long format? Is there a threshold?


Ones that cause the linked-to test to return false I suppose.

David J.

As an aside, for anyone more fluent than I who reads this, is the use of the word "dynamic scale" in this code comment supposed to be "display scale"?


Re: NumericShort vs NumericLong format

From
Tom Lane
Date:
"David G. Johnston" <david.g.johnston@gmail.com> writes:
> As an aside, for anyone more fluent than I who reads this, is the use of
> the word "dynamic scale" in this code comment supposed to be "display
> scale"?
>
https://github.com/postgres/postgres/blob/cf96907aadca454c4094819c2ecddee07eafe203/src/backend/utils/adt/numeric.c#L121

Yeah, I think you're right.

            regards, tom lane



Re: NumericShort vs NumericLong format

From
Ole Peder Brandtzæg
Date:
On Tue, Mar 07, 2023 at 12:15:27AM -0500, Tom Lane wrote:
> "David G. Johnston" <david.g.johnston@gmail.com> writes:
> > As an aside, for anyone more fluent than I who reads this, is the use of
> > the word "dynamic scale" in this code comment supposed to be "display
> > scale"?
> >
https://github.com/postgres/postgres/blob/cf96907aadca454c4094819c2ecddee07eafe203/src/backend/utils/adt/numeric.c#L121
> 
> Yeah, I think you're right.

Familiarizing myself with numeric.c today, I too was confused by this.
AFAICT, it's meant to say display scale as used elsewhere in the file;
for instance, the comment for NumericShort's n_header reads "Sign +
display scale + weight". Would it be appropriate if I submitted a patch
for this? It's admittedly trivial, but I figured I should say hi before
submitting one.

All the best,
Ole

-- 
Ole Peder Brandtzæg | En KLST/ITK-hybrid
Please don't look at me with those eyes
Please don't hint that you're capable of lies