pgsql: Fix ON CONFLICT ON CONSTRAINT during REINDEX CONCURRENTLY - Mailing list pgsql-committers

From Álvaro Herrera
Subject pgsql: Fix ON CONFLICT ON CONSTRAINT during REINDEX CONCURRENTLY
Date
Msg-id E1vQ6rP-002Inv-0j@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Fix ON CONFLICT ON CONSTRAINT during REINDEX CONCURRENTLY

When REINDEX CONCURRENTLY is processing the index that supports a
constraint, there are periods during which multiple indexes match the
constraint index's definition.  Those must all be included in the set of
inferred index for INSERT ON CONFLICT, in order to avoid spurious
"duplicate key" errors.

To fix, we set things up to match all indexes against attributes,
expressions and predicates of the constraint index, then return all
indexes that match those, rather than just the one constraint index.
This is more onerous than before, where we would just test the named
constraint for validity, but it's not more onerous than processing
"conventional" inference (where a list of attribute names etc is given).

This is closely related to the misbehaviors fixed by bc32a12e0db2, for a
different situation.  We're not backpatching this one for now either,
for the same reasons.

Author: Mihail Nikalayeu <mihailnikalayeu@gmail.com>
Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de>
Discussion: https://postgr.es/m/CANtu0ojXmqjmEzp-=aJSxjsdE76iAsRgHBoK0QtYHimb_mEfsg@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/2bc7e886fc1baaeee3987a141bff3ac490037d12

Modified Files
--------------
src/backend/optimizer/util/plancat.c               | 187 ++++++++++++----
src/test/modules/injection_points/Makefile         |   1 +
.../reindex-concurrently-upsert-on-constraint.out  | 238 +++++++++++++++++++++
src/test/modules/injection_points/meson.build      |   1 +
.../reindex-concurrently-upsert-on-constraint.spec | 110 ++++++++++
5 files changed, 490 insertions(+), 47 deletions(-)


pgsql-committers by date:

Previous
From: Peter Eisentraut
Date:
Subject: pgsql: Fix a strict aliasing violation
Next
From: Jeff Davis
Date:
Subject: pgsql: Make regex "max_chr" depend on encoding, not provider.