A
<structname>ForeignDataWrapper</structname> object contains properties
of the FDW (see <filename>foreign/foreign.h</filename> for details).
<structfield>flags</structfield> is a bitwise-or'd bit mask indicating
an extra set of options. It can take the value
<literal>FDW_MISSING_OK</literal>, in which case a <literal>NULL</literal>
result is returned to the caller instead of an error for an undefined
object.
</para>
<para>
<programlisting>
ForeignDataWrapper *
GetForeignDataWrapper(Oid fdwid);
</programlisting>
This function returns a <structname>ForeignDataWrapper</structname>
object for the foreign-data wrapper with the given OID. A
<structname>ForeignDataWrapper</structname> object contains properties
of the FDW (see <filename>foreign/foreign.h</filename> for details).
</para>
<para>
<programlisting>
ForeignServer *
GetForeignServerExtended(Oid serverid, bits16 flags);
</programlisting>
This function returns a <structname>ForeignServer</structname> object
for the foreign server with the given OID. A
<structname>ForeignServer</structname> object contains properties
of the server (see <filename>foreign/foreign.h</filename> for details).
<structfield>flags</structfield> is a bitwise-or'd bit mask indicating
an extra set of options. It can take the value
<literal>FSV_MISSING_OK</literal>, in which case a <literal>NULL</literal>
result is returned to the caller instead of an error for an undefined
object.
</para>
<para>
<programlisting>
ForeignServer *
GetForeignServer(Oid serverid);
</programlisting>
This function returns a <structname>ForeignServer</structname> object
for the foreign server with the given OID. A
<structname>ForeignServer</structname> object contains properties
of the server (see <filename>foreign/foreign.h</filename> for details).
</para>
<para>
<programlisting>
UserMapping *
GetUserMapping(Oid userid, Oid serverid);
</programlisting>
This function returns a <structname>UserMapping</structname> object for
the user mapping of the given role on the given server. (If there is no
mapping for the specific user, it will return the mapping for
<literal>PUBLIC</literal>, or throw error if there is none.) A
<structname>UserMapping</structname> object contains properties of the
user mapping (see <filename>foreign/foreign.h</filename> for details).
</para>
<para>
<programlisting>
ForeignTable *
GetForeignTable(Oid relid);
</programlisting>
This function returns a <structname>ForeignTable</structname> object for
the foreign table with the given OID. A
<structname>ForeignTable</structname> object contains properties of the
foreign table (see <filename>foreign/foreign.h</filename> for details).
</para>
<para>
<programlisting>
List *
GetForeignColumnOptions(Oid relid, AttrNumber attnum);
</programlisting>
This function returns the per-column FDW options for the column with the
given foreign table OID and attribute number, in the form of a list of
<structname>DefElem</structname>. NIL is returned if the column has no
options.
</para>
<para>
Some object types have name-based lookup functions in addition to the
OID-based ones:
</para>
<para>
<programlisting>
ForeignDataWrapper *
GetForeignDataWrapperByName(const char *name, bool missing_ok);
</programlisting>
This function returns a <structname>ForeignDataWrapper</structname>
object for the foreign-data wrapper with the given name. If the wrapper
is not found, return NULL if missing_ok is true, otherwise raise an
error.
</para>
<para>
<programlisting>
ForeignServer *
GetForeignServerByName(const char *name, bool missing_ok);
</programlisting>
This function returns a <structname>ForeignServer</structname> object
for the foreign server with the given name.