aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/src/sgml/backup.sgml97
-rw-r--r--doc/src/sgml/ddl.sgml4
-rw-r--r--doc/src/sgml/func.sgml1827
-rw-r--r--doc/src/sgml/ref/set.sgml4
-rw-r--r--doc/src/sgml/ref/show.sgml4
-rw-r--r--src/backend/access/transam/xlog.c232
-rw-r--r--src/backend/postmaster/pgarch.c6
-rw-r--r--src/backend/utils/adt/misc.c82
-rw-r--r--src/include/access/xlog_internal.h17
-rw-r--r--src/include/catalog/catversion.h4
-rw-r--r--src/include/catalog/pg_proc.h17
-rw-r--r--src/include/utils/builtins.h3
12 files changed, 1350 insertions, 947 deletions
diff --git a/doc/src/sgml/backup.sgml b/doc/src/sgml/backup.sgml
index b8b958296cc..8b171f3697e 100644
--- a/doc/src/sgml/backup.sgml
+++ b/doc/src/sgml/backup.sgml
@@ -1,5 +1,5 @@
<!--
-$PostgreSQL: pgsql/doc/src/sgml/backup.sgml,v 2.39 2004/04/22 07:02:35 neilc Exp $
+$PostgreSQL: pgsql/doc/src/sgml/backup.sgml,v 2.40 2004/08/03 20:32:30 tgl Exp $
-->
<chapter id="backup">
<title>Backup and Restore</title>
@@ -14,12 +14,14 @@ $PostgreSQL: pgsql/doc/src/sgml/backup.sgml,v 2.39 2004/04/22 07:02:35 neilc Exp
</para>
<para>
- There are two fundamentally different approaches to backing up
+ There are three fundamentally different approaches to backing up
<productname>PostgreSQL</> data:
<itemizedlist>
<listitem><para><acronym>SQL</> dump</para></listitem>
<listitem><para>File system level backup</para></listitem>
+ <listitem><para>On-line backup</para></listitem>
</itemizedlist>
+ Each has its own strengths and weaknesses.
</para>
<sect1 id="backup-dump">
@@ -314,8 +316,8 @@ tar -cf backup.tar /usr/local/pgsql/data
The database server <emphasis>must</> be shut down in order to
get a usable backup. Half-way measures such as disallowing all
connections will <emphasis>not</emphasis> work
- (<command>tar</command> and similar tools do not take an atomic
- snapshot of the state of the filesystem at a point in
+ (mainly because <command>tar</command> and similar tools do not take an
+ atomic snapshot of the state of the filesystem at a point in
time). Information about stopping the server can be found in
<xref linkend="postmaster-shutdown">. Needless to say that you
also need to shut down the server before restoring the data.
@@ -335,7 +337,8 @@ tar -cf backup.tar /usr/local/pgsql/data
information. Of course it is also impossible to restore only a
table and the associated <filename>pg_clog</filename> data
because that would render all other tables in the database
- cluster useless.
+ cluster useless. So file system backups only work for complete
+ restoration of an entire database cluster.
</para>
</listitem>
</orderedlist>
@@ -355,7 +358,7 @@ tar -cf backup.tar /usr/local/pgsql/data
properly shut down; therefore, when you start the database server
on the backed-up data, it will think the server had crashed
and replay the WAL log. This is not a problem, just be aware of
- it.
+ it (and be sure to include the WAL files in your dump).
</para>
<para>
@@ -373,6 +376,70 @@ tar -cf backup.tar /usr/local/pgsql/data
the contents of indexes for example, just the commands to recreate
them.)
</para>
+ </sect1>
+
+ <sect1 id="backup-online">
+ <title>On-line backup and point-in-time recovery</title>
+
+ <para>
+ At all times, <productname>PostgreSQL</> maintains a <firstterm>write ahead
+ log</> (WAL) that shows details of every change made to the database's data
+ files. This log exists primarily for crash-safety purposes: if the system
+ crashes, the database can be restored to consistency by <quote>replaying</>
+ the log entries made since the last checkpoint. However, the existence
+ of the log makes it possible to use a third strategy for backing up
+ databases: we can combine a filesystem-level backup with backup of the WAL
+ files. If recovery is needed, we restore the backup and then replay from
+ the backed-up WAL files to bring the backup up to current time. This
+ approach is notably more complex to administer than either of the previous
+ approaches, but it has some significant benefits to offer:
+ <itemizedlist>
+ <listitem>
+ <para>
+ We do not need a perfectly consistent backup as the starting point.
+ Any internal inconsistency in the backup will be corrected by log
+ replay (this is not significantly different from what happens during
+ crash recovery). So we don't need filesystem snapshot capability,
+ just <application>tar</> or a similar archiving tool.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Since we can string together an indefinitely long sequence of WAL files
+ for replay, continuous backup can be had simply by continuing to archive
+ the WAL files. This is particularly valuable for large databases, where
+ making a full backup may take an unreasonable amount of time.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ There is nothing that says we have to replay the WAL entries all the
+ way to the end. We could stop the replay at any point and have a
+ consistent snapshot of the database as it was at that time. Thus,
+ this technique supports <firstterm>point-in-time recovery</>: it is
+ possible to restore the database to its state at any time since your base
+ backup was taken.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ If we continuously feed the series of WAL files to another machine
+ that's been loaded with the same base backup, we have a <quote>hot
+ standby</> system: at any point we can bring up the second machine
+ and it will have a nearly-current copy of the database.
+ </para>
+ </listitem>
+ </itemizedlist>
+ </para>
+
+ <para>
+ As with the plain filesystem-backup technique, this method can only
+ support restoration of an entire database cluster, not a subset.
+ Also, it requires a lot of archival storage: the base backup is bulky,
+ and a busy system will generate many megabytes of WAL traffic that
+ have to be archived. Still, it is the preferred backup technique in
+ many situations where high reliability is needed.
+ </para>
</sect1>
@@ -393,16 +460,16 @@ tar -cf backup.tar /usr/local/pgsql/data
change between major releases of <productname>PostgreSQL</> (where
the number after the first dot changes). This does not apply to
different minor releases under the same major release (where the
- number of the second dot changes); these always have compatible
+ number after the second dot changes); these always have compatible
storage formats. For example, releases 7.0.1, 7.1.2, and 7.2 are
not compatible, whereas 7.1.1 and 7.1.2 are. When you update
- between compatible versions, then you can simply reuse the data
- area in disk by the new executables. Otherwise you need to
+ between compatible versions, you can simply replace the executables
+ and reuse the data area on disk. Otherwise you need to
<quote>back up</> your data and <quote>restore</> it on the new
server, using <application>pg_dump</>. (There are checks in place
that prevent you from doing the wrong thing, so no harm can be done
by confusing these things.) The precise installation procedure is
- not subject of this section; these details are in <xref
+ not the subject of this section; those details are in <xref
linkend="installation">.
</para>
@@ -427,7 +494,7 @@ pg_dumpall -p 5432 | psql -d template1 -p 6543
<para>
If you cannot or do not want to run two servers in parallel you can
- do the back up step before installing the new version, bring down
+ do the backup step before installing the new version, bring down
the server, move the old version out of the way, install the new
version, start the new server, restore the data. For example:
@@ -447,6 +514,14 @@ psql template1 < backup
you of strategic places to perform these steps.
</para>
+ <para>
+ You will always need a SQL dump (<application>pg_dump</> dump) for
+ migrating to a new release. Filesystem-level backups (including
+ on-line backups) will not work, for the same reason that you can't
+ just do the update in-place: the file formats won't necessarily be
+ compatible across major releases.
+ </para>
+
<note>
<para>
When you <quote>move the old installation out of the way</quote>
diff --git a/doc/src/sgml/ddl.sgml b/doc/src/sgml/ddl.sgml
index 8f807fe481a..404181482bf 100644
--- a/doc/src/sgml/ddl.sgml
+++ b/doc/src/sgml/ddl.sgml
@@ -1,4 +1,4 @@
-<!-- $PostgreSQL: pgsql/doc/src/sgml/ddl.sgml,v 1.26 2004/03/07 04:31:01 neilc Exp $ -->
+<!-- $PostgreSQL: pgsql/doc/src/sgml/ddl.sgml,v 1.27 2004/08/03 20:32:30 tgl Exp $ -->
<chapter id="ddl">
<title>Data Definition</title>
@@ -1723,7 +1723,7 @@ SET search_path TO myschema;
</para>
<para>
- See also <xref linkend="functions-misc"> for other ways to access
+ See also <xref linkend="functions-info"> for other ways to access
the schema search path.
</para>
diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml
index 998f693c79b..f87b7657b59 100644
--- a/doc/src/sgml/func.sgml
+++ b/doc/src/sgml/func.sgml
@@ -1,5 +1,5 @@
<!--
-$PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.214 2004/07/12 20:23:47 momjian Exp $
+$PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.215 2004/08/03 20:32:31 tgl Exp $
PostgreSQL documentation
-->
@@ -6629,887 +6629,6 @@ SELECT NULLIF(value, '(none)') ...
</sect1>
- <sect1 id="functions-misc">
- <title>Miscellaneous Functions</title>
-
- <para>
- <xref linkend="functions-misc-session-table"> shows several
- functions that extract session and system information.
- </para>
-
- <table id="functions-misc-session-table">
- <title>Session Information Functions</title>
- <tgroup cols="3">
- <thead>
- <row><entry>Name</entry> <entry>Return Type</entry> <entry>Description</entry></row>
- </thead>
-
- <tbody>
- <row>
- <entry><function>current_database()</function></entry>
- <entry><type>name</type></entry>
- <entry>name of current database</entry>
- </row>
-
- <row>
- <entry><function>current_schema()</function></entry>
- <entry><type>name</type></entry>
- <entry>name of current schema</entry>
- </row>
-
- <row>
- <entry><function>current_schemas(boolean)</function></entry>
- <entry><type>name[]</type></entry>
- <entry>names of schemas in search path optionally including implicit schemas</entry>
- </row>
-
- <row>
- <entry><function>current_user</function></entry>
- <entry><type>name</type></entry>
- <entry>user name of current execution context</entry>
- </row>
-
- <row>
- <entry><function>inet_client_addr()</function></entry>
- <entry><type>inet</type></entry>
- <entry>address of the remote connection</entry>
- </row>
-
- <row>
- <entry><function>inet_client_port()</function></entry>
- <entry><type>int4</type></entry>
- <entry>port of the remote connection</entry>
- </row>
-
- <row>
- <entry><function>inet_server_addr()</function></entry>
- <entry><type>inet</type></entry>
- <entry>address of the local connection</entry>
- </row>
-
- <row>
- <entry><function>inet_server_port()</function></entry>
- <entry><type>int4</type></entry>
- <entry>port of the local connection</entry>
- </row>
-
- <row>
- <entry><function>session_user</function></entry>
- <entry><type>name</type></entry>
- <entry>session user name</entry>
- </row>
-
- <row>
- <entry><function>user</function></entry>
- <entry><type>name</type></entry>
- <entry>equivalent to <function>current_user</function></entry>
- </row>
-
- <row>
- <entry><function>version()</function></entry>
- <entry><type>text</type></entry>
- <entry>PostgreSQL version information</entry>
- </row>
- </tbody>
- </tgroup>
- </table>
-
- <indexterm zone="functions-misc">
- <primary>user</primary>
- <secondary>current</secondary>
- </indexterm>
-
- <indexterm zone="functions-misc">
- <primary>schema</primary>
- <secondary>current</secondary>
- </indexterm>
-
- <indexterm zone="functions-misc">
- <primary>search path</primary>
- <secondary>current</secondary>
- </indexterm>
-
- <para>
- The <function>session_user</function> is the user that initiated a
- database connection; it is fixed for the duration of that
- connection. The <function>current_user</function> is the user identifier
- that is applicable for permission checking. Normally, it is equal
- to the session user, but it changes during the execution of
- functions with the attribute <literal>SECURITY DEFINER</literal>.
- In Unix parlance, the session user is the <quote>real user</quote> and
- the current user is the <quote>effective user</quote>.
- </para>
-
- <note>
- <para>
- <function>current_user</function>, <function>session_user</function>, and
- <function>user</function> have special syntactic status in <acronym>SQL</acronym>:
- they must be called without trailing parentheses.
- </para>
- </note>
-
- <para>
- <function>current_schema</function> returns the name of the schema that is
- at the front of the search path (or a null value if the search path is
- empty). This is the schema that will be used for any tables or
- other named objects that are created without specifying a target schema.
- <function>current_schemas(boolean)</function> returns an array of the names of all
- schemas presently in the search path. The Boolean option determines whether or not
- implicitly included system schemas such as <literal>pg_catalog</> are included in the search
- path returned.
- </para>
-
- <note>
- <para>
- The search path may be altered at run time. The command is:
-<programlisting>
-SET search_path TO <replaceable>schema</> <optional>, <replaceable>schema</>, ...</optional>
-</programlisting>
- </para>
- </note>
-
- <indexterm zone="functions-misc">
- <primary>inet_client_addr</primary>
- </indexterm>
-
- <indexterm zone="functions-misc">
- <primary>inet_client_port</primary>
- </indexterm>
-
- <indexterm zone="functions-misc">
- <primary>inet_server_addr</primary>
- </indexterm>
-
- <indexterm zone="functions-misc">
- <primary>inet_server_port</primary>
- </indexterm>
-
- <para>
- <function>inet_client_addr</function> returns the IP address of the
- current client, and <function>inet_client_port</function> returns the
- port number.
- <function>inet_server_addr</function> returns the IP address on which
- the server accepted the current connection, and
- <function>inet_server_port</function> returns the port number.
- All these functions return NULL if the connection is via a Unix-domain
- socket.
- </para>
-
- <indexterm zone="functions-misc">
- <primary>version</primary>
- </indexterm>
-
- <para>
- <function>version()</function> returns a string describing the
- <productname>PostgreSQL</productname> server's version.
- </para>
-
- <para>
- <xref linkend="functions-misc-set-table"> shows the functions
- available to query and alter run-time configuration parameters.
- </para>
-
- <table id="functions-misc-set-table">
- <title>Configuration Settings Functions</title>
- <tgroup cols="3">
- <thead>
- <row><entry>Name</entry> <entry>Return Type</entry> <entry>Description</entry></row>
- </thead>
-
- <tbody>
- <row>
- <entry>
- <literal><function>current_setting</function>(<parameter>setting_name</parameter>)</literal>
- </entry>
- <entry><type>text</type></entry>
- <entry>current value of setting</entry>
- </row>
- <row>
- <entry>
- <literal><function>set_config(<parameter>setting_name</parameter>,
- <parameter>new_value</parameter>,
- <parameter>is_local</parameter>)</function></literal>
- </entry>
- <entry><type>text</type></entry>
- <entry>set parameter and return new value</entry>
- </row>
- </tbody>
- </tgroup>
- </table>
-
- <indexterm zone="functions-misc">
- <primary>SET</primary>
- </indexterm>
-
- <indexterm zone="functions-misc">
- <primary>SHOW</primary>
- </indexterm>
-
- <indexterm zone="functions-misc">
- <primary>configuration</primary>
- <secondary sortas="server">of the server</secondary>
- <tertiary>functions</tertiary>
- </indexterm>
-
- <para>
- The function <function>current_setting</function> yields the
- current value of the setting <parameter>setting_name</parameter>.
- It corresponds to the <acronym>SQL</acronym> command
- <command>SHOW</command>. An example:
-<programlisting>
-SELECT current_setting('datestyle');
-
- current_setting
------------------
- ISO, MDY
-(1 row)
-</programlisting>
- </para>
-
- <para>
- <function>set_config</function> sets the parameter
- <parameter>setting_name</parameter> to
- <parameter>new_value</parameter>. If
- <parameter>is_local</parameter> is <literal>true</literal>, the
- new value will only apply to the current transaction. If you want
- the new value to apply for the current session, use
- <literal>false</literal> instead. The function corresponds to the
- SQL command <command>SET</command>. An example:
-<programlisting>
-SELECT set_config('log_statement_stats', 'off', false);
-
- set_config
-------------
- off
-(1 row)
-</programlisting>
- </para>
-
- <indexterm>
- <primary>privilege</primary>
- <secondary>querying</secondary>
- </indexterm>
-
- <para>
- <xref linkend="functions-misc-access-table"> lists functions that
- allow the user to query object access privileges programmatically.
- See <xref linkend="ddl-priv"> for more information about
- privileges.
- </para>
-
- <table id="functions-misc-access-table">
- <title>Access Privilege Inquiry Functions</title>
- <tgroup cols="3">
- <thead>
- <row><entry>Name</entry> <entry>Return Type</entry> <entry>Description</entry></row>
- </thead>
-
- <tbody>
- <row>
- <entry><literal><function>has_table_privilege</function>(<parameter>user</parameter>,
- <parameter>table</parameter>,
- <parameter>privilege</parameter>)</literal>
- </entry>
- <entry><type>boolean</type></entry>
- <entry>does user have privilege for table</entry>
- </row>
- <row>
- <entry><literal><function>has_table_privilege</function>(<parameter>table</parameter>,
- <parameter>privilege</parameter>)</literal>
- </entry>
- <entry><type>boolean</type></entry>
- <entry>does current user have privilege for table</entry>
- </row>
- <row>
- <entry><literal><function>has_database_privilege</function>(<parameter>user</parameter>,
- <parameter>database</parameter>,
- <parameter>privilege</parameter>)</literal>
- </entry>
- <entry><type>boolean</type></entry>
- <entry>does user have privilege for database</entry>
- </row>
- <row>
- <entry><literal><function>has_database_privilege</function>(<parameter>database</parameter>,
- <parameter>privilege</parameter>)</literal>
- </entry>
- <entry><type>boolean</type></entry>
- <entry>does current user have privilege for database</entry>
- </row>
- <row>
- <entry><literal><function>has_function_privilege</function>(<parameter>user</parameter>,
- <parameter>function</parameter>,
- <parameter>privilege</parameter>)</literal>
- </entry>
- <entry><type>boolean</type></entry>
- <entry>does user have privilege for function</entry>
- </row>
- <row>
- <entry><literal><function>has_function_privilege</function>(<parameter>function</parameter>,
- <parameter>privilege</parameter>)</literal>
- </entry>
- <entry><type>boolean</type></entry>
- <entry>does current user have privilege for function</entry>
- </row>
- <row>
- <entry><literal><function>has_language_privilege</function>(<parameter>user</parameter>,
- <parameter>language</parameter>,
- <parameter>privilege</parameter>)</literal>
- </entry>
- <entry><type>boolean</type></entry>
- <entry>does user have privilege for language</entry>
- </row>
- <row>
- <entry><literal><function>has_language_privilege</function>(<parameter>language</parameter>,
- <parameter>privilege</parameter>)</literal>
- </entry>
- <entry><type>boolean</type></entry>
- <entry>does current user have privilege for language</entry>
- </row>
- <row>
- <entry><literal><function>has_schema_privilege</function>(<parameter>user</parameter>,
- <parameter>schema</parameter>,
- <parameter>privilege</parameter>)</literal>
- </entry>
- <entry><type>boolean</type></entry>
- <entry>does user have privilege for schema</entry>
- </row>
- <row>
- <entry><literal><function>has_schema_privilege</function>(<parameter>schema</parameter>,
- <parameter>privilege</parameter>)</literal>
- </entry>
- <entry><type>boolean</type></entry>
- <entry>does current user have privilege for schema</entry>
- </row>
- <row>
- <entry><literal><function>has_tablespace_privilege</function>(<parameter>user</parameter>,
- <parameter>tablespace</parameter>,
- <parameter>privilege</parameter>)</literal>
- </entry>
- <entry><type>boolean</type></entry>
- <entry>does user have privilege for tablespace</entry>
- </row>
- <row>
- <entry><literal><function>has_tablespace_privilege</function>(<parameter>tablespace</parameter>,
- <parameter>privilege</parameter>)</literal>
- </entry>
- <entry><type>boolean</type></entry>
- <entry>does current user have privilege for tablespace</entry>
- </row>
- </tbody>
- </tgroup>
- </table>
-
- <indexterm zone="functions-misc">
- <primary>has_table_privilege</primary>
- </indexterm>
- <indexterm zone="functions-misc">
- <primary>has_database_privilege</primary>
- </indexterm>
- <indexterm zone="functions-misc">
- <primary>has_function_privilege</primary>
- </indexterm>
- <indexterm zone="functions-misc">
- <primary>has_language_privilege</primary>
- </indexterm>
- <indexterm zone="functions-misc">
- <primary>has_schema_privilege</primary>
- </indexterm>
- <indexterm zone="functions-misc">
- <primary>has_tablespace_privilege</primary>
- </indexterm>
-
- <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 ID
- (<literal>pg_user.usesysid</literal>), or if the argument is
- omitted
- <function>current_user</function> is assumed. The table can be specified
- by name or by OID. (Thus, there are actually six variants of
- <function>has_table_privilege</function>, which can be distinguished by
- the number and types of their arguments.) When specifying by name,
- the name can be schema-qualified if necessary.
- The desired access privilege type
- is specified by a text string, which must evaluate to one of the
- values <literal>SELECT</literal>, <literal>INSERT</literal>, <literal>UPDATE</literal>,
- <literal>DELETE</literal>, <literal>RULE</literal>, <literal>REFERENCES</literal>, or
- <literal>TRIGGER</literal>. (Case of the string is not significant, however.)
- An example is:
-<programlisting>
-SELECT has_table_privilege('myschema.mytable', 'select');
-</programlisting>
- </para>
-
- <para>
- <function>has_database_privilege</function> checks whether a user
- can access a database 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>CREATE</literal>,
- <literal>TEMPORARY</literal>, or
- <literal>TEMP</literal> (which is equivalent to
- <literal>TEMPORARY</literal>).
- </para>
-
- <para>
- <function>has_function_privilege</function> checks whether a user
- can access a function in a particular way. The possibilities for its
- arguments are analogous to <function>has_table_privilege</function>.
- When specifying a function by a text string rather than by OID,
- the allowed input is the same as for the <type>regprocedure</> data type.
- The desired access privilege type must evaluate to
- <literal>EXECUTE</literal>.
- An example is:
-<programlisting>
-SELECT has_function_privilege('joeuser', 'myfunc(int, text)', 'execute');
-</programlisting>
- </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>.
- The desired access privilege type must evaluate to
- <literal>USAGE</literal>.
- </para>
-
- <para>
- <function>has_schema_privilege</function> checks whether a user
- can access a schema 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>CREATE</literal> or
- <literal>USAGE</literal>.
- </para>
-
- <para>
- <function>has_tablespace_privilege</function> checks whether a user
- can access a tablespace 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>CREATE</literal>.
- </para>
-
- <para>
- To evaluate whether a user holds a grant option on the privilege,
- append <literal> WITH GRANT OPTION</literal> to the privilege key
- word; for example <literal>'UPDATE WITH GRANT OPTION'</literal>.
- </para>
-
- <para>
- <xref linkend="functions-misc-schema-table"> shows functions that
- determine whether a certain object is <firstterm>visible</> in the
- current schema search path. A table is said to be visible if its
- containing schema is in the search path and no table of the same
- name appears earlier in the search path. This is equivalent to the
- statement that the table can be referenced by name without explicit
- schema qualification. For example, to list the names of all
- visible tables:
-<programlisting>
-SELECT relname FROM pg_class WHERE pg_table_is_visible(oid);
-</programlisting>
- </para>
-
- <table id="functions-misc-schema-table">
- <title>Schema Visibility Inquiry Functions</title>
- <tgroup cols="3">
- <thead>
- <row><entry>Name</entry> <entry>Return Type</entry> <entry>Description</entry></row>
- </thead>
-
- <tbody>
- <row>
- <entry><literal><function>pg_table_is_visible</function>(<parameter>table_oid</parameter>)</literal>
- </entry>
- <entry><type>boolean</type></entry>
- <entry>is table visible in search path</entry>
- </row>
- <row>
- <entry><literal><function>pg_type_is_visible</function>(<parameter>type_oid</parameter>)</literal>
- </entry>
- <entry><type>boolean</type></entry>
- <entry>is type (or domain) visible in search path</entry>
- </row>
- <row>
- <entry><literal><function>pg_function_is_visible</function>(<parameter>function_oid</parameter>)</literal>
- </entry>
- <entry><type>boolean</type></entry>
- <entry>is function visible in search path</entry>
- </row>
- <row>
- <entry><literal><function>pg_operator_is_visible</function>(<parameter>operator_oid</parameter>)</literal>
- </entry>
- <entry><type>boolean</type></entry>
- <entry>is operator visible in search path</entry>
- </row>
- <row>
- <entry><literal><function>pg_opclass_is_visible</function>(<parameter>opclass_oid</parameter>)</literal>
- </entry>
- <entry><type>boolean</type></entry>
- <entry>is operator class visible in search path</entry>
- </row>
- <row>
- <entry><literal><function>pg_conversion_is_visible</function>(<parameter>conversion_oid</parameter>)</literal>
- </entry>
- <entry><type>boolean</type></entry>
- <entry>is conversion visible in search path</entry>
- </row>
- </tbody>
- </tgroup>
- </table>
-
- <indexterm zone="functions-misc">
- <primary>pg_table_is_visible</primary>
- </indexterm>
- <indexterm zone="functions-misc">
- <primary>pg_type_is_visible</primary>
- </indexterm>
- <indexterm zone="functions-misc">
- <primary>pg_function_is_visible</primary>
- </indexterm>
- <indexterm zone="functions-misc">
- <primary>pg_operator_is_visible</primary>
- </indexterm>
- <indexterm zone="functions-misc">
- <primary>pg_opclass_is_visible</primary>
- </indexterm>
- <indexterm zone="functions-misc">
- <primary>pg_conversion_is_visible</primary>
- </indexterm>
-
- <para>
- <function>pg_table_is_visible</function> performs the check for
- tables (or views, or any other kind of <literal>pg_class</> entry).
- <function>pg_type_is_visible</function>,
- <function>pg_function_is_visible</function>,
- <function>pg_operator_is_visible</function>,
- <function>pg_opclass_is_visible</function>, and
- <function>pg_conversion_is_visible</function> perform the same sort of
- visibility check for types (and domains), functions, operators, operator classes
- and conversions, respectively. For functions and operators, an object in
- the search path is visible if there is no object of the same name
- <emphasis>and argument data type(s)</> earlier in the path. For
- operator classes, both name and associated index access method are
- considered.
- </para>
-
- <para>
- All these functions require object OIDs to identify the object to be
- checked. If you want to test an object by name, it is convenient to use
- the OID alias types (<type>regclass</>, <type>regtype</>,
- <type>regprocedure</>, or <type>regoperator</>), for example
-<programlisting>
-SELECT pg_type_is_visible('myschema.widget'::regtype);
-</programlisting>
- Note that it would not make much sense to test an unqualified name in
- this way --- if the name can be recognized at all, it must be visible.
- </para>
-
- <indexterm zone="functions-misc">
- <primary>pg_get_viewdef</primary>
- </indexterm>
-
- <indexterm zone="functions-misc">
- <primary>pg_get_ruledef</primary>
- </indexterm>
-
- <indexterm zone="functions-misc">
- <primary>pg_get_indexdef</primary>
- </indexterm>
-
- <indexterm zone="functions-misc">
- <primary>pg_get_triggerdef</primary>
- </indexterm>
-
- <indexterm zone="functions-misc">
- <primary>pg_get_constraintdef</primary>
- </indexterm>
-
- <indexterm zone="functions-misc">
- <primary>pg_get_expr</primary>
- </indexterm>
-
- <indexterm zone="functions-misc">
- <primary>pg_get_userbyid</primary>
- </indexterm>
-
- <indexterm zone="functions-misc">
- <primary>pg_get_serial_sequence</primary>
- </indexterm>
-
- <indexterm zone="functions-misc">
- <primary>pg_tablespace_databases</primary>
- </indexterm>
-
- <para>
- <xref linkend="functions-misc-catalog-table"> lists functions that
- extract information from the system catalogs.
- </para>
-
- <table id="functions-misc-catalog-table">
- <title>System Catalog Information Functions</title>
- <tgroup cols="3">
- <thead>
- <row><entry>Name</entry> <entry>Return Type</entry> <entry>Description</entry></row>
- </thead>
-
- <tbody>
- <row>
- <entry><literal><function>pg_get_viewdef</function>(<parameter>view_name</parameter>)</literal></entry>
- <entry><type>text</type></entry>
- <entry>get <command>CREATE VIEW</> command for view (<emphasis>deprecated</emphasis>)</entry>
- </row>
- <row>
- <entry><literal><function>pg_get_viewdef</function>(<parameter>view_name</parameter>, <parameter>pretty_bool</>)</literal></entry>
- <entry><type>text</type></entry>
- <entry>get <command>CREATE VIEW</> command for view (<emphasis>deprecated</emphasis>)</entry>
- </row>
- <row>
- <entry><literal><function>pg_get_viewdef</function>(<parameter>view_oid</parameter>)</literal></entry>
- <entry><type>text</type></entry>
- <entry>get <command>CREATE VIEW</> command for view</entry>
- </row>
- <row>
- <entry><literal><function>pg_get_viewdef</function>(<parameter>view_oid</parameter>, <parameter>pretty_bool</>)</literal></entry>
- <entry><type>text</type></entry>
- <entry>get <command>CREATE VIEW</> command for view</entry>
- </row>
- <row>
- <entry><literal><function>pg_get_ruledef</function>(<parameter>rule_oid</parameter>)</literal></entry>
- <entry><type>text</type></entry>
- <entry>get <command>CREATE RULE</> command for rule</entry>
- </row>
- <row>
- <entry><literal><function>pg_get_ruledef</function>(<parameter>rule_oid</parameter>, <parameter>pretty_bool</>)</literal></entry>
- <entry><type>text</type></entry>
- <entry>get <command>CREATE RULE</> command for rule</entry>
- </row>
- <row>
- <entry><literal><function>pg_get_indexdef</function>(<parameter>index_oid</parameter>)</literal></entry>
- <entry><type>text</type></entry>
- <entry>get <command>CREATE INDEX</> command for index</entry>
- </row>
- <row>
- <entry><literal><function>pg_get_indexdef</function>(<parameter>index_oid</parameter>, <parameter>column_no</>, <parameter>pretty_bool</>)</literal></entry>
- <entry><type>text</type></entry>
- <entry>get <command>CREATE INDEX</> command for index,
- or definition of just one index column when
- <parameter>column_no</> is not zero</entry>
- </row>
- <row>
- <entry><function>pg_get_triggerdef</function>(<parameter>trigger_oid</parameter>)</entry>
- <entry><type>text</type></entry>
- <entry>get <command>CREATE [ CONSTRAINT ] TRIGGER</> command for trigger</entry>
- </row>
- <row>
- <entry><literal><function>pg_get_constraintdef</function>(<parameter>constraint_oid</parameter>)</literal></entry>
- <entry><type>text</type></entry>
- <entry>get definition of a constraint</entry>
- </row>
- <row>
- <entry><literal><function>pg_get_constraintdef</function>(<parameter>constraint_oid</parameter>, <parameter>pretty_bool</>)</literal></entry>
- <entry><type>text</type></entry>
- <entry>get definition of a constraint</entry>
- </row>
- <row>
- <entry><literal><function>pg_get_expr</function>(<parameter>expr_text</parameter>, <parameter>relation_oid</>)</literal></entry>
- <entry><type>text</type></entry>
- <entry>decompile internal form of an expression, assuming that any Vars
- in it refer to the relation indicated by the second parameter</entry>
- </row>
- <row>
- <entry><literal><function>pg_get_expr</function>(<parameter>expr_text</parameter>, <parameter>relation_oid</>, <parameter>pretty_bool</>)</literal></entry>
- <entry><type>text</type></entry>
- <entry>decompile internal form of an expression, assuming that any Vars
- in it refer to the relation indicated by the second parameter</entry>
- </row>
- <row>
- <entry><literal><function>pg_get_userbyid</function>(<parameter>userid</parameter>)</literal></entry>
- <entry><type>name</type></entry>
- <entry>get user name with given ID</entry>
- </row>
- <row>
- <entry><literal><function>pg_get_serial_sequence</function>(<parameter>table_name</parameter>, <parameter>column_name</parameter>)</literal></entry>
- <entry><type>text</type></entry>
- <entry>get name of the sequence that a serial or bigserial column
- uses</entry>
- </row>
- <row>
- <entry><literal><function>pg_tablespace_databases</function>(<parameter>tablespace_oid</parameter>)</literal></entry>
- <entry><type>setof oid</type></entry>
- <entry>get set of database OIDs that have objects in the tablespace</entry>
- </row>
- </tbody>
- </tgroup>
- </table>
-
- <para>
- <function>pg_get_viewdef</function>,
- <function>pg_get_ruledef</function>,
- <function>pg_get_indexdef</function>,
- <function>pg_get_triggerdef</function>, and
- <function>pg_get_constraintdef</function> respectively
- reconstruct the creating command for a view, rule, index, trigger, or
- constraint. (Note that this is a decompiled reconstruction, not
- the original text of the command.)
- <function>pg_get_expr</function> decompiles the internal form of an
- individual expression, such as the default value for a column. It
- may be useful when examining the contents of system catalogs.
- Most of these functions come in two
- variants, one of which can optionally <quote>pretty-print</> the result.
- The pretty-printed format is more readable, but the default format is more
- likely to be
- interpreted the same way by future versions of <productname>PostgreSQL</>;
- avoid using pretty-printed output for dump purposes.
- Passing <literal>false</> for the pretty-print parameter yields the
- same result as the variant that does not have the parameter at all.
- </para>
-
- <para>
- <function>pg_get_userbyid</function>
- extracts a user's name given a user ID number.
- <function>pg_get_serial_sequence</function>
- fetches the name of the sequence associated with a serial or
- bigserial column. The name is suitably formatted
- for passing to the sequence functions (see <xref
- linkend="functions-sequence">).
- NULL is returned if the column does not have a sequence attached.
- </para>
-
- <para>
- <function>pg_tablespace_databases</function> allows usage examination of a
- tablespace. It will return a set of OIDs of databases that have objects
- stored in the tablespace. If this function returns any row, the
- tablespace is not empty and cannot be dropped. To
- display the specific objects populating the tablespace, you will need
- to connect to the databases identified by
- <function>pg_tablespace_databases</function> and query their
- <structname>pg_class</> catalogs.
- </para>
-
- <indexterm zone="functions-misc">
- <primary>obj_description</primary>
- </indexterm>
-
- <indexterm zone="functions-misc">
- <primary>col_description</primary>
- </indexterm>
-
- <indexterm zone="functions-misc">
- <primary>comment</primary>
- <secondary sortas="database objects">about database objects</secondary>
- </indexterm>
-
- <para>
- The functions shown in <xref
- linkend="functions-misc-comment-table"> extract comments
- previously stored with the <command>COMMENT</command> command. A
- null value is returned if no comment could be found matching the
- specified parameters.
- </para>
-
- <table id="functions-misc-comment-table">
- <title>Comment Information Functions</title>
- <tgroup cols="3">
- <thead>
- <row><entry>Name</entry> <entry>Return Type</entry> <entry>Description</entry></row>
- </thead>
-
- <tbody>
- <row>
- <entry><literal><function>obj_description</function>(<parameter>object_oid</parameter>, <parameter>catalog_name</parameter>)</literal></entry>
- <entry><type>text</type></entry>
- <entry>get comment for a database object</entry>
- </row>
- <row>
- <entry><literal><function>obj_description</function>(<parameter>object_oid</parameter>)</literal></entry>
- <entry><type>text</type></entry>
- <entry>get comment for a database object (<emphasis>deprecated</emphasis>)</entry>
- </row>
- <row>
- <entry><literal><function>col_description</function>(<parameter>table_oid</parameter>, <parameter>column_number</parameter>)</literal></entry>
- <entry><type>text</type></entry>
- <entry>get comment for a table column</entry>
- </row>
- </tbody>
- </tgroup>
- </table>
-
- <para>
- The two-parameter form of <function>obj_description</function> returns the
- comment for a database object specified by its OID and the name of the
- containing system catalog. For example,
- <literal>obj_description(123456,'pg_class')</literal>
- would retrieve the comment for a table with OID 123456.
- The one-parameter form of <function>obj_description</function> requires only
- the object OID. It is now deprecated since there is no guarantee that
- OIDs are unique across different system catalogs; therefore, the wrong
- comment could be returned.
- </para>
-
- <para>
- <function>col_description</function> returns the comment for a table column,
- which is specified by the OID of its table and its column number.
- <function>obj_description</function> cannot be used for table columns since
- columns do not have OIDs of their own.
- </para>
-
- <indexterm zone="functions-misc">
- <primary>pg_cancel_backend</primary>
- </indexterm>
-
- <indexterm zone="functions-misc">
- <primary>pg_terminate_backend</primary>
- </indexterm>
-
- <indexterm zone="functions-misc">
- <primary>signal</primary>
- <secondary sortas="backend">backend processes</secondary>
- </indexterm>
-
- <para>
- The functions shown in <xref
- linkend="functions-misc-signal-table"> send control signals to
- other server processes. Use of these functions is restricted
- to superusers.
- </para>
-
- <table id="functions-misc-signal-table">
- <title>Backend Signalling Functions</title>
- <tgroup cols="3">
- <thead>
- <row><entry>Name</entry> <entry>Return Type</entry> <entry>Description</entry>
- </row>
- </thead>
-
- <tbody>
- <row>
- <entry>
- <literal><function>pg_cancel_backend</function>(<parameter>pid</parameter>)</literal>
- </entry>
- <entry><type>int</type></entry>
- <entry>Cancel a backend's current query</entry>
- </row>
- <row>
- <entry>
- <literal><function>pg_terminate_backend</function>(<parameter>pid</parameter>)</literal>
- </entry>
- <entry><type>int</type></entry>
- <entry>Terminate a backend process</entry>
- </row>
- </tbody>
- </tgroup>
- </table>
-
- <para>
- These functions return 1 if successful, 0 if not successful.
- The process ID (<literal>pid</literal>) of an active backend can be found
- from the <structfield>procpid</structfield> column in the
- <structname>pg_stat_activity</structname> view, or by listing the postgres
- processes on the server.
- </para>
- </sect1>
-
<sect1 id="functions-array">
<title>Array Functions and Operators</title>
@@ -8734,6 +7853,950 @@ select current_date + s.a as dates from generate_series(0,14,7) as s(a);
</programlisting>
</para>
</sect1>
+
+ <sect1 id="functions-info">
+ <title>System Information Functions</title>
+
+ <para>
+ <xref linkend="functions-info-session-table"> shows several
+ functions that extract session and system information.
+ </para>
+
+ <table id="functions-info-session-table">
+ <title>Session Information Functions</title>
+ <tgroup cols="3">
+ <thead>
+ <row><entry>Name</entry> <entry>Return Type</entry> <entry>Description</entry></row>
+ </thead>
+
+ <tbody>
+ <row>
+ <entry><function>current_database()</function></entry>
+ <entry><type>name</type></entry>
+ <entry>name of current database</entry>
+ </row>
+
+ <row>
+ <entry><function>current_schema()</function></entry>
+ <entry><type>name</type></entry>
+ <entry>name of current schema</entry>
+ </row>
+
+ <row>
+ <entry><function>current_schemas(boolean)</function></entry>
+ <entry><type>name[]</type></entry>
+ <entry>names of schemas in search path optionally including implicit schemas</entry>
+ </row>
+
+ <row>
+ <entry><function>current_user</function></entry>
+ <entry><type>name</type></entry>
+ <entry>user name of current execution context</entry>
+ </row>
+
+ <row>
+ <entry><function>inet_client_addr()</function></entry>
+ <entry><type>inet</type></entry>
+ <entry>address of the remote connection</entry>
+ </row>
+
+ <row>
+ <entry><function>inet_client_port()</function></entry>
+ <entry><type>int4</type></entry>
+ <entry>port of the remote connection</entry>
+ </row>
+
+ <row>
+ <entry><function>inet_server_addr()</function></entry>
+ <entry><type>inet</type></entry>
+ <entry>address of the local connection</entry>
+ </row>
+
+ <row>
+ <entry><function>inet_server_port()</function></entry>
+ <entry><type>int4</type></entry>
+ <entry>port of the local connection</entry>
+ </row>
+
+ <row>
+ <entry><function>session_user</function></entry>
+ <entry><type>name</type></entry>
+ <entry>session user name</entry>
+ </row>
+
+ <row>
+ <entry><function>user</function></entry>
+ <entry><type>name</type></entry>
+ <entry>equivalent to <function>current_user</function></entry>
+ </row>
+
+ <row>
+ <entry><function>version()</function></entry>
+ <entry><type>text</type></entry>
+ <entry>PostgreSQL version information</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+
+ <indexterm zone="functions-info">
+ <primary>user</primary>
+ <secondary>current</secondary>
+ </indexterm>
+
+ <indexterm zone="functions-info">
+ <primary>schema</primary>
+ <secondary>current</secondary>
+ </indexterm>
+
+ <indexterm zone="functions-info">
+ <primary>search path</primary>
+ <secondary>current</secondary>
+ </indexterm>
+
+ <para>
+ The <function>session_user</function> is the user that initiated a
+ database connection; it is fixed for the duration of that
+ connection. The <function>current_user</function> is the user identifier
+ that is applicable for permission checking. Normally, it is equal
+ to the session user, but it changes during the execution of
+ functions with the attribute <literal>SECURITY DEFINER</literal>.
+ In Unix parlance, the session user is the <quote>real user</quote> and
+ the current user is the <quote>effective user</quote>.
+ </para>
+
+ <note>
+ <para>
+ <function>current_user</function>, <function>session_user</function>, and
+ <function>user</function> have special syntactic status in <acronym>SQL</acronym>:
+ they must be called without trailing parentheses.
+ </para>
+ </note>
+
+ <para>
+ <function>current_schema</function> returns the name of the schema that is
+ at the front of the search path (or a null value if the search path is
+ empty). This is the schema that will be used for any tables or
+ other named objects that are created without specifying a target schema.
+ <function>current_schemas(boolean)</function> returns an array of the names of all
+ schemas presently in the search path. The Boolean option determines whether or not
+ implicitly included system schemas such as <literal>pg_catalog</> are included in the search
+ path returned.
+ </para>
+
+ <note>
+ <para>
+ The search path may be altered at run time. The command is:
+<programlisting>
+SET search_path TO <replaceable>schema</> <optional>, <replaceable>schema</>, ...</optional>
+</programlisting>
+ </para>
+ </note>
+
+ <indexterm zone="functions-info">
+ <primary>inet_client_addr</primary>
+ </indexterm>
+
+ <indexterm zone="functions-info">
+ <primary>inet_client_port</primary>
+ </indexterm>
+
+ <indexterm zone="functions-info">
+ <primary>inet_server_addr</primary>
+ </indexterm>
+
+ <indexterm zone="functions-info">
+ <primary>inet_server_port</primary>
+ </indexterm>
+
+ <para>
+ <function>inet_client_addr</function> returns the IP address of the
+ current client, and <function>inet_client_port</function> returns the
+ port number.
+ <function>inet_server_addr</function> returns the IP address on which
+ the server accepted the current connection, and
+ <function>inet_server_port</function> returns the port number.
+ All these functions return NULL if the connection is via a Unix-domain
+ socket.
+ </para>
+
+ <indexterm zone="functions-info">
+ <primary>version</primary>
+ </indexterm>
+
+ <para>
+ <function>version()</function> returns a string describing the
+ <productname>PostgreSQL</productname> server's version.
+ </para>
+
+ <indexterm>
+ <primary>privilege</primary>
+ <secondary>querying</secondary>
+ </indexterm>
+
+ <para>
+ <xref linkend="functions-info-access-table"> lists functions that
+ allow the user to query object access privileges programmatically.
+ See <xref linkend="ddl-priv"> for more information about
+ privileges.
+ </para>
+
+ <table id="functions-info-access-table">
+ <title>Access Privilege Inquiry Functions</title>
+ <tgroup cols="3">
+ <thead>
+ <row><entry>Name</entry> <entry>Return Type</entry> <entry>Description</entry></row>
+ </thead>
+
+ <tbody>
+ <row>
+ <entry><literal><function>has_table_privilege</function>(<parameter>user</parameter>,
+ <parameter>table</parameter>,
+ <parameter>privilege</parameter>)</literal>
+ </entry>
+ <entry><type>boolean</type></entry>
+ <entry>does user have privilege for table</entry>
+ </row>
+ <row>
+ <entry><literal><function>has_table_privilege</function>(<parameter>table</parameter>,
+ <parameter>privilege</parameter>)</literal>
+ </entry>
+ <entry><type>boolean</type></entry>
+ <entry>does current user have privilege for table</entry>
+ </row>
+ <row>
+ <entry><literal><function>has_database_privilege</function>(<parameter>user</parameter>,
+ <parameter>database</parameter>,
+ <parameter>privilege</parameter>)</literal>
+ </entry>
+ <entry><type>boolean</type></entry>
+ <entry>does user have privilege for database</entry>
+ </row>
+ <row>
+ <entry><literal><function>has_database_privilege</function>(<parameter>database</parameter>,
+ <parameter>privilege</parameter>)</literal>
+ </entry>
+ <entry><type>boolean</type></entry>
+ <entry>does current user have privilege for database</entry>
+ </row>
+ <row>
+ <entry><literal><function>has_function_privilege</function>(<parameter>user</parameter>,
+ <parameter>function</parameter>,
+ <parameter>privilege</parameter>)</literal>
+ </entry>
+ <entry><type>boolean</type></entry>
+ <entry>does user have privilege for function</entry>
+ </row>
+ <row>
+ <entry><literal><function>has_function_privilege</function>(<parameter>function</parameter>,
+ <parameter>privilege</parameter>)</literal>
+ </entry>
+ <entry><type>boolean</type></entry>
+ <entry>does current user have privilege for function</entry>
+ </row>
+ <row>
+ <entry><literal><function>has_language_privilege</function>(<parameter>user</parameter>,
+ <parameter>language</parameter>,
+ <parameter>privilege</parameter>)</literal>
+ </entry>
+ <entry><type>boolean</type></entry>
+ <entry>does user have privilege for language</entry>
+ </row>
+ <row>
+ <entry><literal><function>has_language_privilege</function>(<parameter>language</parameter>,
+ <parameter>privilege</parameter>)</literal>
+ </entry>
+ <entry><type>boolean</type></entry>
+ <entry>does current user have privilege for language</entry>
+ </row>
+ <row>
+ <entry><literal><function>has_schema_privilege</function>(<parameter>user</parameter>,
+ <parameter>schema</parameter>,
+ <parameter>privilege</parameter>)</literal>
+ </entry>
+ <entry><type>boolean</type></entry>
+ <entry>does user have privilege for schema</entry>
+ </row>
+ <row>
+ <entry><literal><function>has_schema_privilege</function>(<parameter>schema</parameter>,
+ <parameter>privilege</parameter>)</literal>
+ </entry>
+ <entry><type>boolean</type></entry>
+ <entry>does current user have privilege for schema</entry>
+ </row>
+ <row>
+ <entry><literal><function>has_tablespace_privilege</function>(<parameter>user</parameter>,
+ <parameter>tablespace</parameter>,
+ <parameter>privilege</parameter>)</literal>
+ </entry>
+ <entry><type>boolean</type></entry>
+ <entry>does user have privilege for tablespace</entry>
+ </row>
+ <row>
+ <entry><literal><function>has_tablespace_privilege</function>(<parameter>tablespace</parameter>,
+ <parameter>privilege</parameter>)</literal>
+ </entry>
+ <entry><type>boolean</type></entry>
+ <entry>does current user have privilege for tablespace</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+
+ <indexterm zone="functions-info">
+ <primary>has_table_privilege</primary>
+ </indexterm>
+ <indexterm zone="functions-info">
+ <primary>has_database_privilege</primary>
+ </indexterm>
+ <indexterm zone="functions-info">
+ <primary>has_function_privilege</primary>
+ </indexterm>
+ <indexterm zone="functions-info">
+ <primary>has_language_privilege</primary>
+ </indexterm>
+ <indexterm zone="functions-info">
+ <primary>has_schema_privilege</primary>
+ </indexterm>
+ <indexterm zone="functions-info">
+ <primary>has_tablespace_privilege</primary>
+ </indexterm>
+
+ <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 ID
+ (<literal>pg_user.usesysid</literal>), or if the argument is
+ omitted
+ <function>current_user</function> is assumed. The table can be specified
+ by name or by OID. (Thus, there are actually six variants of
+ <function>has_table_privilege</function>, which can be distinguished by
+ the number and types of their arguments.) When specifying by name,
+ the name can be schema-qualified if necessary.
+ The desired access privilege type
+ is specified by a text string, which must evaluate to one of the
+ values <literal>SELECT</literal>, <literal>INSERT</literal>, <literal>UPDATE</literal>,
+ <literal>DELETE</literal>, <literal>RULE</literal>, <literal>REFERENCES</literal>, or
+ <literal>TRIGGER</literal>. (Case of the string is not significant, however.)
+ An example is:
+<programlisting>
+SELECT has_table_privilege('myschema.mytable', 'select');
+</programlisting>
+ </para>
+
+ <para>
+ <function>has_database_privilege</function> checks whether a user
+ can access a database 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>CREATE</literal>,
+ <literal>TEMPORARY</literal>, or
+ <literal>TEMP</literal> (which is equivalent to
+ <literal>TEMPORARY</literal>).
+ </para>
+
+ <para>
+ <function>has_function_privilege</function> checks whether a user
+ can access a function in a particular way. The possibilities for its
+ arguments are analogous to <function>has_table_privilege</function>.
+ When specifying a function by a text string rather than by OID,
+ the allowed input is the same as for the <type>regprocedure</> data type.
+ The desired access privilege type must evaluate to
+ <literal>EXECUTE</literal>.
+ An example is:
+<programlisting>
+SELECT has_function_privilege('joeuser', 'myfunc(int, text)', 'execute');
+</programlisting>
+ </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>.
+ The desired access privilege type must evaluate to
+ <literal>USAGE</literal>.
+ </para>
+
+ <para>
+ <function>has_schema_privilege</function> checks whether a user
+ can access a schema 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>CREATE</literal> or
+ <literal>USAGE</literal>.
+ </para>
+
+ <para>
+ <function>has_tablespace_privilege</function> checks whether a user
+ can access a tablespace 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>CREATE</literal>.
+ </para>
+
+ <para>
+ To evaluate whether a user holds a grant option on the privilege,
+ append <literal> WITH GRANT OPTION</literal> to the privilege key
+ word; for example <literal>'UPDATE WITH GRANT OPTION'</literal>.
+ </para>
+
+ <para>
+ <xref linkend="functions-info-schema-table"> shows functions that
+ determine whether a certain object is <firstterm>visible</> in the
+ current schema search path. A table is said to be visible if its
+ containing schema is in the search path and no table of the same
+ name appears earlier in the search path. This is equivalent to the
+ statement that the table can be referenced by name without explicit
+ schema qualification. For example, to list the names of all
+ visible tables:
+<programlisting>
+SELECT relname FROM pg_class WHERE pg_table_is_visible(oid);
+</programlisting>
+ </para>
+
+ <table id="functions-info-schema-table">
+ <title>Schema Visibility Inquiry Functions</title>
+ <tgroup cols="3">
+ <thead>
+ <row><entry>Name</entry> <entry>Return Type</entry> <entry>Description</entry></row>
+ </thead>
+
+ <tbody>
+ <row>
+ <entry><literal><function>pg_table_is_visible</function>(<parameter>table_oid</parameter>)</literal>
+ </entry>
+ <entry><type>boolean</type></entry>
+ <entry>is table visible in search path</entry>
+ </row>
+ <row>
+ <entry><literal><function>pg_type_is_visible</function>(<parameter>type_oid</parameter>)</literal>
+ </entry>
+ <entry><type>boolean</type></entry>
+ <entry>is type (or domain) visible in search path</entry>
+ </row>
+ <row>
+ <entry><literal><function>pg_function_is_visible</function>(<parameter>function_oid</parameter>)</literal>
+ </entry>
+ <entry><type>boolean</type></entry>
+ <entry>is function visible in search path</entry>
+ </row>
+ <row>
+ <entry><literal><function>pg_operator_is_visible</function>(<parameter>operator_oid</parameter>)</literal>
+ </entry>
+ <entry><type>boolean</type></entry>
+ <entry>is operator visible in search path</entry>
+ </row>
+ <row>
+ <entry><literal><function>pg_opclass_is_visible</function>(<parameter>opclass_oid</parameter>)</literal>
+ </entry>
+ <entry><type>boolean</type></entry>
+ <entry>is operator class visible in search path</entry>
+ </row>
+ <row>
+ <entry><literal><function>pg_conversion_is_visible</function>(<parameter>conversion_oid</parameter>)</literal>
+ </entry>
+ <entry><type>boolean</type></entry>
+ <entry>is conversion visible in search path</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+
+ <indexterm zone="functions-info">
+ <primary>pg_table_is_visible</primary>
+ </indexterm>
+ <indexterm zone="functions-info">
+ <primary>pg_type_is_visible</primary>
+ </indexterm>
+ <indexterm zone="functions-info">
+ <primary>pg_function_is_visible</primary>
+ </indexterm>
+ <indexterm zone="functions-info">
+ <primary>pg_operator_is_visible</primary>
+ </indexterm>
+ <indexterm zone="functions-info">
+ <primary>pg_opclass_is_visible</primary>
+ </indexterm>
+ <indexterm zone="functions-info">
+ <primary>pg_conversion_is_visible</primary>
+ </indexterm>
+
+ <para>
+ <function>pg_table_is_visible</function> performs the check for
+ tables (or views, or any other kind of <literal>pg_class</> entry).
+ <function>pg_type_is_visible</function>,
+ <function>pg_function_is_visible</function>,
+ <function>pg_operator_is_visible</function>,
+ <function>pg_opclass_is_visible</function>, and
+ <function>pg_conversion_is_visible</function> perform the same sort of
+ visibility check for types (and domains), functions, operators, operator classes
+ and conversions, respectively. For functions and operators, an object in
+ the search path is visible if there is no object of the same name
+ <emphasis>and argument data type(s)</> earlier in the path. For
+ operator classes, both name and associated index access method are
+ considered.
+ </para>
+
+ <para>
+ All these functions require object OIDs to identify the object to be
+ checked. If you want to test an object by name, it is convenient to use
+ the OID alias types (<type>regclass</>, <type>regtype</>,
+ <type>regprocedure</>, or <type>regoperator</>), for example
+<programlisting>
+SELECT pg_type_is_visible('myschema.widget'::regtype);
+</programlisting>
+ Note that it would not make much sense to test an unqualified name in
+ this way --- if the name can be recognized at all, it must be visible.
+ </para>
+
+ <indexterm zone="functions-info">
+ <primary>pg_get_viewdef</primary>
+ </indexterm>
+
+ <indexterm zone="functions-info">
+ <primary>pg_get_ruledef</primary>
+ </indexterm>
+
+ <indexterm zone="functions-info">
+ <primary>pg_get_indexdef</primary>
+ </indexterm>
+
+ <indexterm zone="functions-info">
+ <primary>pg_get_triggerdef</primary>
+ </indexterm>
+
+ <indexterm zone="functions-info">
+ <primary>pg_get_constraintdef</primary>
+ </indexterm>
+
+ <indexterm zone="functions-info">
+ <primary>pg_get_expr</primary>
+ </indexterm>
+
+ <indexterm zone="functions-info">
+ <primary>pg_get_userbyid</primary>
+ </indexterm>
+
+ <indexterm zone="functions-info">
+ <primary>pg_get_serial_sequence</primary>
+ </indexterm>
+
+ <indexterm zone="functions-info">
+ <primary>pg_tablespace_databases</primary>
+ </indexterm>
+
+ <para>
+ <xref linkend="functions-info-catalog-table"> lists functions that
+ extract information from the system catalogs.
+ </para>
+
+ <table id="functions-info-catalog-table">
+ <title>System Catalog Information Functions</title>
+ <tgroup cols="3">
+ <thead>
+ <row><entry>Name</entry> <entry>Return Type</entry> <entry>Description</entry></row>
+ </thead>
+
+ <tbody>
+ <row>
+ <entry><literal><function>pg_get_viewdef</function>(<parameter>view_name</parameter>)</literal></entry>
+ <entry><type>text</type></entry>
+ <entry>get <command>CREATE VIEW</> command for view (<emphasis>deprecated</emphasis>)</entry>
+ </row>
+ <row>
+ <entry><literal><function>pg_get_viewdef</function>(<parameter>view_name</parameter>, <parameter>pretty_bool</>)</literal></entry>
+ <entry><type>text</type></entry>
+ <entry>get <command>CREATE VIEW</> command for view (<emphasis>deprecated</emphasis>)</entry>
+ </row>
+ <row>
+ <entry><literal><function>pg_get_viewdef</function>(<parameter>view_oid</parameter>)</literal></entry>
+ <entry><type>text</type></entry>
+ <entry>get <command>CREATE VIEW</> command for view</entry>
+ </row>
+ <row>
+ <entry><literal><function>pg_get_viewdef</function>(<parameter>view_oid</parameter>, <parameter>pretty_bool</>)</literal></entry>
+ <entry><type>text</type></entry>
+ <entry>get <command>CREATE VIEW</> command for view</entry>
+ </row>
+ <row>
+ <entry><literal><function>pg_get_ruledef</function>(<parameter>rule_oid</parameter>)</literal></entry>
+ <entry><type>text</type></entry>
+ <entry>get <command>CREATE RULE</> command for rule</entry>
+ </row>
+ <row>
+ <entry><literal><function>pg_get_ruledef</function>(<parameter>rule_oid</parameter>, <parameter>pretty_bool</>)</literal></entry>
+ <entry><type>text</type></entry>
+ <entry>get <command>CREATE RULE</> command for rule</entry>
+ </row>
+ <row>
+ <entry><literal><function>pg_get_indexdef</function>(<parameter>index_oid</parameter>)</literal></entry>
+ <entry><type>text</type></entry>
+ <entry>get <command>CREATE INDEX</> command for index</entry>
+ </row>
+ <row>
+ <entry><literal><function>pg_get_indexdef</function>(<parameter>index_oid</parameter>, <parameter>column_no</>, <parameter>pretty_bool</>)</literal></entry>
+ <entry><type>text</type></entry>
+ <entry>get <command>CREATE INDEX</> command for index,
+ or definition of just one index column when
+ <parameter>column_no</> is not zero</entry>
+ </row>
+ <row>
+ <entry><function>pg_get_triggerdef</function>(<parameter>trigger_oid</parameter>)</entry>
+ <entry><type>text</type></entry>
+ <entry>get <command>CREATE [ CONSTRAINT ] TRIGGER</> command for trigger</entry>
+ </row>
+ <row>
+ <entry><literal><function>pg_get_constraintdef</function>(<parameter>constraint_oid</parameter>)</literal></entry>
+ <entry><type>text</type></entry>
+ <entry>get definition of a constraint</entry>
+ </row>
+ <row>
+ <entry><literal><function>pg_get_constraintdef</function>(<parameter>constraint_oid</parameter>, <parameter>pretty_bool</>)</literal></entry>
+ <entry><type>text</type></entry>
+ <entry>get definition of a constraint</entry>
+ </row>
+ <row>
+ <entry><literal><function>pg_get_expr</function>(<parameter>expr_text</parameter>, <parameter>relation_oid</>)</literal></entry>
+ <entry><type>text</type></entry>
+ <entry>decompile internal form of an expression, assuming that any Vars
+ in it refer to the relation indicated by the second parameter</entry>
+ </row>
+ <row>
+ <entry><literal><function>pg_get_expr</function>(<parameter>expr_text</parameter>, <parameter>relation_oid</>, <parameter>pretty_bool</>)</literal></entry>
+ <entry><type>text</type></entry>
+ <entry>decompile internal form of an expression, assuming that any Vars
+ in it refer to the relation indicated by the second parameter</entry>
+ </row>
+ <row>
+ <entry><literal><function>pg_get_userbyid</function>(<parameter>userid</parameter>)</literal></entry>
+ <entry><type>name</type></entry>
+ <entry>get user name with given ID</entry>
+ </row>
+ <row>
+ <entry><literal><function>pg_get_serial_sequence</function>(<parameter>table_name</parameter>, <parameter>column_name</parameter>)</literal></entry>
+ <entry><type>text</type></entry>
+ <entry>get name of the sequence that a serial or bigserial column
+ uses</entry>
+ </row>
+ <row>
+ <entry><literal><function>pg_tablespace_databases</function>(<parameter>tablespace_oid</parameter>)</literal></entry>
+ <entry><type>setof oid</type></entry>
+ <entry>get set of database OIDs that have objects in the tablespace</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+
+ <para>
+ <function>pg_get_viewdef</function>,
+ <function>pg_get_ruledef</function>,
+ <function>pg_get_indexdef</function>,
+ <function>pg_get_triggerdef</function>, and
+ <function>pg_get_constraintdef</function> respectively
+ reconstruct the creating command for a view, rule, index, trigger, or
+ constraint. (Note that this is a decompiled reconstruction, not
+ the original text of the command.)
+ <function>pg_get_expr</function> decompiles the internal form of an
+ individual expression, such as the default value for a column. It
+ may be useful when examining the contents of system catalogs.
+ Most of these functions come in two
+ variants, one of which can optionally <quote>pretty-print</> the result.
+ The pretty-printed format is more readable, but the default format is more
+ likely to be
+ interpreted the same way by future versions of <productname>PostgreSQL</>;
+ avoid using pretty-printed output for dump purposes.
+ Passing <literal>false</> for the pretty-print parameter yields the
+ same result as the variant that does not have the parameter at all.
+ </para>
+
+ <para>
+ <function>pg_get_userbyid</function>
+ extracts a user's name given a user ID number.
+ <function>pg_get_serial_sequence</function>
+ fetches the name of the sequence associated with a serial or
+ bigserial column. The name is suitably formatted
+ for passing to the sequence functions (see <xref
+ linkend="functions-sequence">).
+ NULL is returned if the column does not have a sequence attached.
+ </para>
+
+ <para>
+ <function>pg_tablespace_databases</function> allows usage examination of a
+ tablespace. It will return a set of OIDs of databases that have objects
+ stored in the tablespace. If this function returns any row, the
+ tablespace is not empty and cannot be dropped. To
+ display the specific objects populating the tablespace, you will need
+ to connect to the databases identified by
+ <function>pg_tablespace_databases</function> and query their
+ <structname>pg_class</> catalogs.
+ </para>
+
+ <indexterm zone="functions-info">
+ <primary>obj_description</primary>
+ </indexterm>
+
+ <indexterm zone="functions-info">
+ <primary>col_description</primary>
+ </indexterm>
+
+ <indexterm zone="functions-info">
+ <primary>comment</primary>
+ <secondary sortas="database objects">about database objects</secondary>
+ </indexterm>
+
+ <para>
+ The functions shown in <xref
+ linkend="functions-info-comment-table"> extract comments
+ previously stored with the <command>COMMENT</command> command. A
+ null value is returned if no comment could be found matching the
+ specified parameters.
+ </para>
+
+ <table id="functions-info-comment-table">
+ <title>Comment Information Functions</title>
+ <tgroup cols="3">
+ <thead>
+ <row><entry>Name</entry> <entry>Return Type</entry> <entry>Description</entry></row>
+ </thead>
+
+ <tbody>
+ <row>
+ <entry><literal><function>obj_description</function>(<parameter>object_oid</parameter>, <parameter>catalog_name</parameter>)</literal></entry>
+ <entry><type>text</type></entry>
+ <entry>get comment for a database object</entry>
+ </row>
+ <row>
+ <entry><literal><function>obj_description</function>(<parameter>object_oid</parameter>)</literal></entry>
+ <entry><type>text</type></entry>
+ <entry>get comment for a database object (<emphasis>deprecated</emphasis>)</entry>
+ </row>
+ <row>
+ <entry><literal><function>col_description</function>(<parameter>table_oid</parameter>, <parameter>column_number</parameter>)</literal></entry>
+ <entry><type>text</type></entry>
+ <entry>get comment for a table column</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+
+ <para>
+ The two-parameter form of <function>obj_description</function> returns the
+ comment for a database object specified by its OID and the name of the
+ containing system catalog. For example,
+ <literal>obj_description(123456,'pg_class')</literal>
+ would retrieve the comment for a table with OID 123456.
+ The one-parameter form of <function>obj_description</function> requires only
+ the object OID. It is now deprecated since there is no guarantee that
+ OIDs are unique across different system catalogs; therefore, the wrong
+ comment could be returned.
+ </para>
+
+ <para>
+ <function>col_description</function> returns the comment for a table column,
+ which is specified by the OID of its table and its column number.
+ <function>obj_description</function> cannot be used for table columns since
+ columns do not have OIDs of their own.
+ </para>
+ </sect1>
+
+ <sect1 id="functions-admin">
+ <title>System Administration Functions</title>
+
+ <para>
+ <xref linkend="functions-admin-set-table"> shows the functions
+ available to query and alter run-time configuration parameters.
+ </para>
+
+ <table id="functions-admin-set-table">
+ <title>Configuration Settings Functions</title>
+ <tgroup cols="3">
+ <thead>
+ <row><entry>Name</entry> <entry>Return Type</entry> <entry>Description</entry></row>
+ </thead>
+
+ <tbody>
+ <row>
+ <entry>
+ <literal><function>current_setting</function>(<parameter>setting_name</parameter>)</literal>
+ </entry>
+ <entry><type>text</type></entry>
+ <entry>current value of setting</entry>
+ </row>
+ <row>
+ <entry>
+ <literal><function>set_config(<parameter>setting_name</parameter>,
+ <parameter>new_value</parameter>,
+ <parameter>is_local</parameter>)</function></literal>
+ </entry>
+ <entry><type>text</type></entry>
+ <entry>set parameter and return new value</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+
+ <indexterm zone="functions-admin">
+ <primary>SET</primary>
+ </indexterm>
+
+ <indexterm zone="functions-admin">
+ <primary>SHOW</primary>
+ </indexterm>
+
+ <indexterm zone="functions-admin">
+ <primary>configuration</primary>
+ <secondary sortas="server">of the server</secondary>
+ <tertiary>functions</tertiary>
+ </indexterm>
+
+ <para>
+ The function <function>current_setting</function> yields the
+ current value of the setting <parameter>setting_name</parameter>.
+ It corresponds to the <acronym>SQL</acronym> command
+ <command>SHOW</command>. An example:
+<programlisting>
+SELECT current_setting('datestyle');
+
+ current_setting
+-----------------
+ ISO, MDY
+(1 row)
+</programlisting>
+ </para>
+
+ <para>
+ <function>set_config</function> sets the parameter
+ <parameter>setting_name</parameter> to
+ <parameter>new_value</parameter>. If
+ <parameter>is_local</parameter> is <literal>true</literal>, the
+ new value will only apply to the current transaction. If you want
+ the new value to apply for the current session, use
+ <literal>false</literal> instead. The function corresponds to the
+ SQL command <command>SET</command>. An example:
+<programlisting>
+SELECT set_config('log_statement_stats', 'off', false);
+
+ set_config
+------------
+ off
+(1 row)
+</programlisting>
+ </para>
+
+ <indexterm zone="functions-admin">
+ <primary>pg_cancel_backend</primary>
+ </indexterm>
+
+ <indexterm zone="functions-admin">
+ <primary>signal</primary>
+ <secondary sortas="backend">backend processes</secondary>
+ </indexterm>
+
+ <para>
+ The function shown in <xref
+ linkend="functions-admin-signal-table"> sends control signals to
+ other server processes. Use of this function is restricted
+ to superusers.
+ </para>
+
+ <table id="functions-admin-signal-table">
+ <title>Backend Signalling Functions</title>
+ <tgroup cols="3">
+ <thead>
+ <row><entry>Name</entry> <entry>Return Type</entry> <entry>Description</entry>
+ </row>
+ </thead>
+
+ <tbody>
+ <row>
+ <entry>
+ <literal><function>pg_cancel_backend</function>(<parameter>pid</parameter>)</literal>
+ </entry>
+ <entry><type>int</type></entry>
+ <entry>Cancel a backend's current query</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+
+ <para>
+ This function returns 1 if successful, 0 if not successful.
+ The process ID (<literal>pid</literal>) of an active backend can be found
+ from the <structfield>procpid</structfield> column in the
+ <structname>pg_stat_activity</structname> view, or by listing the postgres
+ processes on the server with <application>ps</>.
+ </para>
+
+ <indexterm zone="functions-admin">
+ <primary>pg_start_backup</primary>
+ </indexterm>
+
+ <indexterm zone="functions-admin">
+ <primary>pg_stop_backup</primary>
+ </indexterm>
+
+ <indexterm zone="functions-admin">
+ <primary>backup</primary>
+ </indexterm>
+
+ <para>
+ The functions shown in <xref
+ linkend="functions-admin-backup-table"> assist in making on-line backups.
+ Use of these functions is restricted to superusers.
+ </para>
+
+ <table id="functions-admin-backup-table">
+ <title>Backup Control Functions</title>
+ <tgroup cols="3">
+ <thead>
+ <row><entry>Name</entry> <entry>Return Type</entry> <entry>Description</entry>
+ </row>
+ </thead>
+
+ <tbody>
+ <row>
+ <entry>
+ <literal><function>pg_start_backup</function>(<parameter>label_text</parameter>)</literal>
+ </entry>
+ <entry><type>text</type></entry>
+ <entry>Set up for performing on-line backup</entry>
+ </row>
+ <row>
+ <entry>
+ <literal><function>pg_stop_backup</function>()</literal>
+ </entry>
+ <entry><type>text</type></entry>
+ <entry>Finish performing on-line backup</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+
+ <para>
+ <function>pg_start_backup</> accepts a single parameter which is an
+ arbitrary user-defined label for the backup. (Typically this would be
+ the name under which the backup dump file will be stored.) The function
+ writes a backup label file into the database cluster's data directory,
+ and then returns the backup's starting WAL offset as text. (The user
+ need not pay any attention to this result value, but it is provided in
+ case it is of use.)
+ </para>
+
+ <para>
+ <function>pg_stop_backup</> removes the label file created by
+ <function>pg_start_backup</>, and instead creates a backup history file in
+ the WAL archive area. The history file includes the label given to
+ <function>pg_start_backup</>, the starting and ending WAL offsets for
+ the backup, and the starting and ending times of the backup. The return
+ value is the backup's ending WAL offset (which again may be of little
+ interest).
+ </para>
+
+ <para>
+ For details about proper usage of these functions, see
+ <xref linkend="backup-online">.
+ </para>
+ </sect1>
</chapter>
<!-- Keep this comment at the end of the file
diff --git a/doc/src/sgml/ref/set.sgml b/doc/src/sgml/ref/set.sgml
index a09927a1eca..5e5a923ac7e 100644
--- a/doc/src/sgml/ref/set.sgml
+++ b/doc/src/sgml/ref/set.sgml
@@ -1,5 +1,5 @@
<!--
-$PostgreSQL: pgsql/doc/src/sgml/ref/set.sgml,v 1.84 2003/11/29 19:51:39 pgsql Exp $
+$PostgreSQL: pgsql/doc/src/sgml/ref/set.sgml,v 1.85 2004/08/03 20:32:32 tgl Exp $
PostgreSQL documentation
-->
@@ -229,7 +229,7 @@ SELECT setseed(<replaceable>value</replaceable>);
<para>
The function <function>set_config</function> provides equivalent
- functionality. See <xref linkend="functions-misc">.
+ functionality. See <xref linkend="functions-admin">.
</para>
</refsect1>
diff --git a/doc/src/sgml/ref/show.sgml b/doc/src/sgml/ref/show.sgml
index 85dbfdcedcc..cbd78a99467 100644
--- a/doc/src/sgml/ref/show.sgml
+++ b/doc/src/sgml/ref/show.sgml
@@ -1,5 +1,5 @@
<!--
-$PostgreSQL: pgsql/doc/src/sgml/ref/show.sgml,v 1.35 2004/01/06 17:26:23 neilc Exp $
+$PostgreSQL: pgsql/doc/src/sgml/ref/show.sgml,v 1.36 2004/08/03 20:32:32 tgl Exp $
PostgreSQL documentation
-->
@@ -130,7 +130,7 @@ SHOW ALL
<para>
The function <function>current_setting</function> produces
- equivalent output. See <xref linkend="functions-misc">.
+ equivalent output. See <xref linkend="functions-admin">.
</para>
</refsect1>
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index b0fac745266..59666580035 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.153 2004/08/01 17:45:42 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.154 2004/08/03 20:32:32 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -5048,3 +5048,233 @@ issue_xlog_fsync(void)
break;
}
}
+
+
+/*
+ * pg_start_backup: set up for taking an on-line backup dump
+ *
+ * Essentially what this does is to create a backup label file in $PGDATA,
+ * where it will be archived as part of the backup dump. The label file
+ * contains the user-supplied label string (typically this would be used
+ * to tell where the backup dump will be stored) and the starting time and
+ * starting WAL offset for the dump.
+ */
+Datum
+pg_start_backup(PG_FUNCTION_ARGS)
+{
+ text *backupid = PG_GETARG_TEXT_P(0);
+ text *result;
+ char *backupidstr;
+ XLogRecPtr startpoint;
+ time_t stamp_time;
+ char strfbuf[128];
+ char labelfilename[MAXPGPATH];
+ char xlogfilename[MAXFNAMELEN];
+ uint32 _logId;
+ uint32 _logSeg;
+ struct stat stat_buf;
+ FILE *fp;
+
+ if (!superuser())
+ ereport(ERROR,
+ (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
+ (errmsg("must be superuser to run a backup"))));
+ backupidstr = DatumGetCString(DirectFunctionCall1(textout,
+ PointerGetDatum(backupid)));
+ /*
+ * The oldest point in WAL that would be needed to restore starting from
+ * the most recent checkpoint is precisely the RedoRecPtr.
+ */
+ startpoint = GetRedoRecPtr();
+ XLByteToSeg(startpoint, _logId, _logSeg);
+ XLogFileName(xlogfilename, ThisTimeLineID, _logId, _logSeg);
+ /*
+ * We deliberately use strftime/localtime not the src/timezone functions,
+ * so that backup labels will consistently be recorded in the same
+ * timezone regardless of TimeZone setting. This matches elog.c's
+ * practice.
+ */
+ stamp_time = time(NULL);
+ strftime(strfbuf, sizeof(strfbuf),
+ "%Y-%m-%d %H:%M:%S %Z",
+ localtime(&stamp_time));
+ /*
+ * Check for existing backup label --- implies a backup is already running
+ */
+ snprintf(labelfilename, MAXPGPATH, "%s/backup_label", DataDir);
+ if (stat(labelfilename, &stat_buf) != 0)
+ {
+ if (errno != ENOENT)
+ ereport(ERROR,
+ (errcode_for_file_access(),
+ errmsg("could not stat \"%s\": %m",
+ labelfilename)));
+ }
+ else
+ ereport(ERROR,
+ (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
+ errmsg("a backup is already in progress"),
+ errhint("If you're sure there is no backup in progress, remove file \"%s\" and try again.",
+ labelfilename)));
+ /*
+ * Okay, write the file
+ */
+ fp = AllocateFile(labelfilename, "w");
+ if (!fp)
+ ereport(ERROR,
+ (errcode_for_file_access(),
+ errmsg("could not create file \"%s\": %m",
+ labelfilename)));
+ fprintf(fp, "START WAL LOCATION: %X/%X (file %s)\n",
+ startpoint.xlogid, startpoint.xrecoff, xlogfilename);
+ fprintf(fp, "START TIME: %s\n", strfbuf);
+ fprintf(fp, "LABEL: %s\n", backupidstr);
+ if (fflush(fp) || ferror(fp) || FreeFile(fp))
+ ereport(ERROR,
+ (errcode_for_file_access(),
+ errmsg("could not write file \"%s\": %m",
+ labelfilename)));
+ /*
+ * We're done. As a convenience, return the starting WAL offset.
+ */
+ snprintf(xlogfilename, sizeof(xlogfilename), "%X/%X",
+ startpoint.xlogid, startpoint.xrecoff);
+ result = DatumGetTextP(DirectFunctionCall1(textin,
+ CStringGetDatum(xlogfilename)));
+ PG_RETURN_TEXT_P(result);
+}
+
+/*
+ * pg_stop_backup: finish taking an on-line backup dump
+ *
+ * We remove the backup label file created by pg_start_backup, and instead
+ * create a backup history file in pg_xlog (whence it will immediately be
+ * archived). The backup history file contains the same info found in
+ * the label file, plus the backup-end time and WAL offset.
+ */
+Datum
+pg_stop_backup(PG_FUNCTION_ARGS)
+{
+ text *result;
+ XLogCtlInsert *Insert = &XLogCtl->Insert;
+ XLogRecPtr startpoint;
+ XLogRecPtr stoppoint;
+ time_t stamp_time;
+ char strfbuf[128];
+ char labelfilename[MAXPGPATH];
+ char histfilename[MAXPGPATH];
+ char startxlogfilename[MAXFNAMELEN];
+ char stopxlogfilename[MAXFNAMELEN];
+ uint32 _logId;
+ uint32 _logSeg;
+ FILE *lfp;
+ FILE *fp;
+ char ch;
+ int ich;
+
+ if (!superuser())
+ ereport(ERROR,
+ (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
+ (errmsg("must be superuser to run a backup"))));
+ /*
+ * Get the current end-of-WAL position; it will be unsafe to use this
+ * dump to restore to a point in advance of this time.
+ */
+ LWLockAcquire(WALInsertLock, LW_EXCLUSIVE);
+ INSERT_RECPTR(stoppoint, Insert, Insert->curridx);
+ LWLockRelease(WALInsertLock);
+
+ XLByteToSeg(stoppoint, _logId, _logSeg);
+ XLogFileName(stopxlogfilename, ThisTimeLineID, _logId, _logSeg);
+ /*
+ * We deliberately use strftime/localtime not the src/timezone functions,
+ * so that backup labels will consistently be recorded in the same
+ * timezone regardless of TimeZone setting. This matches elog.c's
+ * practice.
+ */
+ stamp_time = time(NULL);
+ strftime(strfbuf, sizeof(strfbuf),
+ "%Y-%m-%d %H:%M:%S %Z",
+ localtime(&stamp_time));
+ /*
+ * Open the existing label file
+ */
+ snprintf(labelfilename, MAXPGPATH, "%s/backup_label", DataDir);
+ lfp = AllocateFile(labelfilename, "r");
+ if (!lfp)
+ {
+ if (errno != ENOENT)
+ ereport(ERROR,
+ (errcode_for_file_access(),
+ errmsg("could not read file \"%s\": %m",
+ labelfilename)));
+ ereport(ERROR,
+ (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
+ errmsg("a backup is not in progress")));
+ }
+ /*
+ * Read and parse the START WAL LOCATION line (this code is pretty
+ * crude, but we are not expecting any variability in the file format).
+ */
+ if (fscanf(lfp, "START WAL LOCATION: %X/%X (file %24s)%c",
+ &startpoint.xlogid, &startpoint.xrecoff, startxlogfilename,
+ &ch) != 4 || ch != '\n')
+ ereport(ERROR,
+ (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
+ errmsg("invalid data in file \"%s\"", labelfilename)));
+ /*
+ * Write the backup history file
+ */
+ XLByteToSeg(startpoint, _logId, _logSeg);
+ BackupHistoryFilePath(histfilename, ThisTimeLineID, _logId, _logSeg,
+ startpoint.xrecoff % XLogSegSize);
+ fp = AllocateFile(histfilename, "w");
+ if (!fp)
+ ereport(ERROR,
+ (errcode_for_file_access(),
+ errmsg("could not create file \"%s\": %m",
+ histfilename)));
+ fprintf(fp, "START WAL LOCATION: %X/%X (file %s)\n",
+ startpoint.xlogid, startpoint.xrecoff, startxlogfilename);
+ fprintf(fp, "STOP WAL LOCATION: %X/%X (file %s)\n",
+ stoppoint.xlogid, stoppoint.xrecoff, stopxlogfilename);
+ /* transfer start time and label lines from label to history file */
+ while ((ich = fgetc(lfp)) != EOF)
+ fputc(ich, fp);
+ fprintf(fp, "STOP TIME: %s\n", strfbuf);
+ if (fflush(fp) || ferror(fp) || FreeFile(fp))
+ ereport(ERROR,
+ (errcode_for_file_access(),
+ errmsg("could not write file \"%s\": %m",
+ histfilename)));
+ /*
+ * Close and remove the backup label file
+ */
+ if (ferror(lfp) || FreeFile(lfp))
+ ereport(ERROR,
+ (errcode_for_file_access(),
+ errmsg("could not read file \"%s\": %m",
+ labelfilename)));
+ if (unlink(labelfilename) != 0)
+ ereport(ERROR,
+ (errcode_for_file_access(),
+ errmsg("could not remove file \"%s\": %m",
+ labelfilename)));
+ /*
+ * Notify archiver that history file may be archived immediately
+ */
+ if (XLogArchivingActive())
+ {
+ BackupHistoryFileName(histfilename, ThisTimeLineID, _logId, _logSeg,
+ startpoint.xrecoff % XLogSegSize);
+ XLogArchiveNotify(histfilename);
+ }
+ /*
+ * We're done. As a convenience, return the ending WAL offset.
+ */
+ snprintf(stopxlogfilename, sizeof(stopxlogfilename), "%X/%X",
+ stoppoint.xlogid, stoppoint.xrecoff);
+ result = DatumGetTextP(DirectFunctionCall1(textin,
+ CStringGetDatum(stopxlogfilename)));
+ PG_RETURN_TEXT_P(result);
+}
diff --git a/src/backend/postmaster/pgarch.c b/src/backend/postmaster/pgarch.c
index a4038963331..960ece75831 100644
--- a/src/backend/postmaster/pgarch.c
+++ b/src/backend/postmaster/pgarch.c
@@ -19,7 +19,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/postmaster/pgarch.c,v 1.3 2004/08/01 17:45:43 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/postmaster/pgarch.c,v 1.4 2004/08/03 20:32:33 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -64,8 +64,8 @@
* ----------
*/
#define MIN_XFN_CHARS 16
-#define MAX_XFN_CHARS 24
-#define VALID_XFN_CHARS "0123456789ABCDEF.history"
+#define MAX_XFN_CHARS 40
+#define VALID_XFN_CHARS "0123456789ABCDEF.history.backup"
#define NUM_ARCHIVE_RETRIES 3
diff --git a/src/backend/utils/adt/misc.c b/src/backend/utils/adt/misc.c
index 0cc315c6205..8bf989a8658 100644
--- a/src/backend/utils/adt/misc.c
+++ b/src/backend/utils/adt/misc.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/adt/misc.c,v 1.35 2004/07/02 18:59:22 joe Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/misc.c,v 1.36 2004/08/03 20:32:33 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -27,6 +27,8 @@
#include "catalog/pg_type.h"
#include "catalog/pg_tablespace.h"
+#define atooid(x) ((Oid) strtoul((x), NULL, 10))
+
/*
* Check if data is Null
@@ -67,8 +69,7 @@ current_database(PG_FUNCTION_ARGS)
/*
- * Functions to terminate a backend or cancel a query running on
- * a different backend.
+ * Functions to send signals to other backends.
*/
static int pg_signal_backend(int pid, int sig)
@@ -76,14 +77,16 @@ static int pg_signal_backend(int pid, int sig)
if (!superuser())
ereport(ERROR,
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
- (errmsg("only superuser can signal other backends"))));
+ (errmsg("must be superuser to signal other server processes"))));
if (!IsBackendPid(pid))
{
- /* This is just a warning so a loop-through-resultset will not abort
- * if one backend terminated on it's own during the run */
+ /*
+ * This is just a warning so a loop-through-resultset will not abort
+ * if one backend terminated on it's own during the run
+ */
ereport(WARNING,
- (errmsg("pid %i is not a postgresql backend",pid)));
+ (errmsg("PID %d is not a PostgreSQL server process", pid)));
return 0;
}
@@ -91,24 +94,32 @@ static int pg_signal_backend(int pid, int sig)
{
/* Again, just a warning to allow loops */
ereport(WARNING,
- (errmsg("failed to send signal to backend %i: %m",pid)));
+ (errmsg("could not send signal to process %d: %m",pid)));
return 0;
}
return 1;
}
Datum
-pg_terminate_backend(PG_FUNCTION_ARGS)
+pg_cancel_backend(PG_FUNCTION_ARGS)
{
- PG_RETURN_INT32(pg_signal_backend(PG_GETARG_INT32(0),SIGTERM));
+ PG_RETURN_INT32(pg_signal_backend(PG_GETARG_INT32(0),SIGINT));
}
+#ifdef NOT_USED
+
+/* Disabled in 8.0 due to reliability concerns; FIXME someday */
+
Datum
-pg_cancel_backend(PG_FUNCTION_ARGS)
+pg_terminate_backend(PG_FUNCTION_ARGS)
{
- PG_RETURN_INT32(pg_signal_backend(PG_GETARG_INT32(0),SIGINT));
+ PG_RETURN_INT32(pg_signal_backend(PG_GETARG_INT32(0),SIGTERM));
}
+#endif
+
+
+/* Function to find out which databases make use of a tablespace */
typedef struct
{
@@ -140,9 +151,8 @@ Datum pg_tablespace_databases(PG_FUNCTION_ARGS)
if (tablespaceOid == GLOBALTABLESPACE_OID)
{
fctx->dirdesc = NULL;
- ereport(NOTICE,
- (errcode(ERRCODE_WARNING),
- errmsg("global tablespace never has databases.")));
+ ereport(WARNING,
+ (errmsg("global tablespace never has databases")));
}
else
{
@@ -154,10 +164,17 @@ Datum pg_tablespace_databases(PG_FUNCTION_ARGS)
fctx->dirdesc = AllocateDir(fctx->location);
- if (!fctx->dirdesc) /* not a tablespace */
- ereport(NOTICE,
- (errcode(ERRCODE_WARNING),
- errmsg("%d is no tablespace oid.", tablespaceOid)));
+ if (!fctx->dirdesc)
+ {
+ /* the only expected error is ENOENT */
+ if (errno != ENOENT)
+ ereport(ERROR,
+ (errcode_for_file_access(),
+ errmsg("could not open directory \"%s\": %m",
+ fctx->location)));
+ ereport(WARNING,
+ (errmsg("%u is not a tablespace oid", tablespaceOid)));
+ }
}
funcctx->user_fctx = fctx;
MemoryContextSwitchTo(oldcontext);
@@ -174,27 +191,30 @@ Datum pg_tablespace_databases(PG_FUNCTION_ARGS)
char *subdir;
DIR *dirdesc;
- Oid datOid = atol(de->d_name);
+ Oid datOid = atooid(de->d_name);
+ /* this test skips . and .., but is awfully weak */
if (!datOid)
continue;
+ /* if database subdir is empty, don't report tablespace as used */
+
/* size = path length + dir sep char + file name + terminator */
subdir = palloc(strlen(fctx->location) + 1 + strlen(de->d_name) + 1);
sprintf(subdir, "%s/%s", fctx->location, de->d_name);
dirdesc = AllocateDir(subdir);
- if (dirdesc)
- {
- while ((de = readdir(dirdesc)) != 0)
- {
- if (strcmp(de->d_name, ".") && strcmp(de->d_name, ".."))
- break;
- }
- pfree(subdir);
- FreeDir(dirdesc);
+ pfree(subdir);
+ if (!dirdesc)
+ continue; /* XXX more sloppiness */
- if (!de) /* database subdir is empty; don't report tablespace as used */
- continue;
+ while ((de = readdir(dirdesc)) != 0)
+ {
+ if (strcmp(de->d_name, ".") != 0 && strcmp(de->d_name, "..") != 0)
+ break;
}
+ FreeDir(dirdesc);
+
+ if (!de)
+ continue; /* indeed, nothing in it */
SRF_RETURN_NEXT(funcctx, ObjectIdGetDatum(datOid));
}
diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h
index 09877bf64be..89c37b7d66a 100644
--- a/src/include/access/xlog_internal.h
+++ b/src/include/access/xlog_internal.h
@@ -11,12 +11,13 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/access/xlog_internal.h,v 1.1 2004/07/21 22:31:25 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/access/xlog_internal.h,v 1.2 2004/08/03 20:32:34 tgl Exp $
*/
#ifndef XLOG_INTERNAL_H
#define XLOG_INTERNAL_H
#include "access/xlog.h"
+#include "fmgr.h"
#include "storage/block.h"
#include "storage/relfilenode.h"
@@ -177,7 +178,7 @@ typedef XLogLongPageHeaderData *XLogLongPageHeader;
* These macros encapsulate knowledge about the exact layout of XLog file
* names, timeline history file names, and archive-status file names.
*/
-#define MAXFNAMELEN 32
+#define MAXFNAMELEN 64
#define XLogFileName(fname, tli, log, seg) \
snprintf(fname, MAXFNAMELEN, "%08X%08X%08X", tli, log, seg)
@@ -194,6 +195,12 @@ typedef XLogLongPageHeaderData *XLogLongPageHeader;
#define StatusFilePath(path, xlog, suffix) \
snprintf(path, MAXPGPATH, "%s/archive_status/%s%s", XLogDir, xlog, suffix)
+#define BackupHistoryFileName(fname, tli, log, seg, offset) \
+ snprintf(fname, MAXFNAMELEN, "%08X%08X%08X.%08X.backup", tli, log, seg, offset)
+
+#define BackupHistoryFilePath(path, tli, log, seg, offset) \
+ snprintf(path, MAXPGPATH, "%s/%08X%08X%08X.%08X.backup", XLogDir, tli, log, seg, offset)
+
extern char XLogDir[MAXPGPATH];
/*
@@ -221,4 +228,10 @@ typedef struct RmgrData
extern const RmgrData RmgrTable[];
+/*
+ * These aren't in xlog.h because I'd rather not include fmgr.h there.
+ */
+extern Datum pg_start_backup(PG_FUNCTION_ARGS);
+extern Datum pg_stop_backup(PG_FUNCTION_ARGS);
+
#endif /* XLOG_INTERNAL_H */
diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h
index d7d180eaf51..0d5ac8f13c5 100644
--- a/src/include/catalog/catversion.h
+++ b/src/include/catalog/catversion.h
@@ -37,7 +37,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.247 2004/07/21 20:43:53 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.248 2004/08/03 20:32:35 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -53,6 +53,6 @@
*/
/* yyyymmddN */
-#define CATALOG_VERSION_NO 200407211
+#define CATALOG_VERSION_NO 200408031
#endif
diff --git a/src/include/catalog/pg_proc.h b/src/include/catalog/pg_proc.h
index 646fa73dd15..21bd60fb946 100644
--- a/src/include/catalog/pg_proc.h
+++ b/src/include/catalog/pg_proc.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.342 2004/07/12 20:23:53 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.343 2004/08/03 20:32:35 tgl Exp $
*
* NOTES
* The script catalog/genbki.sh reads this file and generates .bki
@@ -2815,11 +2815,6 @@ DESCR("Statistics: Blocks fetched for database");
DATA(insert OID = 1945 ( pg_stat_get_db_blocks_hit PGNSP PGUID 12 f f t f s 1 20 "26" _null_ pg_stat_get_db_blocks_hit - _null_ ));
DESCR("Statistics: Blocks found in cache for database");
-DATA(insert OID = 2171 ( pg_terminate_backend PGNSP PGUID 12 f f t f s 1 23 "23" _null_ pg_terminate_backend - _null_ ));
-DESCR("Terminate a backend process");
-DATA(insert OID = 2172 ( pg_cancel_backend PGNSP PGUID 12 f f t f s 1 23 "23" _null_ pg_cancel_backend - _null_ ));
-DESCR("Cancel running query on a backend process");
-
DATA(insert OID = 1946 ( encode PGNSP PGUID 12 f f t f i 2 25 "17 25" _null_ binary_encode - _null_ ));
DESCR("Convert bytea value into some ascii-only text string");
DATA(insert OID = 1947 ( decode PGNSP PGUID 12 f f t f i 2 17 "25 25" _null_ binary_decode - _null_ ));
@@ -2993,10 +2988,18 @@ DATA(insert OID = 2082 ( pg_operator_is_visible PGNSP PGUID 12 f f t f s 1 16 "
DESCR("is operator visible in search path?");
DATA(insert OID = 2083 ( pg_opclass_is_visible PGNSP PGUID 12 f f t f s 1 16 "26" _null_ pg_opclass_is_visible - _null_ ));
DESCR("is opclass visible in search path?");
-DATA(insert OID = 2093 ( pg_conversion_is_visible PGNSP PGUID 12 f f t f s 1 16 "26" _null_ pg_conversion_is_visible - _null_ ));
+DATA(insert OID = 2093 ( pg_conversion_is_visible PGNSP PGUID 12 f f t f s 1 16 "26" _null_ pg_conversion_is_visible - _null_ ));
DESCR("is conversion visible in search path?");
+DATA(insert OID = 2171 ( pg_cancel_backend PGNSP PGUID 12 f f t f v 1 23 "23" _null_ pg_cancel_backend - _null_ ));
+DESCR("Cancel a server process' current query");
+DATA(insert OID = 2172 ( pg_start_backup PGNSP PGUID 12 f f t f v 1 25 "25" _null_ pg_start_backup - _null_ ));
+DESCR("Prepare for taking an online backup");
+DATA(insert OID = 2173 ( pg_stop_backup PGNSP PGUID 12 f f t f v 0 25 "" _null_ pg_stop_backup - _null_ ));
+DESCR("Finish taking an online backup");
+
+
/* Aggregates (moved here from pg_aggregate for 7.3) */
DATA(insert OID = 2100 ( avg PGNSP PGUID 12 t f f f i 1 1700 "20" _null_ aggregate_dummy - _null_ ));
diff --git a/src/include/utils/builtins.h b/src/include/utils/builtins.h
index 3e9f58e7f26..09d91d985c9 100644
--- a/src/include/utils/builtins.h
+++ b/src/include/utils/builtins.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/utils/builtins.h,v 1.246 2004/07/12 20:23:59 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/utils/builtins.h,v 1.247 2004/08/03 20:32:36 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -360,7 +360,6 @@ extern Datum float84ge(PG_FUNCTION_ARGS);
extern Datum nullvalue(PG_FUNCTION_ARGS);
extern Datum nonnullvalue(PG_FUNCTION_ARGS);
extern Datum current_database(PG_FUNCTION_ARGS);
-extern Datum pg_terminate_backend(PG_FUNCTION_ARGS);
extern Datum pg_cancel_backend(PG_FUNCTION_ARGS);
extern Datum pg_tablespace_databases(PG_FUNCTION_ARGS);