From: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
To: Thomas Kellerer <spam_eater@gmx.net>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: Identity columns, DEFAULT keyword and multi-row inserts
Date: Wed, 11 Dec 2019 16:24:37 +0100
Message-ID: <ac250211-6fa6-715e-5b32-072358571661@2ndquadrant.com> (raw)
In-Reply-To: <9820.1575996793@sss.pgh.pa.us>
References: <ae6d3563-f3c9-ce42-1f2c-32934e844505@gmx.net>
<9820.1575996793@sss.pgh.pa.us>
On 2019-12-10 17:53, Tom Lane wrote:
>> However, a multi-row insert like the following:
>> insert into test (id, data)
>> values
>> (default,1),
>> (default,2);
>> fails with:
>> ERROR: cannot insert into column "id"
>> Detail: Column "id" is an identity column defined as GENERATED ALWAYS.
>> Hint: Use OVERRIDING SYSTEM VALUE to override.
> Yeah, in principle a multi-row INSERT could grovel through all the
> rows of the VALUES clause and confirm that every one of them has
> DEFAULT there. Not sure it's worth the trouble, but if it's not
> a lot of code then maybe. It certainly seems a bit inconsistent.
It looks like the multi-row case in transformInsertStmt() would have to
develop a bit more smarts to discover this case and then replace the RTE
reference in the target list with a single SetToDefault node?
--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: peter.eisentraut@2ndquadrant.com, tgl@sss.pgh.pa.us, spam_eater@gmx.net
Subject: Re: Identity columns, DEFAULT keyword and multi-row inserts
In-Reply-To: <ac250211-6fa6-715e-5b32-072358571661@2ndquadrant.com>
References: <ae6d3563-f3c9-ce42-1f2c-32934e844505@gmx.net> <9820.1575996793@sss.pgh.pa.us> <ac250211-6fa6-715e-5b32-072358571661@2ndquadrant.com>
* 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