Skip to content

Commit e1dd1f9

Browse files
committed
Doc: cover index CONCURRENTLY causing errors in INSERT ... ON CONFLICT.
Author: Mikhail Nikalayeu <mihailnikalayeu@gmail.com> Reviewed-by: Noah Misch <noah@leadboat.com> Discussion: https://postgr.es/m/CANtu0ojXmqjmEzp-=aJSxjsdE76iAsRgHBoK0QtYHimb_mEfsg@mail.gmail.com Backpatch-through: 13
1 parent cd55aba commit e1dd1f9

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

doc/src/sgml/ref/insert.sgml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,15 @@ INSERT INTO <replaceable class="parameter">table_name</replaceable> [ AS <replac
556556
</para>
557557
</tip>
558558

559+
<warning>
560+
<para>
561+
While <command>CREATE INDEX CONCURRENTLY</command> or <command>REINDEX
562+
CONCURRENTLY</command> is running on a unique index, <command>INSERT
563+
... ON CONFLICT</command> statements on the same table may unexpectedly
564+
fail with a unique violation.
565+
</para>
566+
</warning>
567+
559568
</refsect2>
560569
</refsect1>
561570

src/backend/optimizer/util/plancat.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,11 @@ get_relation_foreign_keys(PlannerInfo *root, RelOptInfo *rel,
637637
* the purposes of inference. If no opclass (or collation) is specified, then
638638
* all matching indexes (that may or may not match the default in terms of
639639
* each attribute opclass/collation) are used for inference.
640+
*
641+
* Note: during index CONCURRENTLY operations, different transactions may
642+
* reference different sets of arbiter indexes. This can lead to false unique
643+
* constraint violations that wouldn't occur during normal operations. For
644+
* more information, see insert.sgml.
640645
*/
641646
List *
642647
infer_arbiter_indexes(PlannerInfo *root)

0 commit comments

Comments
 (0)