3 PostgreSQL documentation
6 <refentry id=
"SQL-CREATEFOREIGNDATAWRAPPER">
8 <refentrytitle id=
"sql-createforeigndatawrapper-title">CREATE FOREIGN DATA WRAPPER
</refentrytitle>
9 <manvolnum>7</manvolnum>
10 <refmiscinfo>SQL - Language Statements
</refmiscinfo>
14 <refname>CREATE FOREIGN DATA WRAPPER
</refname>
15 <refpurpose>define a new foreign-data wrapper
</refpurpose>
18 <indexterm zone=
"sql-createforeigndatawrapper">
19 <primary>CREATE FOREIGN DATA WRAPPER
</primary>
24 CREATE FOREIGN DATA WRAPPER
<replaceable class=
"parameter">name
</replaceable>
25 [ VALIDATOR
<replaceable class=
"parameter">valfunction
</replaceable> | NO VALIDATOR ]
26 [ OPTIONS (
<replaceable class=
"PARAMETER">option
</replaceable> '
<replaceable class=
"PARAMETER">value
</replaceable>' [, ... ] ) ]
31 <title>Description
</title>
34 <command>CREATE FOREIGN DATA WRAPPER
</command> creates a new
35 foreign-data wrapper. The user who defines a foreign-data wrapper
40 The foreign-data wrapper name must be unique within the database.
44 Only superusers can create foreign-data wrappers.
49 <title>Parameters
</title>
53 <term><replaceable class=
"parameter">name
</replaceable></term>
56 The name of the foreign-data wrapper to be created.
62 <term><literal>VALIDATOR
<replaceable class=
"parameter">valfunction
</replaceable></literal></term>
65 <replaceable class=
"parameter">valfunction
</replaceable> is the
66 name of a previously registered function that will be called to
67 check the generic options given to the foreign-data wrapper, as
68 well as to foreign servers and user mappings using the
69 foreign-data wrapper. If no validator function or
<literal>NO
70 VALIDATOR
</literal> is specified, then options will not be
71 checked at creation time. (Foreign-data wrappers will possibly
72 ignore or reject invalid option specifications at run time,
73 depending on the implementation.) The validator function must
74 take two arguments: one of type
<type>text[]
</type>, which will
75 contain the array of options as stored in the system catalogs,
76 and one of type
<type>oid
</type>, which will be the OID of the
77 system catalog containing the options, or zero if the context is
78 not known. The return type is ignored; the function should
79 indicate invalid options using
80 the
<function>ereport()
</function> function.
86 <term><literal>OPTIONS (
<replaceable class=
"PARAMETER">option
</replaceable> '
<replaceable class=
"PARAMETER">value
</replaceable>' [, ... ] )
</literal></term>
89 This clause specifies options for the new foreign-data wrapper.
90 The allowed option names and values are specific to each foreign
91 data wrapper and are validated using the foreign-data wrapper
92 library. Option names must be unique.
103 At the moment, the foreign-data wrapper functionality is very
104 rudimentary. The purpose of foreign-data wrappers, foreign
105 servers, and user mappings is to store this information in a
106 standard way so that it can be queried by interested applications.
107 One such application is
<application>dblink
</application>;
108 see
<xref linkend=
"dblink">. The functionality to actually query
109 external data through a foreign-data wrapper library does not exist
114 There is currently one foreign-data wrapper validator function
116 <filename>postgresql_fdw_validator
</filename>, which accepts
117 options corresponding to
<application>libpq<
/> connection
123 <title>Examples
</title>
126 Create a foreign-data wrapper
<literal>dummy<
/>:
128 CREATE FOREIGN DATA WRAPPER dummy;
133 Create a foreign-data wrapper
<literal>postgresql<
/> with
134 validator function
<literal>postgresql_fdw_validator<
/>:
136 CREATE FOREIGN DATA WRAPPER postgresql VALIDATOR postgresql_fdw_validator;
141 Create a foreign-data wrapper
<literal>mywrapper<
/> with some
144 CREATE FOREIGN DATA WRAPPER mywrapper
145 OPTIONS (debug 'true');
151 <title>Compatibility
</title>
154 <command>CREATE FOREIGN DATA WRAPPER
</command> conforms to ISO/IEC
155 9075-
9 (SQL/MED), with the exception that
156 the
<literal>VALIDATOR
</literal> clause is an extension and the
157 clauses
<literal>LIBRARY
</literal> and
<literal>LANGUAGE
</literal>
158 are not yet implemented in PostgreSQL.
162 Note, however, that the SQL/MED functionality as a whole is not yet
168 <title>See Also
</title>
170 <simplelist type=
"inline">
171 <member><xref linkend=
"sql-alterforeigndatawrapper" endterm=
"sql-alterforeigndatawrapper-title"></member>
172 <member><xref linkend=
"sql-dropforeigndatawrapper" endterm=
"sql-dropforeigndatawrapper-title"></member>
173 <member><xref linkend=
"sql-createserver" endterm=
"sql-createserver-title"></member>
174 <member><xref linkend=
"sql-createusermapping" endterm=
"sql-createusermapping-title"></member>