From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Michael Paquier <michael(at)paquier(dot)xyz> |
Cc: | Richard Guo <guofenglinux(at)gmail(dot)com>, postgresql(at)middaysomewhere(dot)com, Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>, PostgreSQL mailing lists <pgsql-bugs(at)lists(dot)postgresql(dot)org> |
Subject: | Re: BUG #17558: 15beta2: Endless loop with UNIQUE NULLS NOT DISTINCT and INSERT ... ON CONFLICT |
Date: | 2022-08-04 17:17:48 |
Message-ID: | 3566362.1659633468@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
Michael Paquier <michael(at)paquier(dot)xyz> writes:
> On Tue, Jul 26, 2022 at 11:17:45AM +0800, Richard Guo wrote:
>> Yeah, I can see the same problem. _bt_check_unique() can catch violation
>> of unique index constraint successfully, so insert without 'ON CONFLICT'
>> has no problem. But ExecCheckIndexConstraints() fails to tell the NULL
>> tuple violates unique constraint, and the logic below is quite
>> suspicious to me.
> This is still an open item assigned to Peter, and beta3 is planned for
> the 11th of August. Would a resolution by the beginning of next week
> be doable?
Since nothing seems to be happening here, I looked into it. I think
Richard has correctly fingered the buggy code: we need to teach
check_exclusion_or_unique_constraint() that a NULL isn't necessarily
an instant pass. As attached.
Since the presented test case caused an uninterruptible loop, I also added
a CHECK_FOR_INTERRUPTS() that could stop it. (I was initially pretty
surprised that we could get through an index scan without hitting any CFI,
but on reflection it's less surprising, because no index scan actually
happens: check_exclusion_or_unique_constraint() short-circuits things
before very much code has been reached.) I'm kind of inclined to
back-patch the nodeModifyTable.c change all the way, just for safety.
regards, tom lane
Attachment | Content-Type | Size |
---|---|---|
fix-infinite-loop-in-ON-CONFLICT.patch | text/x-diff | 3.8 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Julien Rouhaud | 2022-08-04 17:26:09 | Re: BUG #17571: PostgreSQL 15b2 ICU collation defined at db level sorts differently in collate clause vs implicit |
Previous Message | Daniel Halsey | 2022-08-04 15:59:12 | RE: BUG #17571: PostgreSQL 15b2 ICU collation defined at db level sorts differently in collate clause vs implicit |