summaryrefslogtreecommitdiffstats
path: root/doc/src/sgml/html/custom-scan-plan.html
diff options
context:
space:
mode:
Diffstat (limited to 'doc/src/sgml/html/custom-scan-plan.html')
-rw-r--r--doc/src/sgml/html/custom-scan-plan.html67
1 files changed, 67 insertions, 0 deletions
diff --git a/doc/src/sgml/html/custom-scan-plan.html b/doc/src/sgml/html/custom-scan-plan.html
new file mode 100644
index 0000000..cf37532
--- /dev/null
+++ b/doc/src/sgml/html/custom-scan-plan.html
@@ -0,0 +1,67 @@
+<?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>61.2. Creating Custom Scan Plans</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-path.html" title="61.1. Creating Custom Scan Paths" /><link rel="next" href="custom-scan-execution.html" title="61.3. Executing Custom Scans" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">61.2. Creating Custom Scan Plans</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="custom-scan-path.html" title="61.1. Creating Custom Scan Paths">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="custom-scan.html" title="Chapter 61. Writing a Custom Scan Provider">Up</a></td><th width="60%" align="center">Chapter 61. Writing a Custom Scan Provider</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 15.4 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="custom-scan-execution.html" title="61.3. Executing Custom Scans">Next</a></td></tr></table><hr /></div><div class="sect1" id="CUSTOM-SCAN-PLAN"><div class="titlepage"><div><div><h2 class="title" style="clear: both">61.2. Creating Custom Scan Plans</h2></div></div></div><div class="toc"><dl class="toc"><dt><span class="sect2"><a href="custom-scan-plan.html#CUSTOM-SCAN-PLAN-CALLBACKS">61.2.1. Custom Scan Plan Callbacks</a></span></dt></dl></div><p>
+ A custom scan is represented in a finished plan tree using the following
+ structure:
+</p><pre class="programlisting">
+typedef struct CustomScan
+{
+ Scan scan;
+ uint32 flags;
+ List *custom_plans;
+ List *custom_exprs;
+ List *custom_private;
+ List *custom_scan_tlist;
+ Bitmapset *custom_relids;
+ const CustomScanMethods *methods;
+} CustomScan;
+</pre><p>
+ </p><p>
+ <code class="structfield">scan</code> must be initialized as for any other scan, including
+ estimated costs, target lists, qualifications, and so on.
+ <code class="structfield">flags</code> is a bit mask with the same meaning as in
+ <code class="structname">CustomPath</code>.
+ <code class="structfield">custom_plans</code> can be used to store child
+ <code class="structname">Plan</code> nodes.
+ <code class="structfield">custom_exprs</code> should be used to
+ store expression trees that will need to be fixed up by
+ <code class="filename">setrefs.c</code> and <code class="filename">subselect.c</code>, while
+ <code class="structfield">custom_private</code> should be used to store other private data
+ that is only used by the custom scan provider itself.
+ <code class="structfield">custom_scan_tlist</code> can be NIL when scanning a base
+ relation, indicating that the custom scan returns scan tuples that match
+ the base relation's row type. Otherwise it is a target list describing
+ the actual scan tuples. <code class="structfield">custom_scan_tlist</code> must be
+ provided for joins, and could be provided for scans if the custom scan
+ provider can compute some non-Var expressions.
+ <code class="structfield">custom_relids</code> is set by the core code to the set of
+ relations (range table indexes) that this scan node handles; except when
+ this scan is replacing a join, it will have only one member.
+ <code class="structfield">methods</code> must point to a (usually statically allocated)
+ object implementing the required custom scan methods, which are further
+ detailed below.
+ </p><p>
+ When a <code class="structname">CustomScan</code> scans a single relation,
+ <code class="structfield">scan.scanrelid</code> must be the range table index of the table
+ to be scanned. When it replaces a join, <code class="structfield">scan.scanrelid</code>
+ should be zero.
+ </p><p>
+ Plan trees must be able to be duplicated using <code class="function">copyObject</code>,
+ so all the data stored within the <span class="quote">“<span class="quote">custom</span>”</span> fields must consist of
+ nodes that that function can handle. Furthermore, custom scan providers
+ cannot substitute a larger structure that embeds
+ a <code class="structname">CustomScan</code> for the structure itself, as would be possible
+ for a <code class="structname">CustomPath</code> or <code class="structname">CustomScanState</code>.
+ </p><div class="sect2" id="CUSTOM-SCAN-PLAN-CALLBACKS"><div class="titlepage"><div><div><h3 class="title">61.2.1. Custom Scan Plan Callbacks</h3></div></div></div><p>
+</p><pre class="programlisting">
+Node *(*CreateCustomScanState) (CustomScan *cscan);
+</pre><p>
+ Allocate a <code class="structname">CustomScanState</code> for this
+ <code class="structname">CustomScan</code>. The actual allocation will often be larger than
+ required for an ordinary <code class="structname">CustomScanState</code>, because many
+ providers will wish to embed that as the first field of a larger structure.
+ The value returned must have the node tag and <code class="structfield">methods</code>
+ set appropriately, but other fields should be left as zeroes at this
+ stage; after <code class="function">ExecInitCustomScan</code> performs basic initialization,
+ the <code class="function">BeginCustomScan</code> callback will be invoked to give the
+ custom scan provider a chance to do whatever else is needed.
+ </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-path.html" title="61.1. Creating Custom Scan Paths">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="custom-scan.html" title="Chapter 61. Writing a Custom Scan Provider">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="custom-scan-execution.html" title="61.3. Executing Custom Scans">Next</a></td></tr><tr><td width="40%" align="left" valign="top">61.1. Creating Custom Scan Paths </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 15.4 Documentation">Home</a></td><td width="40%" align="right" valign="top"> 61.3. Executing Custom Scans</td></tr></table></div></body></html> \ No newline at end of file