]> begriffs open source - ai-pg/blob - full-docs/html/fdw-helpers.html
Include links to all subsection html pages, with shorter paths too
[ai-pg] / full-docs / html / fdw-helpers.html
1 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2 <!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>58.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="58.2. Foreign Data Wrapper Callback Routines" /><link rel="next" href="fdw-planning.html" title="58.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">58.3. Foreign Data Wrapper Helper Functions</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="fdw-callbacks.html" title="58.2. Foreign Data Wrapper Callback Routines">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="fdwhandler.html" title="Chapter 58. Writing a Foreign Data Wrapper">Up</a></td><th width="60%" align="center">Chapter 58. Writing a Foreign Data Wrapper</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 18.0 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="fdw-planning.html" title="58.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">58.3. Foreign Data Wrapper Helper Functions <a href="#FDW-HELPERS" class="id_link">#</a></h2></div></div></div><p>
3      Several helper functions are exported from the core server so that
4      authors of foreign data wrappers can get easy access to attributes of
5      FDW-related objects, such as FDW options.
6      To use any of these functions, you need to include the header file
7      <code class="filename">foreign/foreign.h</code> in your source file.
8      That header also defines the struct types that are returned by
9      these functions.
10     </p><p>
11 </p><pre class="programlisting">
12 ForeignDataWrapper *
13 GetForeignDataWrapperExtended(Oid fdwid, bits16 flags);
14 </pre><p>
15
16      This function returns a <code class="structname">ForeignDataWrapper</code>
17      object for the foreign-data wrapper with the given OID.  A
18      <code class="structname">ForeignDataWrapper</code> object contains properties
19      of the FDW (see <code class="filename">foreign/foreign.h</code> for details).
20      <code class="structfield">flags</code> is a bitwise-or'd bit mask indicating
21      an extra set of options.  It can take the value
22      <code class="literal">FDW_MISSING_OK</code>, in which case a <code class="literal">NULL</code>
23      result is returned to the caller instead of an error for an undefined
24      object.
25     </p><p>
26 </p><pre class="programlisting">
27 ForeignDataWrapper *
28 GetForeignDataWrapper(Oid fdwid);
29 </pre><p>
30
31      This function returns a <code class="structname">ForeignDataWrapper</code>
32      object for the foreign-data wrapper with the given OID.  A
33      <code class="structname">ForeignDataWrapper</code> object contains properties
34      of the FDW (see <code class="filename">foreign/foreign.h</code> for details).
35     </p><p>
36 </p><pre class="programlisting">
37 ForeignServer *
38 GetForeignServerExtended(Oid serverid, bits16 flags);
39 </pre><p>
40
41      This function returns a <code class="structname">ForeignServer</code> object
42      for the foreign server with the given OID.  A
43      <code class="structname">ForeignServer</code> object contains properties
44      of the server (see <code class="filename">foreign/foreign.h</code> for details).
45      <code class="structfield">flags</code> is a bitwise-or'd bit mask indicating
46      an extra set of options.  It can take the value
47      <code class="literal">FSV_MISSING_OK</code>, in which case a <code class="literal">NULL</code>
48      result is returned to the caller instead of an error for an undefined
49      object.
50     </p><p>
51 </p><pre class="programlisting">
52 ForeignServer *
53 GetForeignServer(Oid serverid);
54 </pre><p>
55
56      This function returns a <code class="structname">ForeignServer</code> object
57      for the foreign server with the given OID.  A
58      <code class="structname">ForeignServer</code> object contains properties
59      of the server (see <code class="filename">foreign/foreign.h</code> for details).
60     </p><p>
61 </p><pre class="programlisting">
62 UserMapping *
63 GetUserMapping(Oid userid, Oid serverid);
64 </pre><p>
65
66      This function returns a <code class="structname">UserMapping</code> object for
67      the user mapping of the given role on the given server.  (If there is no
68      mapping for the specific user, it will return the mapping for
69      <code class="literal">PUBLIC</code>, or throw error if there is none.)  A
70      <code class="structname">UserMapping</code> object contains properties of the
71      user mapping (see <code class="filename">foreign/foreign.h</code> for details).
72     </p><p>
73 </p><pre class="programlisting">
74 ForeignTable *
75 GetForeignTable(Oid relid);
76 </pre><p>
77
78      This function returns a <code class="structname">ForeignTable</code> object for
79      the foreign table with the given OID.  A
80      <code class="structname">ForeignTable</code> object contains properties of the
81      foreign table (see <code class="filename">foreign/foreign.h</code> for details).
82     </p><p>
83 </p><pre class="programlisting">
84 List *
85 GetForeignColumnOptions(Oid relid, AttrNumber attnum);
86 </pre><p>
87
88      This function returns the per-column FDW options for the column with the
89      given foreign table OID and attribute number, in the form of a list of
90      <code class="structname">DefElem</code>.  NIL is returned if the column has no
91      options.
92     </p><p>
93      Some object types have name-based lookup functions in addition to the
94      OID-based ones:
95     </p><p>
96 </p><pre class="programlisting">
97 ForeignDataWrapper *
98 GetForeignDataWrapperByName(const char *name, bool missing_ok);
99 </pre><p>
100
101      This function returns a <code class="structname">ForeignDataWrapper</code>
102      object for the foreign-data wrapper with the given name.  If the wrapper
103      is not found, return NULL if missing_ok is true, otherwise raise an
104      error.
105     </p><p>
106 </p><pre class="programlisting">
107 ForeignServer *
108 GetForeignServerByName(const char *name, bool missing_ok);
109 </pre><p>
110
111      This function returns a <code class="structname">ForeignServer</code> object
112      for the foreign server with the given name.  If the server is not found,
113      return NULL if missing_ok is true, otherwise raise an error.
114     </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="58.2. Foreign Data Wrapper Callback Routines">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="fdwhandler.html" title="Chapter 58. Writing a Foreign Data Wrapper">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="fdw-planning.html" title="58.4. Foreign Data Wrapper Query Planning">Next</a></td></tr><tr><td width="40%" align="left" valign="top">58.2. Foreign Data Wrapper Callback Routines </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 18.0 Documentation">Home</a></td><td width="40%" align="right" valign="top"> 58.4. Foreign Data Wrapper Query Planning</td></tr></table></div></body></html>