Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 96cf83e

Browse files
committed
Add support of postgres_fdw push-down.
1 parent c7e5bd3 commit 96cf83e

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ REGRESS = aqo_disabled \
1616
schema \
1717
aqo_CVE-2020-14350
1818

19+
fdw_srcdir = $(top_srcdir)/contrib/postgres_fdw
20+
PG_CPPFLAGS += -I$(libpq_srcdir) -I$(fdw_srcdir)
1921
EXTRA_REGRESS_OPTS=--temp-config=$(top_srcdir)/$(subdir)/conf.add
2022

2123
DATA = aqo--1.0.sql aqo--1.0--1.1.sql aqo--1.1--1.2.sql aqo--1.2.sql

postprocessing.c

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "aqo.h"
2020
#include "access/parallel.h"
2121
#include "optimizer/optimizer.h"
22+
#include "postgres_fdw.h"
2223
#include "utils/queryenvironment.h"
2324

2425
typedef struct
@@ -544,7 +545,7 @@ aqo_ExecutorEnd(QueryDesc *queryDesc)
544545
void
545546
aqo_copy_generic_path_info(PlannerInfo *root, Plan *dest, Path *src)
546547
{
547-
bool is_join_path;
548+
bool is_join_path;
548549

549550
if (prev_copy_generic_path_info_hook)
550551
prev_copy_generic_path_info_hook(root, dest, src);
@@ -569,6 +570,23 @@ aqo_copy_generic_path_info(PlannerInfo *root, Plan *dest, Path *src)
569570
dest->path_clauses = ((JoinPath *) src)->joinrestrictinfo;
570571
dest->path_jointype = ((JoinPath *) src)->jointype;
571572
}
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+
}
572590
else
573591
{
574592
dest->path_clauses = list_concat(

0 commit comments

Comments
 (0)