aboutsummaryrefslogtreecommitdiff
path: root/doc/src
diff options
context:
space:
mode:
Diffstat (limited to 'doc/src')
-rw-r--r--doc/src/sgml/catalogs.sgml325
-rw-r--r--doc/src/sgml/features.sgml6
-rw-r--r--doc/src/sgml/func.sgml54
-rw-r--r--doc/src/sgml/information_schema.sgml388
-rw-r--r--doc/src/sgml/keywords.sgml32
-rw-r--r--doc/src/sgml/ref/allfiles.sgml11
-rw-r--r--doc/src/sgml/ref/alter_foreign_data_wrapper.sgml132
-rw-r--r--doc/src/sgml/ref/alter_server.sgml123
-rw-r--r--doc/src/sgml/ref/alter_user_mapping.sgml119
-rw-r--r--doc/src/sgml/ref/create_foreign_data_wrapper.sgml185
-rw-r--r--doc/src/sgml/ref/create_server.sgml140
-rw-r--r--doc/src/sgml/ref/create_user_mapping.sgml111
-rw-r--r--doc/src/sgml/ref/drop_foreign_data_wrapper.sgml112
-rw-r--r--doc/src/sgml/ref/drop_server.sgml112
-rw-r--r--doc/src/sgml/ref/drop_user_mapping.sgml104
-rw-r--r--doc/src/sgml/ref/grant.sgml26
-rw-r--r--doc/src/sgml/ref/psql-ref.sgml60
-rw-r--r--doc/src/sgml/ref/revoke.sgml14
-rw-r--r--doc/src/sgml/reference.sgml11
19 files changed, 2024 insertions, 41 deletions
diff --git a/doc/src/sgml/catalogs.sgml b/doc/src/sgml/catalogs.sgml
index f5f26d035d9..52be7a4d26d 100644
--- a/doc/src/sgml/catalogs.sgml
+++ b/doc/src/sgml/catalogs.sgml
@@ -1,4 +1,4 @@
-<!-- $PostgreSQL: pgsql/doc/src/sgml/catalogs.sgml,v 2.184 2008/12/18 18:20:33 tgl Exp $ -->
+<!-- $PostgreSQL: pgsql/doc/src/sgml/catalogs.sgml,v 2.185 2008/12/19 16:25:16 petere Exp $ -->
<!--
Documentation of the system catalogs, directed toward PostgreSQL developers
-->
@@ -134,6 +134,16 @@
</row>
<row>
+ <entry><link linkend="catalog-pg-foreign-data-wrapper"><structname>pg_foreign_data_wrapper</structname></link></entry>
+ <entry>foreign-data wrapper definitions</entry>
+ </row>
+
+ <row>
+ <entry><link linkend="catalog-pg-foreign-server"><structname>pg_foreign_server</structname></link></entry>
+ <entry>foreign server definitions</entry>
+ </row>
+
+ <row>
<entry><link linkend="catalog-pg-index"><structname>pg_index</structname></link></entry>
<entry>additional index information</entry>
</row>
@@ -247,6 +257,11 @@
<entry><link linkend="catalog-pg-type"><structname>pg_type</structname></link></entry>
<entry>data types</entry>
</row>
+
+ <row>
+ <entry><link linkend="catalog-pg-user-mapping"><structname>pg_user_mapping</structname></link></entry>
+ <entry>mappings of users to foreign servers</entry>
+ </row>
</tbody>
</tgroup>
</table>
@@ -2552,6 +2567,229 @@
</sect1>
+ <sect1 id="catalog-pg-foreign-data-wrapper">
+ <title><structname>pg_foreign_data_wrapper</structname></title>
+
+ <indexterm zone="catalog-pg-foreign-data-wrapper">
+ <primary>pg_foreign_data_wrapper</primary>
+ </indexterm>
+
+ <para>
+ The catalog <structname>pg_foreign_data_wrapper</structname> stores
+ foreign-data wrapper definitions. A foreign-data wrapper is the
+ mechanism by which external data, residing on foreign servers, is
+ accessed.
+ </para>
+
+ <table>
+ <title><structname>pg_foreign_data_wrapper</> Columns</title>
+
+ <tgroup cols=4>
+ <thead>
+ <row>
+ <entry>Name</entry>
+ <entry>Type</entry>
+ <entry>References</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+
+ <tbody>
+ <row>
+ <entry><structfield>fdwname</structfield></entry>
+ <entry><type>name</type></entry>
+ <entry></entry>
+ <entry>Name of the foreign-data wrapper</entry>
+ </row>
+
+ <row>
+ <entry><structfield>fdwowner</structfield></entry>
+ <entry><type>oid</type></entry>
+ <entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.oid</literal></entry>
+ <entry>Owner of the foreign-data wrapper</entry>
+ </row>
+
+ <row>
+ <entry><structfield>fdwlibrary</structfield></entry>
+ <entry><type>text</type></entry>
+ <entry></entry>
+ <entry>File name of the library implementing this foreign-data wrapper</entry>
+ </row>
+
+ <row>
+ <entry><structfield>fdwacl</structfield></entry>
+ <entry><type>aclitem[]</type></entry>
+ <entry></entry>
+ <entry>
+ Access privileges; see
+ <xref linkend="sql-grant" endterm="sql-grant-title"> and
+ <xref linkend="sql-revoke" endterm="sql-revoke-title">
+ for details
+ </entry>
+ </row>
+
+ <row>
+ <entry><structfield>fdwoptions</structfield></entry>
+ <entry><type>text[]</type></entry>
+ <entry></entry>
+ <entry>
+ Foreign-data wrapper specific options, as <quote>keyword=value</> strings
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ </sect1>
+
+
+ <sect1 id="catalog-pg-foreign-server">
+ <title><structname>pg_foreign_server</structname></title>
+
+ <indexterm zone="catalog-pg-foreign-server">
+ <primary>pg_foreign_server</primary>
+ </indexterm>
+
+ <para>
+ The catalog <structname>pg_foreign_server</structname> stores
+ foreign server definitions. A foreign server describes the
+ connection to a remote server, managing external data. Foreign
+ servers are accessed via foreign-data wrappers.
+ </para>
+
+ <table>
+ <title><structname>pg_foreign_server</> Columns</title>
+
+ <tgroup cols=4>
+ <thead>
+ <row>
+ <entry>Name</entry>
+ <entry>Type</entry>
+ <entry>References</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+
+ <tbody>
+ <row>
+ <entry><structfield>srvname</structfield></entry>
+ <entry><type>name</type></entry>
+ <entry></entry>
+ <entry>Name of the foreign server</entry>
+ </row>
+
+ <row>
+ <entry><structfield>srvowner</structfield></entry>
+ <entry><type>oid</type></entry>
+ <entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.oid</literal></entry>
+ <entry>Owner of the foreign server</entry>
+ </row>
+
+ <row>
+ <entry><structfield>srvfdw</structfield></entry>
+ <entry><type>oid</type></entry>
+ <entry><literal><link linkend="catalog-pg-foreign-data-wrapper"><structname>pg_foreign_data_wrapper</structname></link>.oid</literal></entry>
+ <entry>The OID of the foreign-data wrapper of this foreign server</entry>
+ </row>
+
+ <row>
+ <entry><structfield>srvtype</structfield></entry>
+ <entry><type>text</type></entry>
+ <entry></entry>
+ <entry>Type of the server (optional)</entry>
+ </row>
+
+ <row>
+ <entry><structfield>srvversion</structfield></entry>
+ <entry><type>text</type></entry>
+ <entry></entry>
+ <entry>Version of the server (optional)</entry>
+ </row>
+
+ <row>
+ <entry><structfield>srvacl</structfield></entry>
+ <entry><type>aclitem[]</type></entry>
+ <entry></entry>
+ <entry>
+ Access privileges; see
+ <xref linkend="sql-grant" endterm="sql-grant-title"> and
+ <xref linkend="sql-revoke" endterm="sql-revoke-title">
+ for details
+ </entry>
+ </row>
+
+ <row>
+ <entry><structfield>srvoptions</structfield></entry>
+ <entry><type>text[]</type></entry>
+ <entry></entry>
+ <entry>
+ Foreign server specific options, as <quote>keyword=value</> strings.
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ </sect1>
+
+
+ <sect1 id="catalog-pg-user-mapping">
+ <title><structname>pg_user_mapping</structname></title>
+
+ <indexterm zone="catalog-pg-user-mapping">
+ <primary>pg_user_mapping</primary>
+ </indexterm>
+
+ <para>
+ The catalog <structname>pg_user_mapping</structname> stores
+ the mappings from local user to remote. Access to this catalog is
+ restricted from normal users, use the view
+ <link linkend="view-pg-user-mappings"><structname>pg_user_mappings</structname></link>
+ instead.
+ </para>
+
+ <table>
+ <title><structname>pg_user_mapping</> Columns</title>
+
+ <tgroup cols=4>
+ <thead>
+ <row>
+ <entry>Name</entry>
+ <entry>Type</entry>
+ <entry>References</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+
+ <tbody>
+ <row>
+ <entry><structfield>umuser</structfield></entry>
+ <entry><type>oid</type></entry>
+ <entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.oid</literal></entry>
+ <entry>OID of the local role being mapped, 0 if the user mapping is public</entry>
+ </row>
+
+ <row>
+ <entry><structfield>umserver</structfield></entry>
+ <entry><type>oid</type></entry>
+ <entry><literal><link linkend="catalog-pg-foreign-server"><structname>pg_foreign_server</structname></link>.oid</literal></entry>
+ <entry>
+ The OID of the foreign server that contains this mapping
+ </entry>
+ </row>
+
+ <row>
+ <entry><structfield>umoptions</structfield></entry>
+ <entry><type>text[]</type></entry>
+ <entry></entry>
+ <entry>
+ User mapping specific options, as <quote>keyword=value</> strings.
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ </sect1>
+
+
<sect1 id="catalog-pg-index">
<title><structname>pg_index</structname></title>
@@ -7019,6 +7257,91 @@
</sect1>
+ <sect1 id="view-pg-user-mappings">
+ <title><structname>pg_user_mappings</structname></title>
+
+ <indexterm zone="view-pg-user-mappings">
+ <primary>pg_user_mappings</primary>
+ </indexterm>
+
+ <para>
+ The view <structname>pg_user_mappings</structname> provides access
+ to information about user mappings. This is essentially a publicly
+ readable view of
+ <link linkend="catalog-pg-user-mapping"><structname>pg_user_mapping</structname></link>
+ that leaves out the options field if the user has no rights to use
+ it.
+ </para>
+
+ <table>
+ <title><structname>pg_user_mappings</> Columns</title>
+
+ <tgroup cols=3>
+ <thead>
+ <row>
+ <entry>Name</entry>
+ <entry>Type</entry>
+ <entry>References</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+
+ <tbody>
+ <row>
+ <entry><structfield>umid</structfield></entry>
+ <entry><type>oid</type></entry>
+ <entry><literal><link linkend="catalog-pg-user-mapping"><structname>pg_user_mapping</structname></link>.oid</literal></entry>
+ <entry>OID of the user mapping</entry>
+ </row>
+
+ <row>
+ <entry><structfield>srvid</structfield></entry>
+ <entry><type>oid</type></entry>
+ <entry><literal><link linkend="catalog-pg-foreign-server"><structname>pg_foreign_server</structname></link>.oid</literal></entry>
+ <entry>
+ The OID of the foreign server that contains this mapping
+ </entry>
+ </row>
+
+ <row>
+ <entry><structfield>srvname</structfield></entry>
+ <entry><type>text</type></entry>
+ <entry></entry>
+ <entry>
+ Name of the foreign server
+ </entry>
+ </row>
+
+ <row>
+ <entry><structfield>umuser</structfield></entry>
+ <entry><type>oid</type></entry>
+ <entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.oid</literal></entry>
+ <entry>OID of the local role being mapped, 0 if the user mapping is public</entry>
+ </row>
+
+ <row>
+ <entry><structfield>usename</structfield></entry>
+ <entry><type>name</type></entry>
+ <entry></entry>
+ <entry>Name of the local user to be mapped</entry>
+ </row>
+
+ <row>
+ <entry><structfield>umoptions</structfield></entry>
+ <entry><type>text[]</type></entry>
+ <entry></entry>
+ <entry>
+ User mapping specific options, as <quote>keyword=value</>
+ strings, if the current user is the owner of the foreign
+ server, else null.
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ </sect1>
+
+
<sect1 id="view-pg-views">
<title><structname>pg_views</structname></title>
diff --git a/doc/src/sgml/features.sgml b/doc/src/sgml/features.sgml
index 712ad4e4ecf..56b5be33183 100644
--- a/doc/src/sgml/features.sgml
+++ b/doc/src/sgml/features.sgml
@@ -1,4 +1,4 @@
-<!-- $PostgreSQL: pgsql/doc/src/sgml/features.sgml,v 2.29 2008/11/27 12:12:02 petere Exp $ -->
+<!-- $PostgreSQL: pgsql/doc/src/sgml/features.sgml,v 2.30 2008/12/19 16:25:16 petere Exp $ -->
<appendix id="features">
<title>SQL Conformance</title>
@@ -71,11 +71,11 @@
</para>
<para>
- The <productname>PostgreSQL</productname> core covers parts 1, 2,
+ The <productname>PostgreSQL</productname> core covers parts 1, 2, 9,
11, and 14. Part 3 is covered by the ODBC driver, and part 13 is
covered by the PL/Java plug-in, but exact conformance is currently
not being verified for these components. There are currently no
- implementations of parts 4, 9, and 10
+ implementations of parts 4 and 10
for <productname>PostgreSQL</productname>.
</para>
diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml
index c08c4801882..de50c0e1d56 100644
--- a/doc/src/sgml/func.sgml
+++ b/doc/src/sgml/func.sgml
@@ -1,4 +1,4 @@
-<!-- $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.462 2008/12/18 18:20:33 tgl Exp $ -->
+<!-- $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.463 2008/12/19 16:25:16 petere Exp $ -->
<chapter id="functions">
<title>Functions and Operators</title>
@@ -11336,6 +11336,21 @@ SET search_path TO <replaceable>schema</> <optional>, <replaceable>schema</>, ..
<entry>does current user have privilege for database</entry>
</row>
<row>
+ <entry><literal><function>has_foreign_data_wrapper_privilege</function>(<parameter>user</parameter>,
+ <parameter>fdw</parameter>,
+ <parameter>privilege</parameter>)</literal>
+ </entry>
+ <entry><type>boolean</type></entry>
+ <entry>does user have privilege for foreign-data wrapper</entry>
+ </row>
+ <row>
+ <entry><literal><function>has_foreign_data_wrapper_privilege</function>(<parameter>fdw</parameter>,
+ <parameter>privilege</parameter>)</literal>
+ </entry>
+ <entry><type>boolean</type></entry>
+ <entry>does current user have privilege for foreign-data wrapper</entry>
+ </row>
+ <row>
<entry><literal><function>has_function_privilege</function>(<parameter>user</parameter>,
<parameter>function</parameter>,
<parameter>privilege</parameter>)</literal>
@@ -11381,6 +11396,21 @@ SET search_path TO <replaceable>schema</> <optional>, <replaceable>schema</>, ..
<entry>does current user have privilege for schema</entry>
</row>
<row>
+ <entry><literal><function>has_server_privilege</function>(<parameter>user</parameter>,
+ <parameter>server</parameter>,
+ <parameter>privilege</parameter>)</literal>
+ </entry>
+ <entry><type>boolean</type></entry>
+ <entry>does user have privilege for foreign server</entry>
+ </row>
+ <row>
+ <entry><literal><function>has_server_privilege</function>(<parameter>server</parameter>,
+ <parameter>privilege</parameter>)</literal>
+ </entry>
+ <entry><type>boolean</type></entry>
+ <entry>does current user have privilege for foreign server</entry>
+ </row>
+ <row>
<entry><literal><function>has_table_privilege</function>(<parameter>user</parameter>,
<parameter>table</parameter>,
<parameter>privilege</parameter>)</literal>
@@ -11436,12 +11466,18 @@ SET search_path TO <replaceable>schema</> <optional>, <replaceable>schema</>, ..
<primary>has_function_privilege</primary>
</indexterm>
<indexterm>
+ <primary>has_foreign_data_wrapper_privilege</primary>
+ </indexterm>
+ <indexterm>
<primary>has_language_privilege</primary>
</indexterm>
<indexterm>
<primary>has_schema_privilege</primary>
</indexterm>
<indexterm>
+ <primary>has_server_privilege</primary>
+ </indexterm>
+ <indexterm>
<primary>has_table_privilege</primary>
</indexterm>
<indexterm>
@@ -11479,6 +11515,14 @@ SELECT has_function_privilege('joeuser', 'myfunc(int, text)', 'execute');
</para>
<para>
+ <function>has_foreign_data_wrapper_privilege</function> checks whether a user
+ can access a foreign-data wrapper in a particular way. The possibilities for its
+ arguments are analogous to <function>has_table_privilege</function>.
+ The desired access privilege type must evaluate to
+ <literal>USAGE</literal>.
+ </para>
+
+ <para>
<function>has_language_privilege</function> checks whether a user
can access a procedural language in a particular way. The possibilities
for its arguments are analogous to <function>has_table_privilege</function>.
@@ -11496,6 +11540,14 @@ SELECT has_function_privilege('joeuser', 'myfunc(int, text)', 'execute');
</para>
<para>
+ <function>has_server_privilege</function> checks whether a user
+ can access a foreign server in a particular way. The possibilities for its
+ arguments are analogous to <function>has_table_privilege</function>.
+ The desired access privilege type must evaluate to
+ <literal>USAGE</literal>.
+ </para>
+
+ <para>
<function>has_table_privilege</function> checks whether a user
can access a table in a particular way. The user can be
specified by name or by OID
diff --git a/doc/src/sgml/information_schema.sgml b/doc/src/sgml/information_schema.sgml
index da01c9cc5a7..f645c1252d6 100644
--- a/doc/src/sgml/information_schema.sgml
+++ b/doc/src/sgml/information_schema.sgml
@@ -1,4 +1,4 @@
-<!-- $PostgreSQL: pgsql/doc/src/sgml/information_schema.sgml,v 1.35 2008/11/25 20:47:42 tgl Exp $ -->
+<!-- $PostgreSQL: pgsql/doc/src/sgml/information_schema.sgml,v 1.36 2008/12/19 16:25:16 petere Exp $ -->
<chapter id="information-schema">
<title>The Information Schema</title>
@@ -2145,6 +2145,237 @@ ORDER BY c.ordinal_position;
</table>
</sect1>
+ <sect1 id="infoschema-foreign-data-wrapper-options">
+ <title><literal>foreign_data_wrapper_options</literal></title>
+
+ <para>
+ The view <literal>foreign_data_wrapper_options</literal> contains
+ all the options defined for foreign-data wrappers in the current
+ database. Only those foreign-data wrappers are shown that the
+ current user has access to (by way of being the owner or having
+ some privilege).
+ </para>
+
+ <table>
+ <title><literal>foreign_data_wrapper_options</literal> Columns</title>
+
+ <tgroup cols="3">
+ <thead>
+ <row>
+ <entry>Name</entry>
+ <entry>Data Type</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+
+ <tbody>
+ <row>
+ <entry><literal>foreign_data_wrapper_catalog</literal></entry>
+ <entry><type>sql_identifier</type></entry>
+ <entry>Name of the database that the foreign-data wrapper is defined in (always the current database)</entry>
+ </row>
+
+ <row>
+ <entry><literal>foreign_data_wrapper_name</literal></entry>
+ <entry><type>sql_identifier</type></entry>
+ <entry>Name of the foreign-data wrapper</entry>
+ </row>
+
+ <row>
+ <entry><literal>option_name</literal></entry>
+ <entry><type>sql_identifier</type></entry>
+ <entry>Name of an option</entry>
+ </row>
+
+ <row>
+ <entry><literal>option_value</literal></entry>
+ <entry><type>character_data</type></entry>
+ <entry>Value of the option</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ </sect1>
+
+ <sect1 id="infoschema-foreign-data-wrappers">
+ <title><literal>foreign_data_wrappers</literal></title>
+
+ <para>
+ The view <literal>foreign_data_wrappers</literal> contains all
+ foreign-data wrappers defined in the current database. Only those
+ foreign-data wrappers are shown that the current user has access to
+ (by way of being the owner or having some privilege).
+ </para>
+
+ <table>
+ <title><literal>foreign_data_wrappers</literal> Columns</title>
+
+ <tgroup cols="3">
+ <thead>
+ <row>
+ <entry>Name</entry>
+ <entry>Data Type</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+
+ <tbody>
+ <row>
+ <entry><literal>foreign_data_wrapper_catalog</literal></entry>
+ <entry><type>sql_identifier</type></entry>
+ <entry>Name of the database that contains the foreign-data
+ wrapper (always the current database)</entry>
+ </row>
+
+ <row>
+ <entry><literal>foreign_data_wrapper_name</literal></entry>
+ <entry><type>sql_identifier</type></entry>
+ <entry>Name of the foreign-data wrapper</entry>
+ </row>
+
+ <row>
+ <entry><literal>authorization_identifier</literal></entry>
+ <entry><type>sql_identifier</type></entry>
+ <entry>Name of the owner of the foreign server</entry>
+ </row>
+
+ <row>
+ <entry><literal>library_name</literal></entry>
+ <entry><type>character_data</type></entry>
+ <entry>File name of the library that implementing this foreign-data wrapper</entry>
+ </row>
+
+ <row>
+ <entry><literal>foreign_data_wrapper_language</literal></entry>
+ <entry><type>character_data</type></entry>
+ <entry>Language used to implement this foreign-data wrapper</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ </sect1>
+
+ <sect1 id="infoschema-foreign-server-options">
+ <title><literal>foreign_server_options</literal></title>
+
+ <para>
+ The view <literal>foreign_server_options</literal> contains all the
+ options defined for foreign servers in the current database. Only
+ those foreign servers are shown that the current user has access to
+ (by way of being the owner or having some privilege).
+ </para>
+
+ <table>
+ <title><literal>foreign_server_options</literal> Columns</title>
+
+ <tgroup cols="3">
+ <thead>
+ <row>
+ <entry>Name</entry>
+ <entry>Data Type</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+
+ <tbody>
+ <row>
+ <entry><literal>foreign_server_catalog</literal></entry>
+ <entry><type>sql_identifier</type></entry>
+ <entry>Name of the database that the foreign server is defined in (always the current database)</entry>
+ </row>
+
+ <row>
+ <entry><literal>foreign_server_name</literal></entry>
+ <entry><type>sql_identifier</type></entry>
+ <entry>Name of the foreign server</entry>
+ </row>
+
+ <row>
+ <entry><literal>option_name</literal></entry>
+ <entry><type>sql_identifier</type></entry>
+ <entry>Name of an option</entry>
+ </row>
+
+ <row>
+ <entry><literal>option_value</literal></entry>
+ <entry><type>character_data</type></entry>
+ <entry>Value of the option</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ </sect1>
+
+ <sect1 id="infoschema-foreign-servers">
+ <title><literal>foreign_servers</literal></title>
+
+ <para>
+ The view <literal>foreign_servers</literal> contains all foreign
+ servers defined in the current database. Only those foreign
+ servers are shown that the current user has access to (by way of
+ being the owner or having some privilege).
+ </para>
+
+ <table>
+ <title><literal>foreign_servers</literal> Columns</title>
+
+ <tgroup cols="3">
+ <thead>
+ <row>
+ <entry>Name</entry>
+ <entry>Data Type</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+
+ <tbody>
+ <row>
+ <entry><literal>foreign_server_catalog</literal></entry>
+ <entry><type>sql_identifier</type></entry>
+ <entry>Name of the database that the foreign server is defined in (always the current database)</entry>
+ </row>
+
+ <row>
+ <entry><literal>foreign_server_name</literal></entry>
+ <entry><type>sql_identifier</type></entry>
+ <entry>Name of the foreign server</entry>
+ </row>
+
+ <row>
+ <entry><literal>foreign_data_wrapper_catalog</literal></entry>
+ <entry><type>sql_identifier</type></entry>
+ <entry>Name of the database that contains the foreign-data
+ wrapper used by the foreign server (always the current database)</entry>
+ </row>
+
+ <row>
+ <entry><literal>foreign_data_wrapper_name</literal></entry>
+ <entry><type>sql_identifier</type></entry>
+ <entry>Name of the foreign-data wrapper used by the foreign server</entry>
+ </row>
+
+ <row>
+ <entry><literal>foreign_server_type</literal></entry>
+ <entry><type>character_data</type></entry>
+ <entry>Foreign server type information, if specified upon creation</entry>
+ </row>
+
+ <row>
+ <entry><literal>foreign_server_version</literal></entry>
+ <entry><type>character_data</type></entry>
+ <entry>Foreign server version information, if specified upon creation</entry>
+ </row>
+
+ <row>
+ <entry><literal>authorization_identifier</literal></entry>
+ <entry><type>sql_identifier</type></entry>
+ <entry>Name of the owner of the foreign server</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ </sect1>
+
<sect1 id="infoschema-key-column-usage">
<title><literal>key_column_usage</literal></title>
@@ -2848,15 +3079,11 @@ ORDER BY c.ordinal_position;
<title><literal>role_usage_grants</literal></title>
<para>
- The view <literal>role_usage_grants</literal> is meant to identify
+ The view <literal>role_usage_grants</literal> identifies
<literal>USAGE</literal> privileges granted on various kinds of
- objects to a currently enabled role or by a currently enabled role.
- In <productname>PostgreSQL</productname>, this currently only
- applies to domains, and since domains do not have real privileges
- in <productname>PostgreSQL</productname>, this view is empty.
+ objects where the grantor or grantee is a currently enabled role.
Further information can be found under
- <literal>usage_privileges</literal>. In the future, this view might
- contain more useful information.
+ <literal>usage_privileges</literal>.
</para>
<table>
@@ -2875,13 +3102,13 @@ ORDER BY c.ordinal_position;
<row>
<entry><literal>grantor</literal></entry>
<entry><type>sql_identifier</type></entry>
- <entry>In the future, the name of the role that granted the privilege</entry>
+ <entry>The name of the role that granted the privilege</entry>
</row>
<row>
<entry><literal>grantee</literal></entry>
<entry><type>sql_identifier</type></entry>
- <entry>In the future, the name of the role that the privilege was granted to</entry>
+ <entry>The name of the role that the privilege was granted to</entry>
</row>
<row>
@@ -2893,7 +3120,8 @@ ORDER BY c.ordinal_position;
<row>
<entry><literal>object_schema</literal></entry>
<entry><type>sql_identifier</type></entry>
- <entry>Name of the schema containing the object</entry>
+ <entry>Name of the schema containing the object, if applicable,
+ else an empty string</entry>
</row>
<row>
@@ -2905,7 +3133,7 @@ ORDER BY c.ordinal_position;
<row>
<entry><literal>object_type</literal></entry>
<entry><type>character_data</type></entry>
- <entry>In the future, the type of the object</entry>
+ <entry><literal>DOMAIN</literal> or <literal>FOREIGN DATA WRAPPER</literal> or <literal>FOREIGN SERVER</literal></entry>
</row>
<row>
@@ -4718,15 +4946,20 @@ ORDER BY c.ordinal_position;
<title><literal>usage_privileges</literal></title>
<para>
- The view <literal>usage_privileges</literal> is meant to identify
+ The view <literal>usage_privileges</literal> identifies
<literal>USAGE</literal> privileges granted on various kinds of
objects to a currently enabled role or by a currently enabled role.
- In <productname>PostgreSQL</productname>, this currently only
- applies to domains, and since domains do not have real privileges
+ In <productname>PostgreSQL</productname>, this currently applies to
+ domains, foreign-data wrappers, and foreign servers. There is one
+ row for each combination of object, grantor, and grantee.
+ </para>
+
+ <para>
+ Since domains do not have real privileges
in <productname>PostgreSQL</productname>, this view shows implicit
- <literal>USAGE</literal> privileges granted to
- <literal>PUBLIC</literal> for all domains. In the future, this
- view might contain more useful information.
+ non-grantable <literal>USAGE</literal> privileges granted by the
+ owner to <literal>PUBLIC</literal> for all domains. The other
+ object types, however, show real privileges.
</para>
<table>
@@ -4745,13 +4978,13 @@ ORDER BY c.ordinal_position;
<row>
<entry><literal>grantor</literal></entry>
<entry><type>sql_identifier</type></entry>
- <entry>Currently set to the name of the owner of the object</entry>
+ <entry>Name of the role that granted the privilege</entry>
</row>
<row>
<entry><literal>grantee</literal></entry>
<entry><type>sql_identifier</type></entry>
- <entry>Currently always <literal>PUBLIC</literal></entry>
+ <entry>Name of the role that the privilege was granted to</entry>
</row>
<row>
@@ -4763,7 +4996,8 @@ ORDER BY c.ordinal_position;
<row>
<entry><literal>object_schema</literal></entry>
<entry><type>sql_identifier</type></entry>
- <entry>Name of the schema containing the object</entry>
+ <entry>Name of the schema containing the object, if applicable,
+ else an empty string</entry>
</row>
<row>
@@ -4775,7 +5009,7 @@ ORDER BY c.ordinal_position;
<row>
<entry><literal>object_type</literal></entry>
<entry><type>character_data</type></entry>
- <entry>Currently always <literal>DOMAIN</literal></entry>
+ <entry><literal>DOMAIN</literal> or <literal>FOREIGN DATA WRAPPER</literal> or <literal>FOREIGN SERVER</literal></entry>
</row>
<row>
@@ -4787,7 +5021,115 @@ ORDER BY c.ordinal_position;
<row>
<entry><literal>is_grantable</literal></entry>
<entry><type>character_data</type></entry>
- <entry>Currently always <literal>NO</literal></entry>
+ <entry><literal>YES</literal> if the privilege is grantable, <literal>NO</literal> if not</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ </sect1>
+
+ <sect1 id="infoschema-user-mapping-options">
+ <title><literal>user_mapping_options</literal></title>
+
+ <para>
+ The view <literal>user_mapping_options</literal> contains all the
+ options defined for user mappings in the current database. Only
+ those user mappings are shown where the current user has access to
+ the corresponding foreign server (by way of being the owner or
+ having some privilege).
+ </para>
+
+ <table>
+ <title><literal>user_mapping_options</literal> Columns</title>
+
+ <tgroup cols="3">
+ <thead>
+ <row>
+ <entry>Name</entry>
+ <entry>Data Type</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+
+ <tbody>
+ <row>
+ <entry><literal>authorization_identifier</literal></entry>
+ <entry><type>sql_identifier</type></entry>
+ <entry>Name of the user being mapped,
+ or <literal>PUBLIC</literal> if the mapping is public</entry>
+ </row>
+
+ <row>
+ <entry><literal>foreign_server_catalog</literal></entry>
+ <entry><type>sql_identifier</type></entry>
+ <entry>Name of the database that the foreign server used by this
+ mapping is defined in (always the current database)</entry>
+ </row>
+
+ <row>
+ <entry><literal>foreign_server_name</literal></entry>
+ <entry><type>sql_identifier</type></entry>
+ <entry>Name of the foreign server used by this mapping</entry>
+ </row>
+
+ <row>
+ <entry><literal>option_name</literal></entry>
+ <entry><type>sql_identifier</type></entry>
+ <entry>Name of an option</entry>
+ </row>
+
+ <row>
+ <entry><literal>option_value</literal></entry>
+ <entry><type>character_data</type></entry>
+ <entry>Value of the option</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ </sect1>
+
+ <sect1 id="infoschema-user-mappings">
+ <title><literal>user_mappings</literal></title>
+
+ <para>
+ The view <literal>user_mappings</literal> contains all user
+ mappings defined in the current database. Only those user mappings
+ are shown where the current user has access to the corresponding
+ foreign server (by way of being the owner or having some
+ privilege).
+ </para>
+
+ <table>
+ <title><literal>user_mappings</literal> Columns</title>
+
+ <tgroup cols="3">
+ <thead>
+ <row>
+ <entry>Name</entry>
+ <entry>Data Type</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+
+ <tbody>
+ <row>
+ <entry><literal>authorization_identifier</literal></entry>
+ <entry><type>sql_identifier</type></entry>
+ <entry>Name of the user being mapped,
+ or <literal>PUBLIC</literal> if the mapping is public</entry>
+ </row>
+
+ <row>
+ <entry><literal>foreign_server_catalog</literal></entry>
+ <entry><type>sql_identifier</type></entry>
+ <entry>Name of the database that the foreign server used by this
+ mapping is defined in (always the current database)</entry>
+ </row>
+
+ <row>
+ <entry><literal>foreign_server_name</literal></entry>
+ <entry><type>sql_identifier</type></entry>
+ <entry>Name of the foreign server used by this mapping</entry>
</row>
</tbody>
</tgroup>
diff --git a/doc/src/sgml/keywords.sgml b/doc/src/sgml/keywords.sgml
index de3bedfdcbe..f7f7d649563 100644
--- a/doc/src/sgml/keywords.sgml
+++ b/doc/src/sgml/keywords.sgml
@@ -1,4 +1,4 @@
-<!-- $PostgreSQL: pgsql/doc/src/sgml/keywords.sgml,v 2.21 2008/12/03 12:39:57 petere Exp $ -->
+<!-- $PostgreSQL: pgsql/doc/src/sgml/keywords.sgml,v 2.22 2008/12/19 16:25:16 petere Exp $ -->
<appendix id="sql-keywords-appendix">
<title><acronym>SQL</acronym> Key Words</title>
@@ -2688,6 +2688,14 @@
<entry>reserved</entry>
</row>
<row>
+ <entry><token>LIBRARY</token></entry>
+ <entry>non-reserved</entry>
+ <entry>non-reserved</entry>
+ <entry>non-reserved</entry>
+ <entry></entry>
+ <entry></entry>
+ </row>
+ <row>
<entry><token>LIKE</token></entry>
<entry>reserved (can be function or type)</entry>
<entry>reserved</entry>
@@ -2818,8 +2826,8 @@
<row>
<entry><token>MAPPING</token></entry>
<entry>non-reserved</entry>
- <entry></entry>
- <entry></entry>
+ <entry>non-reserved</entry>
+ <entry>non-reserved</entry>
<entry></entry>
<entry></entry>
</row>
@@ -3441,7 +3449,7 @@
</row>
<row>
<entry><token>OPTIONS</token></entry>
- <entry></entry>
+ <entry>non-reserved</entry>
<entry>non-reserved</entry>
<entry>non-reserved</entry>
<entry>non-reserved</entry>
@@ -4456,6 +4464,14 @@
<entry>non-reserved</entry>
</row>
<row>
+ <entry><token>SERVER</token></entry>
+ <entry>non-reserved</entry>
+ <entry>non-reserved</entry>
+ <entry>non-reserved</entry>
+ <entry></entry>
+ <entry></entry>
+ </row>
+ <row>
<entry><token>SERVER_NAME</token></entry>
<entry></entry>
<entry>non-reserved</entry>
@@ -5584,6 +5600,14 @@
<entry>reserved</entry>
</row>
<row>
+ <entry><token>WRAPPER</token></entry>
+ <entry>non-reserved</entry>
+ <entry>non-reserved</entry>
+ <entry>non-reserved</entry>
+ <entry></entry>
+ <entry></entry>
+ </row>
+ <row>
<entry><token>WRITE</token></entry>
<entry>non-reserved</entry>
<entry>non-reserved</entry>
diff --git a/doc/src/sgml/ref/allfiles.sgml b/doc/src/sgml/ref/allfiles.sgml
index b80a2cf8f04..6c20b623c49 100644
--- a/doc/src/sgml/ref/allfiles.sgml
+++ b/doc/src/sgml/ref/allfiles.sgml
@@ -1,5 +1,5 @@
<!--
-$PostgreSQL: pgsql/doc/src/sgml/ref/allfiles.sgml,v 1.73 2008/03/27 17:24:16 momjian Exp $
+$PostgreSQL: pgsql/doc/src/sgml/ref/allfiles.sgml,v 1.74 2008/12/19 16:25:16 petere Exp $
PostgreSQL documentation
Complete list of usable sgml source files in this directory.
-->
@@ -10,6 +10,7 @@ Complete list of usable sgml source files in this directory.
<!entity alterConversion system "alter_conversion.sgml">
<!entity alterDatabase system "alter_database.sgml">
<!entity alterDomain system "alter_domain.sgml">
+<!entity alterForeignDataWrapper system "alter_foreign_data_wrapper.sgml">
<!entity alterFunction system "alter_function.sgml">
<!entity alterGroup system "alter_group.sgml">
<!entity alterIndex system "alter_index.sgml">
@@ -19,6 +20,7 @@ Complete list of usable sgml source files in this directory.
<!entity alterOperatorFamily system "alter_opfamily.sgml">
<!entity alterRole system "alter_role.sgml">
<!entity alterSchema system "alter_schema.sgml">
+<!entity alterServer system "alter_server.sgml">
<!entity alterSequence system "alter_sequence.sgml">
<!entity alterTable system "alter_table.sgml">
<!entity alterTableSpace system "alter_tablespace.sgml">
@@ -29,6 +31,7 @@ Complete list of usable sgml source files in this directory.
<!entity alterTrigger system "alter_trigger.sgml">
<!entity alterType system "alter_type.sgml">
<!entity alterUser system "alter_user.sgml">
+<!entity alterUserMapping system "alter_user_mapping.sgml">
<!entity alterView system "alter_view.sgml">
<!entity analyze system "analyze.sgml">
<!entity begin system "begin.sgml">
@@ -45,6 +48,7 @@ Complete list of usable sgml source files in this directory.
<!entity createConversion system "create_conversion.sgml">
<!entity createDatabase system "create_database.sgml">
<!entity createDomain system "create_domain.sgml">
+<!entity createForeignDataWrapper system "create_foreign_data_wrapper.sgml">
<!entity createFunction system "create_function.sgml">
<!entity createGroup system "create_group.sgml">
<!entity createIndex system "create_index.sgml">
@@ -56,6 +60,7 @@ Complete list of usable sgml source files in this directory.
<!entity createRule system "create_rule.sgml">
<!entity createSchema system "create_schema.sgml">
<!entity createSequence system "create_sequence.sgml">
+<!entity createServer system "create_server.sgml">
<!entity createTable system "create_table.sgml">
<!entity createTableAs system "create_table_as.sgml">
<!entity createTableSpace system "create_tablespace.sgml">
@@ -66,6 +71,7 @@ Complete list of usable sgml source files in this directory.
<!entity createTSTemplate system "create_tstemplate.sgml">
<!entity createType system "create_type.sgml">
<!entity createUser system "create_user.sgml">
+<!entity createUserMapping system "create_user_mapping.sgml">
<!entity createView system "create_view.sgml">
<!entity deallocate system "deallocate.sgml">
<!entity declare system "declare.sgml">
@@ -76,6 +82,7 @@ Complete list of usable sgml source files in this directory.
<!entity dropConversion system "drop_conversion.sgml">
<!entity dropDatabase system "drop_database.sgml">
<!entity dropDomain system "drop_domain.sgml">
+<!entity dropForeignDataWrapper system "drop_foreign_data_wrapper.sgml">
<!entity dropFunction system "drop_function.sgml">
<!entity dropGroup system "drop_group.sgml">
<!entity dropIndex system "drop_index.sgml">
@@ -88,6 +95,7 @@ Complete list of usable sgml source files in this directory.
<!entity dropRule system "drop_rule.sgml">
<!entity dropSchema system "drop_schema.sgml">
<!entity dropSequence system "drop_sequence.sgml">
+<!entity dropServer system "drop_server.sgml">
<!entity dropTable system "drop_table.sgml">
<!entity dropTableSpace system "drop_tablespace.sgml">
<!entity dropTrigger system "drop_trigger.sgml">
@@ -97,6 +105,7 @@ Complete list of usable sgml source files in this directory.
<!entity dropTSTemplate system "drop_tstemplate.sgml">
<!entity dropType system "drop_type.sgml">
<!entity dropUser system "drop_user.sgml">
+<!entity dropUserMapping system "drop_user_mapping.sgml">
<!entity dropView system "drop_view.sgml">
<!entity end system "end.sgml">
<!entity execute system "execute.sgml">
diff --git a/doc/src/sgml/ref/alter_foreign_data_wrapper.sgml b/doc/src/sgml/ref/alter_foreign_data_wrapper.sgml
new file mode 100644
index 00000000000..877c4755170
--- /dev/null
+++ b/doc/src/sgml/ref/alter_foreign_data_wrapper.sgml
@@ -0,0 +1,132 @@
+<!--
+$PostgreSQL: pgsql/doc/src/sgml/ref/alter_foreign_data_wrapper.sgml,v 1.1 2008/12/19 16:25:16 petere Exp $
+PostgreSQL documentation
+-->
+
+<refentry id="SQL-ALTERFOREIGNDATAWRAPPER">
+ <refmeta>
+ <refentrytitle id="sql-alterforeigndatawrapper-title">ALTER FOREIGN DATA WRAPPER</refentrytitle>
+ <refmiscinfo>SQL - Language Statements</refmiscinfo>
+ </refmeta>
+
+ <refnamediv>
+ <refname>ALTER FOREIGN DATA WRAPPER</refname>
+ <refpurpose>change the definition of a foreign-data wrapper</refpurpose>
+ </refnamediv>
+
+ <indexterm zone="sql-alterforeigndatawrapper">
+ <primary>ALTER FOREIGN DATA WRAPPER</primary>
+ </indexterm>
+
+ <refsynopsisdiv>
+<synopsis>
+ALTER FOREIGN DATA WRAPPER <replaceable class="parameter">name</replaceable>
+ [ LIBRARY '<replaceable class="parameter">libraryname</replaceable>' ]
+ [ OPTIONS ( [ ADD | SET | DROP ] <replaceable class="PARAMETER">option</replaceable> ['<replaceable class="PARAMETER">value</replaceable>'] [, ... ]) ]
+ALTER FOREIGN DATA WRAPPER <replaceable class="parameter">name</replaceable> OWNER TO <replaceable>new_owner</replaceable>
+</synopsis>
+ </refsynopsisdiv>
+
+ <refsect1>
+ <title>Description</title>
+
+ <para>
+ <command>ALTER FOREIGN DATA WRAPPER</command> changes the
+ definition of a foreign-data wrapper. The first form of the
+ command changes the library or the generic options of the
+ foreign-data wrapper (at least one clause is required). The second
+ form changes the owner of the foreign-data wrapper.
+ </para>
+
+ <para>
+ Only superusers can alter foreign-data wrappers. Additionally,
+ only superusers can own foreign-data wrappers.
+ </para>
+ </refsect1>
+
+ <refsect1>
+ <title>Parameters</title>
+
+ <variablelist>
+ <varlistentry>
+ <term><replaceable class="parameter">name</replaceable></term>
+ <listitem>
+ <para>
+ The name of an existing foreign-data wrapper.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><replaceable class="parameter">libraryname</replaceable></term>
+ <listitem>
+ <para>
+ New name of the foreign-data wrapper library.
+ </para>
+
+ <para>
+ Note that it is possible that after changing the library, the
+ options to the foreign-data wrapper, servers, and user mappings
+ have become invalid. It is up to the user to make sure that
+ these options are correct before using the foreign-data
+ wrapper.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><literal>OPTIONS ( [ ADD | SET | DROP ] <replaceable class="PARAMETER">option</replaceable> ['<replaceable class="PARAMETER">value</replaceable>'] [, ... ] )</literal></term>
+ <listitem>
+ <para>
+ Change options for the foreign-data
+ wrapper. <literal>ADD</>, <literal>SET</>, and <literal>DROP</>
+ specify the action to be performed. <literal>ADD</> is assumed
+ if no operation is explicitly specified. Option names must be
+ unique; names and values are also validated using the foreign
+ data wrapper library.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refsect1>
+
+ <refsect1>
+ <title>Examples</title>
+
+ <para>
+ Change a foreign-data wrapper <literal>dbi</>, add
+ option <literal>foo</>, drop <literal>bar</>:
+<programlisting>
+ALTER FOREIGN DATA WRAPPER dbi OPTIONS (ADD foo '1', DROP 'bar');
+</programlisting>
+ </para>
+
+ <para>
+ Change the foreign-data wrapper <literal>dbi</> library
+ to <literal>/home/bob/mylibrary.so</>:
+<programlisting>
+ALTER FOREIGN DATA WRAPPER dbi LIBRARY '/home/bob/mylibrary.so';
+</programlisting>
+ </para>
+ </refsect1>
+
+ <refsect1>
+ <title>Compatibility</title>
+
+ <para>
+ <command>ALTER FOREIGN DATA WRAPPER</command> conforms to ISO/IEC
+ 9075-9 (SQL/MED). The standard does not specify the <literal>OWNER
+ TO</> variant of the command.
+ </para>
+ </refsect1>
+
+ <refsect1>
+ <title>See Also</title>
+
+ <simplelist type="inline">
+ <member><xref linkend="sql-createforeigndatawrapper" endterm="sql-createforeigndatawrapper-title"></member>
+ <member><xref linkend="sql-dropforeigndatawrapper" endterm="sql-dropforeigndatawrapper-title"></member>
+ </simplelist>
+ </refsect1>
+
+</refentry>
diff --git a/doc/src/sgml/ref/alter_server.sgml b/doc/src/sgml/ref/alter_server.sgml
new file mode 100644
index 00000000000..0595bca63bb
--- /dev/null
+++ b/doc/src/sgml/ref/alter_server.sgml
@@ -0,0 +1,123 @@
+<!--
+$PostgreSQL: pgsql/doc/src/sgml/ref/alter_server.sgml,v 1.1 2008/12/19 16:25:16 petere Exp $
+PostgreSQL documentation
+-->
+
+<refentry id="SQL-ALTERSERVER">
+ <refmeta>
+ <refentrytitle id="sql-alterserver-title">ALTER SERVER</refentrytitle>
+ <refmiscinfo>SQL - Language Statements</refmiscinfo>
+ </refmeta>
+
+ <refnamediv>
+ <refname>ALTER SERVER</refname>
+ <refpurpose>change the definition of a foreign server</refpurpose>
+ </refnamediv>
+
+ <indexterm zone="sql-alterserver">
+ <primary>ALTER SERVER</primary>
+ </indexterm>
+
+ <refsynopsisdiv>
+<synopsis>
+ALTER SERVER <replaceable class="parameter">servername</replaceable> [ VERSION 'newversion' ]
+ [ OPTIONS ( [ ADD | SET | DROP ] <replaceable class="PARAMETER">option</replaceable> ['<replaceable class="PARAMETER">value</replaceable>'] [, ... ] ) ]
+ALTER SERVER <replaceable class="PARAMETER">servername</replaceable> OWNER TO <replaceable>new_owner</replaceable>
+</synopsis>
+ </refsynopsisdiv>
+
+ <refsect1>
+ <title>Description</title>
+
+ <para>
+ <command>ALTER SERVER</command> changes the definition of a foreign
+ server. The first form changes the server version string or the
+ generic options of the server (at least one clause is required).
+ The second form changes the owner of the server.
+ </para>
+
+ <para>
+ To alter the server you must be the owner of the server.
+ Additionally to alter the owner, you must own the server and also
+ be a direct or indirect member of the new owning role, and you must
+ have <literal>USAGE</> privilege on the server's foreign-data
+ wrapper. (Note that superusers satisfy all these criteria
+ automatically.)
+ </para>
+ </refsect1>
+
+ <refsect1>
+ <title>Parameters</title>
+
+ <variablelist>
+ <varlistentry>
+ <term><replaceable class="parameter">servername</replaceable></term>
+ <listitem>
+ <para>
+ The name of an existing server.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><replaceable class="parameter">serverversion</replaceable></term>
+ <listitem>
+ <para>
+ New server version.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><literal>OPTIONS ( [ ADD | SET | DROP ] <replaceable class="PARAMETER">option</replaceable> ['<replaceable class="PARAMETER">value</replaceable>'] [, ... ] )</literal></term>
+ <listitem>
+ <para>
+ Change options for the
+ server. <literal>ADD</>, <literal>SET</>, and <literal>DROP</>
+ specify the action to be performed. <literal>ADD</> is assumed
+ if no operation is explicitly specified. Option names must be
+ unique; names and values are also validated using the server's
+ foreign-data wrapper library.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refsect1>
+
+ <refsect1>
+ <title>Examples</title>
+
+ <para>
+ Alter server <literal>foo</>, add connection options:
+<programlisting>
+ALTER SERVER foo OPTIONS (host 'foo', dbname 'foodb');
+</programlisting>
+ </para>
+
+ <para>
+ Alter server <literal>foo</>, change version,
+ change <literal>host</> option:
+<programlisting>
+ALTER SERVER foo VERSION '8.4' OPTIONS (SET host 'baz');
+</programlisting>
+ </para>
+ </refsect1>
+
+ <refsect1>
+ <title>Compatibility</title>
+
+ <para>
+ <command>ALTER SERVER</command> conforms to ISO/IEC 9075-9 (SQL/MED).
+ </para>
+ </refsect1>
+
+ <refsect1>
+ <title>See Also</title>
+
+ <simplelist type="inline">
+ <member><xref linkend="sql-createserver" endterm="sql-createserver-title"></member>
+ <member><xref linkend="sql-dropserver" endterm="sql-dropserver-title"></member>
+ </simplelist>
+ </refsect1>
+
+</refentry>
diff --git a/doc/src/sgml/ref/alter_user_mapping.sgml b/doc/src/sgml/ref/alter_user_mapping.sgml
new file mode 100644
index 00000000000..38bff39ece7
--- /dev/null
+++ b/doc/src/sgml/ref/alter_user_mapping.sgml
@@ -0,0 +1,119 @@
+<!--
+$PostgreSQL: pgsql/doc/src/sgml/ref/alter_user_mapping.sgml,v 1.1 2008/12/19 16:25:16 petere Exp $
+PostgreSQL documentation
+-->
+
+<refentry id="SQL-ALTERUSERMAPPING">
+ <refmeta>
+ <refentrytitle id="sql-alterusermapping-title">ALTER USER MAPPING</refentrytitle>
+ <refmiscinfo>SQL - Language Statements</refmiscinfo>
+ </refmeta>
+
+ <refnamediv>
+ <refname>ALTER USER MAPPING</refname>
+ <refpurpose>change the definition of a user mapping</refpurpose>
+ </refnamediv>
+
+ <indexterm zone="sql-alterusermapping">
+ <primary>ALTER USER MAPPING</primary>
+ </indexterm>
+
+ <refsynopsisdiv>
+<synopsis>
+ALTER USER MAPPING FOR { <replaceable class="parameter">username</replaceable> | USER | CURRENT_USER | PUBLIC }
+ SERVER <replaceable class="parameter">servername</replaceable>
+ OPTIONS ( [ ADD | SET | DROP ] <replaceable class="PARAMETER">option</replaceable> ['<replaceable class="PARAMETER">value</replaceable>'] [, ... ] )
+</synopsis>
+ </refsynopsisdiv>
+
+ <refsect1>
+ <title>Description</title>
+
+ <para>
+ <command>ALTER USER MAPPING</command> changes the definition of a
+ user mapping. Only the owner of the server can change the user
+ mappings of that server.
+ </para>
+
+ </refsect1>
+
+ <refsect1>
+ <title>Parameters</title>
+
+ <variablelist>
+ <varlistentry>
+ <term><replaceable class="parameter">username</replaceable></term>
+ <listitem>
+ <para>
+ User name of the mapping. <literal>CURRENT_USER</>
+ and <literal>USER</> match the name of the current
+ user. <literal>PUBLIC</> is used to match all present and future
+ user names in the system.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><replaceable class="parameter">servername</replaceable></term>
+ <listitem>
+ <para>
+ Server name of the user mapping.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><literal>OPTIONS ( [ ADD | SET | DROP ] <replaceable class="PARAMETER">option</replaceable> ['<replaceable class="PARAMETER">value</replaceable>'] [, ... ] )</literal></term>
+ <listitem>
+ <para>
+ Change options for the user mapping. The new options override
+ any previously specified
+ options. <literal>ADD</>, <literal>SET</>, and <literal>DROP</>
+ specify the action to be performed. <literal>ADD</> is assumed
+ if no operation is explicitly specified. Option names must be
+ unique; options are also validated by the server's foreign-data
+ wrapper.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refsect1>
+
+ <refsect1>
+ <title>Examples</title>
+
+ <para>
+ Change the password for user mapping <literal>bob</>, server<literal> foo</>:
+<programlisting>
+ALTER USER MAPPING FOR bob SERVER foo OPTIONS (user 'bob', password 'public');
+</programlisting>
+ </para>
+
+ </refsect1>
+
+ <refsect1>
+ <title>Compatibility</title>
+
+ <para>
+ <command>ALTER USER MAPPING</command> conforms to ISO/IEC 9075-9
+ (SQL/MED). There is a subtle syntax issue: The standard omits
+ the <literal>FOR</literal> key word. Since both <literal>CREATE
+ USER MAPPING</literal> and <literal>DROP USER MAPPING</literal> use
+ <literal>FOR</literal> in analogous positions, and IBM DB2 (being
+ the other major SQL/MED implementation) also requires it
+ for <literal>ALTER USER MAPPING</literal>, PostgreSQL diverges from
+ the standard here in the interest of consistency and
+ interoperability.
+ </para>
+ </refsect1>
+
+ <refsect1>
+ <title>See Also</title>
+
+ <simplelist type="inline">
+ <member><xref linkend="sql-createusermapping" endterm="sql-createusermapping-title"></member>
+ <member><xref linkend="sql-dropusermapping" endterm="sql-dropusermapping-title"></member>
+ </simplelist>
+ </refsect1>
+
+</refentry>
diff --git a/doc/src/sgml/ref/create_foreign_data_wrapper.sgml b/doc/src/sgml/ref/create_foreign_data_wrapper.sgml
new file mode 100644
index 00000000000..d46e8e66406
--- /dev/null
+++ b/doc/src/sgml/ref/create_foreign_data_wrapper.sgml
@@ -0,0 +1,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>
diff --git a/doc/src/sgml/ref/create_server.sgml b/doc/src/sgml/ref/create_server.sgml
new file mode 100644
index 00000000000..894eecc5563
--- /dev/null
+++ b/doc/src/sgml/ref/create_server.sgml
@@ -0,0 +1,140 @@
+<!--
+$PostgreSQL: pgsql/doc/src/sgml/ref/create_server.sgml,v 1.1 2008/12/19 16:25:16 petere Exp $
+PostgreSQL documentation
+-->
+
+<refentry id="SQL-CREATESERVER">
+ <refmeta>
+ <refentrytitle id="sql-createserver-title">CREATE SERVER</refentrytitle>
+ <refmiscinfo>SQL - Language Statements</refmiscinfo>
+ </refmeta>
+
+ <refnamediv>
+ <refname>CREATE SERVER</refname>
+ <refpurpose>define a new foreign server</refpurpose>
+ </refnamediv>
+
+ <indexterm zone="sql-createserver">
+ <primary>CREATE SERVER</primary>
+ </indexterm>
+
+ <refsynopsisdiv>
+<synopsis>
+CREATE SERVER <replaceable class="parameter">servername</replaceable> [ TYPE 'servertype' ] [ VERSION 'serverversion' ]
+ FOREIGN DATA WRAPPER <replaceable class="parameter">fdwname</replaceable>
+ [ OPTIONS ( <replaceable class="PARAMETER">option</replaceable> '<replaceable class="PARAMETER">value</replaceable>' [, ... ] ) ]
+</synopsis>
+ </refsynopsisdiv>
+
+ <refsect1>
+ <title>Description</title>
+
+ <para>
+ <command>CREATE SERVER</command> defines a new foreign server. The
+ user who defines the server becomes its owner.
+ </para>
+
+ <para>
+ The server name must be unique within database.
+ </para>
+
+ <para>
+ Creating a server requires <literal>USAGE</> privilege on the
+ foreign-data wrapper being used.
+ </para>
+ </refsect1>
+
+ <refsect1>
+ <title>Parameters</title>
+
+ <variablelist>
+ <varlistentry>
+ <term><replaceable class="parameter">servername</replaceable></term>
+ <listitem>
+ <para>
+ The name of the foreign server to be created.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><replaceable class="parameter">servertype</replaceable></term>
+ <listitem>
+ <para>
+ Optional server type.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><replaceable class="parameter">serverversion</replaceable></term>
+ <listitem>
+ <para>
+ Optional server version.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><replaceable class="parameter">fdwname</replaceable></term>
+ <listitem>
+ <para>
+ The name of the foreign-data wrapper that manages the server.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><literal>OPTIONS ( <replaceable class="PARAMETER">option</replaceable> ['<replaceable class="PARAMETER">value</replaceable>'] [, ... ] )</literal></term>
+ <listitem>
+ <para>
+ This clause specifies the options for the server. The options
+ typically define the connection details of the server, but the
+ actual names and values are dependent on the server's
+ foreign-data wrapper.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refsect1>
+
+ <refsect1>
+ <title>Examples</title>
+
+ <para>
+ Create a server <literal>foo</> that uses the built-in foreign-data
+ wrapper <literal>default</>:
+<programlisting>
+CREATE SERVER foo FOREIGN DATA WRAPPER "default";
+</programlisting>
+ </para>
+
+ <para>
+ Create a server <literal>myserver</> that uses the
+ foreign-data wrapper <literal>pgsql</>:
+<programlisting>
+CREATE SERVER myserver FOREIGN DATA WRAPPER pgsql OPTIONS (host 'foo', dbname 'foodb', port '5432');
+</programlisting>
+ </para>
+ </refsect1>
+
+ <refsect1>
+ <title>Compatibility</title>
+
+ <para>
+ <command>CREATE SERVER</command> conforms to ISO/IEC 9075-9 (SQL/MED).
+ </para>
+ </refsect1>
+
+ <refsect1>
+ <title>See Also</title>
+
+ <simplelist type="inline">
+ <member><xref linkend="sql-alterserver" endterm="sql-alterserver-title"></member>
+ <member><xref linkend="sql-dropserver" endterm="sql-dropserver-title"></member>
+ <member><xref linkend="sql-createforeigndatawrapper" endterm="sql-createforeigndatawrapper-title"></member>
+ <member><xref linkend="sql-createusermapping" endterm="sql-createusermapping-title"></member>
+ </simplelist>
+ </refsect1>
+
+</refentry>
diff --git a/doc/src/sgml/ref/create_user_mapping.sgml b/doc/src/sgml/ref/create_user_mapping.sgml
new file mode 100644
index 00000000000..07cfb0a4c20
--- /dev/null
+++ b/doc/src/sgml/ref/create_user_mapping.sgml
@@ -0,0 +1,111 @@
+<!--
+$PostgreSQL: pgsql/doc/src/sgml/ref/create_user_mapping.sgml,v 1.1 2008/12/19 16:25:16 petere Exp $
+PostgreSQL documentation
+-->
+
+<refentry id="SQL-CREATEUSERMAPPING">
+ <refmeta>
+ <refentrytitle id="sql-createusermapping-title">CREATE USER MAPPING</refentrytitle>
+ <refmiscinfo>SQL - Language Statements</refmiscinfo>
+ </refmeta>
+
+ <refnamediv>
+ <refname>CREATE USER MAPPING</refname>
+ <refpurpose>define a new mapping of a user to a foreign server</refpurpose>
+ </refnamediv>
+
+ <indexterm zone="sql-createusermapping">
+ <primary>CREATE USER MAPPING</primary>
+ </indexterm>
+
+ <refsynopsisdiv>
+<synopsis>
+CREATE USER MAPPING FOR { <replaceable class="parameter">username</replaceable> | USER | CURRENT_USER | PUBLIC }
+ SERVER <replaceable class="parameter">servername</replaceable>
+ [ OPTIONS ( <replaceable class="PARAMETER">option</replaceable> '<replaceable class="PARAMETER">value</replaceable>' [ , ... ] ) ]
+</synopsis>
+ </refsynopsisdiv>
+
+ <refsect1>
+ <title>Description</title>
+
+ <para>
+ <command>CREATE USER MAPPING</command> defines a mapping of a user
+ to a foreign server. You must be the owner of the server to define
+ user mappings for it.
+ </para>
+
+ </refsect1>
+
+ <refsect1>
+ <title>Parameters</title>
+
+ <variablelist>
+ <varlistentry>
+ <term><replaceable class="parameter">username</replaceable></term>
+ <listitem>
+ <para>
+ The name of an existing user that is mapped to foreign server.
+ <literal>CURRENT_USER</> and <literal>USER</> match the name of
+ the current user. <literal>PUBLIC</> is used to match all
+ present and future user names in the system.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><replaceable class="parameter">servername</replaceable></term>
+ <listitem>
+ <para>
+ The name of an existing server for which the user mapping is
+ to be created.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><literal>OPTIONS ( <replaceable class="PARAMETER">option</replaceable> ['<replaceable class="PARAMETER">value</replaceable>'] [, ... ] )</literal></term>
+ <listitem>
+ <para>
+ This clause specifies the options of the user mapping. The
+ options typically define the actual user name and password of
+ the mapping. Option names must be unque. The allowed option
+ names and values are specific to the server's foreign-data wrapper.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refsect1>
+
+ <refsect1>
+ <title>Examples</title>
+
+ <para>
+ Create a user mapping for user <literal>bob</>, server <literal>foo</>:
+<programlisting>
+CREATE USER MAPPING FOR bob SERVER foo OPTIONS (user 'bob', password 'secret');
+</programlisting>
+ </para>
+
+ </refsect1>
+
+ <refsect1>
+ <title>Compatibility</title>
+
+ <para>
+ <command>CREATE USER MAPPING</command> conforms to ISO/IEC 9075-9 (SQL/MED).
+ </para>
+ </refsect1>
+
+ <refsect1>
+ <title>See Also</title>
+
+ <simplelist type="inline">
+ <member><xref linkend="sql-alterusermapping" endterm="sql-alterusermapping-title"></member>
+ <member><xref linkend="sql-dropusermapping" endterm="sql-dropusermapping-title"></member>
+ <member><xref linkend="sql-createforeigndatawrapper" endterm="sql-createforeigndatawrapper-title"></member>
+ <member><xref linkend="sql-createserver" endterm="sql-createserver-title"></member>
+ </simplelist>
+ </refsect1>
+
+</refentry>
diff --git a/doc/src/sgml/ref/drop_foreign_data_wrapper.sgml b/doc/src/sgml/ref/drop_foreign_data_wrapper.sgml
new file mode 100644
index 00000000000..e28b790ceaf
--- /dev/null
+++ b/doc/src/sgml/ref/drop_foreign_data_wrapper.sgml
@@ -0,0 +1,112 @@
+<!--
+$PostgreSQL: pgsql/doc/src/sgml/ref/drop_foreign_data_wrapper.sgml,v 1.1 2008/12/19 16:25:16 petere Exp $
+PostgreSQL documentation
+-->
+
+<refentry id="SQL-DROPFOREIGNDATAWRAPPER">
+ <refmeta>
+ <refentrytitle id="sql-dropforeigndatawrapper-title">DROP FOREIGN DATA WRAPPER</refentrytitle>
+ <refmiscinfo>SQL - Language Statements</refmiscinfo>
+ </refmeta>
+
+ <refnamediv>
+ <refname>DROP FOREIGN DATA WRAPPER</refname>
+ <refpurpose>remove a foreign-data wrapper</refpurpose>
+ </refnamediv>
+
+ <indexterm zone="sql-dropforeigndatawrapper">
+ <primary>DROP FOREIGN DATA WRAPPER</primary>
+ </indexterm>
+
+ <refsynopsisdiv>
+<synopsis>
+DROP FOREIGN DATA WRAPPER [ IF EXISTS ] <replaceable class="parameter">name</replaceable> [ CASCADE | RESTRICT ]
+</synopsis>
+ </refsynopsisdiv>
+
+ <refsect1>
+ <title>Description</title>
+
+ <para>
+ <command>DROP FOREIGN DATA WRAPPER</command> removes an existing
+ foreign-data wrapper. To execute this command, the current user
+ must be the owner of the foreign-data wrapper.
+ </para>
+ </refsect1>
+
+ <refsect1>
+ <title>Parameters</title>
+
+ <variablelist>
+ <varlistentry>
+ <term><literal>IF EXISTS</literal></term>
+ <listitem>
+ <para>
+ Do not throw an error if the foreign-data wrapper does not
+ exist. A notice is issued in this case.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><replaceable class="parameter">name</replaceable></term>
+ <listitem>
+ <para>
+ The name of an existing foreign-data wrapper.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><literal>CASCADE</literal></term>
+ <listitem>
+ <para>
+ Automatically drop objects that depend on the foreign-data
+ wrapper (such as servers).
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><literal>RESTRICT</literal></term>
+ <listitem>
+ <para>
+ Refuse to drop the foreign-data wrappers if any objects depend
+ on it. This is the default.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refsect1>
+
+ <refsect1>
+ <title>Examples</title>
+
+ <para>
+ Drop the foreign-data wrapper <literal>dbi</>:
+<programlisting>
+DROP FOREIGN DATA WRAPPER dbi;
+</programlisting>
+ </para>
+ </refsect1>
+
+ <refsect1>
+ <title>Compatibility</title>
+
+ <para>
+ <command>DROP FOREIGN DATA WRAPPER</command> conforms to ISO/IEC
+ 9075-9 (SQL/MED). The <literal>IF EXISTS</> clause is
+ a <productname>PostgreSQL</> extension.
+ </para>
+ </refsect1>
+
+ <refsect1>
+ <title>See Also</title>
+
+ <simplelist type="inline">
+ <member><xref linkend="sql-createforeigndatawrapper" endterm="sql-createforeigndatawrapper-title"></member>
+ <member><xref linkend="sql-alterforeigndatawrapper" endterm="sql-alterforeigndatawrapper-title"></member>
+ </simplelist>
+ </refsect1>
+
+</refentry>
diff --git a/doc/src/sgml/ref/drop_server.sgml b/doc/src/sgml/ref/drop_server.sgml
new file mode 100644
index 00000000000..b9ddac51b57
--- /dev/null
+++ b/doc/src/sgml/ref/drop_server.sgml
@@ -0,0 +1,112 @@
+<!--
+$PostgreSQL: pgsql/doc/src/sgml/ref/drop_server.sgml,v 1.1 2008/12/19 16:25:16 petere Exp $
+PostgreSQL documentation
+-->
+
+<refentry id="SQL-DROPSERVER">
+ <refmeta>
+ <refentrytitle id="sql-dropserver-title">DROP SERVER</refentrytitle>
+ <refmiscinfo>SQL - Language Statements</refmiscinfo>
+ </refmeta>
+
+ <refnamediv>
+ <refname>DROP SERVER</refname>
+ <refpurpose>remove a foreign server descriptor</refpurpose>
+ </refnamediv>
+
+ <indexterm zone="sql-dropserver">
+ <primary>DROP SERVER</primary>
+ </indexterm>
+
+ <refsynopsisdiv>
+<synopsis>
+DROP SERVER [ IF EXISTS ] <replaceable class="parameter">servername</replaceable> [ CASCADE | RESTRICT ]
+</synopsis>
+ </refsynopsisdiv>
+
+ <refsect1>
+ <title>Description</title>
+
+ <para>
+ <command>DROP SERVER</command> removes an existing foreign server
+ descriptor. To execute this command, the current user must be the
+ owner of the server.
+ </para>
+ </refsect1>
+
+ <refsect1>
+ <title>Parameters</title>
+
+ <variablelist>
+ <varlistentry>
+ <term><literal>IF EXISTS</literal></term>
+ <listitem>
+ <para>
+ Do not throw an error if the server does not exist. A notice is
+ issued in this case.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><replaceable class="parameter">servername</replaceable></term>
+ <listitem>
+ <para>
+ The name of an existing server.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><literal>CASCADE</literal></term>
+ <listitem>
+ <para>
+ Automatically drop objects that depend on the server (such as
+ user mappings).
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><literal>RESTRICT</literal></term>
+ <listitem>
+ <para>
+ Refuse to drop the server if any objects depend on it. This is
+ the default.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refsect1>
+
+ <refsect1>
+ <title>Examples</title>
+
+ <para>
+ Drop a server <literal>foo</> if it exists:
+<programlisting>
+DROP SERVER IF EXISTS foo;
+</programlisting>
+ </para>
+ </refsect1>
+
+ <refsect1>
+ <title>Compatibility</title>
+
+ <para>
+ <command>DROP SERVER</command> conforms to ISO/IEC 9075-9
+ (SQL/MED). The <literal>IF EXISTS</> clause is
+ a <productname>PostgreSQL</> extension.
+ </para>
+ </refsect1>
+
+ <refsect1>
+ <title>See Also</title>
+
+ <simplelist type="inline">
+ <member><xref linkend="sql-createserver" endterm="sql-createserver-title"></member>
+ <member><xref linkend="sql-alterserver" endterm="sql-alterserver-title"></member>
+ </simplelist>
+ </refsect1>
+
+</refentry>
diff --git a/doc/src/sgml/ref/drop_user_mapping.sgml b/doc/src/sgml/ref/drop_user_mapping.sgml
new file mode 100644
index 00000000000..c22dedb661a
--- /dev/null
+++ b/doc/src/sgml/ref/drop_user_mapping.sgml
@@ -0,0 +1,104 @@
+<!--
+$PostgreSQL: pgsql/doc/src/sgml/ref/drop_user_mapping.sgml,v 1.1 2008/12/19 16:25:16 petere Exp $
+PostgreSQL documentation
+-->
+
+<refentry id="SQL-DROPUSERMAPPING">
+ <refmeta>
+ <refentrytitle id="sql-dropusermapping-title">DROP USER MAPPING</refentrytitle>
+ <refmiscinfo>SQL - Language Statements</refmiscinfo>
+ </refmeta>
+
+ <refnamediv>
+ <refname>DROP USER MAPPING</refname>
+ <refpurpose>remove a user mapping for a foreign server</refpurpose>
+ </refnamediv>
+
+ <indexterm zone="sql-dropusermapping">
+ <primary>DROP USER MAPPING</primary>
+ </indexterm>
+
+ <refsynopsisdiv>
+<synopsis>
+DROP USER MAPPING [ IF EXISTS ] FOR { <replaceable class="parameter">username</replaceable> | USER | CURRENT_USER | PUBLIC } SERVER <replaceable class="parameter">servername</replaceable>
+</synopsis>
+ </refsynopsisdiv>
+
+ <refsect1>
+ <title>Description</title>
+
+ <para>
+ <command>DROP USER MAPPING</command> removes an existing user
+ mapping from foreign server. To execute this command, the current
+ user must be the owner of the server containing the mapping.
+ </para>
+ </refsect1>
+
+ <refsect1>
+ <title>Parameters</title>
+
+ <variablelist>
+ <varlistentry>
+ <term><literal>IF EXISTS</literal></term>
+ <listitem>
+ <para>
+ Do not throw an error if the user mapping does not exist. A
+ notice is issued in this case.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><replaceable class="parameter">username</replaceable></term>
+ <listitem>
+ <para>
+ User name of the mapping. <literal>CURRENT_USER</>
+ and <literal>USER</> match the name of the current
+ user. <literal>PUBLIC</> is used to match all present and
+ future user names in the system.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><replaceable class="parameter">servername</replaceable></term>
+ <listitem>
+ <para>
+ Server name of the user mapping.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refsect1>
+
+ <refsect1>
+ <title>Examples</title>
+
+ <para>
+ Drop a user mapping <literal>bob</>, server <literal>foo</> if it exists:
+<programlisting>
+DROP USER MAPPING IF EXISTS FOR bob SERVER foo;
+</programlisting>
+ </para>
+ </refsect1>
+
+ <refsect1>
+ <title>Compatibility</title>
+
+ <para>
+ <command>DROP USER MAPPING</command> conforms to ISO/IEC 9075-9
+ (SQL/MED). The <literal>IF EXISTS</> clause is
+ a <productname>PostgreSQL</> extension.
+ </para>
+ </refsect1>
+
+ <refsect1>
+ <title>See Also</title>
+
+ <simplelist type="inline">
+ <member><xref linkend="sql-createusermapping" endterm="sql-createusermapping-title"></member>
+ <member><xref linkend="sql-alterusermapping" endterm="sql-alterusermapping-title"></member>
+ </simplelist>
+ </refsect1>
+
+</refentry>
diff --git a/doc/src/sgml/ref/grant.sgml b/doc/src/sgml/ref/grant.sgml
index 5c907e1ef05..dafb8ffb523 100644
--- a/doc/src/sgml/ref/grant.sgml
+++ b/doc/src/sgml/ref/grant.sgml
@@ -1,5 +1,5 @@
<!--
-$PostgreSQL: pgsql/doc/src/sgml/ref/grant.sgml,v 1.72 2008/11/14 10:22:47 petere Exp $
+$PostgreSQL: pgsql/doc/src/sgml/ref/grant.sgml,v 1.73 2008/12/19 16:25:16 petere Exp $
PostgreSQL documentation
-->
@@ -35,6 +35,14 @@ GRANT { { CREATE | CONNECT | TEMPORARY | TEMP } [,...] | ALL [ PRIVILEGES ] }
ON DATABASE <replaceable>dbname</replaceable> [, ...]
TO { [ GROUP ] <replaceable class="PARAMETER">rolename</replaceable> | PUBLIC } [, ...] [ WITH GRANT OPTION ]
+GRANT { USAGE | ALL [ PRIVILEGES ] }
+ ON FOREIGN DATA WRAPPER <replaceable>fdwname</> [, ...]
+ TO { [ GROUP ] <replaceable class="PARAMETER">rolename</replaceable> | PUBLIC } [, ...] [ WITH GRANT OPTION ]
+
+GRANT { USAGE | ALL [ PRIVILEGES ] }
+ ON FOREIGN SERVER <replaceable>servername</> [, ...]
+ TO { [ GROUP ] <replaceable class="PARAMETER">rolename</replaceable> | PUBLIC } [, ...] [ WITH GRANT OPTION ]
+
GRANT { EXECUTE | ALL [ PRIVILEGES ] }
ON FUNCTION <replaceable>funcname</replaceable> ( [ [ <replaceable class="parameter">argmode</replaceable> ] [ <replaceable class="parameter">argname</replaceable> ] <replaceable class="parameter">argtype</replaceable> [, ...] ] ) [, ...]
TO { [ GROUP ] <replaceable class="PARAMETER">rolename</replaceable> | PUBLIC } [, ...] [ WITH GRANT OPTION ]
@@ -61,10 +69,10 @@ GRANT <replaceable class="PARAMETER">role</replaceable> [, ...] TO <replaceable
<para>
The <command>GRANT</command> command has two basic variants: one
that grants privileges on a database object (table, view, sequence,
- database, function, procedural language, schema, or tablespace),
- and one that grants membership in a role. These variants are
- similar in many ways, but they are different enough to be described
- separately.
+ database, foreign-data wrapper, foreign server, function,
+ procedural language, schema, or tablespace), and one that grants
+ membership in a role. These variants are similar in many ways, but
+ they are different enough to be described separately.
</para>
<para>
@@ -299,6 +307,14 @@ GRANT <replaceable class="PARAMETER">role</replaceable> [, ...] TO <replaceable
For sequences, this privilege allows the use of the
<function>currval</function> and <function>nextval</function> functions.
</para>
+ <para>
+ For foreign-data wrappers, this privilege enables the grantee
+ to create new servers using that foreign-data wrapper.
+ </para>
+ <para>
+ For servers, this privilege enables the grantee to query the
+ options of the server and associated user mappings.
+ </para>
</listitem>
</varlistentry>
diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml
index fa7f68caf40..fb394b16eef 100644
--- a/doc/src/sgml/ref/psql-ref.sgml
+++ b/doc/src/sgml/ref/psql-ref.sgml
@@ -1,5 +1,5 @@
<!--
-$PostgreSQL: pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.213 2008/12/01 09:20:37 petere Exp $
+$PostgreSQL: pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.214 2008/12/19 16:25:16 petere Exp $
PostgreSQL documentation
-->
@@ -947,6 +947,64 @@ testdb=&gt;
<varlistentry>
+ <term><literal>\des [ <replaceable class="parameter">pattern</replaceable> ]</literal></term>
+ <term><literal>\des+ [ <replaceable class="parameter">pattern</replaceable> ]</literal></term>
+ <listitem>
+ <para>
+ Lists all foreign servers (mnemonic: <quote>external
+ servers</quote>).
+ If <replaceable class="parameter">pattern</replaceable> is
+ specified, only those servers whose name matches the pattern
+ are listed. If the form <literal>\des+</literal> is used, a
+ full desription of each server is shown, including the
+ server's ACL, type, version, and options.
+ </para>
+ </listitem>
+ </varlistentry>
+
+
+ <varlistentry>
+ <term><literal>\deu [ <replaceable class="parameter">pattern</replaceable> ]</literal></term>
+ <term><literal>\deu+ [ <replaceable class="parameter">pattern</replaceable> ]</literal></term>
+ <listitem>
+ <para>
+ Lists all user mappings (mnemonic: <quote>external
+ users</quote>).
+ If <replaceable class="parameter">pattern</replaceable> is
+ specified, only those mappings whose user names match the
+ pattern are listed. If the form <literal>\deu+</literal> is
+ used, additional information about each mapping is shown.
+ </para>
+
+ <caution>
+ <para>
+ <literal>\deu+</literal> might also display the user name and
+ password of the remote user, so care should be taken not to
+ disclose them.
+ </para>
+ </caution>
+ </listitem>
+ </varlistentry>
+
+
+ <varlistentry>
+ <term><literal>\dew [ <replaceable class="parameter">pattern</replaceable> ]</literal></term>
+ <term><literal>\dew+ [ <replaceable class="parameter">pattern</replaceable> ]</literal></term>
+ <listitem>
+ <para>
+ Lists all foreign-data wrappers (mnemonic: <quote>external
+ wrappers</quote>).
+ If <replaceable class="parameter">pattern</replaceable> is
+ specified, only those foreign-data wrappers whose name matches
+ the pattern are listed. If the form <literal>\dew+</literal>
+ is used, the ACL and options of the foreign-data wrapper are
+ also shown.
+ </para>
+ </listitem>
+ </varlistentry>
+
+
+ <varlistentry>
<term><literal>\df [ <replaceable class="parameter">pattern</replaceable> ]</literal></term>
<term><literal>\df+ [ <replaceable class="parameter">pattern</replaceable> ]</literal></term>
diff --git a/doc/src/sgml/ref/revoke.sgml b/doc/src/sgml/ref/revoke.sgml
index 11f576e0fb7..c8e91e0a159 100644
--- a/doc/src/sgml/ref/revoke.sgml
+++ b/doc/src/sgml/ref/revoke.sgml
@@ -1,5 +1,5 @@
<!--
-$PostgreSQL: pgsql/doc/src/sgml/ref/revoke.sgml,v 1.49 2008/11/14 10:22:47 petere Exp $
+$PostgreSQL: pgsql/doc/src/sgml/ref/revoke.sgml,v 1.50 2008/12/19 16:25:16 petere Exp $
PostgreSQL documentation
-->
@@ -42,6 +42,18 @@ REVOKE [ GRANT OPTION FOR ]
[ CASCADE | RESTRICT ]
REVOKE [ GRANT OPTION FOR ]
+ { USAGE | ALL [ PRIVILEGES ] }
+ ON FOREIGN DATA WRAPPER <replaceable>fdwname</replaceable> [, ...]
+ FROM { [ GROUP ] <replaceable class="PARAMETER">rolename</replaceable> | PUBLIC } [, ...]
+ [ CASCADE | RESTRICT ]
+
+REVOKE [ GRANT OPTION FOR ]
+ { USAGE | ALL [ PRIVILEGES ] }
+ ON FOREIGN SERVER <replaceable>servername</replaceable> [, ...]
+ FROM { [ GROUP ] <replaceable class="PARAMETER">rolename</replaceable> | PUBLIC } [, ...]
+ [ CASCADE | RESTRICT ]
+
+REVOKE [ GRANT OPTION FOR ]
{ EXECUTE | ALL [ PRIVILEGES ] }
ON FUNCTION <replaceable>funcname</replaceable> ( [ [ <replaceable class="parameter">argmode</replaceable> ] [ <replaceable class="parameter">argname</replaceable> ] <replaceable class="parameter">argtype</replaceable> [, ...] ] ) [, ...]
FROM { [ GROUP ] <replaceable class="PARAMETER">rolename</replaceable> | PUBLIC } [, ...]
diff --git a/doc/src/sgml/reference.sgml b/doc/src/sgml/reference.sgml
index a0aed8edf53..d3a862959d9 100644
--- a/doc/src/sgml/reference.sgml
+++ b/doc/src/sgml/reference.sgml
@@ -1,4 +1,4 @@
-<!-- $PostgreSQL: pgsql/doc/src/sgml/reference.sgml,v 1.66 2008/03/27 17:24:16 momjian Exp $ -->
+<!-- $PostgreSQL: pgsql/doc/src/sgml/reference.sgml,v 1.67 2008/12/19 16:25:16 petere Exp $ -->
<part id="reference">
<title>Reference</title>
@@ -38,6 +38,7 @@
&alterConversion;
&alterDatabase;
&alterDomain;
+ &alterForeignDataWrapper;
&alterFunction;
&alterGroup;
&alterIndex;
@@ -48,6 +49,7 @@
&alterRole;
&alterSchema;
&alterSequence;
+ &alterServer;
&alterTable;
&alterTableSpace;
&alterTSConfig;
@@ -57,6 +59,7 @@
&alterTrigger;
&alterType;
&alterUser;
+ &alterUserMapping;
&alterView;
&analyze;
&begin;
@@ -73,6 +76,7 @@
&createConversion;
&createDatabase;
&createDomain;
+ &createForeignDataWrapper;
&createFunction;
&createGroup;
&createIndex;
@@ -84,6 +88,7 @@
&createRule;
&createSchema;
&createSequence;
+ &createServer;
&createTable;
&createTableAs;
&createTableSpace;
@@ -94,6 +99,7 @@
&createTrigger;
&createType;
&createUser;
+ &createUserMapping;
&createView;
&deallocate;
&declare;
@@ -104,6 +110,7 @@
&dropConversion;
&dropDatabase;
&dropDomain;
+ &dropForeignDataWrapper;
&dropFunction;
&dropGroup;
&dropIndex;
@@ -116,6 +123,7 @@
&dropRule;
&dropSchema;
&dropSequence;
+ &dropServer;
&dropTable;
&dropTableSpace;
&dropTSConfig;
@@ -125,6 +133,7 @@
&dropTrigger;
&dropType;
&dropUser;
+ &dropUserMapping;
&dropView;
&end;
&execute;