> Here is the updated version, which includes the restructuring you proposed.
> Other than the above issue and the alias issue we discussed, I addressed all
> your comments except one on testing; I tried to add test cases where the
> remote query is deparsed as nested subqueries, but I couldn't because IIUC,
> reduce_outer_joins reduced full joins to inner joins or left joins.
No always. It will do so in some cases as explained in the prologue of
reduce_outer_joins()
* More generally, an outer join can be reduced in strength if there is a* strict qual above it in the qual tree that
constrainsa Var from the* nullable side of the join to be non-null. (For FULL joins this applies* to each side
separately.)
> So, I
> added two test cases: (1) the joining relations are both base relations
> (actually, we already have that) and (2) one of the joining relations is a
> base relation and the other is a join relation. I rebased the patch to
> HEAD, so I added a test case with aggregate pushdown also.
>
This patch again has a lot of unrelated changes, esp. in
deparseSelectStmtForRel(). What was earlier part of deparseSelectSql()
and deparseFromExpr() is now flattened in deparseSelectStmtForRel(),
which seems unnecessary. Or there are changes like
-deparseSelectStmtForRel(StringInfo buf, PlannerInfo *root, RelOptInfo *rel,
- List *tlist, List *remote_conds, List *pathkeys,
+deparseSelectStmtForRel(StringInfo buf, PlannerInfo *root,
+ RelOptInfo *foreignrel, List *tlist,
+ List *remote_conds, List *pathkeys,
which arise because rel has been renamed as foreignrel. The patch will
work even without such renaming.
I think such refactoring, should be done in a separate patch.
--
Best Wishes,
Ashutosh Bapat
EnterpriseDB Corporation
The Postgres Database Company