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 1if3rj-0003Bn-Bm for pgsql-general@arkaria.postgresql.org; Wed, 11 Dec 2019 15:25:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1if3ri-00035d-5H for pgsql-general@arkaria.postgresql.org; Wed, 11 Dec 2019 15:25:26 +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 1if3rI-0006kh-B2 for pgsql-general@lists.postgresql.org; Wed, 11 Dec 2019 15:25:00 +0000 Received: from [64.147.123.24] (helo=wout1-smtp.messagingengine.com) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1if3rA-0004K9-VT for pgsql-general@lists.postgresql.org; Wed, 11 Dec 2019 15:24:59 +0000 Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.west.internal (Postfix) with ESMTP id D8574AB6; Wed, 11 Dec 2019 10:24:40 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute7.internal (MEProxy); Wed, 11 Dec 2019 10:24:41 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=xnlcIORYMjx4Cp0y6fEEHkOquFhjZi7MXASCrePaR gI=; b=mOpn6THViMzzC3rGatSoSA5XaJnKe7zr8lkD+rqZ3SB/RfTnG6DY7fW8c VH+mKLjui4yEvmJruKzmZRjDWq0Kzi/UBPtFEEHV6+d0Zhzt6aPZhTHDq69WhzLE BfxoIqJ6zdWlZV8BY06EowrBF7Jd/RnjVOxPVVgkUFtmh6pF4PZYeYeKx2MuudYd YocoqJmbdCUgTAI/zlaMrnG756jHwAQbxbOGKfecZ03jtUD+LKBuaOedwn3yGHWr GAWpYC4hydN5UuBqgee/s1YPUEX3RfJd/IKD83Ug6z57VJ9UylUMA40yLJd5E/Hu yVCrQpl1dGHHaJBsfwLwcA3m6aBVA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedufedrudelhedgjeduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefuvfhfhfhokffffgggjggtgfesth ejredttdefjeenucfhrhhomheprfgvthgvrhcugfhishgvnhhtrhgruhhtuceophgvthgv rhdrvghishgvnhhtrhgruhhtsedvnhguqhhurggurhgrnhhtrdgtohhmqeenucffohhmrg hinhepvdhnughquhgrughrrghnthdrtghomhenucfkphepleefrddvgeefrdefgedrleel necurfgrrhgrmhepmhgrihhlfhhrohhmpehpvghtvghrrdgvihhsvghnthhrrghuthesvd hnughquhgrughrrghnthdrtghomhenucevlhhushhtvghrufhiiigvpedt X-ME-Proxy: Received: from april.pezone.net (p5df32263.dip0.t-ipconnect.de [93.243.34.99]) by mail.messagingengine.com (Postfix) with ESMTPA id 16A908005A; Wed, 11 Dec 2019 10:24:38 -0500 (EST) Subject: Re: Identity columns, DEFAULT keyword and multi-row inserts To: Tom Lane , Thomas Kellerer References: <9820.1575996793@sss.pgh.pa.us> Cc: pgsql-general@lists.postgresql.org From: Peter Eisentraut Organization: 2ndQuadrant Message-ID: Date: Wed, 11 Dec 2019 16:24:37 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <9820.1575996793@sss.pgh.pa.us> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Host-Lookup-Failed: Reverse DNS lookup failed for 64.147.123.24 (deferred) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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