Insecure initialization of required_relids field - Mailing list pgsql-hackers

From Andrey Lepikhov
Subject Insecure initialization of required_relids field
Date
Msg-id 5c21029d-81a2-c999-6744-6a898fcc9a19@postgrespro.ru
Whole thread Raw
Responses Re: Insecure initialization of required_relids field  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Hi,

commit a31ad27fc5d introduced required_relids field. By default, it 
links to the clause_relids.
It works good while we do not modify clause_relids or required_relids.
But in the case of modification such initialization demands us to 
remember, that this field is shared. And we need to do bms_copy() before 
making any changes (see [1] for example).
Also, we make some changes of the RestrictInfo fields (see patch [2]) 
during removing of unneeded self joins.
I propose to do more secure initialization way of required_relids (see 
patch in attachment).

[1] commit 4e97631e6a9, analyzejoins.c, line 434,435:
rinfo->required_relids = bms_copy(rinfo->required_relids);
rinfo->required_relids = bms_del_member(rinfo->required_relids, relid);
[2] https://commitfest.postgresql.org/23/1712/

-- 
Andrey Lepikhov
Postgres Professional
https://postgrespro.com
The Russian Postgres Company

Attachment

pgsql-hackers by date:

Previous
From: Edmund Horner
Date:
Subject: Re: Tid scan improvements
Next
From: Konstantin Knizhnik
Date:
Subject: Re: Built-in connection pooler