Re: BUG #14952: COPY fails to fill in IDENTITY column default value - Mailing list pgsql-bugs

From Peter Eisentraut
Subject Re: BUG #14952: COPY fails to fill in IDENTITY column default value
Date
Msg-id 4aa8654b-27c5-3c1c-c78e-20e6f73a0cd6@2ndquadrant.com
Whole thread Raw
In response to Re: BUG #14952: COPY fails to fill in IDENTITY column default value  (Michael Paquier <michael.paquier@gmail.com>)
List pgsql-bugs
On 12/7/17 20:37, Michael Paquier wrote:
> On Fri, Dec 8, 2017 at 2:13 AM, Peter Eisentraut
> <peter.eisentraut@2ndquadrant.com> 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


pgsql-bugs by date:

Previous
From: peter.barzakov@gmail.com
Date:
Subject: BUG #14955: postgresql10-server-10.1-3PGDG.rhel6 initdb isssue
Next
From: Peter Eisentraut
Date:
Subject: Re: [BUGS] BUG #14866: The generated constraint in the typed tablecauses the server to crash