1
0
mirror of https://github.com/postgres/postgres.git synced 2025-12-19 17:02:53 +03:00

SQL/MED catalog manipulation facilities

This doesn't do any remote or external things yet, but it gives modules
like plproxy and dblink a standardized and future-proof system for
managing their connection information.

Martin Pihlak and Peter Eisentraut
This commit is contained in:
Peter Eisentraut
2008-12-19 16:25:19 +00:00
parent 1eec10a2de
commit cae565e503
76 changed files with 8452 additions and 125 deletions

View File

@@ -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">

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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
-->
@@ -946,6 +946,64 @@ testdb=&gt;
</varlistentry>
<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>

View File

@@ -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
-->
@@ -41,6 +41,18 @@ REVOKE [ GRANT OPTION FOR ]
FROM { [ GROUP ] <replaceable class="PARAMETER">rolename</replaceable> | PUBLIC } [, ...]
[ 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> [, ...] ] ) [, ...]