public inbox for [email protected]
help / color / mirror / Atom feedFrom: Alvaro Herrera <[email protected]>
Subject: [PATCH v13 1/2] Remember PK oid for partitioned tables even when it's invalid
Date: Wed, 12 Jul 2023 18:57:28 +0200
---
src/backend/utils/cache/relcache.c | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 8a08463c2b..b5a99b4edc 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -4788,19 +4788,28 @@ RelationGetIndexList(Relation relation)
result = lappend_oid(result, index->indexrelid);
/*
- * Invalid, non-unique, non-immediate or predicate indexes aren't
- * interesting for either oid indexes or replication identity indexes,
- * so don't check them.
+ * Non-unique, non-immediate or predicate indexes aren't interesting
+ * for either oid indexes or replication identity indexes, so don't
+ * check them.
*/
- if (!index->indisvalid || !index->indisunique ||
+ if (!index->indisunique ||
!index->indimmediate ||
!heap_attisnull(htup, Anum_pg_index_indpred, NULL))
continue;
- /* remember primary key index if any */
- if (index->indisprimary)
+ /*
+ * Remember primary key index, if any. We do this only if the index
+ * is valid; but if the table is partitioned, then we do it even if
+ * it's invalid. XXX does this cause other problems?
+ */
+ if (index->indisprimary &&
+ (index->indisvalid ||
+ relation->rd_rel->relkind == RELKIND_PARTITIONED_TABLE))
pkeyIndex = index->indexrelid;
+ if (!index->indisvalid)
+ continue;
+
/* remember explicitly chosen replica index */
if (index->indisreplident)
candidateIndex = index->indexrelid;
--
2.39.2
--57gotikuhuh4be5c
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
filename="v13-0002-Add-pg_constraint-rows-for-NOT-NULL-constraints.patch"
view thread (12+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected]
Subject: Re: [PATCH v13 1/2] Remember PK oid for partitioned tables even when it's invalid
In-Reply-To: <no-message-id-1856825@localhost>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox