From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: gatekeeper.mail@gmail.com
Subject: BUG #16714: INSERT ON CONFLICT DO UPDATE fails to infer constraint if it's not at top-level partition
Date: Fri, 13 Nov 2020 03:23:43 +0000
Message-ID: <16714-dbf5759eba70bfe4@postgresql.org> (raw)
The following bug has been logged on the website:
Bug reference: 16714
Logged by: Andy S
Email address: gatekeeper.mail@gmail.com
PostgreSQL version: 11.2
Operating system: Gentoo Linux
Description:
create table tbl (
part_key1 int,
part_key2 int,
part_key3 int,
part_key4 int,
values_columns varchar
) partition by list(part_key1);
create table tbl_p1 partition of tbl for values in (1) partition by
list(part_key2);
create table tbl_p1_p2 partition of tbl_p1 for values in (1) partition by
range (part_key3);
create table tbl_p1_p2_p3 partition of tbl_p1_p2 for values from (0) to
(100) partition by HASH(part_key4);
create table tbl_p1_p2_p3_p4_0 partition of tbl_p1_p2_p3 (constraint
tbl_p1_p2_p3_0_pkey primary key (part_key4)) for values with (modulus 4,
remainder 0);
create table tbl_p1_p2_p3_p4_1 partition of tbl_p1_p2_p3 (constraint
tbl_p1_p2_p3_1_pkey primary key (part_key4)) for values with (modulus 4,
remainder 1);
create table tbl_p1_p2_p3_p4_2 partition of tbl_p1_p2_p3 (constraint
tbl_p1_p2_p3_2_pkey primary key (part_key4)) for values with (modulus 4,
remainder 2);
create table tbl_p1_p2_p3_p4_3 partition of tbl_p1_p2_p3 (constraint
tbl_p1_p2_p3_3_pkey primary key (part_key4)) for values with (modulus 4,
remainder 3);
insert into tbl values (1, 1, 1, 1, 'a');
insert into tbl values (1, 1, 1, 1, 'b');
-- ERROR: duplicate key value violates unique constraint
"tbl_p1_p2_p3_0_pkey"
-- DETAIL: Key (part_key4)=(1) already exists.
insert into tbl values (1, 1, 1, 1, 'b') on conflict (part_key4) do update
set values_columns = excluded.values_columns;
-- ERROR: there is no unique or exclusion constraint matching the ON
CONFLICT specification
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 using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: noreply@postgresql.org, pgsql-bugs@lists.postgresql.org, gatekeeper.mail@gmail.com
Subject: Re: BUG #16714: INSERT ON CONFLICT DO UPDATE fails to infer constraint if it's not at top-level partition
In-Reply-To: <16714-dbf5759eba70bfe4@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