pgsql: Get rid of ojrelid local variable in remove_rel_from_query() - Mailing list pgsql-committers

From Alexander Korotkov
Subject pgsql: Get rid of ojrelid local variable in remove_rel_from_query()
Date
Msg-id E1tnaBT-000Jvg-2N@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Get rid of ojrelid local variable in remove_rel_from_query()

As spotted by Coverity, the calculation of ojrelid mixes signed and unsigned
types causes possible overflow and undefined behavior.  Instead of trying to
fix the expression, this commit eliminates the relied local variable.  The
explicit branching is used to replace the -1 value.  That, in turn, requires
changing the signature of the remove_rel_from_eclass() function.

Reported-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/914330.1740330169%40sss.pgh.pa.us
Reviewed-by: Andrei Lepikhov <lepihov@gmail.com>

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/e167191dc146b65146fbd32e147be30dd8f1f166

Modified Files
--------------
src/backend/optimizer/plan/analyzejoins.c | 81 ++++++++++++++++++++-----------
1 file changed, 53 insertions(+), 28 deletions(-)


pgsql-committers by date:

Previous
From: Thomas Munro
Date:
Subject: pgsql: Remove arbitrary cap on read_stream.c buffer queue.
Next
From: Tom Lane
Date:
Subject: pgsql: Get rid of O(N^2) script-parsing overhead in pgbench.