From: Färber, Franz-Josef (StMUK) <Franz-Josef.Faerber@stmuk.bayern.de>
To: Adrian Klaver <adrian.klaver@aklaver.com>
To: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: AW: UPDATE myTable SET (myTable.*) = json_populate_record(...) ?
Date: Mon, 3 Aug 2026 15:17:56 +0000
Message-ID: <c84d894abc8b4ababe03e1c08255c3b6@stmuk.bayern.de> (raw)
In-Reply-To: <a0519983-dfc1-4660-be0e-985b07bfae02@aklaver.com>
References: <688383b93cf74558b5b9484ca3c3996a@stmuk.bayern.de>
<a0519983-dfc1-4660-be0e-985b07bfae02@aklaver.com>
Yes, the least grave of my items can be worked around by wrapping the function into a subselect, for whatever reason this might be necessary.
(As far as I know there are other places in Postgres where I can substitute a subselect by an expression / a function call, and I am curious: Why not here?)
But what about my other item... what about somehow preventing to write all column names, i. e. changing ...
SET (col1, col2, ...)
... to something like ...
SET (myTable.*)
?
My first intention on posting was: Is there some way to acheive that?
If no, my second intention is a general critique on ... I think it is at least similar to what https://carlineng.com/?postid=sql-critique#blog calls " Lack of Orthogonality" in (Postgres-)SQL.
-----Ursprüngliche Nachricht-----
Von: Adrian Klaver <adrian.klaver@aklaver.com>
Gesendet: Montag, 3. August 2026 17:00
An: Färber, Franz-Josef (StMUK) <Franz-Josef.Faerber@stmuk.bayern.de>; pgsql-general@lists.postgresql.org
Betreff: Re: UPDATE myTable SET (myTable.*) = json_populate_record(...) ?
On 8/3/26 12:09 AM, Färber, Franz-Josef (StMUK) wrote:
> Dear Postgres Community,
>
> cf. https://www.postgresql.org/docs/current/sql-update.html :
>
> As far as I understand, I can
>
> * UPDATE myTable SET col1 = val1, col2 = val2, ...
> * UPDATE myTable SET (col1, col2, ...) = <ROW-or-subselect>
>
> But I cannot, and I am missing that:
> * UPDATE myTable SET (myTable.*) = <ROW-or-subselect>
> * UPDATE myTable SET (col1, col2, ...) = json_populate_record(NULL::myTable, myJson) -- this is a function, not a ROW construct and not a subselect
Make it a subselect? Not tested but:
UPDATE myTable SET (col1, col2, ...) = (select * from json_populate_record(NULL::myTable, myJson))
>
> This would be useful for some of my trigger code.
>
>
> Regards,
> fjf2002
>
>
>
--
Adrian Klaver
adrian.klaver@aklaver.com
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: pgsql-general@postgresql.org
Cc: Franz-Josef.Faerber@stmuk.bayern.de, adrian.klaver@aklaver.com, pgsql-general@lists.postgresql.org
Subject: Re: AW: UPDATE myTable SET (myTable.*) = json_populate_record(...) ?
In-Reply-To: <c84d894abc8b4ababe03e1c08255c3b6@stmuk.bayern.de>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox