diff options
Diffstat (limited to 'src/include/nodes')
| -rw-r--r-- | src/include/nodes/execnodes.h | 16 | ||||
| -rw-r--r-- | src/include/nodes/plannodes.h | 18 | ||||
| -rw-r--r-- | src/include/nodes/relation.h | 30 |
3 files changed, 38 insertions, 26 deletions
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h index 2bffa4be6cd..41b13b2b670 100644 --- a/src/include/nodes/execnodes.h +++ b/src/include/nodes/execnodes.h @@ -1503,9 +1503,16 @@ typedef struct ForeignScanState } ForeignScanState; /* ---------------- - * CustomScanState information + * CustomScanState information * * CustomScan nodes are used to execute custom code within executor. + * + * Core code must avoid assuming that the CustomScanState is only as large as + * the structure declared here; providers are allowed to make it the first + * element in a larger structure, and typically would need to do so. The + * struct is actually allocated by the CreateCustomScanState method associated + * with the plan node. Any additional fields can be initialized there, or in + * the BeginCustomScan method. * ---------------- */ struct ExplainState; /* avoid including explain.h here */ @@ -1515,7 +1522,7 @@ typedef struct CustomExecMethods { const char *CustomName; - /* EXECUTOR methods */ + /* Executor methods: mark/restore are optional, the rest are required */ void (*BeginCustomScan) (struct CustomScanState *node, EState *estate, int eflags); @@ -1525,13 +1532,10 @@ typedef struct CustomExecMethods void (*MarkPosCustomScan) (struct CustomScanState *node); void (*RestrPosCustomScan) (struct CustomScanState *node); - /* EXPLAIN support */ + /* Optional: print additional information in EXPLAIN */ void (*ExplainCustomScan) (struct CustomScanState *node, List *ancestors, struct ExplainState *es); - Node *(*GetSpecialCustomVar) (struct CustomScanState *node, - Var *varnode, - PlanState **child_ps); } CustomExecMethods; typedef struct CustomScanState diff --git a/src/include/nodes/plannodes.h b/src/include/nodes/plannodes.h index dd300b1a191..7f9eaf0df26 100644 --- a/src/include/nodes/plannodes.h +++ b/src/include/nodes/plannodes.h @@ -486,32 +486,32 @@ typedef struct ForeignScan /* ---------------- * CustomScan node + * + * The comments for ForeignScan's fdw_exprs and fdw_private fields apply + * equally to custom_exprs and custom_private. Note that since Plan trees + * can be copied, custom scan providers *must* fit all plan data they need + * into those fields; embedding CustomScan in a larger struct will not work. * ---------------- */ -struct PlannerInfo; /* avoid including relation.h here */ struct CustomScan; typedef struct CustomScanMethods { const char *CustomName; - void (*SetCustomScanRef) (struct PlannerInfo *root, - struct CustomScan *cscan, - int rtoffset); - void (*FinalizeCustomScan) (struct PlannerInfo *root, - struct CustomScan *cscan, - bool (*finalize_primnode) (), - void *finalize_context); + /* Create execution state (CustomScanState) from a CustomScan plan node */ Node *(*CreateCustomScanState) (struct CustomScan *cscan); + /* Optional: print custom_xxx fields in some special way */ void (*TextOutCustomScan) (StringInfo str, const struct CustomScan *node); - struct CustomScan *(*CopyCustomScan) (const struct CustomScan *from); } CustomScanMethods; typedef struct CustomScan { Scan scan; uint32 flags; /* mask of CUSTOMPATH_* flags, see relation.h */ + List *custom_exprs; /* expressions that custom code may evaluate */ + List *custom_private; /* private data for custom code */ const CustomScanMethods *methods; } CustomScan; diff --git a/src/include/nodes/relation.h b/src/include/nodes/relation.h index bd5e8ce5c13..810b9c8893b 100644 --- a/src/include/nodes/relation.h +++ b/src/include/nodes/relation.h @@ -885,17 +885,22 @@ typedef struct ForeignPath } ForeignPath; /* - * CustomPath represents a scan by some out-of-core extension. - * - * We provide a set of hooks here - which the provider must take care to - * set up correctly - to allow extensions to supply their own methods of - * scanning a relation. For example, a provider might provide GPU - * acceleration, a cache-based scan, or some other kind of logic we haven't - * dreamed up yet. - * - * Core code should avoid assuming that the CustomPath is only as large as - * the structure declared here; providers are expected to make it the first - * element in a larger structure. + * CustomPath represents a table scan done by some out-of-core extension. + * + * We provide a set of hooks here - which the provider must take care to set + * up correctly - to allow extensions to supply their own methods of scanning + * a relation. For example, a provider might provide GPU acceleration, a + * cache-based scan, or some other kind of logic we haven't dreamed up yet. + * + * CustomPaths can be injected into the planning process for a relation by + * set_rel_pathlist_hook functions. + * + * Core code must avoid assuming that the CustomPath is only as large as + * the structure declared here; providers are allowed to make it the first + * element in a larger structure. (Since the planner never copies Paths, + * this doesn't add any complication.) However, for consistency with the + * FDW case, we provide a "custom_private" field in CustomPath; providers + * may prefer to use that rather than define another struct type. */ struct CustomPath; @@ -906,11 +911,13 @@ typedef struct CustomPathMethods { const char *CustomName; + /* Convert Path to a Plan */ struct Plan *(*PlanCustomPath) (PlannerInfo *root, RelOptInfo *rel, struct CustomPath *best_path, List *tlist, List *clauses); + /* Optional: print additional fields besides "private" */ void (*TextOutCustomPath) (StringInfo str, const struct CustomPath *node); } CustomPathMethods; @@ -919,6 +926,7 @@ typedef struct CustomPath { Path path; uint32 flags; /* mask of CUSTOMPATH_* flags, see above */ + List *custom_private; const CustomPathMethods *methods; } CustomPath; |
