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

Поиск
Список
Период
Сортировка
От Michael Paquier
Тема Re: BUG #14952: COPY fails to fill in IDENTITY column default value
Дата
Msg-id CAB7nPqTMCmO_Y3HcQn9-oKFQBcWXckf24urAk+_ifBjfjhD0sA@mail.gmail.com
обсуждение исходный текст
Ответ на Re: BUG #14952: COPY fails to fill in IDENTITY column default value  (Peter Eisentraut <peter.eisentraut@2ndquadrant.com>)
Ответы Re: BUG #14952: COPY fails to fill in IDENTITY column default value  (Peter Eisentraut <peter.eisentraut@2ndquadrant.com>)
Re: BUG #14952: COPY fails to fill in IDENTITY column default value  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-bugs
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?

Thanks,
-- 
Michael

Вложения

В списке pgsql-bugs по дате отправления:

Предыдущее
От: Thomas Munro
Дата:
Сообщение: Re: BUG in 10.1 - dsa_area could not attach to a segment that hasbeen freed
Следующее
От: Michael Paquier
Дата:
Сообщение: Re: PostgreSQL crashes with SIGSEGV