Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mC5Eq-0003M1-7u for pgsql-bugs@arkaria.postgresql.org; Fri, 06 Aug 2021 19:10:36 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mC5Ep-0006SY-7X for pgsql-bugs@arkaria.postgresql.org; Fri, 06 Aug 2021 19:10:35 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mC5Ep-0006SQ-15 for pgsql-bugs@lists.postgresql.org; Fri, 06 Aug 2021 19:10:35 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mC5Em-0005r6-D4 for pgsql-bugs@lists.postgresql.org; Fri, 06 Aug 2021 19:10:34 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 176JATKH2501012; Fri, 6 Aug 2021 15:10:29 -0400 From: Tom Lane To: "David G. Johnston" cc: Dean Rasheed , =?UTF-8?B?SsOhbiBQZWNzxZFr?= , PostgreSQL mailing lists Subject: Re: CAST from numeric(18,3) to numeric doesnt work, posgresql 13.3 In-reply-to: References: <2352034.1628127322@sss.pgh.pa.us> <2395471.1628180285@sss.pgh.pa.us> Comments: In-reply-to "David G. Johnston" message dated "Fri, 06 Aug 2021 11:58:45 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2501010.1628277029.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Fri, 06 Aug 2021 15:10:29 -0400 Message-ID: <2501011.1628277029@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk "David G. Johnston" 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) =3D 0 THEN 'Fizz' > ELSE '' END, > CASE WHEN MOD(sequence + 1, 5) =3D 0 THEN 'Buzz' > ELSE '' END > FROM fizz_buzz > WHERE sequence < 100 > ) > SELECT > CASE WHEN CONCAT(modulo_3, modulo_5) =3D '' 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%40postgresq= l.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 updat= e. Yeah, I'm going to push to v14 shortly if I don't hear objections soon. regards, tom lane