Re: Avoid unncessary always true test (src/backend/storage/buffer/bufmgr.c)

Поиск
Список
Период
Сортировка
От Ranier Vilela
Тема Re: Avoid unncessary always true test (src/backend/storage/buffer/bufmgr.c)
Дата
Msg-id CAEudQArD04043ahRO_9mXiYSfhvsac4SSyskUVk5PTm73Ab24A@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Avoid unncessary always true test (src/backend/storage/buffer/bufmgr.c)  (Richard Guo <guofenglinux@gmail.com>)
Ответы Re: Avoid unncessary always true test (src/backend/storage/buffer/bufmgr.c)  (Ranier Vilela <ranier.vf@gmail.com>)
Список pgsql-hackers
Em dom., 4 de jun. de 2023 às 23:37, Richard Guo <guofenglinux@gmail.com> escreveu:

On Sun, Jun 4, 2023 at 8:42 PM Ranier Vilela <ranier.vf@gmail.com> wrote:
Hi,

Per Coverity.

At function ExtendBufferedRelShared, has a always true test.
eb.rel was dereferenced one line above, so in
if (eb.rel) is always true.

I think it's worth removing the test, because Coverity raises dozens of alerts thinking eb.rel might be NULL.
Besides, one less test is one less branch.

This also happens in ExtendBufferedRelTo, and the comment there explains
that the eb.rel 'could have been closed while waiting for lock'.
Well, RelationGetSmgr also dereferences eb.rel.
If eb.rel could be closed while waiting for lock,
anyone who references eb.rel below takes a risk?
 
static inline SMgrRelation
RelationGetSmgr(Relation rel)
{
if (unlikely(rel->rd_smgr == NULL))
smgrsetowner(&(rel->rd_smgr), smgropen(rel->rd_locator, rel->rd_backend));
return rel->rd_smgr;
}

regards,
Ranier Vilela

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

Предыдущее
От: Masahiko Sawada
Дата:
Сообщение: Re: [PoC] Improve dead tuple storage for lazy vacuum
Следующее
От: "Yu Shi (Fujitsu)"
Дата:
Сообщение: RE: [PATCH] Reuse Workers and Replication Slots during Logical Replication