Re: Combining scalar and row types in RETURNING - Mailing list pgsql-general

From Ray O'Donnell
Subject Re: Combining scalar and row types in RETURNING
Date
Msg-id 0102019737692b90-b251a7ea-b3c5-4477-afff-5986a149580a-000000@eu-west-1.amazonses.com
Whole thread Raw
In response to Re: Combining scalar and row types in RETURNING  (Adrian Klaver <adrian.klaver@aklaver.com>)
List pgsql-general
On 03/06/2025 20:01, Adrian Klaver wrote:
> 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?

Whoops, sorry, yes, that's a copy-and-paste error - the target table is 
aliased as "m" in my original.

Ray.


-- 
Raymond O'Donnell // Galway // Ireland
ray@rodonnell.ie




pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Combining scalar and row types in RETURNING
Next
From: David Rowley
Date:
Subject: Re: Sudden increase in n_dead_tup with no corresponding insert/update/delete