From: Tom Lane <tgl@sss.pgh.pa.us>
To: Thomas Kellerer <spam_eater@gmx.net>
Cc: pgsql-general@lists.postgresql.org
Cc: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
Subject: Re: Identity columns, DEFAULT keyword and multi-row inserts
Date: Tue, 10 Dec 2019 11:53:13 -0500
Message-ID: <9820.1575996793@sss.pgh.pa.us> (raw)
In-Reply-To: <ae6d3563-f3c9-ce42-1f2c-32934e844505@gmx.net>
References: <ae6d3563-f3c9-ce42-1f2c-32934e844505@gmx.net>
Thomas Kellerer <spam_eater@gmx.net> writes:
> assume the following table:
> create table test
> (
> id integer not null generated always as identity,
> data integer not null
> );
> The following insert works fine:
> insert into test (id, data)
> values (default,1);
> 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.
regards, tom lane
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: tgl@sss.pgh.pa.us, spam_eater@gmx.net, peter.eisentraut@2ndquadrant.com
Subject: Re: Identity columns, DEFAULT keyword and multi-row inserts
In-Reply-To: <9820.1575996793@sss.pgh.pa.us>
References: <ae6d3563-f3c9-ce42-1f2c-32934e844505@gmx.net> <9820.1575996793@sss.pgh.pa.us>
* 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