Re: CAST from numeric(18,3) to numeric doesnt work, posgresql 13.3 - Mailing list pgsql-bugs

From Tom Lane
Subject Re: CAST from numeric(18,3) to numeric doesnt work, posgresql 13.3
Date
Msg-id 2501011.1628277029@sss.pgh.pa.us
Whole thread Raw
In response to CAST from numeric(18,3) to numeric doesnt work, posgresql 13.3  ("David G. Johnston" <david.g.johnston@gmail.com>)
Responses Re: CAST from numeric(18,3) to numeric doesnt work, posgresql 13.3  (John Naylor <john.naylor@enterprisedb.com>)
List pgsql-bugs
"David G. Johnston" <david.g.johnston@gmail.com> writes:
> Here is a recent newbie help request I fielded in Discord:

> WITH RECURSIVE fizz_buzz (sequence, modulo_3, modulo_5) AS (
>   SELECT 1, CAST('' AS CHAR(4)), CAST('' AS CHAR(4))
>   UNION ALL
>   SELECT sequence + 1,
>        CASE WHEN MOD(sequence + 1, 3) = 0 THEN 'Fizz'
>      ELSE '' END,
>        CASE WHEN MOD(sequence + 1, 5) = 0 THEN 'Buzz'
>      ELSE '' END
>   FROM fizz_buzz
>   WHERE sequence < 100
> )
> SELECT
>     CASE WHEN CONCAT(modulo_3, modulo_5) = '' THEN sequence
>     ELSE CONCAT(modulo_3, modulo_5) END AS fizzbuzz
> FROM fizz_buzz;

I'd class that one as pilot error, in that the query author
isn't even trying to make the two sides of the union agree
type-wise.  It's not the same as the point at hand, where
someone did try to cast to the correct type but the parser
ignored it.

> And the just posted Bug 17137:
> https://www.postgresql.org/message-id/17137-3d3732d5a259612c%40postgresql.org
> Are these related?

Right, that one is a dup of the current issue.

> I would agree with doing this in v14 then back-patch with the next update.

Yeah, I'm going to push to v14 shortly if I don't hear objections soon.

            regards, tom lane



pgsql-bugs by date:

Previous
From: "David G. Johnston"
Date:
Subject: CAST from numeric(18,3) to numeric doesnt work, posgresql 13.3
Next
From: Julien Rouhaud
Date:
Subject: Re: BUG #17136: set shared_preload_libraries = 'pg_stat_statements,pg_prewarm,pg_trgm' , postgresql Cannot Startup