Sophie

Sophie

distrib > Mageia > 7 > i586 > by-pkgid > 9b6cc37ce608401d44f6535a0c7cb777 > files > 172

postgresql11-docs-11.5-1.mga7.noarch.rpm

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!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>59.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 Vsnapshot" /><link rel="prev" href="custom-scan.html" title="Chapter 59. Writing A Custom Scan Provider" /><link rel="next" href="custom-scan-plan.html" title="59.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">59.1. Creating Custom Scan Paths</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="custom-scan.html" title="Chapter 59. Writing A Custom Scan Provider">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="custom-scan.html" title="Chapter 59. Writing A Custom Scan Provider">Up</a></td><th width="60%" align="center">Chapter 59. Writing A Custom Scan Provider</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 11.5 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="custom-scan-plan.html" title="59.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">59.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">59.1.1. Custom Scan Path Callbacks</a></span></dt></dl></div><p>
    A custom scan provider will typically add paths for a base relation by
    setting the following hook, which is called after the core code has
    generated all the access paths it can for the relation (except for
    Gather paths, which are made after this call so that they can use
    partial paths added by the hook):
</p><pre class="programlisting">
typedef void (*set_rel_pathlist_hook_type) (PlannerInfo *root,
                                            RelOptInfo *rel,
                                            Index rti,
                                            RangeTblEntry *rte);
extern PGDLLIMPORT set_rel_pathlist_hook_type set_rel_pathlist_hook;
</pre><p>
  </p><p>
    Although this hook function can be used to examine, modify, or remove
    paths generated by the core system, a custom scan provider will typically
    confine itself to generating <code class="structname">CustomPath</code> objects and adding
    them to <code class="literal">rel</code> using <code class="function">add_path</code>.  The custom scan
    provider is responsible for initializing the <code class="structname">CustomPath</code>
    object, which is declared like this:
</p><pre class="programlisting">
typedef struct CustomPath
{
    Path      path;
    uint32    flags;
    List     *custom_paths;
    List     *custom_private;
    const CustomPathMethods *methods;
} CustomPath;
</pre><p>
  </p><p>
    <code class="structfield">path</code> must be initialized as for any other path, including
    the row-count estimate, start and total cost, and sort ordering provided
    by this path.  <code class="structfield">flags</code> is a bit mask, which should include
    <code class="literal">CUSTOMPATH_SUPPORT_BACKWARD_SCAN</code> if the custom path can support
    a backward scan and <code class="literal">CUSTOMPATH_SUPPORT_MARK_RESTORE</code> if it
    can support mark and restore.  Both capabilities are optional.
    An optional <code class="structfield">custom_paths</code> is a list of <code class="structname">Path</code>
    nodes used by this custom-path node; these will be transformed into
    <code class="structname">Plan</code> nodes by planner.
    <code class="structfield">custom_private</code> can be used to store the custom path's
    private data.  Private data should be stored in a form that can be handled
    by <code class="literal">nodeToString</code>, so that debugging routines that attempt to
    print the custom path will work as designed.  <code class="structfield">methods</code> must
    point to a (usually statically allocated) object implementing the required
    custom path methods, of which there is currently only one.  The
    <code class="structfield">LibraryName</code> and <code class="structfield">SymbolName</code> fields must also
    be initialized so that the dynamic loader can resolve them to locate the
    method table.
  </p><p>
   A custom scan provider can also provide join paths.  Just as for base
   relations, such a path must produce the same output as would normally be
   produced by the join it replaces.  To do this, the join provider should
   set the following hook, and then within the hook function,
   create <code class="structname">CustomPath</code> path(s) for the join relation.
</p><pre class="programlisting">
typedef void (*set_join_pathlist_hook_type) (PlannerInfo *root,
                                             RelOptInfo *joinrel,
                                             RelOptInfo *outerrel,
                                             RelOptInfo *innerrel,
                                             JoinType jointype,
                                             JoinPathExtraData *extra);
extern PGDLLIMPORT set_join_pathlist_hook_type set_join_pathlist_hook;
</pre><p>

   This hook will be invoked repeatedly for the same join relation, with
   different combinations of inner and outer relations; it is the
   responsibility of the hook to minimize duplicated work.
  </p><div class="sect2" id="CUSTOM-SCAN-PATH-CALLBACKS"><div class="titlepage"><div><div><h3 class="title">59.1.1. Custom Scan Path Callbacks</h3></div></div></div><p>
</p><pre class="programlisting">
Plan *(*PlanCustomPath) (PlannerInfo *root,
                         RelOptInfo *rel,
                         CustomPath *best_path,
                         List *tlist,
                         List *clauses,
                         List *custom_plans);
</pre><p>
    Convert a custom path to a finished plan.  The return value will generally
    be a <code class="literal">CustomScan</code> object, which the callback must allocate and
    initialize.  See <a class="xref" href="custom-scan-plan.html" title="59.2. Creating Custom Scan Plans">Section 59.2</a> for more details.
   </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 59. 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"> 59.2. Creating Custom Scan Plans</td></tr></table></div></body></html>