Instead of using 'if' and creating a special case here can't we do something in the above switch?
I thought about that too. IIRC I did not do it in that way because postgresGetForeignPlan expects that there is no scan_clauses for a join rel. So doing that would trigger the Assert there.
/* * For a join rel, baserestrictinfo is NIL and we are not considering * parameterization right now, so there should be no scan_clauses for * a joinrel or an upper rel either. */ Assert(!scan_clauses);