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.98.2) (envelope-from ) id 1xUTAs-00000000zKX-2Xb8 for pgsql-bugs@arkaria.postgresql.org; Fri, 20 Nov 2026 18:17:27 +0000 Received: from localhost ([127.0.0.1]:36438 helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1xUTAr-0000000AkHN-0SpI for pgsql-bugs@arkaria.postgresql.org; Fri, 20 Nov 2026 18:17:25 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]:41172) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xUTAq-0000000AkH9-3aGf for pgsql-bugs@lists.postgresql.org; Fri, 20 Nov 2026 18:17:24 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xUTAo-00000000muH-1rmS for pgsql-bugs@lists.postgresql.org; Fri, 20 Nov 2026 18:17:24 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.18.1/8.18.1) with ESMTP id 6AKIHHiW1537678; Fri, 20 Nov 2026 13:17:17 -0500 DKIM-Filter: OpenDKIM Filter v2.11.0 sss.pgh.pa.us 6AKIHHiW1537678 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sss.pgh.pa.us; s=default; t=1795198637; bh=zbjgxKHAkOhoj2os78haRXStTyBvjbwi59nqHoaDslg=; h=From:To:cc:Subject:In-reply-to:References:Date:From; b=ryFJIK2deBbQHj2BONipshLMn0Ubn2/1ufecNIAOzfUwQpxcapuEPntnxOPM7vO2Y /D47snY0wdUEcovIbG/FGeOy5Mnc7c/p3wUyZZnt+E9tanAx+IewMA1y0JNUOA2or2 jr3QDnWJN5oF23IvlJDBVTrOMw8TjFwFV52GOHWo= From: Tom Lane To: Peter Eisentraut cc: tharakan@gmail.com, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #19923: SEARCH/CYCLE with DISTINCT in the recursive term: rows depend on input order In-reply-to: <1536293.1795197174@sss.pgh.pa.us> References: <19923-24cef1e958fa2370@postgresql.org> <1535856.1795196546@sss.pgh.pa.us> <1536293.1795197174@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Fri, 20 Nov 2026 12:52:54 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1537676.1795198637.1@sss.pgh.pa.us> Date: Fri, 20 Nov 2026 13:17:17 -0500 Message-ID: <1537677.1795198637@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Oh, I have it: the right fix here is to leave the right subquery's tlist entirely alone, and instead compute the extra columns in its parent query. The reason we didn't see a problem for #19922 in the lefthand subquery is that it's done that way for the lefthand subquery; but for some reason we didn't do it like that for the righthand one. Now that I look more closely, I think that the SQL spec's rewrite rule actually directs us to do it like that. So there's no semantic hazard in the spec, only in our implementation. regards, tom lane