Re: CAST from numeric(18,3) to numeric doesnt work, posgresql 13.3

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Ján Pecsők <jan(dot)pecsok(at)gmail(dot)com>
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: CAST from numeric(18,3) to numeric doesnt work, posgresql 13.3
Date: 2021-08-05 01:35:22
Message-ID: 2352034.1628127322@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

=?UTF-8?B?SsOhbiBQZWNzxZFr?= <jan(dot)pecsok(at)gmail(dot)com> writes:
> Where conversion from numeric (18,3) to numeric didnt work as expected.

Hmm, interesting. The cause of this is that coerce_type_typmod
supposes that casting to a -1 typmod is a total no-op. Which
is true so far as the run-time behavior is concerned, but not
if something inspects the exposed type of the expression.

The attached seems to be enough to fix it, though I wonder if
we've made the same assumption anywhere else.

Although this changes no existing regression test results,
I'm still a bit hesitant to back-patch it, because I am not
real sure that nothing out there is depending on the current
behavior (which has stood for decades). I think it'd be all
right to put into HEAD, and maybe it's not too late for v14.

regards, tom lane

Attachment Content-Type Size
label-cast-to-minus-one-typmod-correctly.patch text/x-diff 4.3 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2021-08-05 02:05:55 BUG #17132: About "ALTER SUBSCRIPTION ... ADD/DROP PUBLICATION"
Previous Message Ján Pecsők 2021-08-04 15:15:42 CAST from numeric(18,3) to numeric doesnt work, posgresql 13.3