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 1trjQi-008PY1-IN for pgsql-bugs@arkaria.postgresql.org; Mon, 10 Mar 2025 20:08:52 +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 1trjQg-00HIcK-UU for pgsql-bugs@arkaria.postgresql.org; Mon, 10 Mar 2025 20:08:50 +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 1trjQg-00HIcC-L4 for pgsql-bugs@lists.postgresql.org; Mon, 10 Mar 2025 20:08:50 +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 1trjQe-0025Zi-2Z for pgsql-bugs@lists.postgresql.org; Mon, 10 Mar 2025 20:08:49 +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 52AK8kxF1213531; Mon, 10 Mar 2025 16:08:46 -0400 From: Tom Lane To: Dean Rasheed cc: Tender Wang , Duncan Sands , pgsql-bugs@lists.postgresql.org Subject: Re: Attribute of type record has wrong type error with MERGE ... WHEN NOT MATCHED BY SOURCE THEN DELETE In-reply-to: References: <3518c50a-ab18-482f-b916-a37263622501@deepbluecap.com> <971078.1741629162@sss.pgh.pa.us> <1207317.1741633880@sss.pgh.pa.us> Comments: In-reply-to Dean Rasheed message dated "Mon, 10 Mar 2025 20:03:15 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1213529.1741637326.1@sss.pgh.pa.us> Date: Mon, 10 Mar 2025 16:08:46 -0400 Message-ID: <1213530.1741637326@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Dean Rasheed writes: > However, that's not quite the end of it -- preprocess_function_rtes() > / inline_set_returning_function() can turn a function RTE into a > subquery RTE, leading to a similar problem: > create table foo (a int, b int); > insert into foo values (1,2); > create or replace function f() returns setof foo as > $$ select * from foo offset 0 $$ language sql stable; > update foo set b = f.b from f() as f(a,b) where f.a = foo.a returning f; > ERROR: attribute 3 of type record has wrong type > DETAIL: Table has type record, but query expects foo. Double ugh. I guess we could get preprocess_function_rtes to insert the appropriate relid ... regards, tom lane