Improve RelationGetIdentityKeyBitmap().
authorAmit Kapila <akapila@postgresql.org>
Mon, 28 Jun 2021 05:26:53 +0000 (10:56 +0530)
committerAmit Kapila <akapila@postgresql.org>
Mon, 28 Jun 2021 05:26:53 +0000 (10:56 +0530)
We were using RelationGetIndexList() to update the relation's replica
identity index but instead, we can directly use RelationGetReplicaIndex()
which uses the same functionality. This is a minor code readability
improvement.

Author: Japin Li
Reviewed-By: Takamichi Osumi, Amit Kapila
Discussion: https://postgr.es/m/4C99A862-69C8-431F-960A-81B1151F1B89@enterprisedb.com

src/backend/utils/cache/relcache.c

index d55ae016d090a37c1847e388cc77ea7eeeb4ab7c..94fbf1aa190c42cf77e2ce494da2bd92488fb9f2 100644 (file)
@@ -5244,9 +5244,9 @@ Bitmapset *
 RelationGetIdentityKeyBitmap(Relation relation)
 {
        Bitmapset  *idindexattrs = NULL;        /* columns in the replica identity */
-       List       *indexoidlist;
        Relation        indexDesc;
        int                     i;
+       Oid                     replidindex;
        MemoryContext oldcxt;
 
        /* Quick exit if we already computed the result */
@@ -5260,18 +5260,14 @@ RelationGetIdentityKeyBitmap(Relation relation)
        /* Historic snapshot must be set. */
        Assert(HistoricSnapshotActive());
 
-       indexoidlist = RelationGetIndexList(relation);
-
-       /* Fall out if no indexes (but relhasindex was set) */
-       if (indexoidlist == NIL)
-               return NULL;
+       replidindex = RelationGetReplicaIndex(relation);
 
        /* Fall out if there is no replica identity index */
-       if (!OidIsValid(relation->rd_replidindex))
+       if (!OidIsValid(replidindex))
                return NULL;
 
        /* Look up the description for the replica identity index */
-       indexDesc = RelationIdGetRelation(relation->rd_replidindex);
+       indexDesc = RelationIdGetRelation(replidindex);
 
        if (!RelationIsValid(indexDesc))
                elog(ERROR, "could not open relation with OID %u",
@@ -5295,7 +5291,6 @@ RelationGetIdentityKeyBitmap(Relation relation)
        }
 
        RelationClose(indexDesc);
-       list_free(indexoidlist);
 
        /* Don't leak the old values of these bitmaps, if any */
        bms_free(relation->rd_idattr);