Re: Routed ON CONFLICT inserts broken by partition-local deferrable unique constraints in 19 and master - Mailing list pgsql-hackers

From Dmitry Dolgov
Subject Re: Routed ON CONFLICT inserts broken by partition-local deferrable unique constraints in 19 and master
Date
Msg-id aqsArQmqLrDOo02Z@ddolgov-thinkpadt14sgen1.rmtde.csb
Whole thread
In response to Routed ON CONFLICT inserts broken by partition-local deferrable unique constraints in 19 and master  (Zsolt Parragi <zsolt.parragi@percona.com>)
Responses Re: Routed ON CONFLICT inserts broken by partition-local deferrable unique constraints in 19 and master
List pgsql-hackers
> On Tue, Sep 01, 2026 at 11:15:09AM +0200, Mihail Nikalayeu wrote:
> > 2bc7e886fc1 and the commit that has triggered this thread both refer
> > to the same set of improvements regarding the interactions of rebuilt
> > indexes and ON CONFLICT, so my take is that if we finish by updating
> > the same area of the code we could just group both changes together,
> > but I agree that my line of thoughts may be thin.  It seems to me that
> > we'd better look first at this secondary issue before drawing a
> > conclusion regarding if both issues should be handled together or
> > separately.
> 
> This is a "grouped" version. Also, it handles possible collation
> issues + provides a set of tests to pin the correct behaviour.

+/*
+ * IsIndexCompatibleAsArbiter
+ *        Return true if two indexes of the same table are interchangeable as
+ *        speculative insertion arbiters for INSERT ON CONFLICT.
+ *
+ * To be interchangeable, the two indexes must agree on which tuples conflict,

[...]

+    /* number of key attributes must match */
+    if (indexForm1->indnkeyatts != indexForm2->indnkeyatts)
+        return false;

I see that it was like this in the original commit, but isn't it too
restrictive regarding the goal stated in the function comment? If say
there are two unique indexes on columns (a), and (a, b), they have the
same understanding of what tuples will conflict, but the latter one will
not be used as an arbiter index. To be fair, I don't see how this may
become problem in practice, but still.



pgsql-hackers by date:

Previous
From: Andrey Rachitskiy
Date:
Subject: [PATCH] Catch croak during PL/Perl result conversion
Next
From: Masahiko Sawada
Date:
Subject: Re: [PATCH] Release replication slot on error in SQL-callable slot functions