Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eNJtY-0007zU-OL for pgsql-bugs@arkaria.postgresql.org; Fri, 08 Dec 2017 14:44:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eNJtY-0001Li-8c for pgsql-bugs@arkaria.postgresql.org; Fri, 08 Dec 2017 14:44:56 +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_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1eNJtX-0001LX-Si for pgsql-bugs@lists.postgresql.org; Fri, 08 Dec 2017 14:44:56 +0000 Received: from out3-smtp.messagingengine.com ([66.111.4.27]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1eNJtT-0003ZT-Oh for pgsql-bugs@postgresql.org; Fri, 08 Dec 2017 14:44:55 +0000 Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 83C1020BB7; Fri, 8 Dec 2017 09:44:49 -0500 (EST) Received: from frontend2 ([10.202.2.161]) by compute7.internal (MEProxy); Fri, 08 Dec 2017 09:44:49 -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-sender:x-me-sender:x-sasl-enc; s=fm1; bh=HTx212 4FPTDyrDazemAswebC1cA65u0c7NdU1QKpB2E=; b=O5W7YM/7y/ZdmGdrLlwClu j9sy1p2MmtkB+2O+oTFBqvLJmW6FN9zXiF/ocxiO5kN7VpRhqb8jH26wuCjYaHUF sqK+bbMV01PKjlmmZWVTSUMdyo//TMJKlcvvpdqa+5P2sfCX9yTsF5O/RMECATjA /zZr+nMy+zsb/ljsK9UMZ9496T9zkQSmqdK5+sDaBfSXyrhFzzJK94Ex0ogrHzIs ZK4FxIRMwTIYttbFEEhxYfbRqBXNAFxc1FRYpQxPBWU589UATqZXOTICyRzfWg6p OuPV0veD7HzqeCF/b+7d7P3v420qJNGKZLsRwrlOQ2JrGlHbq8PUiigMNGvyEBLw == X-ME-Sender: Received: from april.local (c-73-13-66-39.hsd1.pa.comcast.net [73.13.66.39]) by mail.messagingengine.com (Postfix) with ESMTPA id 2EE5124735; Fri, 8 Dec 2017 09:44:49 -0500 (EST) Subject: Re: BUG #14952: COPY fails to fill in IDENTITY column default value To: Michael Paquier References: <20171207112930.21696.79944@wrigleys.postgresql.org> <12618e2c-0eb0-3e15-c45d-96891c52eb5f@2ndquadrant.com> Cc: steven.winfield@cantabcapital.com, PostgreSQL mailing lists From: Peter Eisentraut Organization: 2ndQuadrant Message-ID: <4aa8654b-27c5-3c1c-c78e-20e6f73a0cd6@2ndquadrant.com> Date: Fri, 8 Dec 2017 09:44:48 -0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 12/7/17 20:37, Michael Paquier wrote: > On Fri, Dec 8, 2017 at 2:13 AM, Peter Eisentraut > wrote: >> On 12/7/17 06:29, steven.winfield@cantabcapital.com wrote: >>> COPYing data to a table with an IDENTITY column, where the column's value >>> isn't specified in the copied input, fails because COPY attempts to insert a >>> NULL value for the column: >> >> That indeed appears to be a bug. > > That's a bug. When doing a COPY with or without a list of columns, and > that a column is not listed and has a default expression, then this > expression is used. This is a role filled in by build_column_default() > but identity columns need to create a NextValueExpr expression > instead. As this expression is missing, the backend complains about a > NULL input for this column, which is logic without an expression. > Attached is a patch with a regression test. > > Peter, what do you think? Committed. I moved the tests to identity.sql though. -- Peter Eisentraut http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services