Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes15kdownloads
extensible.h165 linesDownload Raw Back to nodes
1/*-------------------------------------------------------------------------2 *3 * extensible.h4 *	  Definitions for extensible nodes and custom scans5 *6 *7 * Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group8 * Portions Copyright (c) 1994, Regents of the University of California9 *10 * src/include/nodes/extensible.h11 *12 *-------------------------------------------------------------------------13 */14#ifndef EXTENSIBLE_H15#define EXTENSIBLE_H16 17#include "access/parallel.h"18#include "commands/explain.h"19#include "nodes/execnodes.h"20#include "nodes/pathnodes.h"21#include "nodes/plannodes.h"22 23/* maximum length of an extensible node identifier */24#define EXTNODENAME_MAX_LEN					6425 26/*27 * An extensible node is a new type of node defined by an extension.  The28 * type is always T_ExtensibleNode, while the extnodename identifies the29 * specific type of node.  extnodename can be looked up to find the30 * ExtensibleNodeMethods for this node type.31 */32typedef struct ExtensibleNode33{34	pg_node_attr(custom_copy_equal, custom_read_write)35 36	NodeTag		type;37	const char *extnodename;	/* identifier of ExtensibleNodeMethods */38} ExtensibleNode;39 40/*41 * node_size is the size of an extensible node of this type in bytes.42 *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 the45 * core system.46 *47 * nodeEqual is a function which performs a deep equality comparison between48 * a and b and returns true or false accordingly.  It does not need to compare49 * type or extnodename, which are compared by the core system.50 *51 * nodeOut is a serialization function for the node type.  It should use the52 * output conventions typical for outfuncs.c.  It does not need to output53 * type or extnodename; the core system handles those.54 *55 * nodeRead is a deserialization function for the node type.  It does not need56 * to read type or extnodename; the core system handles those.  It should fetch57 * the next token using pg_strtok() from the current input stream, and then58 * reconstruct the private fields according to the manner in readfuncs.c.59 *60 * All callbacks are mandatory.61 */62typedef struct ExtensibleNodeMethods63{64	const char *extnodename;65	Size		node_size;66	void		(*nodeCopy) (struct ExtensibleNode *newnode,67							 const struct ExtensibleNode *oldnode);68	bool		(*nodeEqual) (const struct ExtensibleNode *a,69							  const struct ExtensibleNode *b);70	void		(*nodeOut) (struct StringInfoData *str,71							const struct ExtensibleNode *node);72	void		(*nodeRead) (struct ExtensibleNode *node);73} ExtensibleNodeMethods;74 75extern void RegisterExtensibleNodeMethods(const ExtensibleNodeMethods *methods);76extern const ExtensibleNodeMethods *GetExtensibleNodeMethods(const char *extnodename,77															 bool missing_ok);78 79/*80 * Flags for custom paths, indicating what capabilities the resulting scan81 * will have.  The flags fields of CustomPath and CustomScan nodes are82 * bitmasks of these flags.83 */84#define CUSTOMPATH_SUPPORT_BACKWARD_SCAN	0x000185#define CUSTOMPATH_SUPPORT_MARK_RESTORE		0x000286#define CUSTOMPATH_SUPPORT_PROJECTION		0x000487 88/*89 * Custom path methods.  Mostly, we just need to know how to convert a90 * CustomPath to a plan.91 */92typedef struct CustomPathMethods93{94	const char *CustomName;95 96	/* Convert Path to a Plan */97	struct Plan *(*PlanCustomPath) (PlannerInfo *root,98									RelOptInfo *rel,99									struct CustomPath *best_path,100									List *tlist,101									List *clauses,102									List *custom_plans);103	struct List *(*ReparameterizeCustomPathByChild) (PlannerInfo *root,104													 List *custom_private,105													 RelOptInfo *child_rel);106}			CustomPathMethods;107 108/*109 * Custom scan.  Here again, there's not much to do: we need to be able to110 * generate a ScanState corresponding to the scan.111 */112typedef struct CustomScanMethods113{114	const char *CustomName;115 116	/* Create execution state (CustomScanState) from a CustomScan plan node */117	Node	   *(*CreateCustomScanState) (CustomScan *cscan);118} CustomScanMethods;119 120/*121 * Execution-time methods for a CustomScanState.  This is more complex than122 * what we need for a custom path or scan.123 */124typedef struct CustomExecMethods125{126	const char *CustomName;127 128	/* Required executor methods */129	void		(*BeginCustomScan) (CustomScanState *node,130									EState *estate,131									int eflags);132	TupleTableSlot *(*ExecCustomScan) (CustomScanState *node);133	void		(*EndCustomScan) (CustomScanState *node);134	void		(*ReScanCustomScan) (CustomScanState *node);135 136	/* Optional methods: needed if mark/restore is supported */137	void		(*MarkPosCustomScan) (CustomScanState *node);138	void		(*RestrPosCustomScan) (CustomScanState *node);139 140	/* Optional methods: needed if parallel execution is supported */141	Size		(*EstimateDSMCustomScan) (CustomScanState *node,142										  ParallelContext *pcxt);143	void		(*InitializeDSMCustomScan) (CustomScanState *node,144											ParallelContext *pcxt,145											void *coordinate);146	void		(*ReInitializeDSMCustomScan) (CustomScanState *node,147											  ParallelContext *pcxt,148											  void *coordinate);149	void		(*InitializeWorkerCustomScan) (CustomScanState *node,150											   shm_toc *toc,151											   void *coordinate);152	void		(*ShutdownCustomScan) (CustomScanState *node);153 154	/* Optional: print additional information in EXPLAIN */155	void		(*ExplainCustomScan) (CustomScanState *node,156									  List *ancestors,157									  ExplainState *es);158} CustomExecMethods;159 160extern void RegisterCustomScanMethods(const CustomScanMethods *methods);161extern const CustomScanMethods *GetCustomScanMethods(const char *CustomName,162													 bool missing_ok);163 164#endif							/* EXTENSIBLE_H */165 
codekingpro/portable-devtools · Team Ai