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 1uMWtC-00ERot-Jh for pgsql-general@arkaria.postgresql.org; Tue, 03 Jun 2025 19:01:34 +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 1uMWtA-003RdH-Ly for pgsql-general@arkaria.postgresql.org; Tue, 03 Jun 2025 19:01:33 +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.94.2) (envelope-from ) id 1uMWt9-003Rd1-Pf for pgsql-general@lists.postgresql.org; Tue, 03 Jun 2025 19:01:32 +0000 Received: from fhigh-b5-smtp.messagingengine.com ([202.12.124.156]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1uMWt8-00031U-0W for pgsql-general@postgresql.org; Tue, 03 Jun 2025 19:01:32 +0000 Received: from phl-compute-03.internal (phl-compute-03.phl.internal [10.202.2.43]) by mailfhigh.stl.internal (Postfix) with ESMTP id 98AAF2540137; Tue, 3 Jun 2025 15:01:27 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-03.internal (MEProxy); Tue, 03 Jun 2025 15:01:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm3; t=1748977287; x=1749063687; bh=JNVkMWXCkLTa0S69Lp8Y+yJvkMVAQnqBVWAxt0G9cVc=; b= cPUoMjjlQjl/JS3T0tyWscd0pih9J1hJBtcJQTnAUsF9KdwRRCzHXgMz4lRLeCYh Swyz7Hmc3trHHnU3R3TgCgnEo1bzVSaZuMtswNSF5HyM/WeCMpgTMApjDlFTIQSX zB9FThW4WPP7yG5JpPqjfsuHOEDYTw/WwpgiHHgCsjhJwv0F1WJiDbRXIXUk+r4F rUaCnIBvja6TlEC/8QHTT/BO3d6crGiySSNj0PkbF1pNcqFU9jUHXidkaDe3lhHD aOgyzi1hmxNGmHxqUIMDcy6kZVF0H0Nve2QKJDZRyuxZk/QDV8FOJ38ASjI/ypax RqSerRp3wjmUg9QywBY5Mg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1748977287; x= 1749063687; bh=JNVkMWXCkLTa0S69Lp8Y+yJvkMVAQnqBVWAxt0G9cVc=; b=M xz1nTyZcmeE0PqjW9NJPyMG7xHY6qPZZ4OVmjb/LbAcpfChxByeY5LN5l7L+0YS3 05xFr20rvrJ5TMblhz/BNzIxzZ0fztcENkes9aLxFIYT9blsBtS2RKrfSOtOwUrL CXqhKim8JzNvFfvWKKvaErg1KpmBq0Dlstu0n/0q5wetOFfzRF8N+uJS/O4grCKk NL8a9zdtxcLpcKcdmgSSrz7/ceC0mdulMCXNCfmHymnRfmzKR0wgYxx3HJ5CIB0n 4bGAlDwbNMubcJRQeJDeT5IBYh2euA7AdSzY+nZIqnORW2NpDjvdKEOL41PvL7ii B7JWxkI+7fEtcLInZldUg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtddugdellecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdpuffr tefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecunecujfgurhepkfffgggfuf fvvehfhfgjtgfgsehtkeertddtvdejnecuhfhrohhmpeetughrihgrnhcumfhlrghvvghr uceorggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomheqnecuggftrfgrth htvghrnhepfeegfeeiuedtgffgteeggfehkeejheetieeliefgteeikeejvdeiveeigfeh vedtnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprg gurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomhdpnhgspghrtghpthhtohep fedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtoheprhgrhiesrhhoughonhhnvghllh drihgvpdhrtghpthhtohepthhglhesshhsshdrphhghhdrphgrrdhushdprhgtphhtthho pehpghhsqhhlqdhgvghnvghrrghlsehpohhsthhgrhgvshhqlhdrohhrgh X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 3 Jun 2025 15:01:26 -0400 (EDT) Message-ID: <228703a6-f1bf-4af8-a5d6-4edb5bcaa8cf@aklaver.com> Date: Tue, 3 Jun 2025 12:01:25 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Combining scalar and row types in RETURNING To: Ray O'Donnell , Tom Lane Cc: 'PostgreSQL' References: <01020197369aac89-01a7b7b4-b775-471e-ac8e-de8b28d87008-000000@eu-west-1.amazonses.com> <858949.1748969638@sss.pgh.pa.us> <01020197370480a4-f9b53911-e5a8-4bdb-81e5-de41d5db4d8c-000000@eu-west-1.amazonses.com> Content-Language: en-US From: Adrian Klaver In-Reply-To: <01020197370480a4-f9b53911-e5a8-4bdb-81e5-de41d5db4d8c-000000@eu-west-1.amazonses.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 6/3/25 11:18, Ray O'Donnell wrote: > On 03/06/2025 17:53, Tom Lane wrote: > Thanks a million for the explanation, Tom - that makes sense. I tried > what you suggested, with mixed results: > > (i) Running the MERGE as a stand-alone query, with just RETURNING... , > worked - I got a scalar and a row as expected. > > (ii) Running it in a function (actually a DO block), with m_new > correctly declared as the table type, failed with the same error as before. > > (iii) Running (ii) but with the order of the items in RETURNING reversed - > >     ... returning t, merge_action() into m_new, m_action > > - gave me a different error: > > ERROR:  record variable cannot be part of multiple-item INTO list > LINE 53:         m, merge_action() into m_new, m_action > > ...which seems to answer my question definitively. This: ... returning t, merge_action() into m_new, m_action does not match this: LINE 53: m, merge_action() into m_new, m_action Is this a copy and paste error or two different invocations of the function? > > Thanks once more, > > Ray. > > -- Adrian Klaver adrian.klaver@aklaver.com