Fixes for ChangeVarNodes_walker()

This commit fixes two bug in ChangeVarNodes_walker() function.

 * When considering RestrictInfo, walk down to its clauses based on the
   presense of relid to be deleted not just in clause_relids but also in
   required_relids.

 * Incrementally adjust num_base_rels based on the change of clause_relids
   instead of recalculating it using clause_relids, which could contain
   outer-join relids.

Reported-by: Richard Guo <guofengli...@gmail.com>
Discussion: 
https://postgr.es/m/CAMbWs49PE3CvnV8vrQ0Dr%3DHqgZZmX0tdNbzVNJxqc8yg-8kDQQ%40mail.gmail.com
Author: Andrei Lepikhov <lepi...@gmail.com>
Reviewed-by: Alexander Korotkov <aekorot...@gmail.com>

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/2260c7f6d90ecf76d3806d32890a0890688b41e8

Modified Files
--------------
src/backend/rewrite/rewriteManip.c | 28 ++++++++++++++++++++++++----
src/test/regress/expected/join.out | 16 +++++++++++++++-
src/test/regress/sql/join.sql      |  8 +++++++-
3 files changed, 46 insertions(+), 6 deletions(-)

Reply via email to