Re: numeric cast oddity - Mailing list pgsql-general

From Tom Lane
Subject Re: numeric cast oddity
Date
Msg-id 23294.1260112236@sss.pgh.pa.us
Whole thread Raw
In response to Re: numeric cast oddity  (Sim Zacks <sim@compulab.co.il>)
List pgsql-general
Sim Zacks <sim@compulab.co.il> writes:
> If I replace that column with -1::numeric(20,4) or - (1::numeric(20,4))
> the type that goes to the view is numeric without any scale or precision
> and then I get an error that I cannot change the column type.

You've still got the order of operations wrong.
    (-1)::numeric(20,4)
is known to have typmod (20,4), because the cast operation enforces it.
    - (1::numeric(20,4))
is not known to have any particular typmod --- it actually does fit in
(20,4), of course, but that fact depends on the detailed behavior of the
minus operator, which is not known to the type machinery.

            regards, tom lane

pgsql-general by date:

Previous
From: José María Terry Jiménez
Date:
Subject: Re: Error in crosstab using date_trunc
Next
From: Scott Marlowe
Date:
Subject: Re: Error in crosstab using date_trunc