summaryrefslogtreecommitdiffstats
path: root/doc/src/sgml/html/fdw-helpers.html
blob: 8efa3893cdcfccf32fd6eaabca75713fa9475569 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<?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>59.3. Foreign Data Wrapper Helper Functions</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="fdw-callbacks.html" title="59.2. Foreign Data Wrapper Callback Routines" /><link rel="next" href="fdw-planning.html" title="59.4. Foreign Data Wrapper Query Planning" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">59.3. Foreign Data Wrapper Helper Functions</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="fdw-callbacks.html" title="59.2. Foreign Data Wrapper Callback Routines">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="fdwhandler.html" title="Chapter 59. Writing a Foreign Data Wrapper">Up</a></td><th width="60%" align="center">Chapter 59. Writing a Foreign Data Wrapper</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 15.6 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="fdw-planning.html" title="59.4. Foreign Data Wrapper Query Planning">Next</a></td></tr></table><hr /></div><div class="sect1" id="FDW-HELPERS"><div class="titlepage"><div><div><h2 class="title" style="clear: both">59.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><p>
</p><pre class="programlisting">
ForeignDataWrapper *
GetForeignDataWrapperExtended(Oid fdwid, bits16 flags);
</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).
     <code class="structfield">flags</code> is a bitwise-or'd bit mask indicating
     an extra set of options.  It can take the value
     <code class="literal">FDW_MISSING_OK</code>, in which case a <code class="literal">NULL</code>
     result is returned to the caller instead of an error for an undefined
     object.
    </p><p>
</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><p>
</p><pre class="programlisting">
ForeignServer *
GetForeignServerExtended(Oid serverid, bits16 flags);
</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).
     <code class="structfield">flags</code> is a bitwise-or'd bit mask indicating
     an extra set of options.  It can take the value
     <code class="literal">FSV_MISSING_OK</code>, in which case a <code class="literal">NULL</code>
     result is returned to the caller instead of an error for an undefined
     object.
    </p><p>
</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><p>
</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><p>
</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><p>
</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><p>
</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><p>
</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 class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="fdw-callbacks.html" title="59.2. Foreign Data Wrapper Callback Routines">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="fdwhandler.html" title="Chapter 59. Writing a Foreign Data Wrapper">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="fdw-planning.html" title="59.4. Foreign Data Wrapper Query Planning">Next</a></td></tr><tr><td width="40%" align="left" valign="top">59.2. Foreign Data Wrapper Callback Routines </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 15.6 Documentation">Home</a></td><td width="40%" align="right" valign="top"> 59.4. Foreign Data Wrapper Query Planning</td></tr></table></div></body></html>