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 1kP7w3-0004yM-8j for pgsql-bugs@arkaria.postgresql.org; Sun, 04 Oct 2020 17:36:35 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kP7w2-0002QM-6w for pgsql-bugs@arkaria.postgresql.org; Sun, 04 Oct 2020 17:36:34 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kP7w2-0002QF-19 for pgsql-bugs@lists.postgresql.org; Sun, 04 Oct 2020 17:36:34 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kP7vz-00032H-Ty for pgsql-bugs@lists.postgresql.org; Sun, 04 Oct 2020 17:36:33 +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 094HaTLh1508305; Sun, 4 Oct 2020 13:36:29 -0400 From: Tom Lane To: Bruce Momjian cc: cherio@gmail.com, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #16653: Regression in CTE evaluation In-reply-to: <20201004171359.GA10396@momjian.us> References: <16653-3154c42c219f8693@postgresql.org> <20201004171359.GA10396@momjian.us> Comments: In-reply-to Bruce Momjian message dated "Sun, 04 Oct 2020 13:13:59 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1508303.1601832989.1@sss.pgh.pa.us> Date: Sun, 04 Oct 2020 13:36:29 -0400 Message-ID: <1508304.1601832989@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Bruce Momjian writes: > On Sun, Oct 4, 2020 at 04:18:43PM +0000, PG Bug reporting form wrote: >> The following SQL worked in versions 9 through 12. It is throwing an error >> in version 13. > Uh, I am able to reproduce the error in PG _12_ as well, and I am sure > it is related to this change in PG 12: > Allow common table expressions (CTEs) to be inlined into the outer query > (Andreas Karlsson, Andrew Gierth, David Fetter, Tom Lane) Indeed. The planner now inlines the WITH query, allowing "CAST(exp_days.days || ' days' AS interval)" to be folded to a constant, whereupon you get an error since indeed ' days' isn't valid interval input. Sorry, I reject the position that this is a bug. It was something of an implementation artifact that you didn't get this error before. As of v12, we provide explicit control over whether a WITH query can be inlined or not, and you need to use that control if you have a query that's dependent on inlining not happening. regards, tom lane