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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: gatekeeper(dot)mail(at)gmail(dot)com
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #16714: INSERT ON CONFLICT DO UPDATE fails to infer constraint if it's not at top-level partition
Date: 2020-11-13 16:03:17
Message-ID: 288078.1605283397@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

PG Bug reporting form <noreply(at)postgresql(dot)org> writes:
> 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

I see no bug here. The partitioned table indeed does not have any
such index. Moreover, if you had tried to make one, you would have
gotten

ERROR: unique constraint on partitioned table must include all partitioning columns
DETAIL: PRIMARY KEY constraint on table "tbl" lacks column "part_key1" which is part of the partition key.

The short answer here is that uniqueness constraints on the individual
partitions are not a substitute for a constraint on the whole partitioned
table.

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2020-11-13 16:11:42 BUG #16716: postgresql11-devel pckage from Refreshing service 'spacewalk' complains about missing
Previous Message 范孝剑 (康贤) 2020-11-13 06:06:20 回复:SnapBuildSerialize function forgot pfree variable ondisk_c