19
19
#include "aqo.h"
20
20
#include "access/parallel.h"
21
21
#include "optimizer/optimizer.h"
22
+ #include "postgres_fdw.h"
22
23
#include "utils/queryenvironment.h"
23
24
24
25
typedef struct
@@ -544,7 +545,7 @@ aqo_ExecutorEnd(QueryDesc *queryDesc)
544
545
void
545
546
aqo_copy_generic_path_info (PlannerInfo * root , Plan * dest , Path * src )
546
547
{
547
- bool is_join_path ;
548
+ bool is_join_path ;
548
549
549
550
if (prev_copy_generic_path_info_hook )
550
551
prev_copy_generic_path_info_hook (root , dest , src );
@@ -569,6 +570,23 @@ aqo_copy_generic_path_info(PlannerInfo *root, Plan *dest, Path *src)
569
570
dest -> path_clauses = ((JoinPath * ) src )-> joinrestrictinfo ;
570
571
dest -> path_jointype = ((JoinPath * ) src )-> jointype ;
571
572
}
573
+ else if (src -> type == T_ForeignPath )
574
+ {
575
+ ForeignPath * fpath = (ForeignPath * ) src ;
576
+ PgFdwRelationInfo * fpinfo = (PgFdwRelationInfo * ) fpath -> path .parent -> fdw_private ;
577
+
578
+ /*
579
+ * Pushed down foreign join keeps clauses in special fdw_private
580
+ * structure.
581
+ * I'm not sure what fpinfo structure keeps clauses for sufficient time.
582
+ * So, copy clauses.
583
+ */
584
+ dest -> path_clauses = list_concat (list_copy (fpinfo -> joinclauses ),
585
+ list_copy (fpinfo -> remote_conds ));
586
+ dest -> path_clauses = list_concat (dest -> path_clauses ,
587
+ list_copy (fpinfo -> local_conds ));
588
+ dest -> path_jointype = ((JoinPath * ) src )-> jointype ;
589
+ }
572
590
else
573
591
{
574
592
dest -> path_clauses = list_concat (
0 commit comments