GetRelationPublicationActions. - Remove unreachable code - Mailing list pgsql-hackers

From Peter Smith
Subject GetRelationPublicationActions. - Remove unreachable code
Date
Msg-id CAHut+Pv8t3-pXg4L48=5cdy=FMK3EubdpSq6ESgLGVNp8hLx4A@mail.gmail.com
Whole thread Raw
Responses Re: GetRelationPublicationActions. - Remove unreachable code
List pgsql-hackers
Hi hackers.

There appears to be some unreachable code in the relcache function
GetRelationPublicationActions.

When the 'relation->rd_pubactions' is not NULL then the function
unconditionally returns early (near the top).

Therefore, the following code (near the bottom) seems to have no
purpose because IIUC the 'rd_pubactions' can never be not NULL here.

if (relation->rd_pubactions)
{
pfree(relation->rd_pubactions);
relation->rd_pubactions = NULL;
}

The latest Code Coverage report [1] also shows that this code is never executed.

    5601        3556 :     if (relation->rd_pubactions)
    5602             :     {
    5603           0 :         pfree(relation->rd_pubactions);
    5604           0 :         relation->rd_pubactions = NULL;
    5605             :     }

~~

PSA a patch to remove this unreachable code.

------
[1] https://coverage.postgresql.org/src/backend/utils/cache/relcache.c.gcov.html

Kind Regards,
Peter Smith.
Fujitsu Australia

Attachment

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: catalog access with reset GUCs during parallel worker startup
Next
From: Andres Freund
Date:
Subject: Re: catalog access with reset GUCs during parallel worker startup