aboutsummaryrefslogtreecommitdiff
path: root/src/backend
diff options
context:
space:
mode:
authorAmit Kapila <akapila@postgresql.org>2021-06-19 11:30:33 +0530
committerAmit Kapila <akapila@postgresql.org>2021-06-19 11:36:33 +0530
commit2731ce1bd550d08f3fdd7bcb1497af4b95170976 (patch)
treebca3a0edd6e3af0085dfa9f642529937b5c9d0b6 /src/backend
parent3499df0dee8c4ea51d264a674df5b5e31991319a (diff)
downloadpostgresql-2731ce1bd550d08f3fdd7bcb1497af4b95170976.tar.gz
postgresql-2731ce1bd550d08f3fdd7bcb1497af4b95170976.zip
Handle no replica identity index case in RelationGetIdentityKeyBitmap.
Commit e7eea52b2d has introduced a new function RelationGetIdentityKeyBitmap which omits to handle the case where there is no replica identity index on a relation. Author: Mark Dilger Reviewed-by: Takamichi Osumi, Amit Kapila Discussion: https://www.postgresql.org/message-id/4C99A862-69C8-431F-960A-81B1151F1B89@enterprisedb.com
Diffstat (limited to 'src/backend')
-rw-r--r--src/backend/utils/cache/relcache.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index fd05615e769..d55ae016d09 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -5266,8 +5266,18 @@ RelationGetIdentityKeyBitmap(Relation relation)
if (indexoidlist == NIL)
return NULL;
- /* Add referenced attributes to idindexattrs */
+ /* Fall out if there is no replica identity index */
+ if (!OidIsValid(relation->rd_replidindex))
+ return NULL;
+
+ /* Look up the description for the replica identity index */
indexDesc = RelationIdGetRelation(relation->rd_replidindex);
+
+ if (!RelationIsValid(indexDesc))
+ elog(ERROR, "could not open relation with OID %u",
+ relation->rd_replidindex);
+
+ /* Add referenced attributes to idindexattrs */
for (i = 0; i < indexDesc->rd_index->indnatts; i++)
{
int attrnum = indexDesc->rd_index->indkey.values[i];