Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ieafz-0002nl-9z for pgsql-general@arkaria.postgresql.org; Tue, 10 Dec 2019 08:15:23 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1ieafx-000639-Iy for pgsql-general@arkaria.postgresql.org; Tue, 10 Dec 2019 08:15:21 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ieafx-000632-8t for pgsql-general@lists.postgresql.org; Tue, 10 Dec 2019 08:15:21 +0000 Received: from mout.kundenserver.de ([217.72.192.75]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ieafp-0004Gt-Ts for pgsql-general@lists.postgresql.org; Tue, 10 Dec 2019 08:15:20 +0000 Received: from [10.8.0.75] ([185.40.248.10]) by mrelayeu.kundenserver.de (mreue109 [212.227.15.145]) with ESMTPSA (Nemesis) id 1MPGJf-1iNji91YSL-00Pf48 for ; Tue, 10 Dec 2019 09:15:12 +0100 Subject: Re: Identity columns, DEFAULT keyword and multi-row inserts To: pgsql-general@lists.postgresql.org References: From: Thomas Kellerer Message-ID: <6615c093-b124-d680-e489-539ed98cf18b@gmx.net> Date: Tue, 10 Dec 2019 09:15:11 +0100 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.23) Gecko/20090812 Thunderbird/2.0.0.23 Mnenhy/0.7.6.666 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: de-DE Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K1:WSBBhk2a4U4CHm1Zi4ZC+iM0AygkW+77jtffD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jzRwpKqeWM1HMwbojkDOrJOehbpORElRhq2fbARxpT8ZttpVTyRBz8 BOIzLR8wYg7TM/5g/1amzPaBAeY2rnUQPmMrMkTegMe/gcNlH8eyn1YBLX+0Ii List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Patrick FICHE schrieb am 10.12.2019 um 08:56: >> -----Original Message----- >> From: Thomas Kellerer >> >> assume the following table: >> >> create table test >> ( >> id integer not null generated always as identity, >> data integer not null >> ); >> >> 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. >> >> >> My question is: >> >> * If DEFAULT is not allowed for identity columns, then why does the single-row insert work? >> * If DEFAULT _is_ allowed, then why does the multi-row insert fail? > > > I agree that it does not seem very consistent. > > But is there any specific reason why are you using DEFAULT ? > > If you want / have to specify DEFAULT, then you should probably > create your identity as "generated by default". I don't really need (or use) it, I just stumbled upon this: https://stackoverflow.com/questions/59261048 And I think if the single row insert is allowed the multi-row should be as well. Not sure if this is a bug - and if it is, which one is the bug: the failing statement or the working one?