Sophie

Sophie

distrib > Mageia > 7 > i586 > by-pkgid > 9b6cc37ce608401d44f6535a0c7cb777 > files > 839

postgresql11-docs-11.5-1.mga7.noarch.rpm

<?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>CREATE FOREIGN DATA WRAPPER</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="sql-createextension.html" title="CREATE EXTENSION" /><link rel="next" href="sql-createforeigntable.html" title="CREATE FOREIGN TABLE" /></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">CREATE FOREIGN DATA WRAPPER</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="sql-createextension.html" title="CREATE EXTENSION">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="sql-commands.html" title="SQL Commands">Up</a></td><th width="60%" align="center">SQL Commands</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 11.5 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="sql-createforeigntable.html" title="CREATE FOREIGN TABLE">Next</a></td></tr></table><hr></hr></div><div class="refentry" id="SQL-CREATEFOREIGNDATAWRAPPER"><div class="titlepage"></div><a id="id-1.9.3.65.1" class="indexterm"></a><div class="refnamediv"><h2><span class="refentrytitle">CREATE FOREIGN DATA WRAPPER</span></h2><p>CREATE FOREIGN DATA WRAPPER — define a new foreign-data wrapper</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><pre class="synopsis">
CREATE FOREIGN DATA WRAPPER <em class="replaceable"><code>name</code></em>
    [ HANDLER <em class="replaceable"><code>handler_function</code></em> | NO HANDLER ]
    [ VALIDATOR <em class="replaceable"><code>validator_function</code></em> | NO VALIDATOR ]
    [ OPTIONS ( <em class="replaceable"><code>option</code></em> '<em class="replaceable"><code>value</code></em>' [, ... ] ) ]
</pre></div><div class="refsect1" id="id-1.9.3.65.5"><h2>Description</h2><p>
   <code class="command">CREATE FOREIGN DATA WRAPPER</code> creates a new
   foreign-data wrapper.  The user who defines a foreign-data wrapper
   becomes its owner.
  </p><p>
   The foreign-data wrapper name must be unique within the database.
  </p><p>
   Only superusers can create foreign-data wrappers.
  </p></div><div class="refsect1" id="id-1.9.3.65.6"><h2>Parameters</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><em class="replaceable"><code>name</code></em></span></dt><dd><p>
      The name of the foreign-data wrapper to be created.
     </p></dd><dt><span class="term"><code class="literal">HANDLER <em class="replaceable"><code>handler_function</code></em></code></span></dt><dd><p><em class="replaceable"><code>handler_function</code></em> is the
      name of a previously registered function that will be called to
      retrieve the execution functions for foreign tables.
      The handler function must take no arguments, and
      its return type must be <code class="type">fdw_handler</code>.
     </p><p>
      It is possible to create a foreign-data wrapper with no handler
      function, but foreign tables using such a wrapper can only be declared,
      not accessed.
     </p></dd><dt><span class="term"><code class="literal">VALIDATOR <em class="replaceable"><code>validator_function</code></em></code></span></dt><dd><p><em class="replaceable"><code>validator_function</code></em>
      is the name of a previously registered function that will be called to
      check the generic options given to the foreign-data wrapper, as
      well as options for foreign servers, user mappings and foreign tables
      using the foreign-data wrapper.  If no validator function or <code class="literal">NO
      VALIDATOR</code> is specified, then options will not be
      checked at creation time.  (Foreign-data wrappers will possibly
      ignore or reject invalid option specifications at run time,
      depending on the implementation.)  The validator function must
      take two arguments: one of type <code class="type">text[]</code>, which will
      contain the array of options as stored in the system catalogs,
      and one of type <code class="type">oid</code>, which will be the OID of the
      system catalog containing the options. The return type is ignored;
      the function should report invalid options using the
      <code class="function">ereport(ERROR)</code> function.
     </p></dd><dt><span class="term"><code class="literal">OPTIONS ( <em class="replaceable"><code>option</code></em> '<em class="replaceable"><code>value</code></em>' [, ... ] )</code></span></dt><dd><p>
      This clause specifies options for the new foreign-data wrapper.
      The allowed option names and values are specific to each foreign
      data wrapper and are validated using the foreign-data wrapper's
      validator function.  Option names must be unique.
     </p></dd></dl></div></div><div class="refsect1" id="id-1.9.3.65.7"><h2>Notes</h2><p>
   <span class="productname">PostgreSQL</span>'s foreign-data functionality is still under
   active development.  Optimization of queries is primitive (and mostly left
   to the wrapper, too).  Thus, there is considerable room for future
   performance improvements.
  </p></div><div class="refsect1" id="id-1.9.3.65.8"><h2>Examples</h2><p>
   Create a useless foreign-data wrapper <code class="literal">dummy</code>:
</p><pre class="programlisting">
CREATE FOREIGN DATA WRAPPER dummy;
</pre><p>
  </p><p>
   Create a foreign-data wrapper <code class="literal">file</code> with
   handler function <code class="literal">file_fdw_handler</code>:
</p><pre class="programlisting">
CREATE FOREIGN DATA WRAPPER file HANDLER file_fdw_handler;
</pre><p>
  </p><p>
   Create a foreign-data wrapper <code class="literal">mywrapper</code> with some
   options:
</p><pre class="programlisting">
CREATE FOREIGN DATA WRAPPER mywrapper
    OPTIONS (debug 'true');
</pre></div><div class="refsect1" id="id-1.9.3.65.9"><h2>Compatibility</h2><p>
   <code class="command">CREATE FOREIGN DATA WRAPPER</code> conforms to ISO/IEC
   9075-9 (SQL/MED), with the exception that the <code class="literal">HANDLER</code>
   and <code class="literal">VALIDATOR</code> clauses are extensions and the standard
   clauses <code class="literal">LIBRARY</code> and <code class="literal">LANGUAGE</code>
   are not implemented in <span class="productname">PostgreSQL</span>.
  </p><p>
   Note, however, that the SQL/MED functionality as a whole is not yet
   conforming.
  </p></div><div class="refsect1" id="id-1.9.3.65.10"><h2>See Also</h2><span class="simplelist"><a class="xref" href="sql-alterforeigndatawrapper.html" title="ALTER FOREIGN DATA WRAPPER"><span class="refentrytitle">ALTER FOREIGN DATA WRAPPER</span></a>, <a class="xref" href="sql-dropforeigndatawrapper.html" title="DROP FOREIGN DATA WRAPPER"><span class="refentrytitle">DROP FOREIGN DATA WRAPPER</span></a>, <a class="xref" href="sql-createserver.html" title="CREATE SERVER"><span class="refentrytitle">CREATE SERVER</span></a>, <a class="xref" href="sql-createusermapping.html" title="CREATE USER MAPPING"><span class="refentrytitle">CREATE USER MAPPING</span></a>, <a class="xref" href="sql-createforeigntable.html" title="CREATE FOREIGN TABLE"><span class="refentrytitle">CREATE FOREIGN TABLE</span></a></span></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="sql-createextension.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="sql-commands.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="sql-createforeigntable.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">CREATE EXTENSION </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> CREATE FOREIGN TABLE</td></tr></table></div></body></html>