Re: GetRelationPublicationActions. - Remove unreachable code

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: GetRelationPublicationActions. - Remove unreachable code
Дата
Msg-id 1524753.1644453267@sss.pgh.pa.us
обсуждение исходный текст
Ответ на GetRelationPublicationActions. - Remove unreachable code  (Peter Smith <smithpb2250@gmail.com>)
Ответы Re: GetRelationPublicationActions. - Remove unreachable code  (Peter Smith <smithpb2250@gmail.com>)
Список pgsql-hackers
Peter Smith <smithpb2250@gmail.com> writes:
> 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.

I'm not sure it's as unreachable as all that.  What you're not
accounting for is the possibility of recursive cache loading,
ie something down inside the catalog fetches we have to do here
could already have made the field valid.

Admittedly, that's probably not very likely given expected usage
patterns (to wit, that system catalogs shouldn't really have
publication actions).  But there are other places in relcache.c where
a coding pattern similar to this is demonstrably necessary to avoid
memory leakage.  I'd rather leave the code as-is, maybe add a comment
along the lines of "rd_pubactions is probably still NULL, but just in
case something already made it valid, avoid leaking memory".

            regards, tom lane



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Andres Freund
Дата:
Сообщение: Re: catalog access with reset GUCs during parallel worker startup
Следующее
От: Peter Smith
Дата:
Сообщение: Re: row filtering for logical replication