pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Michael Paquier <michael.paquier@gmail.com>
Cc: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
Cc: steven.winfield@cantabcapital.com, PostgreSQL mailing lists <pgsql-bugs@postgresql.org>
Subject: Re: BUG #14952: COPY fails to fill in IDENTITY column default value
Date: Wed, 13 Dec 2017 22:39:00 -0500
Message-ID: <31740.1513222740@sss.pgh.pa.us> (raw)
In-Reply-To: <CAB7nPqTMCmO_Y3HcQn9-oKFQBcWXckf24urAk+_ifBjfjhD0sA@mail.gmail.com>
References: <20171207112930.21696.79944@wrigleys.postgresql.org>
	<12618e2c-0eb0-3e15-c45d-96891c52eb5f@2ndquadrant.com>
	<CAB7nPqTMCmO_Y3HcQn9-oKFQBcWXckf24urAk+_ifBjfjhD0sA@mail.gmail.com>

Michael Paquier <michael.paquier@gmail.com> writes:
> On Fri, Dec 8, 2017 at 2:13 AM, Peter Eisentraut
> <peter.eisentraut@2ndquadrant.com> wrote:
>> 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.

Now that I look more closely at this patch, isn't it fixing things
in the wrong place?  Why is it that COPY needs to know about this,
rather than build_column_default()?  Aren't we going to have to
fix every other caller of build_column_default()?

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?

			regards, tom lane




view thread (14+ messages)  latest in thread

Message-ID: <31740.1513222740@sss.pgh.pa.us>
Permalink:  ../31740.1513222740@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/31740.1513222740@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, michael.paquier@gmail.com, peter.eisentraut@2ndquadrant.com
  Subject: Re: BUG #14952: COPY fails to fill in IDENTITY column default value
  In-Reply-To: <31740.1513222740@sss.pgh.pa.us>
  References: <20171207112930.21696.79944@wrigleys.postgresql.org> <12618e2c-0eb0-3e15-c45d-96891c52eb5f@2ndquadrant.com> <CAB7nPqTMCmO_Y3HcQn9-oKFQBcWXckf24urAk+_ifBjfjhD0sA@mail.gmail.com> <31740.1513222740@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox