gooderp18绿色标准版
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

161 linhas
5.4KB

  1. /*-------------------------------------------------------------------------
  2. *
  3. * extensible.h
  4. * Definitions for extensible nodes and custom scans
  5. *
  6. *
  7. * Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group
  8. * Portions Copyright (c) 1994, Regents of the University of California
  9. *
  10. * src/include/nodes/extensible.h
  11. *
  12. *-------------------------------------------------------------------------
  13. */
  14. #ifndef EXTENSIBLE_H
  15. #define EXTENSIBLE_H
  16. #include "access/parallel.h"
  17. #include "commands/explain.h"
  18. #include "nodes/execnodes.h"
  19. #include "nodes/pathnodes.h"
  20. #include "nodes/plannodes.h"
  21. /* maximum length of an extensible node identifier */
  22. #define EXTNODENAME_MAX_LEN 64
  23. /*
  24. * An extensible node is a new type of node defined by an extension. The
  25. * type is always T_ExtensibleNode, while the extnodename identifies the
  26. * specific type of node. extnodename can be looked up to find the
  27. * ExtensibleNodeMethods for this node type.
  28. */
  29. typedef struct ExtensibleNode
  30. {
  31. NodeTag type;
  32. const char *extnodename; /* identifier of ExtensibleNodeMethods */
  33. } ExtensibleNode;
  34. /*
  35. * node_size is the size of an extensible node of this type in bytes.
  36. *
  37. * nodeCopy is a function which performs a deep copy from oldnode to newnode.
  38. * It does not need to copy type or extnodename, which are copied by the
  39. * core system.
  40. *
  41. * nodeEqual is a function which performs a deep equality comparison between
  42. * a and b and returns true or false accordingly. It does not need to compare
  43. * type or extnodename, which are compared by the core system.
  44. *
  45. * nodeOut is a serialization function for the node type. It should use the
  46. * output conventions typical for outfuncs.c. It does not need to output
  47. * type or extnodename; the core system handles those.
  48. *
  49. * nodeRead is a deserialization function for the node type. It does not need
  50. * to read type or extnodename; the core system handles those. It should fetch
  51. * the next token using pg_strtok() from the current input stream, and then
  52. * reconstruct the private fields according to the manner in readfuncs.c.
  53. *
  54. * All callbacks are mandatory.
  55. */
  56. typedef struct ExtensibleNodeMethods
  57. {
  58. const char *extnodename;
  59. Size node_size;
  60. void (*nodeCopy) (struct ExtensibleNode *newnode,
  61. const struct ExtensibleNode *oldnode);
  62. bool (*nodeEqual) (const struct ExtensibleNode *a,
  63. const struct ExtensibleNode *b);
  64. void (*nodeOut) (struct StringInfoData *str,
  65. const struct ExtensibleNode *node);
  66. void (*nodeRead) (struct ExtensibleNode *node);
  67. } ExtensibleNodeMethods;
  68. extern void RegisterExtensibleNodeMethods(const ExtensibleNodeMethods *method);
  69. extern const ExtensibleNodeMethods *GetExtensibleNodeMethods(const char *name,
  70. bool missing_ok);
  71. /*
  72. * Flags for custom paths, indicating what capabilities the resulting scan
  73. * will have.
  74. */
  75. #define CUSTOMPATH_SUPPORT_BACKWARD_SCAN 0x0001
  76. #define CUSTOMPATH_SUPPORT_MARK_RESTORE 0x0002
  77. /*
  78. * Custom path methods. Mostly, we just need to know how to convert a
  79. * CustomPath to a plan.
  80. */
  81. typedef struct CustomPathMethods
  82. {
  83. const char *CustomName;
  84. /* Convert Path to a Plan */
  85. struct Plan *(*PlanCustomPath) (PlannerInfo *root,
  86. RelOptInfo *rel,
  87. struct CustomPath *best_path,
  88. List *tlist,
  89. List *clauses,
  90. List *custom_plans);
  91. struct List *(*ReparameterizeCustomPathByChild) (PlannerInfo *root,
  92. List *custom_private,
  93. RelOptInfo *child_rel);
  94. } CustomPathMethods;
  95. /*
  96. * Custom scan. Here again, there's not much to do: we need to be able to
  97. * generate a ScanState corresponding to the scan.
  98. */
  99. typedef struct CustomScanMethods
  100. {
  101. const char *CustomName;
  102. /* Create execution state (CustomScanState) from a CustomScan plan node */
  103. Node *(*CreateCustomScanState) (CustomScan *cscan);
  104. } CustomScanMethods;
  105. /*
  106. * Execution-time methods for a CustomScanState. This is more complex than
  107. * what we need for a custom path or scan.
  108. */
  109. typedef struct CustomExecMethods
  110. {
  111. const char *CustomName;
  112. /* Required executor methods */
  113. void (*BeginCustomScan) (CustomScanState *node,
  114. EState *estate,
  115. int eflags);
  116. TupleTableSlot *(*ExecCustomScan) (CustomScanState *node);
  117. void (*EndCustomScan) (CustomScanState *node);
  118. void (*ReScanCustomScan) (CustomScanState *node);
  119. /* Optional methods: needed if mark/restore is supported */
  120. void (*MarkPosCustomScan) (CustomScanState *node);
  121. void (*RestrPosCustomScan) (CustomScanState *node);
  122. /* Optional methods: needed if parallel execution is supported */
  123. Size (*EstimateDSMCustomScan) (CustomScanState *node,
  124. ParallelContext *pcxt);
  125. void (*InitializeDSMCustomScan) (CustomScanState *node,
  126. ParallelContext *pcxt,
  127. void *coordinate);
  128. void (*ReInitializeDSMCustomScan) (CustomScanState *node,
  129. ParallelContext *pcxt,
  130. void *coordinate);
  131. void (*InitializeWorkerCustomScan) (CustomScanState *node,
  132. shm_toc *toc,
  133. void *coordinate);
  134. void (*ShutdownCustomScan) (CustomScanState *node);
  135. /* Optional: print additional information in EXPLAIN */
  136. void (*ExplainCustomScan) (CustomScanState *node,
  137. List *ancestors,
  138. ExplainState *es);
  139. } CustomExecMethods;
  140. extern void RegisterCustomScanMethods(const CustomScanMethods *methods);
  141. extern const CustomScanMethods *GetCustomScanMethods(const char *CustomName,
  142. bool missing_ok);
  143. #endif /* EXTENSIBLE_H */
上海开阖软件有限公司 沪ICP备12045867号-1