1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-26 01:22:12 +03:00

Introduce custom path and scan providers.

This allows extension modules to define their own methods for
scanning a relation, and get the core code to use them.  It's
unclear as yet how much use this capability will find, but we
won't find out if we never commit it.

KaiGai Kohei, reviewed at various times and in various levels
of detail by Shigeru Hanada, Tom Lane, Andres Freund, Álvaro
Herrera, and myself.
This commit is contained in:
Robert Haas
2014-11-07 17:26:02 -05:00
parent 7250d8535b
commit 0b03e5951b
22 changed files with 638 additions and 10 deletions

View File

@ -21,6 +21,7 @@
#include "executor/nodeBitmapIndexscan.h"
#include "executor/nodeBitmapOr.h"
#include "executor/nodeCtescan.h"
#include "executor/nodeCustom.h"
#include "executor/nodeForeignscan.h"
#include "executor/nodeFunctionscan.h"
#include "executor/nodeGroup.h"
@ -49,6 +50,7 @@
#include "executor/nodeWindowAgg.h"
#include "executor/nodeWorktablescan.h"
#include "nodes/nodeFuncs.h"
#include "nodes/relation.h"
#include "utils/rel.h"
#include "utils/syscache.h"
@ -197,6 +199,10 @@ ExecReScan(PlanState *node)
ExecReScanForeignScan((ForeignScanState *) node);
break;
case T_CustomScanState:
ExecReScanCustomScan((CustomScanState *) node);
break;
case T_NestLoopState:
ExecReScanNestLoop((NestLoopState *) node);
break;
@ -291,6 +297,10 @@ ExecMarkPos(PlanState *node)
ExecValuesMarkPos((ValuesScanState *) node);
break;
case T_CustomScanState:
ExecCustomMarkPos((CustomScanState *) node);
break;
case T_MaterialState:
ExecMaterialMarkPos((MaterialState *) node);
break;
@ -348,6 +358,10 @@ ExecRestrPos(PlanState *node)
ExecValuesRestrPos((ValuesScanState *) node);
break;
case T_CustomScanState:
ExecCustomRestrPos((CustomScanState *) node);
break;
case T_MaterialState:
ExecMaterialRestrPos((MaterialState *) node);
break;
@ -379,9 +393,9 @@ ExecRestrPos(PlanState *node)
* and valuesscan support is actually useless code at present.)
*/
bool
ExecSupportsMarkRestore(NodeTag plantype)
ExecSupportsMarkRestore(Path *pathnode)
{
switch (plantype)
switch (pathnode->pathtype)
{
case T_SeqScan:
case T_IndexScan:
@ -403,6 +417,16 @@ ExecSupportsMarkRestore(NodeTag plantype)
*/
return false;
case T_CustomScan:
{
CustomPath *cpath = (CustomPath *) pathnode;
Assert(IsA(cpath, CustomPath));
if (cpath->flags & CUSTOMPATH_SUPPORT_MARK_RESTORE)
return true;
}
break;
default:
break;
}
@ -465,6 +489,16 @@ ExecSupportsBackwardScan(Plan *node)
return ExecSupportsBackwardScan(((SubqueryScan *) node)->subplan) &&
TargetListSupportsBackwardScan(node->targetlist);
case T_CustomScan:
{
uint32 flags = ((CustomScan *) node)->flags;
if (TargetListSupportsBackwardScan(node->targetlist) &&
(flags & CUSTOMPATH_SUPPORT_BACKWARD_SCAN) != 0)
return true;
}
return false;
case T_Material:
case T_Sort:
/* these don't evaluate tlist */