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 1vvszA-00898G-1y for pgsql-bugs@arkaria.postgresql.org; Fri, 27 Feb 2026 08:14:08 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vvsz9-001pbe-1n for pgsql-bugs@arkaria.postgresql.org; Fri, 27 Feb 2026 08:14:07 +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 1vvsz9-001pbV-0x for pgsql-bugs@lists.postgresql.org; Fri, 27 Feb 2026 08:14:07 +0000 Received: from mail-oi1-x230.google.com ([2607:f8b0:4864:20::230]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1vvsz6-00000001XDs-1EmD for pgsql-bugs@lists.postgresql.org; Fri, 27 Feb 2026 08:14:06 +0000 Received: by mail-oi1-x230.google.com with SMTP id 5614622812f47-45effa36240so1357967b6e.1 for ; Fri, 27 Feb 2026 00:14:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1772180043; cv=none; d=google.com; s=arc-20240605; b=E+Vav88v0SYgDz7d0hXX/6ZeskX0YFxkio8B0iS8GOMA6bfzq//EprddNNiD3iQqkQ IdhqhOlL4XahWtOP8KF4ZHZkpLAUXJI1dfrWk+izygJGKIXsKEsLN0k8jQJmbHstgeie ZOb1dtNrKM6uvC32e5TI7x/o47kKY2NpiEHy8Kpc2nn/gpV4lvWsdNtCVnhxjfHJ2d9x pLGSQf5lnCwabNZrQEn40xiGzHKhN3a+vKo/rzKAaKKm3x8umAYMLgMS5O7DIGM7VYjs l0AEr/XRmg8GXug3706Mjruvq4eey/ytnLDGcKkAcKyIwVOgBpX19VjWUHY9eb5i7xBV P4uw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=41NAB0YVn9UrOzpKB/pYMtUQHy65FvolKLdQlpTvTlw=; fh=70TDzJT0bE7FbqJdActDc6zCiwrVVVfmd5bXWBfcNn0=; b=RdGPvsdIM61awdgta8wlSn+V/AU5ZiCxsQGw5ok3SZNGUZXJxzV+5Yz7eVGQAOAN7n LeFnWs0Kozr2flctwwwYVI+o64hx0706Rp++FEFNFQmtUIyeT3z6HUfOL5nYpoiMUNxt iroQEKcZ4jc3IbavP3QovacyyQ2tYOdBxsd1bsnpI1hf0gWyN5cNnJSNOmxW/MtKsfIB pgR52itsUx+EnW2iya6yvH72MO+JxTNfu2zVvj8nUTwZy5j3futoE2Zzky9pjNzG1tRs HePj4sVYb2AVE7gyfgurKy79iGeB/VaH9z22Hb3J/UO5S6HbbM9mOgJA/rpnh7pD5UwE BzbA==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1772180043; x=1772784843; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=41NAB0YVn9UrOzpKB/pYMtUQHy65FvolKLdQlpTvTlw=; b=McJ5v+pV2l4BDpZmK3TMkVl3+xk28gpSMSlQDvd+m76pEk3vIVd5uXioPts2Xnj9KP xejFI1XUkge8+2Tauktq4W8fFmILyPz3ej76Ii2f0RXF7fnQkKGjLIqQa2Utw9odjAlI siIr5t47qCwaUlEVU6RwsU2K1M/LRhrf19TQt/HDWoGOWmnIFghOzohZEueFFLLRXYmG vZjeKdG6mSwYQ2y6G2Xj2oK8RY4slDPrMvi8TsdK9UaRxyVIREgAsOwjuEyMonnkSKnm GWEdgUQkArMTyaiBEAOHs29GVXkImD1bQ1gAHx410dZIiBW4bPmJw35a0C36MRfVvV6Y i+Zg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772180043; x=1772784843; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=41NAB0YVn9UrOzpKB/pYMtUQHy65FvolKLdQlpTvTlw=; b=DPy0cfyXcFdZODCfmq5p+PnXKxp5IGq+Ex39qn6rwEo7uenrfOPMhD3dnDMHw4d65p wtI15TQIBXmAcx8GZN/dkXBE88JWHlFtSqbRcNuZCDW+OvVApY8auF5W/iFpsJ2KJiRf HoRkWWGCzYSukYRslml5nwsbX70vR4YtxMm32d5+MAnPWtGv7WgSfbIhWWM7Qwg7ucsp DIfxP2B9HdSEIOiqV4lL6EbvGTuuklPJcJGt94w3gHnfwoZVkDClspX81R5iMJxjqfG+ 2F10qjCHClI2LHmjRHBKhHmPQNxHLHSDRfBnEzO+vXp2kBuNSR/8LVUVYUnR5AOhcSzU /yIQ== X-Forwarded-Encrypted: i=1; AJvYcCXoBduiX0beUIxGPsDS3zCoSdNRZ65xUGB0kcQIE780f2CiyFQEaN6i5GMAkGqea9xUYKKmHuQiIBwO@lists.postgresql.org X-Gm-Message-State: AOJu0YxVLIw9TOLEDAusdzow3eC0k2oAH/pbPo7DJd8VQTDGifw++QzC e65O+GTLLYbi0Gd6iWXXOVeZQxDqG09tlAH2KFdnp2yuoI67SBs0sknctgbZu9pmgfIv/fdL2+L 62j1JRdbtzlarpaTwMWY4Edv/r8u2Tmw= X-Gm-Gg: ATEYQzxffZfZQC7VLy5z4NSqd4wpuPbm/YRY+P48vPPrin9837WEyznHwnJiBhrvQiS kih3QzkhS/5es3VRt01RQcRaWUYMpM5hhMkOeirG66xk1DQts/qqBpy4UIB2fu0mPOL/fWfVv6R rsLRU1xN4IUN187SNJTOU90QQhZWQ1VFYto0HqLIYIQMdIXQOPy0wP70ZX6xYiUXnV/HzjQlKNu CH4n9dQqiXOkSnXj2x1TCx6/q8r2NcPRtr4euH0lGDSvmqBHLfDbcpJ9mQZNnJTArMuUexAOGI2 nkHAyi9fcg== X-Received: by 2002:a05:6820:1747:b0:679:5634:2b53 with SMTP id 006d021491bc7-679faf4f36bmr1310975eaf.58.1772180043413; Fri, 27 Feb 2026 00:14:03 -0800 (PST) MIME-Version: 1.0 References: <643857.1772122240@sss.pgh.pa.us> <717830.1772130430@sss.pgh.pa.us> In-Reply-To: From: Richard Guo Date: Fri, 27 Feb 2026 17:13:52 +0900 X-Gm-Features: AaiRm53HH2uQXr6O2ZkO1laUENGVo2ZAx5_K3rBrPApmGsPm4Bci89A1SKIZyzY Message-ID: Subject: Re: pg_get_viewdef() produces non-round-trippable SQL for views with USING join on mismatched integer types To: Tom Lane Cc: Swirl Smog Dowry , pgsql-bugs@lists.postgresql.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, Feb 27, 2026 at 12:23=E2=80=AFPM Richard Guo wrote: > On Fri, Feb 27, 2026 at 3:27=E2=80=AFAM Tom Lane wrot= e: > > The problem is obvious after looking at parseCheckAggregates: the > > RTE_GROUP RTE is manufactured using the groupClauses list after we > > have flattened that, which we are only doing for comparison purposes; > > it shouldn't affect what goes into the parse tree. I experimented > > with just changing the order of operations, and that seems to fix it. > Right. We should keep the unmodified GROUP BY expressions in the > parse tree, and then rely on the planner to flatten the join alias > vars within them. > > +1 to the fix. I am on the fence about whether this fix is safe to back-patch to v18. I cautiously think it is safe, as it does not change the parsetree's external representation and does not require an initdb. However, this fix will only apply to newly created views. Users who have existing views affected by this bug will have to recreate them after upgrading to get the corrected pg_get_viewdef output. (really kicking myself for this.) - Richard