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

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: gatekeeper(dot)mail(at)gmail(dot)com
Subject: BUG #16714: INSERT ON CONFLICT DO UPDATE fails to infer constraint if it's not at top-level partition
Date: 2020-11-13 03:23:43
Message-ID: 16714-dbf5759eba70bfe4@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 16714
Logged by: Andy S
Email address: gatekeeper(dot)mail(at)gmail(dot)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

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message 范孝剑 (康贤) 2020-11-13 06:06:20 回复:SnapBuildSerialize function forgot pfree variable ondisk_c
Previous Message Bruce Momjian 2020-11-12 17:29:12 Re: BUG #16713: Can't load server