Commit 3b315285 authored by Tom Lane's avatar Tom Lane

Restructure foreign data wrapper chapter so it has more than one section.

As noted by Laurenz Albe, our SGML tools deal rather oddly with chapters
having just one <sect1>.  Perhaps the tooling could be fixed, but really
the design of this chapter's introduction is pretty bogus anyhow.  Split
it into a true introduction and a <sect1> about the FDW functions, so
that it reads better and dodges the lack-of-a-chapter-TOC problem.
parent 76dfcb94
...@@ -17,6 +17,26 @@ ...@@ -17,6 +17,26 @@
to write a new foreign data wrapper. to write a new foreign data wrapper.
</para> </para>
<para>
The foreign data wrappers included in the standard distribution are good
references when trying to write your own. Look into the
<filename>contrib/file_fdw</> subdirectory of the source tree.
The <xref linkend="sql-createforeigndatawrapper"> reference page also has
some useful details.
</para>
<note>
<para>
The SQL standard specifies an interface for writing foreign data wrappers.
However, PostgreSQL does not implement that API, because the effort to
accommodate it into PostgreSQL would be large, and the standard API hasn't
gained wide adoption anyway.
</para>
</note>
<sect1 id="fdw-functions">
<title>Foreign Data Wrapper Functions</title>
<para> <para>
The FDW author needs to implement a handler function, and optionally The FDW author needs to implement a handler function, and optionally
a validator function. Both functions must be written in a compiled a validator function. Both functions must be written in a compiled
...@@ -31,10 +51,11 @@ ...@@ -31,10 +51,11 @@
Most of the effort in writing an FDW is in implementing these callback Most of the effort in writing an FDW is in implementing these callback
functions. functions.
The handler function must be registered with The handler function must be registered with
<productname>PostgreSQL</productname> as taking no arguments and returning <productname>PostgreSQL</productname> as taking no arguments and
the special pseudo-type <type>fdw_handler</type>. returning the special pseudo-type <type>fdw_handler</type>. The
The callback functions are plain C functions and are not visible or callback functions are plain C functions and are not visible or
callable at the SQL level. callable at the SQL level. The callback functions are described in
<xref linkend="fdw-callbacks">.
</para> </para>
<para> <para>
...@@ -42,10 +63,11 @@ ...@@ -42,10 +63,11 @@
<command>CREATE</command> and <command>ALTER</command> commands for its <command>CREATE</command> and <command>ALTER</command> commands for its
foreign data wrapper, as well as foreign servers, user mappings, and foreign data wrapper, as well as foreign servers, user mappings, and
foreign tables using the wrapper. foreign tables using the wrapper.
The validator function must be registered as taking two arguments, a text The validator function must be registered as taking two arguments, a
array containing the options to be validated, and an OID representing the text array containing the options to be validated, and an OID
type of object the options are associated with (in the form of the OID representing the type of object the options are associated with (in
of the system catalog the object would be stored in, either the form of the OID of the system catalog the object would be stored
in, either
<literal>ForeignDataWrapperRelationId</>, <literal>ForeignDataWrapperRelationId</>,
<literal>ForeignServerRelationId</>, <literal>ForeignServerRelationId</>,
<literal>UserMappingRelationId</>, <literal>UserMappingRelationId</>,
...@@ -54,24 +76,9 @@ ...@@ -54,24 +76,9 @@
creation time or object alteration time. creation time or object alteration time.
</para> </para>
<para> </sect1>
The foreign data wrappers included in the standard distribution are good
references when trying to write your own. Look into the
<filename>contrib/file_fdw</> subdirectory of the source tree.
The <xref linkend="sql-createforeigndatawrapper"> reference page also has
some useful details.
</para>
<note>
<para>
The SQL standard specifies an interface for writing foreign data wrappers.
However, PostgreSQL does not implement that API, because the effort to
accommodate it into PostgreSQL would be large, and the standard API hasn't
gained wide adoption anyway.
</para>
</note>
<sect1 id="fdw-routines"> <sect1 id="fdw-callbacks">
<title>Foreign Data Wrapper Callback Routines</title> <title>Foreign Data Wrapper Callback Routines</title>
<para> <para>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment