From: | Peter Geoghegan <pg(at)bowt(dot)ie> |
---|---|
To: | Daniele Varrazzo <daniele(dot)varrazzo(at)gmail(dot)com> |
Cc: | pgsql-general <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: upsert: is there a shortcut? |
Date: | 2017-07-28 18:41:09 |
Message-ID: | 20170728184109.GB27420@marmot |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Daniele Varrazzo <daniele(dot)varrazzo(at)gmail(dot)com> wrote:
>Is there a way to avoid replicating the list of fields and use instead
>something like (new.*) = (excluded.*) as one could do in a trigger?
>(that would also imply an (id = excluded.id but it seems harmless).
This is certainly something that I've seen requests for before. I tend
to think that using such a feature would be a bit like using "SELECT *"
in production: something that provides an immediate convenience, but
creates unforeseen problems.
As an example, imagine if someone adds an "inserted_at" column, which
has "now()" as its default value. Today, a user can be pretty confident
that no existing or future query is going to change that itself, because
in order for that to happen the query would have to be written with the
explicit intention of updating "inserted_at". That property would go
away with the feature you describe. Subtleties like this could easily be
missed.
--
Peter Geoghegan
From | Date | Subject | |
---|---|---|---|
Next Message | Jerome Wagner | 2017-07-28 18:49:16 | Re: tzdata version |
Previous Message | Timokhin Maxim | 2017-07-28 14:34:43 | Re: duplicate key value violates unique constraint and duplicated records |