public inbox for [email protected]  
help / color / mirror / Atom feed
From: PetSerAl <[email protected]>
To: Ray O'Donnell <[email protected]>
Cc: PostgreSQL <[email protected]>
Subject: Re: Combining scalar and row types in RETURNING
Date: Thu, 5 Jun 2025 20:09:21 +0300
Message-ID: <CAKygsHSmiDzcXSruEjR2XSbyF9WP2Ro3ni5utWS+XAGScJd8EQ@mail.gmail.com> (raw)
In-Reply-To: <01020197369aac89-01a7b7b4-b775-471e-ac8e-de8b28d87008-000000@eu-west-1.amazonses.com>
References: <01020197369aac89-01a7b7b4-b775-471e-ac8e-de8b28d87008-000000@eu-west-1.amazonses.com>

> In my case, m_new_data is actually a table row type rather than plain
> "record". The row is passed on to another function which calculates the
> altered columns and logs the changes.

In my experience, to specify composite-typed receiver as one element
of INTO list, it need to be column of composite variable.

CREATE TABLE t (a int, b int, c int);
CREATE TYPE wrap AS (v t);
DO $DO$
  DECLARE
    s text;
    w wrap;
  BEGIN
    INSERT INTO t VALUES (1, 2, 3)
    RETURNING 'text', t
    INTO s, w.v;
    RAISE '%, %', s, w.v;
  END;
$DO$;

https://dbfiddle.uk/e5Q4Fj6l






reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: Combining scalar and row types in RETURNING
  In-Reply-To: <CAKygsHSmiDzcXSruEjR2XSbyF9WP2Ro3ni5utWS+XAGScJd8EQ@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox