11<!--
2- $PostgreSQL: pgsql/doc/src/sgml/ref/create_foreign_data_wrapper.sgml,v 1.1 2008/12/19 16:25:16 petere Exp $
2+ $PostgreSQL: pgsql/doc/src/sgml/ref/create_foreign_data_wrapper.sgml,v 1.2 2009/02/24 10:06:32 petere Exp $
33PostgreSQL documentation
44-->
55
@@ -21,8 +21,7 @@ PostgreSQL documentation
2121 <refsynopsisdiv>
2222<synopsis>
2323CREATE FOREIGN DATA WRAPPER <replaceable class="parameter">name</replaceable>
24- LIBRARY '<replaceable class="parameter">libraryname</replaceable>'
25- LANGUAGE C
24+ [ VALIDATOR <replaceable class="parameter">valfunction</replaceable> | NO VALIDATOR ]
2625 [ OPTIONS ( <replaceable class="PARAMETER">option</replaceable> '<replaceable class="PARAMETER">value</replaceable>' [, ... ] ) ]
2726</synopsis>
2827 </refsynopsisdiv>
@@ -59,25 +58,25 @@ CREATE FOREIGN DATA WRAPPER <replaceable class="parameter">name</replaceable>
5958 </varlistentry>
6059
6160 <varlistentry>
62- <term><replaceable class="parameter">libraryname </replaceable></term>
61+ <term><literal>VALIDATOR < replaceable class="parameter">valfunction </replaceable></literal ></term>
6362 <listitem>
6463 <para>
65- The name of the shared library implementing the foreign-data
66- wrapper. The file name is specified in the same way as for
67- shared library names in <xref linkend="sql-createfunction"
68- endterm="sql-createfunction-title">; in particular, one can rely
69- on a search path and automatic addition of the system's standard
70- shared library file name extension.
71- </para>
72- </listitem>
73- </varlistentry>
74-
75- <varlistentry>
76- <term><literal>LANGUAGE C</literal></term>
77- <listitem>
78- <para>
79- Currently, only the C programming language is supported for
80- implementing foreign-data wrappers .
64+ <replaceable class="parameter">valfunction</replaceable> is the
65+ name of a previously registered function that will be called to
66+ check the generic options given to the foreign-data wrapper, as
67+ well as to foreign servers and user mappings using the
68+ foreign-data wrapper. If no validator function or <literal>NO
69+ VALIDATOR</literal> is specified, then options will not be
70+ checked at creation time. (Foreign-data wrappers will possibly
71+ ignore or reject invalid option specifications at run time,
72+ depending on the implementation.) The validator function must
73+ take two arguments: one of type <type>text[]</type>, which will
74+ contain the array of options as stored in the system catalogs,
75+ and one of type <type>oid</type>, which will be the OID of the
76+ system catalog containing the options, or zero if the context is
77+ not known. The return type is ignored; the function should
78+ indicate invalid options using
79+ the <function>ereport()</function> function .
8180 </para>
8281 </listitem>
8382 </varlistentry>
@@ -109,47 +108,37 @@ CREATE FOREIGN DATA WRAPPER <replaceable class="parameter">name</replaceable>
109108 </para>
110109
111110 <para>
112- The C language API for foreign-data wrappers is currently not
113- documented, stable, or complete. Would-be authors of functionality
114- interfacing with the SQL/MED functionality are advised to contact
115- the PostgreSQL developers.
116- </para>
117-
118- <para>
119- There are currently two foreign-data wrapper libraries
120- provided: <filename>dummy_fdw</filename>, which does nothing and
121- could be useful for testing,
122- and <filename>postgresql_fdw</filename>, which accepts options
123- corresponding to <application>libpq</> connection parameters.
111+ There is currently one foreign-data wrapper validator function
112+ provided:
113+ <filename>postgresql_fdw_validator</filename>, which accepts
114+ options corresponding to <application>libpq</> connection
115+ parameters.
124116 </para>
125117 </refsect1>
126118
127119 <refsect1>
128120 <title>Examples</title>
129121
130122 <para>
131- Create a foreign-data wrapper <literal>dummy</> with
132- library <literal>dummy_fdw</>:
123+ Create a foreign-data wrapper <literal>dummy</>:
133124<programlisting>
134- CREATE FOREIGN DATA WRAPPER dummy LIBRARY 'dummy_fdw' LANGUAGE C ;
125+ CREATE FOREIGN DATA WRAPPER dummy;
135126</programlisting>
136127 </para>
137128
138129 <para>
139130 Create a foreign-data wrapper <literal>postgresql</> with
140- library <literal>postgresql_fdw </>:
131+ validator function <literal>postgresql_fdw_validator </>:
141132<programlisting>
142- CREATE FOREIGN DATA WRAPPER postgresql LIBRARY 'postgresql_fdw' LANGUAGE C ;
133+ CREATE FOREIGN DATA WRAPPER postgresql VALIDATOR postgresql_fdw_validator ;
143134</programlisting>
144135 </para>
145136
146137 <para>
147- Create a foreign-data wrapper <literal>mywrapper</> with library
148- <literal>/home/bob/mywrapper.so</> and some options:
138+ Create a foreign-data wrapper <literal>mywrapper</> with some
139+ options:
149140<programlisting>
150141CREATE FOREIGN DATA WRAPPER mywrapper
151- LIBRARY '/home/bob/mywrapper.so'
152- LANGUAGE C
153142 OPTIONS (debug 'true');
154143</programlisting>
155144 </para>
@@ -161,8 +150,9 @@ CREATE FOREIGN DATA WRAPPER mywrapper
161150 <para>
162151 <command>CREATE FOREIGN DATA WRAPPER</command> conforms to ISO/IEC
163152 9075-9 (SQL/MED), with the exception that
164- the <literal>LIBRARY</literal> clause is not optional in
165- PostgreSQL.
153+ the <literal>VALIDATOR</literal> clause is an extension and the
154+ clauses <literal>LIBRARY</literal> and <literal>LANGUAGE</literal>
155+ are not yet implemented in PostgreSQL.
166156 </para>
167157
168158 <para>
0 commit comments