1/*-------------------------------------------------------------------------
4 * Definitions for extensible nodes and custom scans
7 * Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
8 * Portions Copyright (c) 1994, Regents of the University of California
10 * src/include/nodes/extensible.h
12 *-------------------------------------------------------------------------
23/* maximum length of an extensible node identifier */
24 #define EXTNODENAME_MAX_LEN 64
27 * An extensible node is a new type of node defined by an extension. The
28 * type is always T_ExtensibleNode, while the extnodename identifies the
29 * specific type of node. extnodename can be looked up to find the
30 * ExtensibleNodeMethods for this node type.
37 const char *
extnodename;
/* identifier of ExtensibleNodeMethods */
41 * node_size is the size of an extensible node of this type in bytes.
43 * nodeCopy is a function which performs a deep copy from oldnode to newnode.
44 * It does not need to copy type or extnodename, which are copied by the
47 * nodeEqual is a function which performs a deep equality comparison between
48 * a and b and returns true or false accordingly. It does not need to compare
49 * type or extnodename, which are compared by the core system.
51 * nodeOut is a serialization function for the node type. It should use the
52 * output conventions typical for outfuncs.c. It does not need to output
53 * type or extnodename; the core system handles those.
55 * nodeRead is a deserialization function for the node type. It does not need
56 * to read type or extnodename; the core system handles those. It should fetch
57 * the next token using pg_strtok() from the current input stream, and then
58 * reconstruct the private fields according to the manner in readfuncs.c.
60 * All callbacks are mandatory.
80 * Flags for custom paths, indicating what capabilities the resulting scan
81 * will have. The flags fields of CustomPath and CustomScan nodes are
82 * bitmasks of these flags.
84 #define CUSTOMPATH_SUPPORT_BACKWARD_SCAN 0x0001
85 #define CUSTOMPATH_SUPPORT_MARK_RESTORE 0x0002
86 #define CUSTOMPATH_SUPPORT_PROJECTION 0x0004
89 * Custom path methods. Mostly, we just need to know how to convert a
90 * CustomPath to a plan.
96 /* Convert Path to a Plan */
104 List *custom_private,
109 * Custom scan. Here again, there's not much to do: we need to be able to
110 * generate a ScanState corresponding to the scan.
116 /* Create execution state (CustomScanState) from a CustomScan plan node */
121 * Execution-time methods for a CustomScanState. This is more complex than
122 * what we need for a custom path or scan.
128 /* Required executor methods */
136 /* Optional methods: needed if mark/restore is supported */
140 /* Optional methods: needed if parallel execution is supported */
154 /* Optional: print additional information in EXPLAIN */
164#endif /* EXTENSIBLE_H */
struct CustomExecMethods CustomExecMethods
struct CustomScanMethods CustomScanMethods
struct CustomPathMethods CustomPathMethods
void RegisterExtensibleNodeMethods(const ExtensibleNodeMethods *methods)
struct ExtensibleNodeMethods ExtensibleNodeMethods
void RegisterCustomScanMethods(const CustomScanMethods *methods)
const ExtensibleNodeMethods * GetExtensibleNodeMethods(const char *extnodename, bool missing_ok)
const CustomScanMethods * GetCustomScanMethods(const char *CustomName, bool missing_ok)
struct ExtensibleNode ExtensibleNode
void(* BeginCustomScan)(CustomScanState *node, EState *estate, int eflags)
void(* EndCustomScan)(CustomScanState *node)
void(* ShutdownCustomScan)(CustomScanState *node)
void(* ReInitializeDSMCustomScan)(CustomScanState *node, ParallelContext *pcxt, void *coordinate)
void(* InitializeDSMCustomScan)(CustomScanState *node, ParallelContext *pcxt, void *coordinate)
void(* RestrPosCustomScan)(CustomScanState *node)
Size(* EstimateDSMCustomScan)(CustomScanState *node, ParallelContext *pcxt)
void(* MarkPosCustomScan)(CustomScanState *node)
void(* InitializeWorkerCustomScan)(CustomScanState *node, shm_toc *toc, void *coordinate)
void(* ExplainCustomScan)(CustomScanState *node, List *ancestors, ExplainState *es)
void(* ReScanCustomScan)(CustomScanState *node)
void(* nodeRead)(struct ExtensibleNode *node)
void(* nodeCopy)(struct ExtensibleNode *newnode, const struct ExtensibleNode *oldnode)
bool(* nodeEqual)(const struct ExtensibleNode *a, const struct ExtensibleNode *b)
void(* nodeOut)(struct StringInfoData *str, const struct ExtensibleNode *node)
pg_node_attr(custom_copy_equal, custom_read_write) NodeTag type