aboutsummaryrefslogtreecommitdiff
path: root/src/backend/catalog/index.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/catalog/index.c')
-rw-r--r--src/backend/catalog/index.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c
index 54f807af577..324828561e7 100644
--- a/src/backend/catalog/index.c
+++ b/src/backend/catalog/index.c
@@ -2046,6 +2046,7 @@ index_constraint_create(Relation heapRelation,
HeapTuple indexTuple;
Form_pg_index indexForm;
bool dirty = false;
+ bool marked_as_primary = false;
pg_index = table_open(IndexRelationId, RowExclusiveLock);
@@ -2059,6 +2060,7 @@ index_constraint_create(Relation heapRelation,
{
indexForm->indisprimary = true;
dirty = true;
+ marked_as_primary = true;
}
if (deferrable && indexForm->indimmediate)
@@ -2071,6 +2073,15 @@ index_constraint_create(Relation heapRelation,
{
CatalogTupleUpdate(pg_index, &indexTuple->t_self, indexTuple);
+ /*
+ * When we mark an existing index as primary, force a relcache
+ * flush on its parent table, so that all sessions will become
+ * aware that the table now has a primary key. This is important
+ * because it affects some replication behaviors.
+ */
+ if (marked_as_primary)
+ CacheInvalidateRelcache(heapRelation);
+
InvokeObjectPostAlterHookArg(IndexRelationId, indexRelationId, 0,
InvalidOid, is_internal);
}