Re: BUG #14952: COPY fails to fill in IDENTITY column default value

From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>, steven(dot)winfield(at)cantabcapital(dot)com, PostgreSQL mailing lists <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: BUG #14952: COPY fails to fill in IDENTITY column default value
Date: 2017-12-14 04:22:03
Message-ID: CAB7nPqSV3nHjgVb-f3arf52W+dvng2MmbTf3V+=0Sm-chR4Xxg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Thu, Dec 14, 2017 at 12:39 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> For that matter, should build_column_default() know about it explicitly
> either? Why aren't we implementing IDENTITY by storing an appropriate
> default expression in the catalogs?

Wait a minute... If I look at the callers of build_column_default(),
rewriteValuesRTE looks broken as well:
=# CREATE TABLE itest10 (a int GENERATED BY DEFAULT AS IDENTITY, b
text, c bigint);
CREATE TABLE
=# insert into itest10 values (default, 'foo', 0), (default, 'foo2', 1);
ERROR: 23502: null value in column "a" violates not-null constraint
DETAIL: Failing row contains (null, foo, 0).
I would expect the second query to work properly.

It seems that slot_fill_defaults() would fail as well for a logical
worker, and so are ATExecAlterColumnType() and ATExecAddColumn()?
Peter, did you do the separation to help in handling better the cases
with INSERT OVERRIDE?
--
Michael

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Evgeniy Kozlov 2017-12-14 07:54:19 Re: BUG #14972: row duplicate on first SELECT from CTE (by JOIN/FOR UPDATE) from which UPDATE performed recently
Previous Message Tom Lane 2017-12-14 03:39:00 Re: BUG #14952: COPY fails to fill in IDENTITY column default value