public inbox for [email protected]
help / color / mirror / Atom feedFrom: Ranier Vilela <[email protected]>
To: Richard Guo <[email protected]>
Cc: Pg Hackers <[email protected]>
Subject: Re: Avoid unncessary always true test (src/backend/storage/buffer/bufmgr.c)
Date: Mon, 5 Jun 2023 08:06:26 -0300
Message-ID: <CAEudQArD04043ahRO_9mXiYSfhvsac4SSyskUVk5PTm73Ab24A@mail.gmail.com> (raw)
In-Reply-To: <CAMbWs4_Jv4p_ib2ZZvUYhgoeSpOABjAW_4chkAhrSU=iW8CRGA@mail.gmail.com>
References: <CAEudQAoSA7saBF7RaoYbRjE+Zojojin0Qc9A4hebPKB8o1J+EQ@mail.gmail.com>
<CAMbWs4_Jv4p_ib2ZZvUYhgoeSpOABjAW_4chkAhrSU=iW8CRGA@mail.gmail.com>
Em dom., 4 de jun. de 2023 às 23:37, Richard Guo <[email protected]>
escreveu:
>
> On Sun, Jun 4, 2023 at 8:42 PM Ranier Vilela <[email protected]> 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
view thread (11+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected]
Subject: Re: Avoid unncessary always true test (src/backend/storage/buffer/bufmgr.c)
In-Reply-To: <CAEudQArD04043ahRO_9mXiYSfhvsac4SSyskUVk5PTm73Ab24A@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox