From: steven.winfield@cantabcapital.com
To: pgsql-bugs@postgresql.org
Cc: steven.winfield@cantabcapital.com
Subject: BUG #14952: COPY fails to fill in IDENTITY column default value
Date: Thu, 07 Dec 2017 11:29:30 +0000
Message-ID: <20171207112930.21696.79944@wrigleys.postgresql.org> (raw)
The following bug has been logged on the website:
Bug reference: 14952
Logged by: Steven Winfield
Email address: steven.winfield@cantabcapital.com
PostgreSQL version: 10.0
Operating system: Linux
Description:
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:
test=# CREATE TABLE identity_test (id bigint GENERATED ALWAYS AS IDENTITY,
name text);
test=# COPY identity_test (name) FROM STDIN;
Enter data to be copied followed by a newline.
End with a backslash and a period on a line by itself, or an EOF signal.
>> foo
>> \.
ERROR: null value in column "id" violates not-null constraint
DETAIL: Failing row contains (null, foo).
CONTEXT: COPY identity_test, line 1: "foo"
Compare this with a serial column:
test=# CREATE TABLE serial_test (id bigserial, name text);
test=# COPY serial_test (name) FROM STDIN;
Enter data to be copied followed by a newline.
End with a backslash and a period on a line by itself, or an EOF signal.
>> foo
>> \.
COPY 1
test=# \d identity_test
Table "public.identity_test"
Column | Type | Collation | Nullable | Default
--------+--------+-----------+----------+------------------------------
id | bigint | | not null | generated always as identity
name | text | | |
test=# \d serial_test
Table "public.serial_test"
Column | Type | Collation | Nullable | Default
--------+--------+-----------+----------+-----------------------------------------
id | bigint | | not null |
nextval('serial_test_id_seq'::regclass)
name | text | | |
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: steven.winfield@cantabcapital.com
Subject: Re: BUG #14952: COPY fails to fill in IDENTITY column default value
In-Reply-To: <20171207112930.21696.79944@wrigleys.postgresql.org>
References: <20171207112930.21696.79944@wrigleys.postgresql.org>
* 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