Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1vI7jt-00EGFK-N2 for pgsql-bugs@arkaria.postgresql.org; Sun, 09 Nov 2025 15:54:01 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1vI7jr-0079bm-Ay for pgsql-bugs@arkaria.postgresql.org; Sun, 09 Nov 2025 15:53:59 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1vI7jr-0079aJ-1z for pgsql-bugs@lists.postgresql.org; Sun, 09 Nov 2025 15:53:59 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vI7jp-006EOD-0S for pgsql-bugs@lists.postgresql.org; Sun, 09 Nov 2025 15:53:58 +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 5A9Frugj1650413; Sun, 9 Nov 2025 10:53:56 -0500 From: Tom Lane To: kamil@monicz.dev cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #19106: Potential regression with CTE materialization planning in Postgres 18 In-reply-to: <19106-9dd3668a0734cd72@postgresql.org> References: <19106-9dd3668a0734cd72@postgresql.org> Comments: In-reply-to PG Bug reporting form message dated "Sun, 09 Nov 2025 13:52:01 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1650411.1762703636.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Sun, 09 Nov 2025 10:53:56 -0500 Message-ID: <1650412.1762703636@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk PG Bug reporting form writes: > After upgrading from Postgres 17 to 18, one of my queries started raisin= g an > error: > "unexpected outer reference in CTE query" I agree that sounds like a bug ... > The problematic query is: > https://github.com/openstreetmap-ng/openstreetmap-ng/blob/eb805d8766fb4b= 359b96eb6b50acc8c2a835a165/app/services/element_spatial_service.py#L82-L21= 5 ... but I am not going to spend time trying to reproduce it given this amount of detail. There's too much missing context, like what data you were running the query on. I could spend all day, not see the failure, and be left no wiser than before as to whether it's already fixed or I just didn't duplicate your context closely enough. Please see if you can reduce the problem case to a self-contained SQL script. regards, tom lane