gooderp18绿色标准版
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

114 lines
7.2KB

  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>56.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 V1.79.1" /><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 12.4 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>
  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. This function returns a <code class="structname">ForeignDataWrapper</code>
  16. object for the foreign-data wrapper with the given OID. A
  17. <code class="structname">ForeignDataWrapper</code> object contains properties
  18. of the FDW (see <code class="filename">foreign/foreign.h</code> for details).
  19. <code class="structfield">flags</code> is a bitwise-or'd bit mask indicating
  20. an extra set of options. It can take the value
  21. <code class="literal">FDW_MISSING_OK</code>, in which case a <code class="literal">NULL</code>
  22. result is returned to the caller instead of an error for an undefined
  23. object.
  24. </p><p>
  25. </p><pre class="programlisting">
  26. ForeignDataWrapper *
  27. GetForeignDataWrapper(Oid fdwid);
  28. </pre><p>
  29. This function returns a <code class="structname">ForeignDataWrapper</code>
  30. object for the foreign-data wrapper with the given OID. A
  31. <code class="structname">ForeignDataWrapper</code> object contains properties
  32. of the FDW (see <code class="filename">foreign/foreign.h</code> for details).
  33. </p><p>
  34. </p><pre class="programlisting">
  35. ForeignServer *
  36. GetForeignServerExtended(Oid serverid, bits16 flags);
  37. </pre><p>
  38. This function returns a <code class="structname">ForeignServer</code> object
  39. for the foreign server with the given OID. A
  40. <code class="structname">ForeignServer</code> object contains properties
  41. of the server (see <code class="filename">foreign/foreign.h</code> for details).
  42. <code class="structfield">flags</code> is a bitwise-or'd bit mask indicating
  43. an extra set of options. It can take the value
  44. <code class="literal">FSV_MISSING_OK</code>, in which case a <code class="literal">NULL</code>
  45. result is returned to the caller instead of an error for an undefined
  46. object.
  47. </p><p>
  48. </p><pre class="programlisting">
  49. ForeignServer *
  50. GetForeignServer(Oid serverid);
  51. </pre><p>
  52. This function returns a <code class="structname">ForeignServer</code> object
  53. for the foreign server with the given OID. A
  54. <code class="structname">ForeignServer</code> object contains properties
  55. of the server (see <code class="filename">foreign/foreign.h</code> for details).
  56. </p><p>
  57. </p><pre class="programlisting">
  58. UserMapping *
  59. GetUserMapping(Oid userid, Oid serverid);
  60. </pre><p>
  61. This function returns a <code class="structname">UserMapping</code> object for
  62. the user mapping of the given role on the given server. (If there is no
  63. mapping for the specific user, it will return the mapping for
  64. <code class="literal">PUBLIC</code>, or throw error if there is none.) A
  65. <code class="structname">UserMapping</code> object contains properties of the
  66. user mapping (see <code class="filename">foreign/foreign.h</code> for details).
  67. </p><p>
  68. </p><pre class="programlisting">
  69. ForeignTable *
  70. GetForeignTable(Oid relid);
  71. </pre><p>
  72. This function returns a <code class="structname">ForeignTable</code> object for
  73. the foreign table with the given OID. A
  74. <code class="structname">ForeignTable</code> object contains properties of the
  75. foreign table (see <code class="filename">foreign/foreign.h</code> for details).
  76. </p><p>
  77. </p><pre class="programlisting">
  78. List *
  79. GetForeignColumnOptions(Oid relid, AttrNumber attnum);
  80. </pre><p>
  81. This function returns the per-column FDW options for the column with the
  82. given foreign table OID and attribute number, in the form of a list of
  83. <code class="structname">DefElem</code>. NIL is returned if the column has no
  84. options.
  85. </p><p>
  86. Some object types have name-based lookup functions in addition to the
  87. OID-based ones:
  88. </p><p>
  89. </p><pre class="programlisting">
  90. ForeignDataWrapper *
  91. GetForeignDataWrapperByName(const char *name, bool missing_ok);
  92. </pre><p>
  93. This function returns a <code class="structname">ForeignDataWrapper</code>
  94. object for the foreign-data wrapper with the given name. If the wrapper
  95. is not found, return NULL if missing_ok is true, otherwise raise an
  96. error.
  97. </p><p>
  98. </p><pre class="programlisting">
  99. ForeignServer *
  100. GetForeignServerByName(const char *name, bool missing_ok);
  101. </pre><p>
  102. This function returns a <code class="structname">ForeignServer</code> object
  103. for the foreign server with the given name. If the server is not found,
  104. return NULL if missing_ok is true, otherwise raise an error.
  105. </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">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="fdwhandler.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="fdw-planning.html">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">Home</a></td><td width="40%" align="right" valign="top"> 56.4. Foreign Data Wrapper Query Planning</td></tr></table></div></body></html>
上海开阖软件有限公司 沪ICP备12045867号-1