pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: David G. Johnston <david.g.johnston@gmail.com>
Cc: Dean Rasheed <dean.a.rasheed@gmail.com>
Cc: Ján Pecsők <jan.pecsok@gmail.com>
Cc: PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>
Subject: Re: CAST from numeric(18,3) to numeric doesnt work, posgresql 13.3
Date: Fri, 06 Aug 2021 15:10:29 -0400
Message-ID: <2501011.1628277029@sss.pgh.pa.us> (raw)
In-Reply-To: <CAKFQuwbcqiOK_XbjkgRK9dTH9n-GmpJtgWUp=Jh+7kEOOVnoGQ@mail.gmail.com>
References: <CABNQVagu3bZGqiTjb31a8D5Od3fUMs7Oh3gmZMQZVHZ=uWWWfQ@mail.gmail.com>
	<2352034.1628127322@sss.pgh.pa.us>
	<CAEZATCWcOOGcYwTV0pv2F0o07w+dL7A2JN88fq5U-K29i=Ls=A@mail.gmail.com>
	<2395471.1628180285@sss.pgh.pa.us>
	<CAKFQuwbcqiOK_XbjkgRK9dTH9n-GmpJtgWUp=Jh+7kEOOVnoGQ@mail.gmail.com>

"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





view thread (8+ messages)  latest in thread

Message-ID: <2501011.1628277029@sss.pgh.pa.us>
Permalink:  ../2501011.1628277029@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/2501011.1628277029@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, david.g.johnston@gmail.com, dean.a.rasheed@gmail.com, jan.pecsok@gmail.com, pgsql-bugs@lists.postgresql.org
  Subject: Re: CAST from numeric(18,3) to numeric doesnt work, posgresql 13.3
  In-Reply-To: <2501011.1628277029@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox