Hello,

The attached small patch is what I have in mind now.

fdwroutine->ExecForeignScan may be unset if the FDW does nothing
special. And all the FDW routine needs is the node.

> Subject: [PATCH] Allow substitute ExecScan body for ExecForignScan
> 
> ForeignScan node may return joined tuple. This joined tuple cannot be
> handled properly by ExecScan during EQP recheck. This patch allows
> FDWs to give a special treat to such tuples.

regards,


> > One thing I can agree is, ForeignScan is enforced to use ExecScan,
> > thus some FDW driver may concern about this hard-wired logic.
> > If we try to make ForeignScan unbound from the ExecScan, I like to
> > suggest to revise ExecForeignScan, just invoke a callback; then
> > FDW driver can choose whether ExecScan is best or not.
> 
> Agreed. Calling ExecScan unconditionally from ForeignScan is the
> cause of the root(?) cause I mentioned. Since there'd be no
> difference in data structure between Foreign(Join&Node), calling
> fdwroutine->ExecForeignScan() or something instaed of ExecScan()
> from ExecForeignScan could be the alternative and most promising
> solution for all problems in focus now.

-- 
Kyotaro Horiguchi
NTT Open Source Software Center
>From cddbb29bf09e33af38bc7690d1b78f4e20f363b3 Mon Sep 17 00:00:00 2001
From: Kyotaro Horiguchi <horiguchi.kyot...@lab.ntt.co.jp>
Date: Fri, 6 Nov 2015 13:23:55 +0900
Subject: [PATCH] Allow substitute ExecScan body for ExecForignScan

ForeignScan node may return joined tuple. This joined tuple cannot be
handled properly by ExecScan during EQP recheck. This patch allows
FDWs to give a special treat to such tuples.
---
 src/backend/executor/nodeForeignscan.c | 3 +++
 src/include/foreign/fdwapi.h           | 3 +++
 2 files changed, 6 insertions(+)

diff --git a/src/backend/executor/nodeForeignscan.c b/src/backend/executor/nodeForeignscan.c
index 6165e4a..f43a50b 100644
--- a/src/backend/executor/nodeForeignscan.c
+++ b/src/backend/executor/nodeForeignscan.c
@@ -100,6 +100,9 @@ ForeignRecheck(ForeignScanState *node, TupleTableSlot *slot)
 TupleTableSlot *
 ExecForeignScan(ForeignScanState *node)
 {
+	if (node->fdwroutine->ExecForeignScan)
+		return node->fdwroutine->ExecForeignScan(node);
+
 	return ExecScan((ScanState *) node,
 					(ExecScanAccessMtd) ForeignNext,
 					(ExecScanRecheckMtd) ForeignRecheck);
diff --git a/src/include/foreign/fdwapi.h b/src/include/foreign/fdwapi.h
index 69b48b4..564898d 100644
--- a/src/include/foreign/fdwapi.h
+++ b/src/include/foreign/fdwapi.h
@@ -41,6 +41,8 @@ typedef ForeignScan *(*GetForeignPlan_function) (PlannerInfo *root,
 typedef void (*BeginForeignScan_function) (ForeignScanState *node,
 													   int eflags);
 
+typedef TupleTableSlot *(*ExecForeignScan_function) (ForeignScanState *node);
+
 typedef TupleTableSlot *(*IterateForeignScan_function) (ForeignScanState *node);
 
 typedef void (*ReScanForeignScan_function) (ForeignScanState *node);
@@ -137,6 +139,7 @@ typedef struct FdwRoutine
 	GetForeignPaths_function GetForeignPaths;
 	GetForeignPlan_function GetForeignPlan;
 	BeginForeignScan_function BeginForeignScan;
+	ExecForeignScan_function ExecForeignScan;
 	IterateForeignScan_function IterateForeignScan;
 	ReScanForeignScan_function ReScanForeignScan;
 	EndForeignScan_function EndForeignScan;
-- 
1.8.3.1

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to