1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-15 19:21:59 +03:00

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
This commit is contained in:
Amit Kapila
2021-06-19 11:30:33 +05:30
parent 3499df0dee
commit 2731ce1bd5
2 changed files with 26 additions and 3 deletions

View File

@ -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];