gooderp18绿色标准版
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

79 lines
7.0KB

  1. <?xml version="1.0" encoding="UTF-8" standalone="no"?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>58.1. Creating Custom Scan Paths</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets V1.79.1" /><link rel="prev" href="custom-scan.html" title="Chapter 58. Writing a Custom Scan Provider" /><link rel="next" href="custom-scan-plan.html" title="58.2. Creating Custom Scan Plans" /></head><body><div xmlns="http://www.w3.org/TR/xhtml1/transitional" class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">58.1. Creating Custom Scan Paths</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="custom-scan.html" title="Chapter 58. Writing a Custom Scan Provider">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="custom-scan.html" title="Chapter 58. Writing a Custom Scan Provider">Up</a></td><th width="60%" align="center">Chapter 58. Writing a Custom Scan Provider</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 12.4 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="custom-scan-plan.html" title="58.2. Creating Custom Scan Plans">Next</a></td></tr></table><hr></hr></div><div class="sect1" id="CUSTOM-SCAN-PATH"><div class="titlepage"><div><div><h2 class="title" style="clear: both">58.1. Creating Custom Scan Paths</h2></div></div></div><div class="toc"><dl class="toc"><dt><span class="sect2"><a href="custom-scan-path.html#CUSTOM-SCAN-PATH-CALLBACKS">58.1.1. Custom Scan Path Callbacks</a></span></dt></dl></div><p>
  3. A custom scan provider will typically add paths for a base relation by
  4. setting the following hook, which is called after the core code has
  5. generated all the access paths it can for the relation (except for
  6. Gather paths, which are made after this call so that they can use
  7. partial paths added by the hook):
  8. </p><pre class="programlisting">
  9. typedef void (*set_rel_pathlist_hook_type) (PlannerInfo *root,
  10. RelOptInfo *rel,
  11. Index rti,
  12. RangeTblEntry *rte);
  13. extern PGDLLIMPORT set_rel_pathlist_hook_type set_rel_pathlist_hook;
  14. </pre><p>
  15. </p><p>
  16. Although this hook function can be used to examine, modify, or remove
  17. paths generated by the core system, a custom scan provider will typically
  18. confine itself to generating <code class="structname">CustomPath</code> objects and adding
  19. them to <code class="literal">rel</code> using <code class="function">add_path</code>. The custom scan
  20. provider is responsible for initializing the <code class="structname">CustomPath</code>
  21. object, which is declared like this:
  22. </p><pre class="programlisting">
  23. typedef struct CustomPath
  24. {
  25. Path path;
  26. uint32 flags;
  27. List *custom_paths;
  28. List *custom_private;
  29. const CustomPathMethods *methods;
  30. } CustomPath;
  31. </pre><p>
  32. </p><p>
  33. <code class="structfield">path</code> must be initialized as for any other path, including
  34. the row-count estimate, start and total cost, and sort ordering provided
  35. by this path. <code class="structfield">flags</code> is a bit mask, which should include
  36. <code class="literal">CUSTOMPATH_SUPPORT_BACKWARD_SCAN</code> if the custom path can support
  37. a backward scan and <code class="literal">CUSTOMPATH_SUPPORT_MARK_RESTORE</code> if it
  38. can support mark and restore. Both capabilities are optional.
  39. An optional <code class="structfield">custom_paths</code> is a list of <code class="structname">Path</code>
  40. nodes used by this custom-path node; these will be transformed into
  41. <code class="structname">Plan</code> nodes by planner.
  42. <code class="structfield">custom_private</code> can be used to store the custom path's
  43. private data. Private data should be stored in a form that can be handled
  44. by <code class="literal">nodeToString</code>, so that debugging routines that attempt to
  45. print the custom path will work as designed. <code class="structfield">methods</code> must
  46. point to a (usually statically allocated) object implementing the required
  47. custom path methods, of which there is currently only one.
  48. </p><p>
  49. A custom scan provider can also provide join paths. Just as for base
  50. relations, such a path must produce the same output as would normally be
  51. produced by the join it replaces. To do this, the join provider should
  52. set the following hook, and then within the hook function,
  53. create <code class="structname">CustomPath</code> path(s) for the join relation.
  54. </p><pre class="programlisting">
  55. typedef void (*set_join_pathlist_hook_type) (PlannerInfo *root,
  56. RelOptInfo *joinrel,
  57. RelOptInfo *outerrel,
  58. RelOptInfo *innerrel,
  59. JoinType jointype,
  60. JoinPathExtraData *extra);
  61. extern PGDLLIMPORT set_join_pathlist_hook_type set_join_pathlist_hook;
  62. </pre><p>
  63. This hook will be invoked repeatedly for the same join relation, with
  64. different combinations of inner and outer relations; it is the
  65. responsibility of the hook to minimize duplicated work.
  66. </p><div class="sect2" id="CUSTOM-SCAN-PATH-CALLBACKS"><div class="titlepage"><div><div><h3 class="title">58.1.1. Custom Scan Path Callbacks</h3></div></div></div><p>
  67. </p><pre class="programlisting">
  68. Plan *(*PlanCustomPath) (PlannerInfo *root,
  69. RelOptInfo *rel,
  70. CustomPath *best_path,
  71. List *tlist,
  72. List *clauses,
  73. List *custom_plans);
  74. </pre><p>
  75. Convert a custom path to a finished plan. The return value will generally
  76. be a <code class="literal">CustomScan</code> object, which the callback must allocate and
  77. initialize. See <a class="xref" href="custom-scan-plan.html" title="58.2. Creating Custom Scan Plans">Section 58.2</a> for more details.
  78. </p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="custom-scan.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="custom-scan.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="custom-scan-plan.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter 58. Writing a Custom Scan Provider </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 58.2. Creating Custom Scan Plans</td></tr></table></div></body></html>
上海开阖软件有限公司 沪ICP备12045867号-1