BUG #16714: INSERT ON CONFLICT DO UPDATE fails to infer constraint if it's not at top-level partition - Mailing list pgsql-bugs

From PG Bug reporting form
Subject BUG #16714: INSERT ON CONFLICT DO UPDATE fails to infer constraint if it's not at top-level partition
Date
Msg-id 16714-dbf5759eba70bfe4@postgresql.org
Whole thread Raw
Responses Re: BUG #16714: INSERT ON CONFLICT DO UPDATE fails to infer constraint if it's not at top-level partition
List pgsql-bugs
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


pgsql-bugs by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: BUG #16713: Can't load server
Next
From: "范孝剑(康贤)"
Date:
Subject: 回复:SnapBuildSerialize function forgot pfree variable ondisk_c