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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
|
<!--
$PostgreSQL: pgsql/doc/src/sgml/ref/create_foreign_data_wrapper.sgml,v 1.1 2008/12/19 16:25:16 petere Exp $
PostgreSQL documentation
-->
<refentry id="SQL-CREATEFOREIGNDATAWRAPPER">
<refmeta>
<refentrytitle id="sql-createforeigndatawrapper-title">CREATE FOREIGN DATA WRAPPER</refentrytitle>
<refmiscinfo>SQL - Language Statements</refmiscinfo>
</refmeta>
<refnamediv>
<refname>CREATE FOREIGN DATA WRAPPER</refname>
<refpurpose>define a new foreign-data wrapper</refpurpose>
</refnamediv>
<indexterm zone="sql-createforeigndatawrapper">
<primary>CREATE FOREIGN DATA WRAPPER</primary>
</indexterm>
<refsynopsisdiv>
<synopsis>
CREATE FOREIGN DATA WRAPPER <replaceable class="parameter">name</replaceable>
LIBRARY '<replaceable class="parameter">libraryname</replaceable>'
LANGUAGE C
[ OPTIONS ( <replaceable class="PARAMETER">option</replaceable> '<replaceable class="PARAMETER">value</replaceable>' [, ... ] ) ]
</synopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>
<command>CREATE FOREIGN DATA WRAPPER</command> creates a new
foreign-data wrapper. The user who defines a foreign-data wrapper
becomes its owner.
</para>
<para>
The foreign-data wrapper name must be unique within the database.
</para>
<para>
Only superusers can create foreign-data wrappers.
</para>
</refsect1>
<refsect1>
<title>Parameters</title>
<variablelist>
<varlistentry>
<term><replaceable class="parameter">name</replaceable></term>
<listitem>
<para>
The name of the foreign-data wrapper to be created.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><replaceable class="parameter">libraryname</replaceable></term>
<listitem>
<para>
The name of the shared library implementing the foreign-data
wrapper. The file name is specified in the same way as for
shared library names in <xref linkend="sql-createfunction"
endterm="sql-createfunction-title">; in particular, one can rely
on a search path and automatic addition of the system's standard
shared library file name extension.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>LANGUAGE C</literal></term>
<listitem>
<para>
Currently, only the C programming language is supported for
implementing foreign-data wrappers.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>OPTIONS ( <replaceable class="PARAMETER">option</replaceable> ['<replaceable class="PARAMETER">value</replaceable>'] [, ... ] )</literal></term>
<listitem>
<para>
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
library. Option names must be unique.
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1>
<title>Notes</title>
<para>
At the moment, the foreign-data wrapper functionality is very
rudimentary. The purpose of foreign-data wrappers, foreign
servers, and user mappings is to store this information in a
standard way so that it can be queried by interested applications.
The functionality to actually query external data does not exist
yet.
</para>
<para>
The C language API for foreign-data wrappers is currently not
documented, stable, or complete. Would-be authors of functionality
interfacing with the SQL/MED functionality are advised to contact
the PostgreSQL developers.
</para>
<para>
There are currently two foreign-data wrapper libraries
provided: <filename>dummy_fdw</filename>, which does nothing and
could be useful for testing,
and <filename>postgresql_fdw</filename>, which accepts options
corresponding to <application>libpq</> connection parameters.
</para>
</refsect1>
<refsect1>
<title>Examples</title>
<para>
Create a foreign-data wrapper <literal>dummy</> with
library <literal>dummy_fdw</>:
<programlisting>
CREATE FOREIGN DATA WRAPPER dummy LIBRARY 'dummy_fdw' LANGUAGE C;
</programlisting>
</para>
<para>
Create a foreign-data wrapper <literal>postgresql</> with
library <literal>postgresql_fdw</>:
<programlisting>
CREATE FOREIGN DATA WRAPPER postgresql LIBRARY 'postgresql_fdw' LANGUAGE C;
</programlisting>
</para>
<para>
Create a foreign-data wrapper <literal>mywrapper</> with library
<literal>/home/bob/mywrapper.so</> and some options:
<programlisting>
CREATE FOREIGN DATA WRAPPER mywrapper
LIBRARY '/home/bob/mywrapper.so'
LANGUAGE C
OPTIONS (debug 'true');
</programlisting>
</para>
</refsect1>
<refsect1>
<title>Compatibility</title>
<para>
<command>CREATE FOREIGN DATA WRAPPER</command> conforms to ISO/IEC
9075-9 (SQL/MED), with the exception that
the <literal>LIBRARY</literal> clause is not optional in
PostgreSQL.
</para>
<para>
Note, however, that the SQL/MED functionality as a whole is not yet
conforming.
</para>
</refsect1>
<refsect1>
<title>See Also</title>
<simplelist type="inline">
<member><xref linkend="sql-alterforeigndatawrapper" endterm="sql-alterforeigndatawrapper-title"></member>
<member><xref linkend="sql-dropforeigndatawrapper" endterm="sql-dropforeigndatawrapper-title"></member>
<member><xref linkend="sql-createserver" endterm="sql-createserver-title"></member>
<member><xref linkend="sql-createusermapping" endterm="sql-createusermapping-title"></member>
</simplelist>
</refsect1>
</refentry>
|