nbtpage.c:356 Expression 'metad->btm_root != P_NONE' is always false.

From: Антон Пацев <patsev(dot)anton(at)gmail(dot)com>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: nbtpage.c:356 Expression 'metad->btm_root != P_NONE' is always false.
Date: 2020-10-07 02:31:15
Message-ID: CAOx4deojaPzpUo__yS-yV2mDeX_F5qvGfaf7r42ugx2TkZHfNQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello!
I am trying to help for Project PostgreSQL. Check source code PostgreSQL by
PVS-Studio.
PVS-Studio have many issue, but some issue is interesting.
nbtpage.c:356 <http://localhost/sources/nbtpage.c_24.html#ln356> *High* V547
<https://www.viva64.com/en/w/v547/> Expression 'metad->btm_root != 0' is
always false.
Source file src/backend/access/nbtree/nbtpage.c

if (metad->btm_root == P_NONE)
{
Page metapg;
/* If access = BT_READ, caller doesn't want us to create root yet */
if (access == BT_READ)
{
_bt_relbuf(rel, metabuf);
return InvalidBuffer;
}
/* trade in our read lock for a write lock */
_bt_unlockbuf(rel, metabuf);
_bt_lockbuf(rel, metabuf, BT_WRITE);
/*
* Race condition: if someone else initialized the metadata between
* the time we released the read lock and acquired the write lock, we
* must avoid doing it again.
*/
if (metad->btm_root != P_NONE)

↑ V547 <https://www.viva64.com/en/w/v547/> Expression 'metad->btm_root !=
0' is always false.

--
С уважением, Антон Пацев.
Best regards, Anton Patsev.

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2020-10-07 02:51:54 Re: nbtpage.c:356 Expression 'metad->btm_root != P_NONE' is always false.
Previous Message Bharath Rupireddy 2020-10-07 02:30:32 Re: Use standard SIGHUP and SIGTERM handlers in autoprewarm module