| Server IP : 104.21.25.180 / Your IP : 104.23.197.122 Web Server : Apache/2.4.37 System : Linux almalinux.duckdns.org 4.18.0-553.111.1.el8_10.x86_64 #1 SMP Sun Mar 8 20:06:07 EDT 2026 x86_64 User : ricodeal ( 1046) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/share/doc/postgresql-docs/html/ |
Upload File : |
<?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>56.3. Foreign Data Wrapper Helper Functions</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="[email protected]" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="fdw-callbacks.html" title="56.2. Foreign Data Wrapper Callback Routines" /><link rel="next" href="fdw-planning.html" title="56.4. Foreign Data Wrapper Query Planning" /></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">56.3. Foreign Data Wrapper Helper Functions</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="fdw-callbacks.html" title="56.2. Foreign Data Wrapper Callback Routines">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="fdwhandler.html" title="Chapter 56. Writing A Foreign Data Wrapper">Up</a></td><th width="60%" align="center">Chapter 56. Writing A Foreign Data Wrapper</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 10.23 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="fdw-planning.html" title="56.4. Foreign Data Wrapper Query Planning">Next</a></td></tr></table><hr></hr></div><div class="sect1" id="FDW-HELPERS"><div class="titlepage"><div><div><h2 class="title" style="clear: both">56.3. Foreign Data Wrapper Helper Functions</h2></div></div></div><p> Several helper functions are exported from the core server so that
authors of foreign data wrappers can get easy access to attributes of
FDW-related objects, such as FDW options.
To use any of these functions, you need to include the header file
<code class="filename">foreign/foreign.h</code> in your source file.
That header also defines the struct types that are returned by
these functions.
</p><pre class="programlisting">ForeignDataWrapper *
GetForeignDataWrapper(Oid fdwid);</pre><p>
This function returns a <code class="structname">ForeignDataWrapper</code>
object for the foreign-data wrapper with the given OID. A
<code class="structname">ForeignDataWrapper</code> object contains properties
of the FDW (see <code class="filename">foreign/foreign.h</code> for details).
</p><pre class="programlisting">ForeignServer *
GetForeignServer(Oid serverid);</pre><p>
This function returns a <code class="structname">ForeignServer</code> object
for the foreign server with the given OID. A
<code class="structname">ForeignServer</code> object contains properties
of the server (see <code class="filename">foreign/foreign.h</code> for details).
</p><pre class="programlisting">UserMapping *
GetUserMapping(Oid userid, Oid serverid);</pre><p>
This function returns a <code class="structname">UserMapping</code> 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
<code class="literal">PUBLIC</code>, or throw error if there is none.) A
<code class="structname">UserMapping</code> object contains properties of the
user mapping (see <code class="filename">foreign/foreign.h</code> for details).
</p><pre class="programlisting">ForeignTable *
GetForeignTable(Oid relid);</pre><p>
This function returns a <code class="structname">ForeignTable</code> object for
the foreign table with the given OID. A
<code class="structname">ForeignTable</code> object contains properties of the
foreign table (see <code class="filename">foreign/foreign.h</code> for details).
</p><pre class="programlisting">List *
GetForeignColumnOptions(Oid relid, AttrNumber attnum);</pre><p>
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
<code class="structname">DefElem</code>. NIL is returned if the column has no
options.
</p><p> Some object types have name-based lookup functions in addition to the
OID-based ones:
</p><pre class="programlisting">ForeignDataWrapper *
GetForeignDataWrapperByName(const char *name, bool missing_ok);</pre><p>
This function returns a <code class="structname">ForeignDataWrapper</code>
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.
</p><pre class="programlisting">ForeignServer *
GetForeignServerByName(const char *name, bool missing_ok);</pre><p>
This function returns a <code class="structname">ForeignServer</code> object
for the foreign server with the given name. If the server is not found,
return NULL if missing_ok is true, otherwise raise an error.
</p></div><div xmlns="http://www.w3.org/TR/xhtml1/transitional" class="navfooter"><hr></hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="fdw-callbacks.html" title="56.2. Foreign Data Wrapper Callback Routines">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="fdwhandler.html" title="Chapter 56. Writing A Foreign Data Wrapper">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="fdw-planning.html" title="56.4. Foreign Data Wrapper Query Planning">Next</a></td></tr><tr><td width="40%" align="left" valign="top">56.2. Foreign Data Wrapper Callback Routines </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 10.23 Documentation">Home</a></td><td width="40%" align="right" valign="top"> 56.4. Foreign Data Wrapper Query Planning</td></tr></table></div></body></html>