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 1ieilH-0000A6-Q1 for pgsql-general@arkaria.postgresql.org; Tue, 10 Dec 2019 16:53: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 1ieilG-0001to-KY for pgsql-general@arkaria.postgresql.org; Tue, 10 Dec 2019 16:53:22 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ieilG-0001tg-7E for pgsql-general@lists.postgresql.org; Tue, 10 Dec 2019 16:53:22 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ieilD-0002El-RV for pgsql-general@lists.postgresql.org; Tue, 10 Dec 2019 16:53:21 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id xBAGrDoQ009821; Tue, 10 Dec 2019 11:53:13 -0500 From: Tom Lane To: Thomas Kellerer cc: pgsql-general@lists.postgresql.org, Peter Eisentraut Subject: Re: Identity columns, DEFAULT keyword and multi-row inserts In-reply-to: References: Comments: In-reply-to Thomas Kellerer message dated "Tue, 10 Dec 2019 08:41:37 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <9819.1575996793.1@sss.pgh.pa.us> Date: Tue, 10 Dec 2019 11:53:13 -0500 Message-ID: <9820.1575996793@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Thomas Kellerer 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