| From: | Álvaro Herrera <alvherre(at)kurilemu(dot)de> |
|---|---|
| To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
| Subject: | pgsql: Fix ON CONFLICT ON CONSTRAINT during REINDEX CONCURRENTLY |
| Date: | 2025-12-01 16:34:47 |
| Message-ID: | E1vQ6rP-002Inv-0j@gemulon.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | 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(at)gmail(dot)com>
Reviewed-by: Álvaro Herrera <alvherre(at)kurilemu(dot)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(-)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Jeff Davis | 2025-12-01 19:09:19 | pgsql: Change some callers to use pg_ascii_toupper(). |
| Previous Message | Peter Eisentraut | 2025-12-01 15:46:48 | pgsql: Fix a strict aliasing violation |