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.96) (envelope-from ) id 1vw2Gf-00Gflm-21 for pgsql-bugs@arkaria.postgresql.org; Fri, 27 Feb 2026 18:08:49 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vw2Ge-005V8y-1d for pgsql-bugs@arkaria.postgresql.org; Fri, 27 Feb 2026 18:08:48 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vw2Ge-005V8n-0o for pgsql-bugs@lists.postgresql.org; Fri, 27 Feb 2026 18:08:48 +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 1vw2Gb-00000001brY-1Oax for pgsql-bugs@lists.postgresql.org; Fri, 27 Feb 2026 18:08:48 +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 61RI8aum988127; Fri, 27 Feb 2026 13:08:36 -0500 From: Tom Lane To: Richard Guo cc: Swirl Smog Dowry , pgsql-bugs@lists.postgresql.org Subject: Re: pg_get_viewdef() produces non-round-trippable SQL for views with USING join on mismatched integer types In-reply-to: <852982.1772205703@sss.pgh.pa.us> References: <643857.1772122240@sss.pgh.pa.us> <717830.1772130430@sss.pgh.pa.us> <852982.1772205703@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Fri, 27 Feb 2026 10:21:43 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <988125.1772215716.1@sss.pgh.pa.us> Date: Fri, 27 Feb 2026 13:08:36 -0500 Message-ID: <988126.1772215716@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk I wrote: > Richard Guo writes: >> I am on the fence about whether this fix is safe to back-patch to v18. > I don't think we have a lot of choice. The cases where it makes a > difference are pretty broken. Fortunately, I think these cases > are rare. JOIN USING combining two different-type columns has got > to be an edge-case usage, and I think it likely doesn't matter much > in other cases. I spent a bit of effort on determining which cases actually cause wrong output, and AFAICT it's very narrow: you need "SELECT ... t1 LEFT JOIN t2 USING (x) GROUP BY x" where t1.x and t2.x are different data types and t1.x is the side requiring coercion. With no coercion, or if the join side to be coerced is nullable, we show the flattened alias Var but that doesn't actually break anything. So I went ahead and pushed this, using your test case. regards, tom lane