OID of the system catalog the object
would be stored in, one of:
<itemizedlist spacing="compact">
<listitem><para><literal>AttributeRelationId</literal></para></listitem>
<listitem><para><literal>ForeignDataWrapperRelationId</literal></para></listitem>
<listitem><para><literal>ForeignServerRelationId</literal></para></listitem>
<listitem><para><literal>ForeignTableRelationId</literal></para></listitem>
<listitem><para><literal>UserMappingRelationId</literal></para></listitem>
</itemizedlist>
If no validator function is supplied, options are not checked at object
creation time or object alteration time.
</para>
</sect1>
<sect1 id="fdw-callbacks">
<title>Foreign Data Wrapper Callback Routines</title>
<para>
The FDW handler function returns a palloc'd <structname>FdwRoutine</structname>
struct containing pointers to the callback functions described below.
The scan-related functions are required, the rest are optional.
</para>
<para>
The <structname>FdwRoutine</structname> struct type is declared in
<filename>src/include/foreign/fdwapi.h</filename>, which see for additional
details.
</para>
<sect2 id="fdw-callbacks-scan">
<title>FDW Routines for Scanning Foreign Tables</title>
<para>
<programlisting>
void
GetForeignRelSize(PlannerInfo *root,
RelOptInfo *baserel,
Oid foreigntableid);
</programlisting>
Obtain relation size estimates for a foreign table. This is called
at the beginning of planning for a query that scans a foreign table.
<literal>root</literal> is the planner's global information about the query;
<literal>baserel</literal> is the planner's information about this table; and
<literal>foreigntableid</literal> is the <structname>pg_class</structname> OID of the
foreign table. (<literal>foreigntableid</literal> could be obtained from the
planner data structures, but it's passed explicitly to save effort.)
</para>
<para>
This function should update <literal>baserel->rows</literal> to be the
expected number of rows returned by the table scan, after accounting for
the filtering done by the restriction quals. The initial value of
<literal>baserel->rows</literal> is just a constant default estimate, which
should be replaced if at all possible. The function may also choose to
update <literal>baserel->width</literal> if it can compute a better estimate
of the average result row width.
(The initial value is based on column data types and on column
average-width values measured by the last <command>ANALYZE</command>.)
Also, this function may update <literal>baserel->tuples</literal> if
it can compute a better estimate of the foreign table's total row count.
(The initial value is
from <structname>pg_class</structname>.<structfield>reltuples</structfield>
which represents the total row count seen by the
last <command>ANALYZE</command>; it will be <literal>-1</literal> if
no <command>ANALYZE</command> has been done on this foreign table.)
</para>
<para>
See <xref linkend="fdw-planning"/> for additional information.
</para>
<para>
<programlisting>
void
GetForeignPaths(PlannerInfo *root,
RelOptInfo *baserel,
Oid foreigntableid);
</programlisting>
Create possible access paths for a scan on a foreign table.
This is called during query planning.
The parameters are the same as for <function>GetForeignRelSize</function>,
which has already been called.
</para>
<para>
This function must generate at least one access path
(<structname>ForeignPath</structname> node) for a scan on the foreign table and
must call <function>add_path</function> to add each such path to
<literal>baserel->pathlist</literal>. It's recommended to use
<function>create_foreignscan_path</function>