of Norm's Modular Style Sheets and jade/docbook.
From Vince Vielhaber <vev@michvhf.com>.
<Para>
<ProductName>PostgreSQL</ProductName> is available without cost. This manual
describes version 6.4 of <ProductName>PostgreSQL</ProductName>.
-
+</Para>
<Para>
We will use <ProductName>Postgres</ProductName>
to mean the version distributed as <ProductName>PostgreSQL</ProductName>.
-
+</Para>
<Para>
Check the Administrator's Guide for a list of currently supported machines.
In general,
<ProductName>Postgres</ProductName> is portable to any Unix/Posix-compatible system
with full libc library support.
-
+</Para>
</Sect1>
|Mariposa | 1953 |
+----------+----------+
</ProgramListing>
+</Para>
<Para>
On the other hand, to find the names of all cities,
sub-values that can be accessed from the query
language. For example, you can create attributes that
are arrays of base types.
+</Para>
<Sect2>
<Title>Arrays</Title>
+-------------------+
</ProgramListing>
</Para>
-
+</sect2>
</Sect1>
<Sect1>
|Mariposa | 1320 |
+---------+------------+
</ProgramListing>
+</Para>
<Para>
The default beginning of a time range is the earliest
the current time; thus, the above time range can be
abbreviated as ``[,].''
</Para>
+</sect1>
<Sect1>
<Title>More Advanced Features</Title>
<ProductName>Postgres</ProductName> has many features not touched upon in this
tutorial introduction, which has been oriented toward newer users of <Acronym>SQL</Acronym>.
These are discussed in more detail in both the User's and Programmer's Guides.
+</Para>
+</sect1>
</Chapter>
</Para>
</ListItem>
</ItemizedList>
+</Para>
<Para>
A single <Application>postmaster</Application> manages a given collection of
case, all files relating to a database should belong to
this <ProductName>Postgres</ProductName> superuser.
</Para>
-
+</sect1>
</Chapter>
</Para>
</ListItem>
</ItemizedList>
-
+</para>
<Para>
A single <Application>postmaster</Application> manages a given collection of
databases on a single host. Such a collection of
case, all files relating to a database should belong to
this <ProductName>Postgres</ProductName> superuser.
</Para>
-
+</sect1>
</Chapter>
In database jargon, <ProductName>Postgres</ProductName> uses a simple "process
per-user" client/server model. A <ProductName>Postgres</ProductName> session
consists of the following cooperating UNIX processes (programs):
+</Para>
<ItemizedList>
<ListItem>
<Application>postmaster</Application>. Hence, the <Application>postmaster</Application> is always running, waiting
for requests, whereas frontend and backend processes
come and go.
+</Para>
<Para>
The <FileName>libpq</FileName> library allows a single
machine may not be accessible (or may only be accessed
using a different filename) on the database server
machine.
+</Para>
<Para>
You should also be aware that the <Application>postmaster</Application> and
case, all files relating to a database should belong to
this <ProductName>Postgres</ProductName> superuser.
</Para>
-
+</sect1>
</Chapter>
<!--
-$Header: /cvsroot/pgsql/doc/src/sgml/bki.sgml,v 1.1 1998/08/15 06:49:33 thomas Exp $
+$Header: /cvsroot/pgsql/doc/src/sgml/bki.sgml,v 1.2 1998/12/29 02:24:13 thomas Exp $
Transcribed from the original bki.man.5 documentation
- Thomas Lockhart 1998-08-03
<application>genbki</application>
input that builds tables and C header files that describe those
tables.
+</para>
<para>
Related information may be found in documentation for
<application>initdb</application>,
<application>createdb</application>,
and the <acronym>SQL</acronym> command <command>CREATE DATABASE</command>.
+</para>
<sect1>
<title><acronym>BKI</acronym> File Format</title>
at hand as an example. (As explained above, this .source file isn't quite
a <acronym>BKI</acronym> file, but you'll be able to guess what the resulting <acronym>BKI</acronym> file would be
anyway).
+</para>
<para>
Commands are composed of a command name followed by space separated
interpreted as the name of a macro causing the argument to be replaced
with the macro's value. It is an error for this macro to be
undefined.
+</para>
<para>
Macros are defined using
undefine macro macro_name
</programlisting>
and redefined using the same syntax as define.
+</para>
<para>
Lists of general commands and macro commands
follow.
+</para>
+</sect1>
<sect1>
<title>General Commands</title>
Open the class called
<replaceable class="parameter">classname</replaceable>
for further manipulation.
+</para>
+</listitem>
+</varlistentry>
<varlistentry>
<term>
is not already opened. If no
<replaceable class="parameter">classname</replaceable>
is given, then the currently open class is closed.
+</para>
+</listitem>
+</varlistentry>
<varlistentry>
<term>
<listitem>
<para>
Print the currently open class.
+</para>
+</listitem>
+</varlistentry>
<varlistentry>
<term>
<replaceable class="parameter">oid_value</replaceable>
is not <quote>0</quote>, then this value will be used as the instance's
object identifier. Otherwise, it is an error.
+</para>
+</listitem>
+</varlistentry>
<varlistentry>
<term>
<listitem>
<para>
As above, but the system generates a unique object identifier.
+</para>
+</listitem>
+</varlistentry>
<varlistentry>
<term>
Create a class named
<replaceable class="parameter">classname</replaceable>
with the attributes given in parentheses.
+</para>
+</listitem>
+</varlistentry>
<varlistentry>
<term>
<replaceable class="parameter">classname</replaceable>
for writing but do not record its existence in the system catalogs.
(This is primarily to aid in bootstrapping.)
+</para>
+</listitem>
+</varlistentry>
<varlistentry>
<term>
<para>
Destroy the class named
<replaceable class="parameter">classname</replaceable>.
+</para>
+</listitem>
+</varlistentry>
<varlistentry>
<term>
<replaceable class="parameter">collection_1</replaceable>,
<replaceable class="parameter">collection_2</replaceable>
etc., respectively.
-
+</para>
+</listitem>
</varlistentry>
+
</variablelist>
<note>
<para>
This last sentence doesn't reference anything in the example. Should be changed to make sense. - Thomas 1998-08-04
+</para>
</note>
+</sect1>
<sect1>
<title>Macro Commands</title>
with the arguments
<replaceable class="parameter">args</replaceable>
declared in a C-like manner.
+</para>
+</listitem>
+</varlistentry>
<varlistentry>
<term>
which has its value
read from the file called
<replaceable class="parameter">filename</replaceable>.
-
+</para>
+</listitem>
</varlistentry>
+
</variablelist>
+</para>
+</sect1>
<sect1>
<title>Debugging Commands</title>
<note>
<para>
This section on debugging commands was commented-out in the original documentation. Thomas 1998-08-05
+</para>
</note>
<variablelist>
<listitem>
<para>
Randomly print the open class.
+</para>
+</listitem>
+</varlistentry>
<varlistentry>
<term>
<listitem>
<para>
Toggle display of time information.
+</para>
+</listitem>
+</varlistentry>
<varlistentry>
<term>
<listitem>
<para>
Set retrievals to now.
+</para>
+</listitem>
+</varlistentry>
<varlistentry>
<term>
<listitem>
<para>
Set retrievals to snapshots of the specfied time.
+</para>
+</listitem>
+</varlistentry>
<varlistentry>
<term>
Set retrievals to ranges of the specified times.
Either time may be replaced with space
if an unbounded time range is desired.
+</para>
+</listitem>
+</varlistentry>
<varlistentry>
<term>
<replaceable class="parameter">type2</replaceable>,
etc. to the class
<replaceable class="parameter">classname</replaceable>.
+</para>
+</listitem>
+</varlistentry>
<varlistentry>
<term>
<replaceable class="parameter">oldclassname</replaceable>
class to
<replaceable class="parameter">newclassname</replaceable>.
+</para>
+</listitem>
+</varlistentry>
<varlistentry>
<term>
<replaceable class="parameter">classname</replaceable>
to
<replaceable class="parameter">newattname</replaceable>.
-
+</para>
+</listitem>
</varlistentry>
</variablelist>
+</para>
+</sect1>
<sect1>
<title>Example</title>
print
close pg_opclass
</programlisting>
-
+</para>
+</sect1>
</chapter>
Contributed by <ULink url="mailto:geek+@cmu.edu">Brian Gallew</ULink>
</Para>
</Note>
+</para>
<Para>
Configuring gcc to use certain flags by default is a simple matter of
"*<Replaceable>section_name</Replaceable>:" (e.g. "*asm:").
The second line is a list of flags,
and the third line is blank.
+</para>
<Para>
The easiest change to make is to append
</ProgramListing>
This will always omit frame pointers, any will build 486-optimized
code unless -m386 is specified on the command line.
+</para>
<Para>
You can actually do quite a lot of customization with the specs file.
Always remember, however, that these changes are global, and affect
all users of the system.
+</para>
</Chapter>
<chapter id="config">
<title id="install-config">Configuration Options</title>
-<sect1>
-<title>Parameters for Configuration (<application>configure</application>)</title>
-
-<para>
-The full set of parameters available in <application>configure</application>
-can be obtained by typing
-
-<programlisting>
-$ ./configure --help
-</programlisting>
-
-<para>
-The following parameters may be of interest to installers:
-
-<programlisting>
+ <sect1>
+ <title>Parameters for Configuration (<application>configure</application>)</title>
+
+ <para>
+ The full set of parameters available in <application>configure</application>
+ can be obtained by typing
+
+ <programlisting>
+ $ ./configure --help
+ </programlisting>
+ </para>
+ <para>
+ The following parameters may be of interest to installers:
+
+ <programlisting>
Directory and file names:
--prefix=PREFIX install architecture-independent files in PREFIX
[/usr/local/pgsql]
--enable-cassert enable assertion checks (debugging)
--with-CC=<replaceable>compiler</replaceable> use specific C compiler
--with-CXX=<replaceable>compiler</replaceable> use specific C++ compiler
-</programlisting>
-
-<para>
-Some systems may have trouble building a specific feature of
-<productname>Postgres</productname>. For example, systems with a damaged
-C++ compiler may need to specify <option>--without-CXX</option> to encourage
-the build procedure to ignore the <filename>libpq++</filename> construction.
-
-<sect1>
-<title>Parameters for Building (<application>make</application>)</title>
-
-<para>
-Many installation-related parameters can be set in the building
-stage of <productname>Postgres</productname> installation.
-
-<para>
-In most cases, these parameters should be place in a file,
-<filename>Makefile.custom</filename>, intended just for that purpose.
-The default distribution does not contain this optional file, so you
-will create it using a text editor of your choice. When upgrading installations,
-you can simply copy your old Makefile.custom to the new installation before
-doing the build.
-
-<synopsis>
-make [ <replaceable>variable</replaceable>=<replaceable class="parameter">value</replaceable> [,...] ]
-</synopsis>
-
-<para>
-A few of the many variables which can be specified are:
-
-<variablelist>
-<varlistentry>
-<term>
-<envar>POSTGRESDIR</envar>
-
-<listitem>
-<para>
-Top of the installation tree.
-
-<varlistentry>
-<term>
-<envar>BINDIR</envar>
-
-<listitem>
-<para>
-Location of applications and utilities.
-
-<varlistentry>
-<term>
-<envar>LIBDIR</envar>
-
-<listitem>
-<para>
-Location of object libraries, including shared libraries.
-
-<varlistentry>
-<term>
-<envar>HEADERDIR</envar>
-
-<listitem>
-<para>
-Location of include files.
-
-<varlistentry>
-<term>
-<envar>ODBCINST</envar>
-
-<listitem>
-<para>
-Location of installation-wide <application>psqlODBC</application>
-(<acronym>ODBC</acronym>) configuration file.
-
-</variablelist>
-
-<para>
-There are other optional parameters which are not as commonly used.
-Many of those listed below are appropriate when doing
-<application>Postgres</application> server code development.
-
-<variablelist>
-<varlistentry>
-<term>
-<envar>CFLAGS</envar>
-
-<listitem>
-<para>
-Set flags for the C compiler.
-Should be assigned with "+=" to retain relevant default parameters.
-
-<varlistentry>
-<term>
-YFLAGS
-
-<listitem>
-<para>
-Set flags for the yacc/bison parser. <option>-v</option> might be
-used to help diagnose problems building a new parser.
-Should be assigned with "+=" to retain relevant default parameters.
-
-<varlistentry>
-<term>
-<envar>USE_TCL</envar>
-
-<listitem>
-<para>
-Enable Tcl interface building.
-
-<varlistentry>
-<term>
-<envar>HSTYLE</envar>
-
-<listitem>
-<para>
-DocBook <acronym>HTML</acronym> style sheets for building the
-documentation from scratch.
-Not used unless you are developing new documentation from the
-DocBook-compatible <acronym>SGML</acronym> source documents in
-<filename>doc/src/sgml/</filename>.
-
-<varlistentry>
-<term>
-<envar>PSTYLE</envar>
-
-<listitem>
-<para>
-DocBook style sheets for building printed documentation from scratch.
-Not used unless you are developing new documentation from the
-DocBook-compatible <acronym>SGML</acronym> source documents in
-<filename>doc/src/sgml/</filename>.
-
-</variablelist>
-
-<para>
-Here is an example <filename>Makefile.custom</filename> for a
-PentiumPro Linux system:
-
-<programlisting>
+ </programlisting>
+ </para>
+ <para>
+ Some systems may have trouble building a specific feature of
+ <productname>Postgres</productname>. For example, systems with a damaged
+ C++ compiler may need to specify <option>--without-CXX</option> to encourage
+ the build procedure to ignore the <filename>libpq++</filename> construction.
+ </para>
+ </sect1>
+ <sect1>
+ <title>Parameters for Building (<application>make</application>)</title>
+
+ <para>
+ Many installation-related parameters can be set in the building
+ stage of <productname>Postgres</productname> installation.
+ </para>
+ <para>
+ In most cases, these parameters should be place in a file,
+ <filename>Makefile.custom</filename>, intended just for that purpose.
+ The default distribution does not contain this optional file, so you
+ will create it using a text editor of your choice. When upgrading installations,
+ you can simply copy your old Makefile.custom to the new installation before
+ doing the build.
+
+ <synopsis>
+ make [ <replaceable>variable</replaceable>=<replaceable class="parameter">value</replaceable> [,...] ]
+ </synopsis>
+ </para>
+ <para>
+ A few of the many variables which can be specified are:
+
+ <variablelist>
+ <varlistentry>
+ <term>
+ <envar>POSTGRESDIR</envar>
+ </term>
+ <listitem>
+ <para>
+ Top of the installation tree.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ <envar>BINDIR</envar>
+ </term>
+ <listitem>
+ <para>
+ Location of applications and utilities.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ <envar>LIBDIR</envar>
+ </term>
+ <listitem>
+ <para>
+ Location of object libraries, including shared libraries.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ <envar>HEADERDIR</envar>
+ </term>
+ <listitem>
+ <para>
+ Location of include files.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ <envar>ODBCINST</envar>
+ </term>
+ <listitem>
+ <para>
+ Location of installation-wide <application>psqlODBC</application>
+ (<acronym>ODBC</acronym>) configuration file.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </para>
+ <para>
+ There are other optional parameters which are not as commonly used.
+ Many of those listed below are appropriate when doing
+ <application>Postgres</application> server code development.
+
+ <variablelist>
+ <varlistentry>
+ <term>
+ <envar>CFLAGS</envar>
+ </term>
+ <listitem>
+ <para>
+ Set flags for the C compiler.
+ Should be assigned with "+=" to retain relevant default parameters.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ YFLAGS
+ </term>
+ <listitem>
+ <para>
+ Set flags for the yacc/bison parser. <option>-v</option> might be
+ used to help diagnose problems building a new parser.
+ Should be assigned with "+=" to retain relevant default parameters.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ <envar>USE_TCL</envar>
+ </term>
+ <listitem>
+ <para>
+ Enable Tcl interface building.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ <envar>HSTYLE</envar>
+ </term>
+ <listitem>
+ <para>
+ DocBook <acronym>HTML</acronym> style sheets for building the
+ documentation from scratch.
+ Not used unless you are developing new documentation from the
+ DocBook-compatible <acronym>SGML</acronym> source documents in
+ <filename>doc/src/sgml/</filename>.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ <envar>PSTYLE</envar>
+ </term>
+ <listitem>
+ <para>
+ DocBook style sheets for building printed documentation from scratch.
+ Not used unless you are developing new documentation from the
+ DocBook-compatible <acronym>SGML</acronym> source documents in
+ <filename>doc/src/sgml/</filename>.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </para>
+ <para>
+ Here is an example <filename>Makefile.custom</filename> for a
+ PentiumPro Linux system:
+
+ <programlisting>
# Makefile.custom
# Thomas Lockhart 1998-03-01
HSTYLE= /home/tgl/SGML/db118.d/docbook/html
PSTYLE= /home/tgl/SGML/db118.d/docbook/print
-</programlisting>
-
-<Sect1>
-<Title>Locale Support</Title>
-
-<Para>
-<Note>
-<Para>
-Written by Oleg Bartunov.
-See <ULink url="http://www.sai.msu.su/~megera/postgres/">Oleg's web page</ULink>
- for additional information on locale and Russian language support.
-
-</Para>
-</Note>
-While doing a project for a company in Moscow, Russia,
-I encountered the problem that postgresql had no
-support of national alphabets. After looking for possible workarounds
-I decided to develop support of locale myself.
-I'm not a C-programer but already had some experience with locale programming
-when I work with perl
-(debugging) and glimpse. After several days of digging through
- the <ProductName>Postgres</ProductName> source tree I made very minor corections to
-src/backend/utils/adt/varlena.c and src/backend/main/main.c and got what I needed!
-I did support only for
-<envar>LC_CTYPE</envar> and <envar>LC_COLLATE</envar>,
-but later <envar>LC_MONETARY</envar> was added by others. I got many
-messages from people about this patch so I decided to send it to developers
-and (to my surprise) it was
-incorporated into the <productname>Postgres</productname> distribution.
-
-<Para>
- People often complain that locale doesn't work for them.
-There are several common mistakes:
-
-<ItemizedList>
-<ListItem>
-<Para>
- Didn't properly configure postgresql before compilation.
- You must run configure with --enable-locale option to enable locale support.
- Didn't setup environment correctly when starting postmaster.
- You must define environment variables
-<envar>LC_CTYPE</envar> and <envar>LC_COLLATE</envar>
-before running postmaster
- because backend gets information about locale from environment.
-I use following shell script
- (runpostgres):
-
-<ProgramListing>
- #!/bin/sh
-
- export LC_CTYPE=koi8-r
- export LC_COLLATE=koi8-r
- postmaster -B 1024 -S -D/usr/local/pgsql/data/ -o '-Fe'
-</ProgramListing>
-
- and run it from rc.local as
-
-<ProgramListing>
- /bin/su - postgres -c "/home/postgres/runpostgres"
-</ProgramListing>
-
-</Para>
-</ListItem>
-<ListItem>
-<Para>
- Broken locale support in OS (for example, locale support in libc
-under Linux several times has changed
- and this caused a lot of problems). Latest perl has also support of
-locale and if locale is broken <command>perl -v</command> will
- complain something like:
-
-<programlisting>
- 8:17[mira]:~/WWW/postgres>setenv LC_CTYPE not_exist
- 8:18[mira]:~/WWW/postgres>perl -v
- perl: warning: Setting locale failed.
- perl: warning: Please check that your locale settings:
- LC_ALL = (unset),
- LC_CTYPE = "not_exist",
- LANG = (unset)
- are supported and installed on your system.
- perl: warning: Falling back to the standard locale ("C").
-</programlisting>
-
-</Para>
-</ListItem>
-<ListItem>
-<Para>
- Wrong location of locale files!
-
- Possible locations include:
-<filename>/usr/lib/locale</filename>
-(Linux, Solaris), <filename>/usr/share/locale</filename> (Linux),
-<filename>/usr/lib/nls/loc</filename> (DUX 4.0).
-
- Check <command>man locale</command> to find the correct location.
-Under Linux I did a symbolic link between <filename>/usr/lib/locale</filename> and
- <filename>/usr/share/locale</filename> to be sure that
-the next libc will not break my locale.
-</Para>
-</ListItem>
-</ItemizedList>
-
-<Sect2>
-<Title>What are the Benefits?</Title>
-
-<Para>
-You can use ~* and order by operators for strings contain characters
-from national alphabets. Non-english users
-definitely need that. If you won't use locale stuff just undefine
-the USE_LOCALE variable.
-
-<Sect2>
-<Title>What are the Drawbacks?</Title>
-
-<Para>
-There is one evident drawback of using locale - it's speed!
-So, use locale only if you really need it.
-
-
-<Sect1>
-<Title>Kerberos Authentication</Title>
-
-<Para>
-<productname>Kerberos</productname> is an industry-standard secure authentication
-system suitable for distributed computing over a public network.
-
-<sect2>
-<title>Availability</title>
-
-<para>
-The
-<productname>Kerberos</productname>
-authentication system is not distributed with <Productname>Postgres</Productname>. Versions of
-<productname>Kerberos</productname>
-are typically available as optional software from operating system
-vendors. In addition, a source code distribution may be obtained through
-<ulink url="ftp://athena-dist.mit.edu">MIT Project Athena</ulink>.
-
-<note>
-<para>
-You may wish to obtain the MIT version even if your
-vendor provides a version, since some vendor ports have been
-deliberately crippled or rendered non-interoperable with the MIT
-version.
-</note>
-Users located outside the United States of America and
-Canada are warned that distribution of the actual encryption code in
-<productname>Kerberos</productname>
-is restricted by U. S. Government export regulations.
-
-<para>
-Inquiries regarding your <productname>Kerberos</productname>
-should be directed to your vendor or
-<ulink url="info-kerberos@athena.mit.edu">MIT Project Athena</ulink>.
-Note that <acronym>FAQL</acronym>s
-(Frequently-Asked Questions Lists) are periodically posted to the
-<ulink url="mailto:kerberos@ATHENA.MIT.EDU"><productname>Kerberos</productname> mailing list</ulink>
-(send
-<ulink url="mailto:kerberos-request@ATHENA.MIT.EDU">mail to subscribe</ulink>),
-and
-<ulink url="news:comp.protocols.kerberos">USENET news group</ulink>.
-
-<sect2>
-<title>Installation</title>
-
-<para>
-Installation of
-<productname>Kerberos</productname>
-itself is covered in detail in the
-<citetitle>Kerberos Installation Notes</citetitle> .
-Make sure that the server key file (the <filename>srvtab</filename>
-or <filename>keytab</filename>)
-is somehow readable by the <productname>Postgres</productname> account.
-
-<para>
-<Productname>Postgres</Productname> and its clients can be compiled to use
-either Version 4 or Version 5 of the MIT
-<productname>Kerberos</productname>
-protocols by setting the
-<envar>KRBVERS</envar>
-variable in the file <filename>src/Makefile.global</filename> to the
-appropriate value. You can also change the location where
- <Productname>Postgres</Productname>
-expects to find the associated libraries, header files and its own
-server key file.
-
-<para>
-After compilation is complete, <Productname>Postgres</Productname>
- must be registered as a <productname>Kerberos</productname>
-service. See the
-<citetitle>Kerberos Operations Notes</citetitle>
-and related manual pages for more details on registering services.
-
-<sect2>
-<title>Operation</title>
-
-<para>
-After initial installation, <Productname>Postgres</Productname>
-should operate in all ways as a normal
-<productname>Kerberos</productname>
-service. For details on the use of authentication, see the
-<citetitle>PostgreSQL User's Guide</citetitle> reference sections
-for <application>postmaster</application>
-and <application>psql</application>.
-
-<para>
-In the
-<productname>Kerberos</productname>
-Version 5 hooks, the following assumptions are made about user
-and service naming:
-
-<itemizedlist>
-<listitem>
-<para>
-User principal names (anames) are assumed to
-contain the actual Unix/<Productname>Postgres</Productname> user name
- in the first component.
-
-<listitem>
-<para>
-The <Productname>Postgres</Productname> service is assumed to be have two components,
- the service name and a hostname, canonicalized as in Version 4 (i.e., with all domain
-suffixes removed).
-
-</itemizedlist>
-
-<para>
-<table tocentry="1">
-<title>Kerberos Parameter Examples</title>
-<titleabbrev>Kerberos</titleabbrev>
-
-<tgroup cols="2">
-<thead>
-<row>
-<entry>
-Parameter
-</entry>
-<entry>
-Example
-</entry>
-
-<tbody>
-<row>
-<entry>
-user
-</entry>
-<entry>
-frew@S2K.ORG
-</entry>
-
-<row>
-<entry>
-user
-</entry>
-<entry>
-aoki/HOST=miyu.S2K.Berkeley.EDU@S2K.ORG
-</entry>
-
-<row>
-<entry>
-host
-</entry>
-<entry>
-postgres_dbms/ucbvax@S2K.ORG
-</entry>
-</tbody>
-</tgroup>
-</table>
-
-<para>
-Support for Version 4 will disappear sometime after the production
-release of Version 5 by MIT.
+ </programlisting>
+ </para>
+ </sect1>
+ <Sect1>
+ <Title>Locale Support</Title>
+
+ <Para>
+ <Note>
+ <Para>
+ Written by Oleg Bartunov.
+ See <ULink url="http://www.sai.msu.su/~megera/postgres/">Oleg's web page</ULink>
+ for additional information on locale and Russian language support.
+
+ </Para>
+ </Note>
+ While doing a project for a company in Moscow, Russia,
+ I encountered the problem that postgresql had no
+ support of national alphabets. After looking for possible workarounds
+ I decided to develop support of locale myself.
+ I'm not a C-programer but already had some experience with locale programming
+ when I work with perl
+ (debugging) and glimpse. After several days of digging through
+ the <ProductName>Postgres</ProductName> source tree I made very minor corections to
+ src/backend/utils/adt/varlena.c and src/backend/main/main.c and got what I needed!
+ I did support only for
+ <envar>LC_CTYPE</envar> and <envar>LC_COLLATE</envar>,
+ but later <envar>LC_MONETARY</envar> was added by others. I got many
+ messages from people about this patch so I decided to send it to developers
+ and (to my surprise) it was
+ incorporated into the <productname>Postgres</productname> distribution.
+ </para>
+ <Para>
+ People often complain that locale doesn't work for them.
+ There are several common mistakes:
+
+ <ItemizedList>
+ <ListItem>
+ <Para>
+ Didn't properly configure postgresql before compilation.
+ You must run configure with --enable-locale option to enable locale support.
+ Didn't setup environment correctly when starting postmaster.
+ You must define environment variables
+ <envar>LC_CTYPE</envar> and <envar>LC_COLLATE</envar>
+ before running postmaster
+ because backend gets information about locale from environment.
+ I use following shell script
+ (runpostgres):
+
+ <ProgramListing>
+ #!/bin/sh
+
+ export LC_CTYPE=koi8-r
+ export LC_COLLATE=koi8-r
+ postmaster -B 1024 -S -D/usr/local/pgsql/data/ -o '-Fe'
+ </ProgramListing>
+
+ and run it from rc.local as
+
+ <ProgramListing>
+ /bin/su - postgres -c "/home/postgres/runpostgres"
+ </ProgramListing>
+
+ </Para>
+ </ListItem>
+ <ListItem>
+ <Para>
+ Broken locale support in OS (for example, locale support in libc
+ under Linux several times has changed
+ and this caused a lot of problems). Latest perl has also support of
+ locale and if locale is broken <command>perl -v</command> will
+ complain something like:
+
+ <programlisting>
+ 8:17[mira]:~/WWW/postgres>setenv LC_CTYPE not_exist
+ 8:18[mira]:~/WWW/postgres>perl -v
+ perl: warning: Setting locale failed.
+ perl: warning: Please check that your locale settings:
+ LC_ALL = (unset),
+ LC_CTYPE = "not_exist",
+ LANG = (unset)
+ are supported and installed on your system.
+ perl: warning: Falling back to the standard locale ("C").
+ </programlisting>
+
+ </Para>
+ </ListItem>
+ <ListItem>
+ <Para>
+ Wrong location of locale files!
+
+ Possible locations include:
+ <filename>/usr/lib/locale</filename>
+ (Linux, Solaris), <filename>/usr/share/locale</filename> (Linux),
+ <filename>/usr/lib/nls/loc</filename> (DUX 4.0).
+
+ Check <command>man locale</command> to find the correct location.
+ Under Linux I did a symbolic link between <filename>/usr/lib/locale</filename> and
+ <filename>/usr/share/locale</filename> to be sure that
+ the next libc will not break my locale.
+ </Para>
+ </ListItem>
+ </ItemizedList>
+ </para>
+
+ <Sect2>
+ <Title>What are the Benefits?</Title>
+
+ <Para>
+ You can use ~* and order by operators for strings contain characters
+ from national alphabets. Non-english users
+ definitely need that. If you won't use locale stuff just undefine
+ the USE_LOCALE variable.
+ </para>
+ </sect2>
+
+ <Sect2>
+ <Title>What are the Drawbacks?</Title>
+
+ <Para>
+ There is one evident drawback of using locale - it's speed!
+ So, use locale only if you really need it.
+ </para>
+ </sect2>
+ </sect1>
+
+ <Sect1>
+ <Title>Kerberos Authentication</Title>
+
+ <Para>
+ <productname>Kerberos</productname> is an industry-standard secure authentication
+ system suitable for distributed computing over a public network.
+ </para>
+
+ <sect2>
+ <title>Availability</title>
+
+ <para>
+ The
+ <productname>Kerberos</productname>
+ authentication system is not distributed with <Productname>Postgres</Productname>. Versions of
+ <productname>Kerberos</productname>
+ are typically available as optional software from operating system
+ vendors. In addition, a source code distribution may be obtained through
+ <ulink url="ftp://athena-dist.mit.edu">MIT Project Athena</ulink>.
+ </para>
+ <note>
+ <para>
+ You may wish to obtain the MIT version even if your
+ vendor provides a version, since some vendor ports have been
+ deliberately crippled or rendered non-interoperable with the MIT
+ version.
+ </para>
+ </note>
+ <para>
+ Users located outside the United States of America and
+ Canada are warned that distribution of the actual encryption code in
+ <productname>Kerberos</productname>
+ is restricted by U. S. Government export regulations.
+ </para>
+ <para>
+ Inquiries regarding your <productname>Kerberos</productname>
+ should be directed to your vendor or
+ <ulink url="info-kerberos@athena.mit.edu">MIT Project Athena</ulink>.
+ Note that <acronym>FAQL</acronym>s
+ (Frequently-Asked Questions Lists) are periodically posted to the
+ <ulink url="mailto:kerberos@ATHENA.MIT.EDU"><productname>Kerberos</productname> mailing list</ulink>
+ (send
+ <ulink url="mailto:kerberos-request@ATHENA.MIT.EDU">mail to subscribe</ulink>),
+ and
+ <ulink url="news:comp.protocols.kerberos">USENET news group</ulink>.
+ </para>
+ </sect2>
+
+ <sect2>
+ <title>Installation</title>
+
+ <para>
+ Installation of
+ <productname>Kerberos</productname>
+ itself is covered in detail in the
+ <citetitle>Kerberos Installation Notes</citetitle> .
+ Make sure that the server key file (the <filename>srvtab</filename>
+ or <filename>keytab</filename>)
+ is somehow readable by the <productname>Postgres</productname> account.
+ </para>
+ <para>
+ <Productname>Postgres</Productname> and its clients can be compiled to use
+ either Version 4 or Version 5 of the MIT
+ <productname>Kerberos</productname>
+ protocols by setting the
+ <envar>KRBVERS</envar>
+ variable in the file <filename>src/Makefile.global</filename> to the
+ appropriate value. You can also change the location where
+ <Productname>Postgres</Productname>
+ expects to find the associated libraries, header files and its own
+ server key file.
+ </para>
+ <para>
+ After compilation is complete, <Productname>Postgres</Productname>
+ must be registered as a <productname>Kerberos</productname>
+ service. See the
+ <citetitle>Kerberos Operations Notes</citetitle>
+ and related manual pages for more details on registering services.
+ </para>
+ </sect2>
+
+ <sect2>
+ <title>Operation</title>
+
+ <para>
+ After initial installation, <Productname>Postgres</Productname>
+ should operate in all ways as a normal
+ <productname>Kerberos</productname>
+ service. For details on the use of authentication, see the
+ <citetitle>PostgreSQL User's Guide</citetitle> reference sections
+ for <application>postmaster</application>
+ and <application>psql</application>.
+ </para>
+ <para>
+ In the
+ <productname>Kerberos</productname>
+ Version 5 hooks, the following assumptions are made about user
+ and service naming:
+
+ <itemizedlist>
+ <listitem>
+ <para>
+ User principal names (anames) are assumed to
+ contain the actual Unix/<Productname>Postgres</Productname> user name
+ in the first component.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ The <Productname>Postgres</Productname> service is assumed to be have two components,
+ the service name and a hostname, canonicalized as in Version 4 (i.e., with all domain
+ suffixes removed).
+ </para>
+ </listitem>
+
+ </itemizedlist>
+ </para>
+ <para>
+ <table tocentry="1">
+ <title>Kerberos Parameter Examples</title>
+ <titleabbrev>Kerberos</titleabbrev>
+
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry>
+ Parameter
+ </entry>
+ <entry>
+ Example
+ </entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>
+ user
+ </entry>
+ <entry>
+ frew@S2K.ORG
+ </entry>
+ </row>
+ <row>
+ <entry>
+ user
+ </entry>
+ <entry>
+ aoki/HOST=miyu.S2K.Berkeley.EDU@S2K.ORG
+ </entry>
+ </row>
+ <row>
+ <entry>
+ host
+ </entry>
+ <entry>
+ postgres_dbms/ucbvax@S2K.ORG
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ </para>
+ <para>
+ Support for Version 4 will disappear sometime after the production
+ release of Version 5 by MIT.
+ </para>
+ </sect2>
+ </sect1>
+</chapter>
Views and rules are now functional thanks to extensive new code in the
rewrite rules system from Jan Wieck. He also wrote a chapter on it
for the <citetitle>Programmer's Guide</citetitle>.
-
+</para>
+</listitem>
<listitem>
<para>
Jan also contributed a second procedural language, PL/pgSQL, to go with the
original PL/pgTCL procedural language he contributed last release.
+</para>
+</listitem>
<listitem>
<para>
We have optional multiple-byte character set support from Tatsuo Iishi
to complement our existing locale support.
+</para>
+</listitem>
<listitem>
<para>
Client/server communications has been cleaned up, with better support for
asynchronous messages and interrupts thanks to Tom Lane.
+</para>
+</listitem>
<listitem>
<para>
the type extensibility features of <productname>Postgres</productname>.
There is a new chapter in the <citetitle>User's Guide</citetitle>
which covers this topic.
+</para>
+</listitem>
<listitem>
<para>
in the <citetitle>User's Guide</citetitle> for details.
A fourth type, <type>serial</type>, is now supported by the parser as an
amalgam of the <type>int4</type> type, a sequence, and a unique index.
+</para>
+</listitem>
<listitem>
<para>
Several more <acronym>SQL92</acronym>-compatible syntax features have been
added, including <command>INSERT DEFAULT VALUES</command>
+</para>
+</listitem>
<listitem>
<para>
The automatic configuration and installation system has received some
attention, and should be more robust for more platforms than it has ever
been.
+</para>
+</listitem>
</itemizedlist>
-
+</para>
<sect2>
<title>Migration to v6.4</title>
or <application>pg_dumpall</application>
is required for those wishing to migrate data from any
previous release of <productname>Postgres</productname>.
-
-
+</para>
+</sect2>
<sect2>
<title>Detailed Change List</title>
new Makefile.shlib for shared library configuration(Tom)
</programlisting>
</Para>
-
+</sect2>
</Sect1>
postprocessed a bit before it can be loaded into <ProductName>Postgres</ProductName>. We
hope that the large increase in speed and reliability will
make up for the slight decrease in convenience.
-<Para>
+</para>
</Tip>
- You should expect to read (and reread, and re-reread) the
+</para>
+<para>
+ You should expect to read (and reread, and re-reread) the
manual pages for the C compiler, cc(1), and the link
editor, ld(1), if you have specific questions. In
addition, the regression test suites in the directory
</Para>
</ListItem>
</ItemizedList>
+</para>
<Sect1>
<Title><Acronym>ULTRIX</Acronym></Title>
<!--
-$Header: /cvsroot/pgsql/doc/src/sgml/docguide.sgml,v 1.12 1998/12/18 16:17:29 thomas Exp $
+$Header: /cvsroot/pgsql/doc/src/sgml/docguide.sgml,v 1.13 1998/12/29 02:24:14 thomas Exp $
Documentation Guide
Thomas Lockhart
$Log: docguide.sgml,v $
+Revision 1.13 1998/12/29 02:24:14 thomas
+Clean up to ensure tag completion as required by the newest versions
+ of Norm's Modular Style Sheets and jade/docbook.
+From Vince Vielhaber <vev@michvhf.com>.
+
Revision 1.12 1998/12/18 16:17:29 thomas
Include more details on editing with Emacs.
Remove mention of the old "migration" flat files.
It should be able to answer
common questions and to allow a user to find those answers on his own
without resorting to mailing list support.
+</para>
<sect1>
<title>Documentation Roadmap</title>
<acronym>man pages</acronym>, for quick reference.
</para></listitem>
</itemizedlist>
+</para>
<para>
<table tocentry="1">
</tbody>
</tgroup>
</table>
+</para>
<para>
There are man pages available for installation, as well as a large number
of plain-text README-type files throughout the <productname>Postgres</productname>
source tree.
+</para>
+</sect1>
<sect1>
<title>The Documentation Project</title>
<productname>Postgres</productname> installation. We discuss here
working with the documentation sources and generating documentation
packages.
+</para>
<para>
The purpose of <productname>DocBook</productname> <acronym>SGML</acronym>
final form (e.g. using Norm Walsh's
<productname>Modular Style Sheets</productname>).</para>
+
<para>
See <ulink url="http://nis-www.lanl.gov/~rosalia/mydocs/docbook-intro.html">
Introduction to DocBook</ulink> for a nice "quickstart" summary of
<ulink url="http://www.ora.com/homepages/dtdparse/docbook/3.0/"> DocBook Elements</ulink>
provides a powerful cross-reference for features of
<productname>DocBook</productname>.
+</para>
<para>
This documentation set is constructed using several tools, including
<ulink url="http://www.jclark.com/jade/"> <productname>jade</productname></ulink>
and Norm Walsh's
<ulink url="http://www.berkshire.net/~norm/docbook/dsssl">Modular DocBook Stylesheets</ulink>.
+</para>
<para>
Currently, hardcopy is produced by importing <firstterm>Rich Text
<productname>ApplixWare</productname> for minor formatting fixups then
exporting as a Postscript file.</para>
+
<para>
<ulink url="http://sunsite.unc.edu/pub/packages/TeX/systems/unix/">
<productname>TeX</productname></ulink> is a supported format for
support in the <productname>TeX</productname>
stylesheets.</para>
+</sect1>
+
<sect1>
<title>Documentation Sources</title>
<ulink url="http://www.ora.com/davenport/"> <productname>DocBook</productname></ulink>
<firstterm>Document Type Definition</firstterm> (<acronym>DTD</acronym>).
Much of the existing documentation has been or will be converted to <acronym>SGML</acronym>.
+</para>
<para>
The purpose of <acronym>SGML</acronym> is to allow an author to
<productname>DocBook</productname> <acronym>DTD</acronym>), and to
have the document style define how that content is rendered into a
final form (e.g. using Norm Walsh's stylesheets).
+</para>
<para>
Documentation has accumulated from several sources. As we integrate
distribution. However, this will not happen immediately, and will not
happen to all documents at the same time. To ease the transition, and
to help guide developers and writers, we have defined a transition roadmap.
+</para>
<para>
Here is the documentation plan for v6.5:
<listitem>
<para>
Start compiling index information for the User's and Administrator's Guides.
+</para>
+</listitem>
<listitem>
<para>
Write more sections for the User's Guide covering areas outside the reference pages.
This would include introductory information and suggestions for approaches to typical
design problems.
+</para>
+</listitem>
<listitem>
<para>
Merge information in the existing man pages into the reference pages and User's Guide.
Condense the man pages down to reminder information, with references into the
primary doc set.
+</para>
+</listitem>
<listitem>
<para>
Convert the new sgml reference pages to new man pages, replacing the existing man pages.
+</para>
+</listitem>
<listitem>
<para>
Convert all source graphics to CGM format files for portability. Currently we mostly have
Applix Graphics sources from which we can generate .gif output. One graphic is only
available in .gif and .ps, and should be redrawn or removed.
+</para>
+</listitem>
</itemizedlist>
+</para>
<sect2>
<title>Document Structure</title>
</listitem>
</varlistentry>
</variablelist>
+</para>
<!--
Disable for the hardcopy production release.
Too much tabular info and not very helpful in hardcopy.
- thomas 1998-10-27
-->
+</sect2>
<sect2>
<title>Documentation Files</title>
</tbody>
</tgroup>
</table>
+</para>
+</sect2>
<sect2>
<title>Document Conversion</title>
</tbody>
</tgroup>
</table>
-
+</para>
+</sect2>
<sect2>
<title>Styles and Conventions</title>
</table>
</para>
-->
+</sect2>
<sect2>
<title>SGML Authoring Tools</title>
The current <acronym>Postgres</acronym> documentation set was written using
a plain text editor (or emacs/psgml; see below) with the content marked up using
<acronym>SGML</acronym> DocBook tags.
+</para>
<para>
<acronym>SGML</acronym> and <productname>DocBook</productname> do not suffer
from an oversupply of open-source authoring tools. The most common toolset is
the emacs/xemacs editing package with the psgml feature extension.
On some systems (e.g. RedHat Linux) these tools are provided in a typical full installation.
+</para>
<sect3>
<title>emacs/psgml</title>
an <acronym>SGML</acronym> <firstterm>major mode</firstterm>. When properly configured,
this will allow you to use <application>emacs</application> to insert tags and
check markup consistancy.
+</para>
<para>
Put the following in your <filename>~/.emacs</filename> environment file:
sgml-local-catalogs:"/usr/lib/sgml/catalog"
sgml-local-ecat-files:nil
End:
---<sgmltag>
+--</sgmltag>
</programlisting>
+</para>
<para>
The <productname>Postgres</productname> distribution includes a
parsed DTD definitions file <filename>reference.ced</filename>.
You may find that
+</para>
<para>
When using <application>emacs</application>/psgml, a comfortable way of working with
This means that anything and everything that reads <acronym>SGML</acronym> will get it
right, and I can verify the document with "nsgmls -s docguide.sgml".
+</para>
</sect3>
</sect2>
<filename>/usr/share/lib/sgml/</filename>,
or
<filename>/usr/local/lib/sgml/</filename>.
+</para>
<para>
<acronym>HTML</acronym> documentation packages can be generated from the <acronym>SGML</acronym> source by
importing into <productname>ApplixWare-4.4.1</productname>.
After a little cleanup (see the following
section) the output is "printed" to a postscript file.
+</para>
<para>
Some figures were redrawn to avoid having bitmap
these tools. <productname>FreeBSD</productname> seems to have them
available. Please report package status to the docs mailing list and
we will include that information here.
+</para>
<sect2>
<title><acronym>RPM</acronym> installation on
installing the software you'll need to edit DocBook source with Emacs
and process it with Norman Walsh's DSSSL style sheets to create <acronym>HTML</acronym>
and <acronym>RTF</acronym>.
+</para>
<para>
These instructions do not cover new <application>jade</application>/DocBook
<ulink url="http://www.sgmltools.org/"><productname>sgml-tools</productname></ulink>
package. The authors have not tried this package since it adopted DocBook,
but it is almost certainly a good candidate for use.
+</para>
<sect3><title>Prerequisites</title>
<listitem><para><ulink url="http://www.sil.org/sgml/publicSW.html">
Robin Cover's database of <acronym>SGML</acronym> software</ulink></para></listitem>
</itemizedlist>
+</para>
</sect3>
<sect3>
<title>Installing Jade</title>
-<para>
<procedure>
<title>Installing Jade</title>
<para>
Read the installation instructions at the above listed
URL.
+</para>
+</step>
<step performance="required">
<para>
unzip -aU jade1_1.zip
</programlisting>
</para>
+</step>
<step performance="required">
<para><productname>Jade</productname> is not built using
<command>ranlib</command> command, leave them as they are in the
<filename>Makefile</filename>.
</para>
+</step>
<step performance="required">
<para>Type <command>make</command> to build Jade and the various
<productname>SP</productname> tools.</para>
+</step>
<step performance="required">
<para>Once the software is built, <command>make install</command> will
do the obvious.</para>
-
+</step>
</procedure>
+</sect3>
<sect3>
<title>Installing the <productname>DocBook</productname> <acronym>DTD</acronym> Kit</title>
-<para>
<procedure>
<title>Installing the <productname>DocBook</productname> <acronym>DTD</acronym> Kit</title>
<programlisting>
CATALOG /usr/local/share/sgml/CATALOG
</programlisting>
+</para>
+</step>
<step performance="required">
<para>
PUBLIC "-//Davenport//ELEMENTS DocBook Document Hierarchy V3.0//EN" dbhier.mod
PUBLIC "-//Davenport//ENTITIES DocBook Additional General Entities V3.0//EN" dbgenent.mod
</programlisting>
+</para>
+</step>
<step performance="required">
<para>
named <filename>ISO</filename>. Again, proper catalog entries should
accompany the entity kit you fetch.
</para>
+</step>
</procedure>
+</sect3>
<sect3>
<title>Installing Norman Walsh's <acronym>DSSSL</acronym> Style Sheets</title>
-<para>
<procedure>
<title>Installing Norman Walsh's <acronym>DSSSL</acronym> Style Sheets</title>
<step performance="required">
<para>Read the installation instructions at the above listed
URL.</para>
+</step>
<step performance="required">
<para>To install Norman's style sheets, simply unzip the distribution
unzip -aU db119.zip
</programlisting>
</para>
+</step>
<step performance="required">
<para>One way to test the installation is to build the
<acronym>HTML</acronym> and <acronym>RTF</acronym> forms of the
<citetitle><productname>PostgreSQL</productname> User's Guide</citetitle>.
+</para>
<substeps>
<programlisting>
jade -t sgml -d /usr/local/share/docbook/html/docbook.dsl -D ../graphics postgres.sgml
</programlisting>
+</para>
<para>
<filename>book1.htm</filename> is the top level node of the output..
+</para>
+</step>
<step performance="required">
<para>
<programlisting>
jade -t rtf -d /usr/local/share/docbook/print/docbook.dsl -D ../graphics postgres.sgml
</programlisting>
+</para>
+</step>
</substeps>
+</step>
</procedure>
+</sect3>
<sect3>
<title>Installing <productname>PSGML</productname></title>
-<para>
<procedure>
<title>Installing <productname>PSGML</productname></title>
<step performance="required">
<para>Read the installation instructions at the above listed
URL.</para>
+</step>
<step performance="required">
<para>Unpack the distribution file, run configure, make and make
install to put the byte-compiled files and info library in place.
+</para>
+</step>
<step performance="required" id="psgml-setup">
<para>
(cons "/usr/local/share/emacs/site-lisp/psgml" load-path))
(autoload 'sgml-mode "psgml" "Major mode to edit SGML files." t)
</programlisting>
+</para>
+</step>
<step performance="optional">
<para>
(cons '("\\.s?html?\\'" . sgml-mode) auto-mode-alist))
</programlisting>
</para>
-
+</step>
<step performance="optional">
<para>There is one important thing to note with
<filename>/usr/local/lib/sgml</filename>. If, as in the examples in
this chapter, you use <filename>/usr/local/share/sgml</filename>, you
have to compensate for this.
+</para>
<substeps>
<step performance="optional">
<para>
You can set the
<filename>SGML_CATALOG_FILES</filename> environment variable.
+</para>
+</step>
<step performance="optional">
<para>
You can
customize your <productname>PSGML</productname> installation (its
manual tells you how).
+</para>
+</step>
<step performance="optional">
<para>
<filename>psgml.el</filename> before compiling and installing
<productname>PSGML</productname>, changing the hard-coded paths to
match your own default.</para>
+</step>
</substeps>
+</step>
</procedure>
+</sect3>
<sect3><title>Installing <productname>JadeTeX</productname></title>
and <productname>DocBook</productname>. It may be the preferred toolset
for working with <acronym>SGML</acronym> but we have not had a chance to
evaluate the new package.
+</para>
<!--
</para></sect2></sect1>
-->
-
+</sect1>
</appendix>
<!-- Keep this comment at the end of the file
to copy and use the rest of the <ProductName>PostgreSQL</ProductName>.
</Para>
</Note>
-
+</para>
<Sect1>
<Title>Why Embedded <Acronym>SQL</Acronym>?</Title>
from variables in your <Acronym>C</Acronym> program.
Many <Acronym>RDBMS</Acronym> packages
support this embedded language.
+</Para>
<Para> There is an ANSI-standard describing how the embedded language should
work. <Application>ecpg</Application> was designed to meet this standard
other <Acronym>RDBMS</Acronym> packages to
<ProductName>Postgres</ProductName> and thus promoting the spirit of free
software.
-
+</Para>
+</sect1>
<Sect1>
<Title>The Concept</Title>
<Acronym>SQL</Acronym> statements you need to
put them in a special declare section.
You use a special syntax for the <Acronym>SQL</Acronym> queries.
+</Para>
<Para>
Before compiling you run the file through
as input to the <Acronym>SQL</Acronym> statements and variables that will
contain the
result are passed.
+</Para>
<Para>
Then you compile and at link time you link with a special library that
the <Acronym>SQL</Acronym> query using the ordinary interface
(<FileName>libpq</FileName>) and puts back
the result in the arguments dedicated for output.
+</Para>
<Para>
Then you run your program and when the control arrives to
statement the <Acronym>SQL</Acronym> statement is performed against
the database and you
can continue with the result.
-
+</Para>
+</sect1>
<Sect1>
<Title>How To Use <Application>egpc</Application></Title>
<Para>
This section describes how to use the <Application>egpc</Application> tool.
+</Para>
<Sect2>
-<Title>Preprocessor
+<Title>Preprocessor</title>
<Para>
The preprocessor is called <Application>ecpg</Application>.
After installation it resides in
the <ProductName>Postgres</ProductName> <FileName>bin/</FileName> directory.
-
+</Para>
+</sect2>
<Sect2>
-<Title>Library
+<Title>Library</title>
<Para>
The <Application>ecpg</Application> library is called
uses the <FileName>libpq</FileName> library for communication to the
<ProductName>Postgres</ProductName> server so you will
have to link your program with <Parameter>-lecpg -lpq</Parameter>.
+</Para>
<Para>
The library has some methods that are "hidden" but that could prove very
turns on debug logging if called with the first argument non-zero.
Debug logging is done on <replaceable class="parameter">stream</replaceable>.
Most <Acronym>SQL</Acronym> statement logs its arguments and result.
+</Para>
<Para>
The most important one (<Function>ECPGdo</Function>)
</Para>
</ListItem>
</itemizedlist>
+</Para>
+</sect2>
<Sect2>
-<Title>Error handling
+<Title>Error handling</title>
<Para>
To be able to detect errors from the <ProductName>Postgres</ProductName>
} sqlerrm;
} sqlca;
</ProgramListing>
+</Para>
<Para>
If an error occured in the last <Acronym>SQL</Acronym> statement
some kind of serious error, like the database definition does not match
the query given. If it is bigger than 0 then this is a normal error like
the table did not contain the requested row.
+</Para>
<Para>
sqlca.sqlerrm.sqlerrmc will contain a string that describes the error.
The string ends with <Quote>line 23.</Quote> where the line is the line number
in the source file (actually the file generated by the preprocessor but
I hope I can fix this to be the line number in the input file.)
+</Para>
<Para>
List of errors that can occur:
</ListItem>
</VarListEntry>
</VariableList>
-
+</Para>
</Sect2>
+</sect1>
<Sect1>
<Title>Limitations</Title>
client process per application process both the database part and the
application part is run in the same process. In later versions of oracle
this is no longer supported.
+</Para>
<Para>
This would require a total redesign of the <ProductName>Postgres</ProductName> access model and
</ListItem>
</VarListEntry>
</VariableList>
+</Para>
+</sect1>
<Sect1>
<Title>Porting From Other <Acronym>RDBMS</Acronym> Packages</Title>
To be written by someone who knows the different
<Acronym>RDBMS</Acronym> packages and who
actually does port something...
+</Para>
+</sect1>
<Sect1>
<Title>Installation</Title>
together with <ProductName>Postgres</ProductName>. So you
should get your precompiler, libraries and header files compiled and
installed by default as a part of your installation.
+</Para>
+</sect1>
<Sect1>
<Title>For the Developer</Title>
So, read this before looking at the internals of the
<Application>ecpg</Application>. If
you are not interested in how it really works, skip this section.
+</Para>
<Sect2>
<Title>ToDo List</Title>
<ListItem>
<Para>
Records or structures have to be defined in the declare section.
-
+</Para>
</ListItem>
</VarListEntry>
<Term> exec sql type</Term>
<ListItem>
<Para>
+</Para>
+</listitem>
</VarListEntry>
<VarListEntry>
<Term> exec sql prepare</Term>
<ListItem>
<Para>
+</Para>
+</listitem>
</VarListEntry>
<VarListEntry>
<Term> exec sql allocate</Term>
<ListItem>
<Para>
+</Para>
+</listitem>
</VarListEntry>
<VarListEntry>
<Term> exec sql free</Term>
<ListItem>
<Para>
+</Para>
+</listitem>
</VarListEntry>
<VarListEntry>
<Term> exec sql whenever sqlwarning</Term>
<ListItem>
<Para>
+</Para>
+</listitem>
</VarListEntry>
<VarListEntry>
<Term> SQLSTATE</Term>
<ListItem>
<Para>
+</Para>
+</listitem>
</VarListEntry>
</VariableList>
</Para>
other configuration parameters. If you have these scripts for an old
database you would like to just apply them to get a
<ProductName>Postgres</ProductName> database that works in the same way.
+</Para>
<Para>
To set up a database you need a few scripts with table definitions and
</ListItem>
</VarListEntry>
</VariableList>
+</Para>
+</sect2>
<Sect2>
<Title>The Preprocessor</Title>
<Para>
First four lines are written to the output. Two comments and two include
lines necessary for the interface to the library.
+</Para>
<Para>
Then the preprocessor works in one pass only reading the input file and
writing to the output as it goes along. Normally it just echoes
everything to the output without looking at it further.
+</Para>
<Para>
When it comes to an <Command>EXEC SQL</Command> statements it interviens and
In the section only variable declarations are allowed. Every variable
declare within this section is also entered in a list of variables
indexed on their name together with the corresponding type.
+</Para>
<Para>
The declaration is echoed to the file to make the variable a normal
C-variable also.
+</Para>
<Para>
The special types VARCHAR and VARCHAR2 are converted into a named struct
<Command>exec sql</Command> and ends with <Command>;</Command>.
Everything inbetween is treated
as an <Acronym>SQL</Acronym> statement and parsed for variable substitution.
+</Para>
<Para>
Variable substitution occur when a symbol starts with a colon
a variable for input or
output the pointers to the variables are written to the output to allow
for access by the function.
+</Para>
<Para>
For every variable that is part of the <Acronym>SQL</Acronym> request
<Member>Number of elements in the array (for array fetches)</Member>
<Member>The offset to the next element in the array (for array fetches)</Member>
</SimpleList>
+</Para>
<Para>
Since the array fetches are not implemented yet the two last arguments
</ListItem>
</VarListEntry>
</VariableList>
-
+</Para>
</Sect2>
<Sect2>
</ProgramListing>
(the indentation in this manual is added for readability and not
something that the preprocessor can do.)
+</Para>
+</sect2>
<Sect2>
<Title>The Library</Title>
into machines with limits on the amount of variables that can be
accepted by a varchar function. This could easily add up to 50 or so
arguments.
+</Para>
<Para>
The arguments are:
</ListItem>
</VarListEntry>
</VariableList>
+</Para>
<Para>
All the <Acronym>SQL</Acronym> statements are performed in one transaction
unless you issue
a commit transaction. This works so that the first transaction or the
first after a commit or rollback always begins a transaction.
+</Para>
<Para>
To be completed: entries describing the other entries.
-
+</Para>
+</sect2>
+</sect1>
</Chapter>
and will be described in depth (in the section
on interfacing types and operators to indices)
after we have discussed basic extensions.
+</para>
</ListItem>
</ItemizedList>
</Para>
+</sect1>
</Chapter>
</TGROUP>
</TABLE>
</Para>
+</sect1>
<sect1>
<title>String Functions</title>
<para>
Most functions explicitly defined for text will work for char() and varchar() arguments.
</para>
+</sect1>
<sect1>
<title>Date/Time Functions</title>
to return day of week and `epoch' to return seconds since 1970 (for <Type>datetime</Type>)
or 'epoch' to return total elapsed seconds (for <Type>timespan</Type>).
</Para>
+</sect1>
<sect1>
<title>Geometric Functions</title>
</TGROUP>
</TABLE>
</Para>
+</sect1>
<sect1>
<title id="cidr-funcs">IP V4 Functions</title>
<!--
-$Header: /cvsroot/pgsql/doc/src/sgml/geqo.sgml,v 1.4 1998/08/15 06:55:05 thomas Exp $
+$Header: /cvsroot/pgsql/doc/src/sgml/geqo.sgml,v 1.5 1998/12/29 02:24:15 thomas Exp $
Genetic Optimizer
$Log: geqo.sgml,v $
+Revision 1.5 1998/12/29 02:24:15 thomas
+Clean up to ensure tag completion as required by the newest versions
+ of Norm's Modular Style Sheets and jade/docbook.
+From Vince Vielhaber <vev@michvhf.com>.
+
Revision 1.4 1998/08/15 06:55:05 thomas
Change Id field in chapter tag to change html output file name.
for the Institute of Automatic Control at the University of Mining and Technology in Freiberg, Germany.
</Para>
</Note>
+</para>
<Sect1>
<Title>Query Handling as a Complex Optimization Problem</Title>
(e.g., nested loop, index scan, merge join in <ProductName>Postgres</ProductName>) to
process individual <Command>join</Command>s and a diversity of <FirstTerm>indices</FirstTerm> (e.g., r-tree,
b-tree, hash in <ProductName>Postgres</ProductName>) as access paths for relations.
+</para>
<Para>
The current <ProductName>Postgres</ProductName> optimizer implementation performs a <FirstTerm>near-
optimization technique is inadequate to support database application
domains that involve the need for extensive queries, such as artificial
intelligence.
+</para>
<Para>
The Institute of Automatic Control at the University of Mining and
support knowledge based system for the maintenance of an electrical
power grid. The DBMS needed to handle large <Command>join</Command> queries for the
inference machine of the knowledge based system.
+</para>
<Para>
Performance difficulties within exploring the space of possible query
plans arose the demand for a new optimization technique being developed.
+</para>
<Para>
In the following we propose the implementation of a <FirstTerm>Genetic Algorithm</FirstTerm>
as an option for the database query optimization problem.
-
+</para>
+</sect1>
<Sect1>
<Title>Genetic Algorithms (<Acronym>GA</Acronym>)</Title>
optimization problem is considered as a <FirstTerm>population</FirstTerm> of <FirstTerm>individuals</FirstTerm>.
The degree of adaption of an individual to its environment is specified
by its <FirstTerm>fitness</FirstTerm>.
+</para>
<Para>
The coordinates of an individual in the search space are represented
subsection of a chromosome which encodes the value of a single parameter
being optimized. Typical encodings for a gene could be <FirstTerm>binary</FirstTerm> or
<FirstTerm>integer</FirstTerm>.
+</para>
<Para>
Through simulation of the evolutionary operations <FirstTerm>recombination</FirstTerm>,
<FirstTerm>mutation</FirstTerm>, and <FirstTerm>selection</FirstTerm> new generations of search points are found
that show a higher average fitness than their ancestors.
+</para>
<Para>
According to the "comp.ai.genetic" <Acronym>FAQ</Acronym> it cannot be stressed too
| | t := t + 1 |
+===+=====================================+
</ProgramListing>
+</para>
+</sect1>
<Sect1>
<Title>Genetic Query Optimization (<Acronym>GEQO</Acronym>) in Postgres</Title>
is encoded by the integer string '4-1-3-2',
which means, first join relation '4' and '1', then '3', and
then '2', where 1, 2, 3, 4 are relids in <ProductName>Postgres</ProductName>.
+</para>
<Para>
Parts of the <Acronym>GEQO</Acronym> module are adapted from D. Whitley's Genitor
algorithm.
+</para>
<Para>
Specific characteristics of the <Acronym>GEQO</Acronym> implementation in <ProductName>Postgres</ProductName>
</Para>
</ListItem>
</ItemizedList>
+</para>
<Para>
The <Acronym>GEQO</Acronym> module gives the following benefits to the <ProductName>Postgres</ProductName> DBMS
</Para>
</ListItem>
</ItemizedList>
+</para>
</Sect1>
<Function>OrderedElemPop</Function>, file <FileName>backend/utils/mmgr/oset.c</FileName>.
The same problems arise with long queries when using the normal
<ProductName>Postgres</ProductName> query optimization algorithm.
+</para>
+</sect3>
<Sect3>
<Title>Improve genetic algorithm parameter settings</Title>
</Para>
</ListItem>
</ItemizedList>
+</para>
+</sect3>
<Sect3>
<Title>Find better solution for integer overflow</Title>
value of <StructField>rel->size</StructField> to its logarithm.
Modifications of <StructName>Rel</StructName> in <FileName>backend/nodes/relation.h</FileName> will
surely have severe impacts on the whole <ProductName>Postgres</ProductName> implementation.
+</para>
+</sect3>
<Sect3>
<Title>Find solution for exhausted memory</Title>
Of course the <StructName>rel</StructName> data structure of the <Command>join</Command> keeps growing and
growing the more relations are packed into it.
Suggestions are welcome :-(
-
+</para>
+</sect3>
+</sect2>
<Sect2>
<Title>Further Improvements</Title>
<Para>
Enable bushy query tree processing within <ProductName>Postgres</ProductName>;
that may improve the quality of query plans.
+</para>
<BIBLIOGRAPHY Id="geqo-biblio">
<TITLE>
</BIBLIOENTRY>
</BIBLIOGRAPHY>
+</sect2>
+</sect1>
</Chapter>
And there is more interesting reading at the Berkely database site at
<ULink url="http://epoch.cs.berkeley.edu:8000/">http://epoch.cs.berkeley.edu:8000/</ULink>.
-
+</para>
<Para>
<Note>
- thomas 1998-03-01
</Para>
</Note>
-
+</para>
<Para>
Well, I can't say I quite understand what's going on, but at least
I (almost) succeeded in porting GiST examples to linux. The GiST access
method is already in the postgres tree (<FileName>src/backend/access/gist</FileName>).
-
+</para>
<Para>
<ULink url="ftp://s2k-ftp.cs.berkeley.edu/pub/gist/pggist/pggist.tgz">Examples at Berkeley</ULink>
come with an overview of the methods and demonstrate spatial index
(PostgreSQL 6.3 Sun Feb 1 14:57:30 EST 1998)
</ProgramListing>
-
+</para>
<Para>
I could not get sense of this error message; it appears to be something
we'd rather ask the developers about (see also Note 4 below). What I
original sources quoted above and apply my patch (see attachment) and
tell us what you feel about it. Looks cool to me, but I would not like
to hold it up while there are so many competent people around.
-
+</para>
<Para>
A few notes on the sources:
-
+</para>
<Para>
1. I failed to make use of the original (HPUX) Makefile and rearranged
the Makefile from the ancient postgres95 tutorial to do the job. I tried
to keep it generic, but I am a very poor makefile writer -- just did
some monkey work. Sorry about that, but I guess it is now a little
more portable that the original makefile.
-
+</para>
<Para>
2. I built the example sources right under pgsql/src (just extracted the
tar file there). The aforementioned Makefile assumes it is one level
below pgsql/src (in our case, in pgsql/src/pggist).
-
+</para>
<Para>
3. The changes I made to the *.c files were all about #include's,
function prototypes and typecasting. Other than that, I just threw
away a bunch of unused vars and added a couple parentheses to please
gcc. I hope I did not screw up too much :)
-
+</para>
<Para>
4. There is a comment in polyproc.sql:
<ProductName>Postgres</ProductName> versions
back and tried the query. My system went nuts and I had to shoot down
the postmaster in about ten minutes.
-
+</para>
<Para>
I will continue to look into GiST for a while, but I would also
appreciate
more examples of R-tree usage.
-
+</para>
</Chapter>
was reset to start at 6.0,
putting the numbers back into the sequence originally begun by
the <ProductName>Postgres</ProductName> Project.
+</Para>
<Para>
The emphasis on development for the v1.0.x releases of
identifying and understanding existing problems in the backend
to augmenting features and capabilities, although
work continues in all areas.
+</Para>
<Para>
Major enhancements include:
+</Para>
<ItemizedList>
<ListItem>
Built-in types have been improved, including new wide-range date/time types
and additional geometric type support.
</Para>
+
</ListItem>
<ListItem>
<Para>
</Para>
</ListItem>
</ItemizedList>
-</Para>
</Sect2>
-</sect1>
\ No newline at end of file
+</sect1>
<Para>
This manual set is organized into several parts:
+</Para>
<VariableList>
<VarListEntry>
<Para>
In addition to this manual set, there are other resources to help you with
<ProductName>Postgres</ProductName> installation and use:
+</Para>
<VariableList>
<VarListEntry>
|Mariposa | 1953 |
+----------+----------+
</ProgramListing>
+</para>
<Para>
On the other hand, to find the names of all cities,
</Para>
</ListItem>
</ItemizedList>
-
+</para>
<Para>
Commands were tested on RedHat Linux version 4.2 using the tcsh shell.
Except where noted, they will probably work on most systems. Commands
In general, most Unix-compatible
platforms with modern libraries should be able to run <ProductName>Postgres</ProductName>.
-
+</para>
<para>
Although the minimum required memory for running <ProductName>Postgres</ProductName>
is as little as 8MB, there are noticable improvements in runtimes for the regression
tests when expanding memory up to 96MB on a relatively fast dual-processor system
running X-Windows.
The rule is you can never have too much memory.
-
+</para>
<Para>
Check that you have sufficient disk space. You will need about
30 Mbytes for <filename>/usr/src/pgsql</filename>,
<programlisting>
$ df -k
</programlisting>
-
+</para>
</Sect1>
<Sect1>
<Title>Installation Procedure</Title>
-<Para>
<Procedure>
<Title><ProductName>Postgres</ProductName> Installation</Title>
<Para>
Create the <ProductName>Postgres</ProductName> superuser account
(<literal>postgres</literal> is commonly used) if it does not already exist.
-
+</para>
<para>
The owner of the Postgres files can be any unprivileged user account.
It <emphasis>must not</emphasis> be <literal>root</literal>, <literal>bin</literal>,
or any other account with special access rights, as that would create a security risk.
-
+</para>
</Step>
<Step Performance="required">
<Para>
Log in to the <ProductName>Postgres</ProductName> superuser account. Most of the
remaining steps in the installation will happen in this account.
-
+</para>
+</step>
<Step Performance="required">
<Para>
Ftp file
in the HACKERS mailing list. Full releases always require a dump/reload
from previous releases. It is therefore a bad idea to skip this
step.
-
+</para>
<tip>
<para>
Do not use the <application>pg_dumpall</application>
script from v6.0 or everything
will be owned by the <ProductName>Postgres</ProductName> super user.
+</para>
</tip>
<para>
<programlisting>
$ pg_dumpall -z > db.out
</programlisting>
-
+</para>
<para>
To use the latest <application>pg_dumpall</application> script on your
existing older database before upgrading <productname>Postgres</productname>,
$ /etc/rc.d/init.d/postgres.init stop
</programlisting>
to halt <productname>Postgres</productname>.
+</para>
</tip>
</Para>
</Step>
<Para>
Make new source and install directories. The actual paths can be
different for your installation but you must be consistant throughout this procedure.
+</para>
<note>
<para>
There are two places in this installation procedure where you will have an opportunity
to specify installation locations for programs, libraries, documentation, and other files.
Usually it is sufficient to specify these at the <command>make install</command> stage
of installation.
+</para>
</note>
<para>
send email to
<ulink url="mailto:scrappy@hub.org">scrappy@hub.org</ulink> with the output of the program
<application>./config.guess</application>. Indicate what the template file should be.
+</para>
</note>
</Para>
-
+</step>
<Step Performance="optional">
<Para>
Choose configuration options. Check <xref linkend="config" endterm="install-config">
present.)
</ProgramListing>
</Para>
-
+</step>
<Step Performance="required">
<Para>
Here is the configure script used on a Sparc Solaris 2.5 system
<para>
Of course, you may type these three lines all
on the same line.
+</para>
</tip>
</Para>
</Step>
</substeps>
-
+</step>
<Step Performance="required">
<Para>
Install the <application>man</application> and
$ cd /usr/src/pgsql/doc
$ gmake install
</ProgramListing>
-
+</para>
<para>
The documentation is also available in Postscript format. Look for files
ending with <filename>.ps.gz</filename> in the same directory.
-
+</para>
+</step>
<Step Performance="required">
<Para>
Compile the program. Type
You will probably find a number of warning
messages in make.log. Unless you have problems later on, these
messages may be safely ignored.
+</para>
</note>
-
+</para>
<Para>
If the compiler fails with a message stating that
the <application>flex</application> command
<Para>
If necessary, tell your system how to find the new shared libraries. You can
do <emphasis>one</emphasis> of the following, preferably the first:
-
+</para>
<SubSteps>
<Step Performance="optional">
<Para>
<ProgramListing>
setenv LD_LIBRARY_PATH /usr/local/pgsql/lib
</ProgramListing>
+</para>
</Step>
</SubSteps>
</Para>
</Step>
-<Step Performance="optional">
-<Para>
-If you used the <option>--with-perl</option> option to configure, check
-the install log to see whether the Perl module was actually installed.
-If you've followed our advice to make the Postgres files be owned by
-an unprivileged userid, then the Perl module won't have been installed,
-for lack of write privileges on the Perl library directories. You can
-complete its installation, either now or later, by becoming the user that
-does own the Perl library (often root) (via <command>su</command>) and doing
-<ProgramListing>
-$ cd /usr/src/pgsql/src/interfaces/perl5
-$ gmake install
-</ProgramListing>
-</Para>
-</Step>
-
-<Step Performance="required">
-<Para>
- If it has not already been done, then prepare account <literal>postgres</literal>
+ <Step Performance="optional">
+ <Para>
+ If you used the <option>--with-perl</option> option to configure, check
+ the install log to see whether the Perl module was actually installed.
+ If you've followed our advice to make the Postgres files be owned by
+ an unprivileged userid, then the Perl module won't have been installed,
+ for lack of write privileges on the Perl library directories. You can
+ complete its installation, either now or later, by becoming the user that
+ does own the Perl library (often root) (via <command>su</command>) and doing
+ <ProgramListing>
+ $ cd /usr/src/pgsql/src/interfaces/perl5
+ $ gmake install
+ </ProgramListing>
+ </Para>
+ </Step>
+
+ <Step Performance="required">
+ <Para>
+ If it has not already been done, then prepare account <literal>postgres</literal>
for using <ProductName>Postgres</ProductName>.
-Any account that will use <ProductName>Postgres</ProductName> must
+ Any account that will use <ProductName>Postgres</ProductName> must
be similarly prepared.
-
-<para>
-There are several ways to influence the runtime environment of the
- <ProductName>Postgres</ProductName>
-server. Refer to the <citetitle>Administrator's Guide</citetitle>
- for more information.
-
-<note>
-<para>
-The following instructions are for a
- bash/sh shell. Adapt accordingly for other shells.
-</note>
-
-</Para>
-
-<substeps>
-
-<Step Performance="required">
-<Para>
- Add the following lines to your login environment:
-
- shell, <filename>~/.bash_profile</filename>:
-<ProgramListing>
-PATH=$PATH:/usr/local/pgsql/bin
-MANPATH=$MANPATH:/usr/local/pgsql/man
-PGLIB=/usr/local/pgsql/lib
-PGDATA=/usr/local/pgsql/data
-export PATH MANPATH PGLIB PGDATA
-</ProgramListing>
-</Para>
-
-<Step Performance="required">
-<para>
-Several regression tests could failed if the user's locale collation
-scheme is different from that of standard C locale.
-
-<para>
-If you configure and compile <ProductName>Postgres</ProductName>
- with the <option>--enable-locale</option> option then
- set locale environment to C (or unset all LC_* variables)
-by putting these additional lines to your login environment
- before starting postmaster:
-<ProgramListing>
-LC_COLLATE=C
-LC_CTYPE=C
-LC_COLLATE=C
-export LC_COLLATE LC_CTYPE LC_COLLATE
-</ProgramListing>
-
-<ProgramListing>
-
-</ProgramListing>
-
-
-<Step Performance="required">
-<Para>
- Make sure that you have defined these variables before continuing
- with the remaining steps. The easiest way to do this is to type:
-<ProgramListing>
-$ source ~/.bash_profile
-</ProgramListing>
-</Para>
-</Step>
-
-</substeps>
+ </para>
+ <para>
+ There are several ways to influence the runtime environment of the
+ <ProductName>Postgres</ProductName>
+ server. Refer to the <citetitle>Administrator's Guide</citetitle>
+ for more information.
+ <note>
+ <para>
+ The following instructions are for a
+ bash/sh shell. Adapt accordingly for other shells.
+ </para>
+ </note>
+ </Para>
+
+ <substeps>
+
+ <Step Performance="required">
+ <Para>
+ Add the following lines to your login environment:
+
+ shell, <filename>~/.bash_profile</filename>:
+ <ProgramListing>
+ PATH=$PATH:/usr/local/pgsql/bin
+ MANPATH=$MANPATH:/usr/local/pgsql/man
+ PGLIB=/usr/local/pgsql/lib
+ PGDATA=/usr/local/pgsql/data
+ export PATH MANPATH PGLIB PGDATA
+ </ProgramListing>
+ </Para>
+ </step>
+ <Step Performance="required">
+ <para>
+ Several regression tests could failed if the user's locale collation
+ scheme is different from that of standard C locale.
+ </para>
+ <para>
+ If you configure and compile <ProductName>Postgres</ProductName>
+ with the <option>--enable-locale</option> option then
+ set locale environment to C (or unset all LC_* variables)
+ by putting these additional lines to your login environment
+ before starting postmaster:
+ <ProgramListing>
+ LC_COLLATE=C
+ LC_CTYPE=C
+ LC_COLLATE=C
+ export LC_COLLATE LC_CTYPE LC_COLLATE
+ </ProgramListing>
+
+ <ProgramListing>
+
+ </ProgramListing>
+ </para>
+ </step>
+
+ <Step Performance="required">
+ <Para>
+ Make sure that you have defined these variables before continuing
+ with the remaining steps. The easiest way to do this is to type:
+ <ProgramListing>
+ $ source ~/.bash_profile
+ </ProgramListing>
+ </Para>
+ </Step>
+
+ </substeps>
+ </step>
<Step Performance="required">
<Para>
<para>
Briefly test that the backend will start and run by running it from
the command line.
-
+</para>
<substeps>
<Step Performance="required">
<ProgramListing>
$ createdb
</ProgramListing>
-
+</para>
+</step>
<Step Performance="required">
<para>
Connect to the new database:
<ProgramListing>
$ psql
</ProgramListing>
-
+</para>
+</step>
<Step Performance="required">
<para>
And run a sample query:
<ProgramListing>
postgres=> SELECT datetime 'now';
</ProgramListing>
-
+</para>
+</step>
<Step Performance="required">
<para>
Exit <application>psql</application>:
<ProgramListing>
postgres=> \q
</ProgramListing>
-
+</para>
+</step>
<Step Performance="required">
<para>
Remove the test database (unless you will want to use it later for other tests):
<ProgramListing>
$ destroydb
</ProgramListing>
-
+</para>
+</step>
</substeps>
-
+</step>
<Step Performance="required">
<Para>
Run postmaster in the background from your <ProductName>Postgres</ProductName>
superuser account (typically account <literal>postgres</literal>).
<emphasis>Do not run <application>postmaster</application>
from the root account!</emphasis>
-
+</para>
<Para>
Usually, you will want to modify
your computer so that it will automatically start postmaster whenever
it boots. It is not required; the <ProductName>Postgres</ProductName>
server can
be run successfully from non-privileged accounts without root intervention.
-
+</para>
<para>
Here are some suggestions on how to do this, contributed by various
users.
-
+</para>
<para>
Whatever you do, postmaster must be run by
the <ProductName>Postgres</ProductName> superuser (<literal>postgres</literal>?)
$ cd
$ nohup postmaster > regress.log 2>&1 &
</ProgramListing>
-
+</para>
+</listitem>
<listitem>
<para>
Edit file rc.local on NetBSD or file rc2.d on SPARC Solaris
<programlisting>
su postgres -c "/usr/local/pgsql/bin/postmaster -S -D /usr/local/pgsql/data"
</programlisting>
+</para>
+</listitem>
<listitem>
<para>
enough to keep parsing beyond end-of-line if there is an
expression unfinished. The exec saves one layer of shell under
the postmaster process so the parent is init.
+</para>
+</listitem>
<listitem>
<para>
which is based on the example in <filename>contrib/linux/</filename>.
Then make a softlink to this file from
<filename>/etc/rc.d/rc5.d/S98postgres.init</filename>.
+</para>
+</listitem>
<listitem>
<para>
(The author of this example says this example will revive the
postmaster if it dies, but he doesn't know if there are other side
effects.)
+</para>
+</listitem>
</itemizedlist>
For a i686/Linux-ELF platform, no tests failed since this is the
v6.4 regression testing reference platform.
</Para>
+</listitem>
<listitem>
<Para>
floating point numbers. select_views produces massively different output,
but the differences are due to minor floating point differences.
</Para>
-</itemizedlist>
+</listitem>
+</itemizedlist>
+</para>
<Para>
Even if a test result clearly indicates a real failure, it may be a
localized problem that will not affect you. An example is that the
</Step>
</substeps>
-
+</step>
<Step Performance="required">
<Para>
If you haven't already done so, this would be a good time to modify
your computer to do regular maintainence. The following should be
done at regular intervals:
-
+</para>
<procedure>
<title>Minimal Backup Procedure</title>
<para>
Run the <acronym>SQL</acronym> command <command>VACUUM</command>.
This will clean up your database.
-
+</para>
+</step>
<step performance="required">
<para>
Back up your system. (You should probably keep the last few
backups on hand.) Preferably, no one else should be using the
system at the time.
-
+</para>
+</step>
</procedure>
<para>
$ cd /usr/local/pgsql/doc
$ gunzip user.ps.tz | lpr
</programlisting>
-
+</para>
<para>
Here is how
you might do it if you have Ghostscript on your system and are
$ gzip user.ps
$ lpr -l -s -r manpage.hp
</programlisting>
-
+</para>
</Step>
<Step Performance="required">
<listitem>
<para>
The version of <ProductName>Postgres</ProductName> (v6.4, 6.3.2, beta 981014, etc.).
+</para>
+</listitem>
<listitem>
<para>
Your operating system (i.e. RedHat v5.1 Linux v2.0.34).
+</para>
+</listitem>
<listitem>
<para>
Your hardware (SPARC, i486, etc.).
+</para>
+</listitem>
<listitem>
<para>
applied, changes you made, etc.), what tests failed, etc.
It is normal to get many warning when you compile. You do
not need to report these.
+</para>
+</listitem>
</itemizedlist>
</Para>
</Step>
</Procedure>
+</sect1>
<Sect1>
<Title>Playing with <ProductName>Postgres</ProductName></Title>
</Para>
</Note>
-<Sect2>
-<Title>Ultrix4.x</Title>
-
-<para>
-<note>
-<para>
-There have been no recent reports of Ultrix usage with <productname>Postgres</productname>.
-</note>
-
-<para>
- You need to install the libdl-1.1 package since Ultrix 4.x doesn't
- have a dynamic loader. It's available in
- s2k-ftp.CS.Berkeley.EDU:pub/personal/andrew/libdl-1.1.tar.Z
-</Para>
-</Sect2>
-
-<Sect2>
-<Title>Linux</Title>
-
-<Sect3>
-<Sect3Info>
-<Author>
-<FirstName>Thomas G.</FirstName>
-<SurName>Lockhart</SurName>
-</Author>
-<Date>1998-02-19</Date>
-</Sect3Info>
-<Title>Linux ELF</Title>
-
-<Para>
-The regression test reference machine is
-a linux-2.0.30/libc-5.3.12/RedHat-4.2 installation running on a dual processor i686.
-The linux-elf port installs cleanly. See the Linux FAQ for more details.
-</Para>
-</Sect3>
+ <Sect2>
+ <Title>Ultrix4.x</Title>
+
+ <para>
+ <note>
+ <para>
+ There have been no recent reports of Ultrix usage with <productname>Postgres</productname>.
+ </para>
+ </note>
+ </para>
+ <para>
+ You need to install the libdl-1.1 package since Ultrix 4.x doesn't
+ have a dynamic loader. It's available in
+ s2k-ftp.CS.Berkeley.EDU:pub/personal/andrew/libdl-1.1.tar.Z
+ </Para>
+ </Sect2>
+
+ <Sect2>
+ <Title>Linux</Title>
+
+ <Sect3>
+ <Sect3Info>
+ <Author>
+ <FirstName>Thomas G.</FirstName>
+ <SurName>Lockhart</SurName>
+ </Author>
+ <Date>1998-02-19</Date>
+ </Sect3Info>
+ <Title>Linux ELF</Title>
+
+ <Para>
+ The regression test reference machine is
+ a linux-2.0.30/libc-5.3.12/RedHat-4.2 installation running on a dual processor i686.
+ The linux-elf port installs cleanly. See the Linux FAQ for more details.
+ </Para>
+ </Sect3>
<Sect3>
<Sect3Info>
a product so contact him for information. He has also indicated that
binary releases of <ProductName>Postgres</ProductName> for NEXTSTEP will be made available to
the general public. Contact Info@RnA.nl for information.
-
+</para>
<Para>
We have no recent reports of successful NeXT installations (as of v6.2.1).
However, the client-side libraries should work even
So, although <ProductName>Postgres</ProductName> has some object-oriented features,
it is firmly in the relational database world. In fact, some commercial databases
have recently incorporated features pioneered by <ProductName>Postgres</ProductName>.
+</Para>
</Sect1>
<para>
Written by <ulink url="peter@retep.org.uk">Peter T. Mount</ulink>, the
author of the <acronym>JDBC</acronym> driver.
+</para>
</note>
+</para>
<para>
<acronym>JDBC</acronym> is a core <acronym>API</acronym> of Java 1.1 and later.
It provides a standard set of
interfaces to <acronym>SQL</acronym>-compliant databases.
+</para>
<para>
<application>Postgres</application> provides
a type 4 <acronym>JDBC</acronym> Driver. Type 4 indicates that the driver
is written in Pure Java, and communicates in the database's own network
protocol. Because of this, the driver is platform independent. Once compiled,
the driver can be used on any platform.
+</para>
<sect1>
<title>Building the <acronym>JDBC</acronym> Interface</title>
-<para>
-
<sect2>
<title>Compiling the Driver</title>
<programlisting>
% make
</programlisting>
+</para>
<para>
Upon completion, you will find the archive <filename>postgresql.jar</filename>
loading techniques for performance reasons,
and <application>javac</application> cannot cope.
The <filename>Makefile</filename> will generate the jar archive.
+</para>
</note>
+</para>
+</sect2>
<sect2>
<title>Installing the Driver</title>
<para>
To use the driver, the jar archive postgresql.jar needs to be included in
the CLASSPATH.
+</para>
<para>
Example:
+</para>
<para>
I have an application that uses the <acronym>JDBC</acronym> driver to access a large database
containing astronomical objects. I have the application and the jdbc driver
installed in the /usr/local/lib directory, and the java jdk installed in /usr/local/jdk1.1.6.
+</para>
<para>
To run the application, I would use:
+</para>
<para>
export CLASSPATH = \
/usr/local/lib/finder.jar:/usr/local/lib/postgresql.jar:.
java uk.org.retep.finder.Main
+</para>
<para>
Loading the driver is covered later on in this chapter.
-<para>
+</para>
+</sect2>
+</sect1>
<sect1>
<title>Preparing the Database for <acronym>JDBC</acronym></title>
<para>
Because Java can only use TCP/IP connections, the <application>Postgres</application> postmaster
must be running with the -i flag.
+</para>
<para>
Also, the <filename>pg_hba.conf</filename> file must be configured. It's located in the PGDATA
directory. In a default installation, this file permits access only by UNIX
domain sockets. For the <acronym>JDBC</acronym> driver to connect to the same localhost, you need
to add something like:
+</para>
<para>
host all 127.0.0.1 255.255.255.255 password
+</para>
<para>
Here access to all databases are possible from the local machine
with <acronym>JDBC</acronym>.
+</para>
<para>
The <acronym>JDBC</acronym> Driver supports trust, ident,
password and crypt authentication methods.
-
-<para>
+</para>
+</sect1>
<sect1>
<title>Using the Driver</title>
<acronym>JDBC</acronym> programming, but
should help to get you started. For more information refer to the standard
<acronym>JDBC</acronym> <acronym>API</acronym> documentation.
+</para>
<para>
Also, take a look at the examples included with the source. The basic
example is used here.
-<para>
+</para>
+</sect1>
<sect1>
<title>Importing <acronym>JDBC</acronym></title>
<para>
Do not import the postgresql package. If you do, your source will not
compile, as javac will get confused.
+</para>
</important>
+</para>
+</sect1>
<sect1>
<title>Loading the Driver</title>
<para>
Before you can connect to a database, you need to load the driver. There
are two methods available, and it depends on your code to the best one to use.
+</para>
<para>
In the first method, your code implicitly loads the driver using the
This will load the driver, and while loading, the driver will automatically
register itself with <acronym>JDBC</acronym>.
+</para>
<para>
Note: The <function>forName()</function> method
can throw a ClassNotFoundException, so you will
need to catch it if the driver is not available.
+</para>
<para>
This is the most common method to use, but restricts your code to use just
<application>Postgres</application>.
If your code may access another database in the future, and you
don't use our extensions, then the second method is advisable.
+</para>
<para>
The second method passes the driver as a parameter to the JVM as it starts,
using the -D argument.
+</para>
<para>
Example:
<programlisting>
% java -Djdbc.drivers=postgresql.Driver example.ImageViewer
</programlisting>
+</para>
<para>
In this example, the JVM will attempt to load the driver as part of it's
initialisation. Once done, the ImageViewer is started.
+</para>
<para>
Now, this method is the better one to use because it allows your code to
be used with other databases, without recompiling the code. The only thing
that would also change is the URL, which is covered next.
+</para>
<para>
One last thing. When your code then tries to open a Connection, and you get
this is probably
caused by the driver not being in the classpath, or the value in the parameter
not being correct.
+</para>
+</sect1>
<sect1>
<title>Connecting to the Database</title>
<listitem>
<para>
jdbc:postgresql:<replaceable class="parameter">database</replaceable>
+</para>
+</listitem>
<listitem>
<para>
jdbc:postgresql://<replaceable class="parameter">host</replaceable>/<replaceable class="parameter">database</replaceable>
+</para>
+</listitem>
<listitem>
<para>
jdbc:postgresql://<replaceable class="parameter">host</replaceable>:<replaceable class="parameter">port</replaceable>/<replaceable class="parameter">database</replaceable>
+</para>
+</listitem>
+
</itemizedlist>
where:
<varlistentry>
<term>
<replaceable class="parameter">host</replaceable>
-
+</term>
<listitem>
<para>
The hostname of the server. Defaults to "localhost".
+</para>
+</listitem>
+</varlistentry>
<varlistentry>
<term>
<replaceable class="parameter">port</replaceable>
-
+</term>
<listitem>
<para>
The port number the server is listening on. Defaults to the Postgres
standard port number (5432).
+</para>
+</listitem>
+</varlistentry>
<varlistentry>
<term>
<replaceable class="parameter">database</replaceable>
-
+</term>
<listitem>
<para>
The database name.
+</para>
+</listitem>
+</varlistentry>
</variablelist>
+</para>
<para>
To connect, you need to get a Connection instance from
<acronym>JDBC</acronym>. To do this,
you would use the DriverManager.getConnection() method:
+</para>
<para>
Connection db = DriverManager.getConnection(url,user,pwd);
-<para>
+</para>
+</sect1>
<sect1>
<title>Issuing a Query and Processing the Result</title>
Statement instance. Once you have a Statement, you can use the executeQuery()
method to issue a query. This will return a ResultSet instance, which contains
the entire result.
-<para>
+</para>
<sect2>
<title>Using the Statement Interface</title>
You can use a Statement instance as many times as you want. You could
create one as soon as you open the connection, and use it for the connections
lifetime. You have to remember that only one ResultSet can exist per Statement.
+</para>
+</listitem>
<listitem>
<para>
If you need to perform a query while processing a ResultSet, you can
simply create and use another Statement.
+</para>
+</listitem>
<listitem>
<para>
If you are using Threads, and several are using the database, you must
use a separate Statement for each thread. Refer to the sections covering
Threads and Servlets later in this document if you are thinking of using them,
as it covers some important points.
+</para>
+</listitem>
</itemizedlist>
-
+</para>
+</sect2>
<sect2>
<title>Using the ResultSet Interface</title>
<para>
Before reading any values, you must call <function>next()</function>. This returns true if
there is a result, but more importantly, it prepares the row for processing.
+</para>
+</listitem>
<listitem>
<para>
Under the <acronym>JDBC</acronym> spec, you should access a field only once. It's safest
to stick to this rule, although at the current time, the <application>Postgres</application> driver
will allow you to access a field as many times as you want.
+</para>
+</listitem>
<listitem>
<para>
You must close a ResultSet by calling <function>close()</function> once you have finished with it.
+</para>
+</listitem>
<listitem>
<para>
Once you request another query with the Statement used to create a
ResultSet, the currently open instance is closed.
+</para>
+</listitem>
</itemizedlist>
+</para>
<para>
An example is as follows:
rs.close();
st.close();
</programlisting>
-
+</para>
+</sect2>
+</sect1>
<sect1>
<title>Performing Updates</title>
<programlisting>
st.executeUpdate(<literal>create table basic (a int2, b int2)</literal>);
</programlisting>
-
+</para>
+</sect1>
<sect1>
<title>Closing the Connection</title>
<programlisting>
db.close();
</programlisting>
+</para>
+</sect1>
<sect1>
<title>Using Large Objects</title>
large objects (also known as <firstterm>blobs</firstterm>) are used to hold data in
the database that cannot be stored in a normal SQL table. They are stored as a
Table/Index pair, and are refered to from your own tables, by an OID value.
+</para>
<para>
Now, there are you methods of using Large Objects. The first is the
to the api, which presents the libpq large object <acronym>API</acronym> to Java, providing even
better access to large objects than the standard. Internally, the driver uses
the extension to provide large object support.
+</para>
<para>
In <acronym>JDBC</acronym>, the standard way to access them is using the getBinaryStream()
method in ResultSet, and setBinaryStream() method in PreparedStatement. These
methods make the large object appear as a Java stream, allowing you to use the
java.io package, and others, to manipulate the object.
+</para>
<para>
For example, suppose
<programlisting>
create table images (imgname name,imgoid oid);
</programlisting>
+</para>
<para>
To insert an image, you would use:
ps.close();
fis.close();
</programlisting>
+</para>
<para>
Now in this example, setBinaryStream transfers a set number of bytes from a
stream into a large object, and stores the OID into the field holding a
reference to it.
+</para>
<para>
Retrieving an image is even easier (I'm using PreparedStatement here, but
}
ps.close();
</programlisting>
+</para>
<para>
Now here you can see where the Large Object is retrieved as an InputStream.
You'll also notice that we close the stream before processing the next row in
the result. This is part of the <acronym>JDBC</acronym> Specification, which states that any
InputStream returned is closed when ResultSet.next() or ResultSet.close() is called.
-
+</para>
+</sect1>
<sect1>
<title><application>Postgres</application> Extensions to the <acronym>JDBC</acronym> <acronym>API</acronym></title>
You can add your own functions
to the backend, which can then be called from queries, or even add your own
data types.
+</para>
<para>
Now, as these are facilities unique to us, we support them from Java, with
a set of extension <acronym>API</acronym>'s. Some features within
It's up to you, and your applications requirements.
</programlisting>
+</para>
+</sect1>
<sect1>
<title>Further Reading</title>
and the <acronym>JDBC</acronym> Specification.
Both are available on
<ulink url="http://www.javasoft.com">JavaSoft's web site</ulink>.
+</para>
<para>
<ulink url="http://www.retep.org.uk">My own web site</ulink>
contains updated information not included in this
document, and also includes precompiled drivers for v6.4, and earlier.
-
-</chapter>
\ No newline at end of file
+</para>
+</sect1>
+</chapter>
<!--
-$Header: /cvsroot/pgsql/doc/src/sgml/Attic/keys.sgml,v 1.2 1998/08/17 16:18:13 thomas Exp $
+$Header: /cvsroot/pgsql/doc/src/sgml/Attic/keys.sgml,v 1.3 1998/12/29 02:24:16 thomas Exp $
Indices and Keys
$Log: keys.sgml,v $
+Revision 1.3 1998/12/29 02:24:16 thomas
+Clean up to ensure tag completion as required by the newest versions
+ of Norm's Modular Style Sheets and jade/docbook.
+From Vince Vielhaber <vev@michvhf.com>.
+
Revision 1.2 1998/08/17 16:18:13 thomas
Small sentence cleanups. Add tags for acronyms and products.
</Para>
</ListItem>
</itemizedlist>
+</para>
+</listitem>
<ListItem>
<Para>
</Para>
</ListItem>
</itemizedlist>
+</para>
+</listitem>
</itemizedlist>
+</para>
<Para>
As for why no non-unique keys are defined explicitly in standard <acronym>SQL</acronym> syntax?
<ProductName>PostgreSQL</ProductName> is copyright (C) 1996-8
by the PostgreSQL Global Development Group,
and is distributed under the terms of the Berkeley license.
+</Para>
<Para>
<ProductName>Postgres95</ProductName> is copyright (C) 1994-5
Hewlett-Packard Co. OSF/1 is a trademark of the Open
Software Foundation.
</Para>
+</Sect1>
+
</TITLE>
<PARA><FUNCTION>pg_connect</FUNCTION> opens a connection to the
<ProductName>Postgres</ProductName> backend.
+</Para>
<para>
Two syntaxes are available. In the older one, each possible option
The result is a list describing the possible connection options and their
current default values.
Each entry in the list is a sublist of the format:
+</Para>
<para>
{optname label dispchar dispsize value}
+</Para>
<Para>
where the optname is usable as an option in
<FUNCTION>pg_connect -conninfo</FUNCTION>.
Query result handles start with the connection handle and add a period
and a result number.
+</Para>
<PARA>
Note that lack of a Tcl error is not proof that the query succeeded!
in pg_exec.
</PARA>
</REFSECT1>
+</refentry>
<REFENTRY ID="PGTCL-PGRESULT">
<REFMETA>
<PARA>
<FUNCTION>pg_result</FUNCTION> returns information about a query result
created by a prior <FUNCTION>pg_exec</FUNCTION>.
+</Para>
<para>
You can keep a query result around for as long as you need it, but when
idle state of an application written with Tk. In non-Tk Tcl shells, you can
execute <FUNCTION>update</FUNCTION> or <FUNCTION>vwait</FUNCTION> to cause
the idle loop to be entered.
+</Para>
<para>
You should not invoke the SQL statements LISTEN or UNLISTEN directly when
../src/test/examples
../src/bin/psql
</ProgramListing>
+</Para>
<Para>
Frontend programs which use <FileName>libpq</FileName> must include the
<synopsis>
ConnStatusType *PQstatus(PGconn *conn)
</synopsis>
+</Para>
<Para>
A failed connection attempt is signaled by status CONNECTION_BAD.
communications failure might result in the status changing to
CONNECTION_BAD prematurely. In that case the application could
try to recover by calling PQreset.
+</Para>
</ListItem>
<ListItem>
<synopsis>
char *PQerrorMessage(PGconn* conn);
</synopsis>
+</Para>
<Para>
Nearly all libpq functions will set PQerrorMessage if they fail.
Note that by libpq convention, a non-empty PQerrorMessage will
include a trailing newline.
+</Para>
</ListItem>
<ListItem>
int PQfnumber(PGresult *res,
char* field_name);
</synopsis>
+</Para>
<Para>
-1 is returned if the given name does not match any field.
+</Para>
</ListItem>
<ListItem>
The PQexec function is adequate for submitting queries in simple synchronous
applications. It has a couple of major deficiencies however:
-<Para>
<ItemizedList>
<ListItem>
<Para>
underlying functions that PQexec is built from: PQsendQuery and
PQgetResult.
-<Para>
<ItemizedList>
<ListItem>
<Para>
next SQL command. This can be avoided by proper use of three more
functions:
-<Para>
<ItemizedList>
<ListItem>
<Para>
if PQisBusy returns FALSE. It can also call PQnotifies to detect NOTIFY
messages (see "Asynchronous Notification", below). An example is given
in the sample programs section.
+</Para>
<Para>
A frontend that uses PQsendQuery/PQgetResult can also attempt to cancel
a query that is still being processed by the backend.
+</Para>
<Para>
<ItemizedList>
<Para>
Note that if the current query is part of a transaction, cancellation
will abort the whole transaction.
+</Para>
<Para>
PQrequestCancel can safely be invoked from a signal handler. So, it is
cancellation of queries that it issues through PQexec. Note that
PQrequestCancel will have no effect if the connection is not currently open
or the backend is not currently processing a query.
+</Para>
</Sect1>
function calls to the backend. This is a trapdoor into system internals and
can be a potential security hole. Most users will not need this feature.
-<Para>
<ItemizedList>
<ListItem>
<Para>
that needs to be communicated is transferred through a database relation.
Commonly the condition name is the same as the associated relation, but it is
not necessary for there to be any associated relation.
+</Para>
<Para>
<FileName>libpq</FileName> applications submit LISTEN and UNLISTEN
commands as ordinary SQL queries. Subsequently, arrival of NOTIFY
messages can be detected by calling PQnotifies().
-<Para>
<ItemizedList>
<ListItem>
<Para>
<Para>
The second sample program gives an example of the use
of asynchronous notification.
+</Para>
<Para>
PQnotifies() does not actually read backend data; it just returns messages
<synopsis>
int PQendcopy(PGconn *conn);
</synopsis>
+</Para>
<Para>
As an example:
fprintf(stderr, "%s", message);
}
</ProgramListing>
+</Para>
<Para>
To use a special notice processor, call <function>PQsetNoticeProcessor</function> just after
creation of a new PGconn object.
+</Para>
</Sect1>
}
</ProgramListing>
-<Para>
+</Para>
</Sect2>
</Sect1>
lo_open. On success, <Acronym>lo_close</Acronym> returns zero. On error,
the return value is negative.
</Para>
+</sect2>
</Sect1>
<Sect1>
location for the installation. Remember that all database access actually
occurs through the database backend, so that any location specified must
be accessible by the backend.
+</Para>
<Para>
Alternate database locations are created and referenced by an environment variable
although using variable names with a prefix of <quote>PGDATA</quote> is recommended
to avoid confusion
and conflict with other variables.
+</Para>
<Note>
<Para>
For security and integrity reasons,
any path or environment variable specified has some
additional path fields appended.
+</Para>
<Para>
Alternate database locations must be prepared by running
<Application>initlocation</Application>.
+</Para>
<Para>
To create a data storage area using the environment variable
Creating Postgres database system directory /alt/postgres/data
Creating Postgres database system directory /alt/postgres/data/base
</ProgramListing>
+</Para>
<Para>
-To create a database in the alternate storage area <envar>PGDATA2<envar>
+To create a database in the alternate storage area <envar>PGDATA2</envar>
from the command line, use the following command:
<ProgramListing>
% createdb -D PGDATA2 mydb
ERROR: Unable to create database directory /alt/postgres/data/base/mydb
createdb: database creation failed on mydb.
</ProgramListing>
+</Para>
</Sect1>
<Title>Database Privileges</Title>
<Para>
+</para>
</Sect2>
<Sect2>
databases on a single host, this term more precisely denotes any
particular set of installed
<Productname>Postgres</Productname> binaries and databases.
+</para>
<para>
The
the same as the Unix superuser (which will be referred to as <firstterm>root</firstterm>).
The superuser should have a non-zero user identifier (<firstterm>UID</firstterm>)
for security reasons.
+</para>
<para>
The
the method described below
and maintain a set of template databases for use by
<application>createdb</application>.
+</para>
<para>
The <application>postmaster</application>
can take several command-line arguments to tune its behavior.
However, supplying arguments is necessary only if you intend to run multiple
sites or a non-default site.
+</para>
<para>
The <Productname>Postgres</Productname> backend
doing this bypasses the shared buffer pool and lock table associated
with a postmaster/site, therefore this is not recommended in a multiuser
site.
+</para>
+</sect1>
<sect1>
<title>Notation</title>
<quote>...</quote> or <filename>/usr/local/pgsql/</filename>
at the front of a file name is used to represent the
path to the <Productname>Postgres</Productname> superuser's home directory.
+</para>
<para>
In a command synopsis, brackets
Anything in braces
(<quote>{</quote> and <quote>}</quote>) and containing vertical bars (<quote>|</quote>)
indicates that you must choose one.
+</para>
<para>
In examples, parentheses (<quote>(</quote> and <quote>)</quote>) are used to group boolean
expressions. <quote>|</quote> is the boolean operator OR.
+</para>
<para>
Examples will show commands executed from various accounts and programs.
<quote>$</quote>.
<acronym>SQL</acronym> commands will be preceeded with <quote>=></quote>
or will have no leading prompt, depending on the context.
+</para>
<note>
<para>
flagging commands is not universally consistant throughout the documentation set.
Please report problems to
<ulink url="mailto:docs@postgresql.org">the Documentation Mailing List</ulink>.
+</para>
</note>
</sect1>
<Title>ODBC Interface</Title>
-<Para>
<Note>
<Para>
Background information originally by
between frontend applications and database servers,
allowing a user or developer to write applications which are
transportable between servers from different manufacturers..
+</Para>
<Sect1>
<Title>Background</Title>
on the backend to an <acronym>ODBC</acronym>-compatible data source.
This could be anything from a text file to an Oracle or
<productname>Postgres</productname> <acronym>RDBMS</acronym>.
+</Para>
<Para>
The backend access come from <acronym>ODBC</acronym> drivers,
allow data access. <productname>psqlODBC</productname> is such a driver,
along with others that are
available, such as the OpenLink <acronym>ODBC</acronym> drivers.
+</Para>
<Para>
Once you write an <acronym>ODBC</acronym> application,
you <emphasis>should</emphasis> be able to connect to <emphasis>any</emphasis>
back end database, regardless of the vendor, as long as the database schema
is the same.
+</Para>
<Para>
For example. you could have <productname>MS SQL Server</productname>
your Windows application would make exactly the
same calls and the back end data source would look the same (to the Windows
app).
+</Para>
<para>
<ulink url="http://www.insightdist.com/">Insight Distributors</ulink>
<ulink url="http://www.insightdist.com/psqlodbc/"><acronym>FAQ</acronym></ulink>,
ongoing development on the code base, and actively participate on the
<ulink url="mailto:interfaces@postgresql.org">interfaces mailing list</ulink>.
+</Para>
+</sect1>
<sect1>
<title><productname>Windows</productname> Applications</title>
<ListItem>
<Para>
Access, Delphi, and Visual Basic all support <acronym>ODBC</acronym> directly.
-
+</Para>
+</listitem>
<ListItem>
<Para>
Under C++, such as Visual C++,
you can use the C++ <acronym>ODBC</acronym> <acronym>API</acronym>.
+</Para>
+</listitem>
<ListItem>
<Para>
<acronym>ODBC</acronym> <acronym>API</acronym>
set within an MFC 4.2 class. This is the easiest route if you are doing
Windows C++ development under Windows NT.
+</Para>
+</listitem>
</ItemizedList>
+</Para>
<sect2>
<title>Writing Applications</title>
to the <productname>Postgres</productname> server,
or is that only when another database program
like MS SQL Server or Access needs to access the data?</quote>
-
+</para>
<Para>
The <acronym>ODBC</acronym> <acronym>API</acronym>
is the way to go.
For <productname>Visual C++</productname> coding you can find out more at
Microsoft's web site or in your <productname>VC++</productname> docs.
+</Para>
<Para>
Visual Basic and the other RAD tools have Recordset objects
directly to access data. Using the data-aware controls, you can quickly
link to the <acronym>ODBC</acronym> back end database
(<Emphasis>very</Emphasis> quickly).
+</Para>
<Para>
Playing around with MS Access will help you sort this out. Try using
<literal>File->Get External Data</literal>.
+</Para>
<Tip>
<Para>
</Para>
</Tip>
-->
+</sect2>
+</sect1>
<sect1>
<title>Unix Installation</title>
demonstrated under Linux with <productname>Postgres</productname> v6.4
using the <productname>psqlODBC</productname>
driver contained in the <productname>Postgres</productname> distribution.
+</Para>
<sect2>
<title>Building the Driver</title>
document, but there is a <filename>README</filename>
that can be found inside the <productname>iodbc</productname> compressed
.shar file that should explain how to get it up and running.
+</Para>
<para>
Having said that, any driver manager that you can find for your platform
should support the <productname>psqlODBC</productname> driver
or any <acronym>ODBC</acronym> driver.
+</Para>
<para>
The Unix configuration files for <productname>psqlODBC</productname>
these include Linux and FreeBSD but we are hoping other users will
contribute the necessary information to quickly expand the number of
platforms for which the driver can be built.
+</Para>
<para>
There are actually two separate methods to build the driver depending on
client applications on multiple, heterogeneous platforms. The integrated
installation is convenient when the target client is the same as the
server, or when the client and server have similar runtime configurations.
+</Para>
<para>
Specifically if you have received the <productname>psqlODBC</productname>
If you received the driver as a standalone package than you will run
configure and make from the directory in which you unpacked the
driver source.
+</Para>
<procedure>
<title>Integrated Installation</title>
<para>
This installation procedure is appropriate for an integrated installation.
+</Para>
<step performance="required">
<para>
% ./configure --with-odbc
% make
</programlisting>
-
+</Para>
+</step>
<step performance="required">
<para>
Rebuild the <productname>Postgres</productname> distribution:
<programlisting>
% make install
</programlisting>
-
+</Para>
+</step>
</procedure>
<para>
<programlisting>
% make ODBCINST=<replaceable>filename</replaceable> install
</programlisting>
+</Para>
<procedure>
<title>Pre-v6.4 Integrated Installation</title>
v6.4, you have the original source tree available,
and you want to use the newest version of the <acronym>ODBC</acronym>
driver, then you may want to try this form of installation.
+</Para>
<step performance="required">
<para>
Copy the output tar file to your target system and unpack it into a
clean directory.
-
+</Para>
+</step>
<step performance="required">
<para>
From the directory containing the
% make
% make POSTGRESDIR=<replaceable class="parameter">PostgresTopDir</replaceable> install
</programlisting>
+</Para>
+</step>
<step performance="optional">
<para>
<programlisting>
% make BINDIR=bindir LIBDIR=libdir HEADERDIR=headerdir ODBCINST=instfile install
</programlisting>
-
+</Para>
+</step>
</procedure>
<procedure>
for building the <acronym>ODBC</acronym> driver for multiple, heterogeneous
clients who do not have a locally-installed <productname>Postgres</productname>
source tree.
+</Para>
<para>
The default location for libraries and headers
as <filename>/share/odbcinst.ini</filename> (if <filename>/share</filename>
exists) or as <filename>/etc/odbcinst.ini</filename>
(if <filename>/share</filename> does not exist).
+</Para>
<note>
<para>
have this requirement, and you can choose another destination which
is writable by your non-root <productname>Postgres</productname> superuser
account instead.
+</Para>
</note>
<step performance="required">
<productname>Postgres</productname> distribution or may be obtained from
<ulink url="http://www.insightdist.com/psqlodbc">Insight Distributors</ulink>,
the current maintainers of the non-Unix sources.
+</Para>
<para>
Copy the zip
The <option>-a</option> option
is necessary to get rid of <acronym>DOS</acronym>
CR/LF pairs in the source files.
+</Para>
<para>
If you have the gzipped tar package than simply run
<programlisting>
tar -xzf <replaceable>packagename</replaceable>
</programlisting>
+</Para>
<substeps>
<para>
To create a tar file for a complete standalone installation
from the main <productname>Postgres</productname> source tree:
-
+</Para>
+</step>
</substeps>
-
+</step>
<step performance="required">
<para>
Configure the main <productname>Postgres</productname> distribution.
-
+</Para>
+</step>
<step performance="required">
<para>
Create the tar file:
% cd interfaces/odbc
% make standalone
</programlisting>
+</Para>
+</step>
<step performance="required">
<para>
Copy the output tar file to your target system. Be sure to transfer as
a binary file if using <application>ftp</application>.
+</Para>
+</step>
<step performance="required">
<para>
Unpack the tar file into a clean
directory.
+</Para>
+</step>
<step performance="required">
<para>
<programlisting>
% ./configure
</programlisting>
+</Para>
<para>
The configuration can be done with options:
<filename><replaceable>rootdir</replaceable>/include/iodbc</filename>, and
<option>--with-odbc</option> installs <filename>odbcinst.ini</filename> in the
specified directory.
+</Para>
<para>
Note that both of these options can also be used from the integrated build
your <productname>Postgres</productname> installation.
<option>--with-odbc</option> applies only to the configuration file
<filename>odbcinst.ini</filename>.
+</Para>
+</step>
<step performance="required">
<para>
<programlisting>
% make ODBCINST=<replaceable>instdir</replaceable>
</programlisting>
+</Para>
<para>
You can also override the default location for installation on the
headaches. It is safest simply to allow the driver to install the
odbcinst.ini file in the default directory or the directory you specified
on the './configure' command line with --with-odbc.
+</Para>
+</step>
<!--
This doesn't currently work - thomas 1998-10-19
<programlisting>
% make POSTGRESDIR=<replaceable>targettree</replaceable> install
</programlisting>
+</Para>
<para>
To override the library and header installation directories separately
<envar>LIBDIR</envar> and <envar>HEADERDIR</envar>
to be rooted at the new directory you specify.
<envar>ODBCINST</envar> is independent of <envar>POSTGRESDIR</envar>.
+</Para>
<para>
Here is how you would specify the various destinations explicitly:
<programlisting>
% make BINDIR=<replaceable>bindir</replaceable> LIBDIR=<replaceable>libdir</replaceable> HEADERDIR=<replaceable>headerdir</replaceable> install
</programlisting>
+</Para>
<para>
For example, typing
will cause the libraries and headers to be installed in the directories
<filename>/opt/psqlodbc/lib</filename>
and <filename>/opt/psqlodbc/include/iodbc</filename> respectively.
+</Para>
<para>
The command
should cause the libraries to be installed in /opt/psqlodbc/lib and
the headers in /usr/local/include/iodbc. If this doesn't work as
expected please contact one of the maintainers.
-
+</Para>
+</step>
</procedure>
+</sect2>
+</sect1>
<sect1>
<title>Configuration Files</title>
for the <productname>psqlODBC</productname> driver.
The file uses conventions typical for <productname>Windows</productname>
Registry files, but despite this restriction can be made to work.
+</Para>
<para>
The <filename>.odbc.ini</filename> file has three required sections.
usually a single word, without path names of any sort.
The <productname>Postgres</productname> server manages the actual access
to the database, and you need only specify the name from the client.
+</Para>
</tip>
Other entries may be inserted to control the format of the display.
The third required section is <literal>[ODBC]</literal>
which must contain the <literal>InstallDir</literal> keyword
and which may contain other options.
+</Para>
<para>
Here is an example <filename>.odbc.ini</filename> file,
[ODBC]
InstallDir = /opt/applix/axdata/axshlib
</programlisting>
-
+</Para>
+</sect1>
<sect1>
<title>ApplixWare</title>
-<para>
-
<sect2>
<title>Configuration</title>
in order for it to
be able to access the <productname>Postgres</productname>
<acronym>ODBC</acronym> software drivers.
+</Para>
<procedure>
<title>Enabling ApplixWare Database Access</title>
<productname>ApplixWare</productname> on <productname>Linux</productname>.
Refer to the <citetitle>Linux Sys Admin</citetitle> on-line book
for more detailed information.
+</Para>
<step performance="required">
<para>
This library is included with the ApplixWare distribution,
but <filename>axnet.cnf</filename> needs to be modified to point to the
correct location.
+</Para>
<para>
As root, edit the file
<filename><replaceable>applixroot</replaceable>/applix/axdata/axnet.cnf</filename>.
+</Para>
<substeps>
<programlisting>
#libFor elfodbc /ax/<replaceable>...</replaceable>
</programlisting>
-
+</Para>
+</step>
<step performance="required">
<para>
Change line to read
for the <acronym>ODBC</acronym> support library.
If you have installed applix somewhere else,
change the path accordingly.
-
+</Para>
+</step>
</substeps>
+</step>
<step performance="required">
<para>
to the database-specific portion of <filename>.odbc.ini</filename>
so that text fields will not be shown as <literal>**BLOB**</literal>.
-
+</Para>
+</step>
</procedure>
<procedure>
<step performance="required">
<para>
Bring up <application>Applix Data</application>
+</Para>
+</step>
<step performance="required">
<para>
Select the <productname>Postgres</productname> database of interest.
+</Para>
<substeps>
<step performance="required">
<para>
Select <command>Query->Choose Server</command>.
-
+</Para>
+</step>
<step performance="required">
<para>
Select <acronym>ODBC</acronym>, and click <command>Browse</command>.
should be shown. Make sure that the <option>Host: field</option>
is empty (if it is not, axnet will try to contact axnet on another machine
to look for the database).
-
+</Para>
+</step>
<step performance="required">
<para>
Select the database in the box that was launched by <command>Browse</command>,
then click <command>OK</command>.
-
+</Para>
+</step>
<step performance="required">
<para>
Enter username and password in the login identification dialog,
and click <command>OK</command>.
-
+</Para>
+</step>
</substeps>
<para>
in the lower left corner of the
data window. If you get an error dialog box, see the debugging section
below.
-
+</Para>
+</step>
<step performance="required">
<para>
The 'Ready' message will appear in the lower left corner of the data
window. This indicates that you can now enter queries.
-
+</Para>
+</step>
<step performance="required">
<para>
Select a table from Query->Choose tables, and then select Query->Query
to access the database. The first 50 or so rows from the table should
appear.
-
+</Para>
+</step>
</procedure>
+</sect2>
<sect2>
<title>Common Problems</title>
<varlistentry>
<term>
Cannot launch gateway on server
-
+</term>
<listitem>
<para>
<literal>elfodbc</literal> can't find <filename>libodbc.so</filename>.
Check your <filename>axnet.cnf</filename>.
+</Para>
+</listitem>
+</varlistentry>
<varlistentry>
<term>
Error from ODBC Gateway:
IM003::[iODBC][Driver Manager]Specified driver could not be loaded
-
+</term>
<listitem>
<para>
<filename>libodbc.so</filename> cannot find the driver listed in
<filename>.odbc.ini</filename>. Verify the settings.
+</Para>
+</listitem>
+</varlistentry>
<varlistentry>
<term>
Server: Broken Pipe
+</term>
<listitem>
<para>
problem. You might not have an up-to-date version
of the <productname>Postgres</productname>
<acronym>ODBC</acronym> package.
+</Para>
+</listitem>
+</varlistentry>
<varlistentry>
<term>
setuid to 256: failed to launch gateway
+</term>
<listitem>
<para>
exceed eight (8) characters in length.
Problem description ontributed by
<ulink url="mailto:scampbell@lear.com">Steve Campbell</ulink>.
+</Para>
+</listitem>
+</varlistentry>
</variablelist>
+</para>
<para>
<note>
Contributed by
<ulink url="mailto:scampbell@lear.com">Steve Campbell</ulink> on
1998-10-20.
+</para>
</note>
The <application>axnet</application> program's security system
(so it can read/write in each user's directory).
I would hesitate to recommend this, however, since we have no idea what
security holes this creates.
+</para>
+</sect2>
<sect2>
<title>Debugging ApplixWare ODBC Connections</title>
<para>
One good tool for debugging connection problems uses the Unix system
utility <application>strace</application>.
-
+</para>
<procedure>
<title>Debugging with strace</title>
<step performance="required">
<para>
Start applixware.
-
+</para>
+</step>
<step performance="required">
<para>
Start an <application>strace</application> on
cary 10432 0.0 2.6 1740 392 ? S Oct 9 0:00 axnet
cary 27883 0.9 31.0 12692 4596 ? S 10:24 0:04 axmain
</programlisting>
+</para>
<para>
Then run
<programlisting>
strace -f -s 1024 -p 10432
</programlisting>
+</para>
+</step>
<step performance="required">
<para>
Check the strace output.
-
+</para>
<note>
<title>Note from Cary</title>
go to <filename>stderr</filename>,
but I'm not sure where <filename>stderr</filename>
is sent, so <application>strace</application> is the way to find out.
+</para>
</note>
-
+</step>
</procedure>
<para>
</programlisting>
So what is happening is that applix elfodbc is searching for libodbc.so, but it
can't find it. That is why axnet.cnf needed to be changed.
+</para>
+</sect2>
<sect2>
<title>Running the ApplixWare Demo</title>
create the tables tries to use a NULL condition
on many of the database columns,
and <productname>Postgres</productname> does not currently allow this option.
-
+</para>
<para>
To get around this problem, you can do the following:
+</para>
<procedure>
<title>Modifying the ApplixWare Demo</title>
<para>
Copy <filename>/opt/applix/axdata/eng/Demos/sqldemo.am</filename>
to a local directory.
+</para>
+</step>
<step performance="required">
<para>
Edit this local copy of <filename>sqldemo.am</filename>:
+</para>
<substeps>
<step performance="required">
<para>
Search for 'null_clause = "NULL"
+</para>
+</step>
<step performance="required">
<para>
Change this to null_clause = ""
+</para>
+</step>
</substeps>
-
+</step>
<step performance="required">
<para>
Start <application>Applix Macro Editor</application>.
+</para>
+</step>
<step performance="required">
<para>
Open the sqldemo.am file from the <application>Macro Editor</application>.
+</para>
+</step>
<step performance="required">
<para>
Select <command>File->Compile and Save</command>.
+</para>
+</step>
<step performance="required">
<para>
Exit <application>Macro Editor</application>.
+</para>
+</step>
<step performance="required">
<para>
Start <application>Applix Data</application>.
+</para>
+</step>
<step performance="required">
<para>
Select <command>*->Run Macro</command>
+</para>
+</step>
<step performance="required">
<para>
Enter the value <quote>sqldemo</quote>, then click <command>OK</command>.
+</para>
<para>
You should see the progress in the status line of the data window
(in the lower left corner).
+</para>
+</step>
<step performance="required">
<para>
You should now be able to access the demo tables.
-
+</para>
+</step>
</procedure>
-
+</sect2>
<sect2>
<title>Useful Macros</title>
in order for it to
be able to access the <productname>Postgres</productname>
<acronym>ODBC</acronym> software drivers.
-
+</para>
<procedure>
<title>Enabling ApplixWare Database Access</title>
<productname>ApplixWare</productname> on <productname>Linux</productname>.
Refer to the <citetitle>Linux Sys Admin</citetitle> on-line book
for more detailed information.
-
+</para>
<step performance="required">
<para>
You must modify <filename>axnet.cnf</filename> so that
This library is included with the ApplixWare distribution,
but <filename>axnet.cnf</filename> needs to be modified to point to the
correct location.
-
+</para>
<para>
As root, edit the file
<filename><replaceable>applixroot</replaceable>/applix/axdata/axnet.cnf</filename>.
-
+</para>
<substeps>
<step performance="required">
<programlisting>
#libFor elfodbc /ax/<replaceable>...</replaceable>
</programlisting>
+</para>
+</step>
<step performance="required">
<para>
for the <acronym>ODBC</acronym> support library.
If you have installed applix somewhere else,
change the path accordingly.
+</para>
+</step>
</substeps>
+</step>
<step performance="required">
<para>
to the database-specific portion of <filename>.odbc.ini</filename>
so that text fields will not be shown as <literal>**BLOB**</literal>.
+</para>
+</step>
</procedure>
<step performance="required">
<para>
Bring up <application>Applix Data</application>
+</para>
+</step>
<step performance="required">
<para>
Select the <productname>Postgres</productname> database of interest.
+</para>
<substeps>
<step performance="required">
<para>
Select <command>Query->Choose Server</command>.
+</para>
+</step>
<step performance="required">
<para>
should be shown. Make sure that the <option>Host: field</option>
is empty (if it is not, axnet will try to contact axnet on another machine
to look for the database).
+</para>
+</step>
<step performance="required">
<para>
Select the database in the box that was launched by <command>Browse</command>,
then click <command>OK</command>.
+</para>
+</step>
<step performance="required">
<para>
Enter username and password in the login identification dialog,
and click <command>OK</command>.
+</para>
+</step>
</substeps>
in the lower left corner of the
data window. If you get an error dialog box, see the debugging section
below.
-
+</para>
+</step>
<step performance="required">
<para>
The 'Ready' message will appear in the lower left corner of the data
window. This indicates that you can now enter queries.
+</para>
+</step>
<step performance="required">
<para>
Select a table from Query->Choose tables, and then select Query->Query
to access the database. The first 50 or so rows from the table should
appear.
+</para>
+</step>
</procedure>
+</sect2>
<sect2>
<title>Common Problems</title>
<varlistentry>
<term>
Cannot launch gateway on server
-
+</term>
<listitem>
<para>
<literal>elfodbc</literal> can't find <filename>libodbc.so</filename>.
Check your <filename>axnet.cnf</filename>.
-
+</para>
+</listitem>
+</varlistentry>
<varlistentry>
<term>
Error from ODBC Gateway:
IM003::[iODBC][Driver Manager]Specified driver could not be loaded
+</term>
<listitem>
<para>
<filename>libodbc.so</filename> cannot find the driver listed in
<filename>.odbc.ini</filename>. Verify the settings.
+</para>
+</listitem>
+</varlistentry>
<varlistentry>
<term>
Server: Broken Pipe
+</term>
<listitem>
<para>
problem. You might not have an up-to-date version
of the <productname>Postgres</productname>
<acronym>ODBC</acronym> package.
+</para>
+</listitem>
+</varlistentry>
</variablelist>
+</para>
+</sect2>
<sect2>
<title>Debugging ApplixWare ODBC Connections</title>
<para>
One good tool for debugging connection problems uses the Unix system
utility <application>strace</application>.
-
+</para>
<procedure>
<title>Debugging with strace</title>
<step performance="required">
<para>
Start applixware.
-
+</para>
+</step>
<step performance="required">
<para>
Start an <application>strace</application> on
cary 10432 0.0 2.6 1740 392 ? S Oct 9 0:00 axnet
cary 27883 0.9 31.0 12692 4596 ? S 10:24 0:04 axmain
</programlisting>
+</para>
<para>
Then run
<programlisting>
strace -f -s 1024 -p 10432
</programlisting>
-
+</para>
+</step>
<step performance="required">
<para>
Check the strace output.
+</para>
<note>
<title>Note from Cary</title>
go to <filename>stderr</filename>,
but I'm not sure where <filename>stderr</filename>
is sent, so <application>strace</application> is the way to find out.
+</para>
</note>
-
+</step>
</procedure>
<para>
</programlisting>
So what is happening is that applix elfodbc is searching for libodbc.so, but it
can't find it. That is why axnet.cnf needed to be changed.
-
+</para>
+</sect2>
<sect2>
<title>Running the ApplixWare Demo</title>
create the tables tries to use a NULL condition
on many of the database columns,
and <productname>Postgres</productname> does not currently allow this option.
+</para>
<para>
To get around this problem, you can do the following:
+</para>
<procedure>
<title>Modifying the ApplixWare Demo</title>
<para>
Copy <filename>/opt/applix/axdata/eng/Demos/sqldemo.am</filename>
to a local directory.
+</para>
+</step>
<step performance="required">
<para>
Edit this local copy of <filename>sqldemo.am</filename>:
+</para>
<substeps>
<step performance="required">
<para>
Search for 'null_clause = "NULL"
+</para>
+</step>
<step performance="required">
<para>
Change this to null_clause = ""
-
+</para>
+</step>
</substeps>
-
+</step>
<step performance="required">
<para>
Start <application>Applix Macro Editor</application>.
-
+</para>
+</step>
<step performance="required">
<para>
Open the sqldemo.am file from the <application>Macro Editor</application>.
+</para>
+</step>
<step performance="required">
<para>
Select <command>File->Compile and Save</command>.
+</para>
+</step>
<step performance="required">
<para>
Exit <application>Macro Editor</application>.
+</para>
+</step>
<step performance="required">
<para>
Start <application>Applix Data</application>.
+</para>
+</step>
<step performance="required">
<para>
Select <command>*->Run Macro</command>
+</para>
+</step>
<step performance="required">
<para>
Enter the value <quote>sqldemo</quote>, then click <command>OK</command>.
+</para>
<para>
You should see the progress in the status line of the data window
(in the lower left corner).
+</para>
+</step>
<step performance="required">
<para>
You should now be able to access the demo tables.
+</para>
+</step>
</procedure>
+</sect2>
<sect2>
<title>Useful Macros</title>
<para>
You should be careful about the file protections on any file containing
username and password information.
+</para>
</caution>
-
+</para>
+</sect2>
<sect2>
<title>Supported Platforms</title>
with FreeBSD and with Solaris. There are no known restrictions
on the basic code for other platforms which already support
<productname>Postgres</productname>.
-
+</para>
+</sect2>
+</sect1>
</Chapter>
<!-- Keep this comment at the end of the file
sgml-indent-step:1
sgml-indent-data:t
sgml-parent-document:nil
-sgml-default-dtd-file:"../reference.ced"
+sgml-default-dtd-file:"./reference.ced"
sgml-exposed-tags:nil
-sgml-local-catalogs:"/usr/lib/sgml/catalog"
+sgml-local-catalogs:"/usr/lib/sgml/CATALOG"
sgml-local-ecat-files:nil
End:
-->
pg_operator. Every entry in pg_operator includes
the name of the procedure that implements the operator and the
class <Acronym>OIDs</Acronym> of the input and output types.
+</Para>
<Para>
To view all variations of the <Quote>||</Quote> string concatenation operator,
<ProgramListing>
select * from emp where int4lt(salary, 40000);
</ProgramListing>
+</Para>
<Para>
<Application>psql</Application>
has a command (<Command>\dd</Command>) to show these operators.
-
+</Para>
<sect1>
<title>Lexical Precedence</title>
<row>
<entry>
Element
+</entry>
<entry>
Precedence
+</entry>
<entry>
Description
+</entry>
+</row>
</thead>
<tbody>
<row>
<entry>
UNION
+</entry>
<entry>
left
+</entry>
<entry>
SQL select construct
+</entry>
+</row>
<row>
<entry>
::
+</entry>
<entry>
+</entry>
<entry>
<productname>Postgres</productname> typecasting
-
+</entry>
+</row>
<row>
<entry>
[ ]
+</entry>
<entry>
left
+</entry>
<entry>
array delimiters
-
+</entry>
+</row>
<row>
<entry>
.
+</entry>
<entry>
left
+</entry>
<entry>
table/column delimiter
-
+</entry>
+</row>
<row>
<entry>
-
+</entry>
<entry>
right
+</entry>
<entry>
unary minus
-
+</entry>
+</row>
<row>
<entry>
;
+</entry>
<entry>
left
+</entry>
<entry>
statement termination, logarithm
-
+</entry>
+</row>
<row>
<entry>
:
+</entry>
<entry>
right
+</entry>
<entry>
exponentiation
-
+</entry>
+</row>
<row>
<entry>
|
+</entry>
<entry>
left
+</entry>
<entry>
start of interval
-
+</entry>
+</row>
<row>
<entry>
* /
+</entry>
<entry>
left
+</entry>
<entry>
multiplication, division
-
+</entry>
+</row>
<row>
<entry>
+ -
+</entry>
<entry>
left
+</entry>
<entry>
addition, subtraction
-
+</entry>
+</row>
<row>
<entry>
IS
+</entry>
<entry>
+</entry>
<entry>
test for TRUE, FALSE, NULL
+</entry>
+</row>
<row>
<entry>
ISNULL
+</entry>
<entry>
+</entry>
<entry>
test for NULL
-
+</entry>
+</row>
<row>
<entry>
NOTNULL
+</entry>
<entry>
+</entry>
<entry>
test for NOT NULL
-
+</entry>
+</row>
<row>
<entry>
(all other operators)
+</entry>
<entry>
+</entry>
<entry>
native and user-defined
-
+</entry>
+</row>
<row>
<entry>
IN
+</entry>
<entry>
+</entry>
<entry>
set membership
-
+</entry>
+</row>
<row>
<entry>
BETWEEN
+</entry>
<entry>
+</entry>
<entry>
containment
-
+</entry>
+</row>
<row>
<entry>
LIKE
+</entry>
<entry>
+</entry>
<entry>
string pattern matching
-
+</entry>
+</row>
<row>
<entry>
< >
+</entry>
<entry>
+</entry>
<entry>
boolean inequality
-
+</entry>
+</row>
<row>
<entry>
=
+</entry>
<entry>
right
+</entry>
<entry>
equality
-
+</entry>
+</row>
<row>
<entry>
NOT
+</entry>
<entry>
right
+</entry>
<entry>
negation
-
+</entry>
+</row>
<row>
<entry>
AND
+</entry>
<entry>
left
+</entry>
<entry>
logical intersection
-
+</entry>
+</row>
<row>
<entry>
OR
+</entry>
<entry>
left
+</entry>
<entry>
logical union
-
+</entry>
+</row>
</tbody>
+</tgroup>
</table>
+</para>
+</sect1>
<sect1>
<title>General Operators</title>
<para>
The operators listed here are defined for a number of native data types,
ranging from numeric types to data/time types.
-
+</para>
<Para>
<TABLE TOCENTRY="1">
<TITLE><ProductName>Postgres</ProductName> Operators</TITLE>
</TGROUP>
</TABLE>
</Para>
+</sect1>
<sect1>
<title id="math-opers">Numerical Operators</title>
</TGROUP>
</TABLE>
</Para>
+</sect1>
<sect1>
<title>Geometric Operators</title>
</TGROUP>
</TABLE>
</Para>
+</sect1>
<sect1>
<title>Time Interval Operators</title>
</TGROUP>
</TABLE>
</Para>
+</sect1>
<Sect1>
<title id="cidr-opers">IP V4 Operators</title>
<para>
This section provides an overview of the page format used by <productname>Postgres</productname>
classes. User-defined access methods need not use this page format.
+</para>
<para>
In the following explanation, a
is assumed to contain 8 bits. In addition, the term
<firstterm>item</firstterm>
refers to data which is stored in <productname>Postgres</productname> classes.
+</para>
<sect1>
<title>Page Structure</title>
</entry>
</row>
</thead>
+
<tbody>
+
<row>
<entry>
itemPointerData
</entry>
+</row>
+
<row>
<entry>
filler
</entry>
+</row>
+
<row>
<entry>
itemData...
</entry>
+</row>
+
<row>
<entry>
Unallocated Space
</entry>
+</row>
+
<row>
<entry>
ItemContinuationData
</entry>
+</row>
+
<row>
<entry>
Special Space
</entry>
+</row>
+
<row>
<entry>
``ItemData 2''
</entry>
+</row>
+
<row>
<entry>
``ItemData 1''
</entry>
+</row>
+
<row>
<entry>
ItemIdData
</entry>
+</row>
+
<row>
<entry>
PageHeaderData
</entry>
+</row>
+
</tbody>
</tgroup>
</table>
+</para>
<!--
.\" Running
buffer pool may be subdivided into equal sized pages on a frame by
frame basis within a class. The internal fragmentation information is
used to aid in determining when page reorganization should occur.
+</para>
<para>
Following the page header are item identifiers
identifier. An item identifier contains a byte-offset to the start of
an item, its length in bytes, and a set of attribute bits which affect
its interpretation.
+</para>
<para>
The items themselves are stored in space allocated backwards from
itemPointerData
which points to the next piece and the piece itself. The last piece
is handled normally.
+</para>
+</sect1>
<sect1>
<title>Files</title>
<listitem>
<para>
Location of shared (global) database files.
+</para>
+</listitem>
+</varlistentry>
<varlistentry>
<term>
<listitem>
<para>
Location of local database files.
+</para>
+</listitem>
+</varlistentry>
</variablelist>
+</para>
+</sect1>
<sect1>
<title>Bugs</title>
<para>
The page format may change in the future to provide more efficient
access to large objects.
+</para>
<para>
This section contains insufficient detail to be of any assistance in
writing a new access method.
-
+</para>
+</sect1>
</chapter>
Contributed by <ULink url="mailto:dz@cs.unitn.it">Massimo Dal Zotto</ULink>
</Para>
</Note>
-
+</para>
<Para>
The optional file <filename>data/pg_options</filename> contains runtime
options used by the backend to control trace messages and other backend
New options and parameters must be defined in
<filename>backend/utils/misc/trace.c</filename> and
<filename>backend/include/utils/trace.h</filename>.
-
+</para>
<Para>
For example suppose we want to add conditional trace messages and a tunable
numeric parameter to the code in file <filename>foo.c</filename>.
}
}
</programlisting>
-
+</para>
<para>
Existing files using private trace flags can be changed by simply adding
the following code:
/* int my_own_flag = 0; -- removed */
#define my_own_flag pg_options[OPT_MY_OWN_FLAG]
</programlisting>
-
+</para>
<para>
All pg_options are initialized to zero at backend startup. If we need a
different default value we must add some initialization code at the beginning
foo=1
fooparam=17
</programlisting>
-
+</para>
<para>
The new options will be read by all new backends when they are started.
To make effective the changes for all running backends we need to send a
SIGHUP to the postmaster. The signal will be automatically sent to all the
backends. We can also activate the changes only for a specific backend by
sending the SIGHUP directly to it.
-
+</para>
<para>
pg_options can also be specified with the <option>-T</option> switch of
<productname>Postgres</productname>:
<programlisting>
postgres <replaceable>options</replaceable> -T "verbose=2,query,hostlookup-"
</programlisting>
-
+</para>
<Para>
The functions used for printing errors and debug messages can now make use
of the <citetitle>syslog(2)</citetitle> facility. Message printed to stdout
980127.19:52:14.413 [29286] Async_NotifyFrontEnd done
980127.19:52:14.466 [29286] Async_NotifyHandler done
</programlisting>
-
+</para>
<para>
This format improves readability of the logs and allows people to understand
exactly which backend is doing what and at which time. It also makes
easier to write simple awk or perl scripts which monitor the log to
detect database errors or problem, or to compute transaction time statistics.
-
+</para>
<para>
Messages printed to syslog use the log facility LOG_LOCAL0.
The use of syslog can be controlled with the syslog pg_option.
<varlistentry>
<term>
all
-
+</term>
<listitem>
<para>
Global trace flag. Allowed values are:
+</para>
<variablelist>
<varlistentry>
<term>
0
-
+</term>
<listitem>
<para>
Trace messages enabled individually
+</para>
+</listitem>
+</varlistentry>
<varlistentry>
<term>
1
-
+</term>
<listitem>
<para>
Enable all trace messages
+</para>
+</listitem>
+</varlistentry>
<varlistentry>
<term>
-1
-
+</term>
<listitem>
<para>
Disable all trace messages
+</para>
+</listitem>
+</varlistentry>
</variablelist>
+</listitem>
+</varlistentry>
<varlistentry>
<term>
verbose
-
+</term>
<listitem>
<para>
Verbosity flag. Allowed values are:
+</para>
<variablelist>
<varlistentry>
<term>
0
-
+</term>
<listitem>
<para>
No messages. This is the default.
+</para>
+</listitem>
+</varlistentry>
<varlistentry>
<term>
1
-
+</term>
<listitem>
<para>
Print information messages.
+</para>
+</listitem>
+</varlistentry>
<varlistentry>
<term>
2
-
+</term>
<listitem>
<para>
Print more information messages.
+</para>
+</listitem>
+</varlistentry>
</variablelist>
+</listitem>
+</varlistentry>
<varlistentry>
<term>
query
-
+</term>
<listitem>
<para>
Query trace flag. Allowed values are:
+</para>
<variablelist>
<varlistentry>
<term>
0
-
+</term>
<listitem>
<para>
Don't print query.
+</para>
+</listitem>
+</varlistentry>
<varlistentry>
<term>
1
-
+</term>
<listitem>
<para>
Print a condensed query in one line.
+</para>
+</listitem>
+</varlistentry>
<varlistentry>
<term>
4
-
+</term>
<listitem>
<para>
Print the full query.
+</para>
+</listitem>
+</varlistentry>
</variablelist>
+</listitem>
+</varlistentry>
<varlistentry>
<term>
plan
-
+</term>
<listitem>
<para>
Print query plan.
+</para>
+</listitem>
+</varlistentry>
<varlistentry>
<term>
parse
-
+</term>
<listitem>
<para>
Print parser output.
+</para>
+</listitem>
+</varlistentry>
<varlistentry>
<term>
rewritten
-
+</term>
<listitem>
<para>
Print rewritten query.
+</para>
+</listitem>
+</varlistentry>
<varlistentry>
<term>
parserstats
-
+</term>
<listitem>
<para>
Print parser statistics.
+</para>
+</listitem>
+</varlistentry>
<varlistentry>
<term>
plannerstats
-
+</term>
<listitem>
<para>
Print planner statistics.
+</para>
+</listitem>
+</varlistentry>
<varlistentry>
<term>
executorstats
-
+</term>
<listitem>
<para>
Print executor statistics.
-
+</para>
+</listitem>
+</varlistentry>
<varlistentry>
<term>
shortlocks
-
+</term>
<listitem>
<para>
Currently unused but needed to enable features in the future.
+</para>
+</listitem>
+</varlistentry>
<varlistentry>
<term>
locks
-
+</term>
<listitem>
<para>
Trace locks.
+</para>
+</listitem>
+</varlistentry>
<varlistentry>
<term>
userlocks
-
+</term>
<listitem>
<para>
Trace user locks.
+</para>
+</listitem>
+</varlistentry>
<varlistentry>
<term>
spinlocks
-
+</term>
<listitem>
<para>
Trace spin locks.
+</para>
+</listitem>
+</varlistentry>
<varlistentry>
<term>
notify
-
+</term>
<listitem>
<para>
Trace notify functions.
-
+</para>
+</listitem>
+</varlistentry>
<varlistentry>
<term>
malloc
-
+</term>
<listitem>
<para>
Currently unused.
+</para>
+</listitem>
+</varlistentry>
<varlistentry>
<term>
palloc
-
+</term>
<listitem>
<para>
Currently unused.
+</para>
+</listitem>
+</varlistentry>
<varlistentry>
<term>
lock_debug_oidmin
-
+</term>
<listitem>
<para>
Minimum relation oid traced by locks.
+</para>
+</listitem>
+</varlistentry>
<varlistentry>
<term>
lock_debug_relid
-
+</term>
<listitem>
<para>
oid, if not zero, of relation traced by locks.
+</para>
+</listitem>
+</varlistentry>
<varlistentry>
<term>
lock_read_priority
-
+</term>
<listitem>
<para>
Currently unused.
-
+</para>
+</listitem>
+</varlistentry>
<varlistentry>
<term>
deadlock_timeout
-
+</term>
<listitem>
<para>
Deadlock check timer.
+</para>
+</listitem>
+</varlistentry>
<varlistentry>
<term>
syslog
-
+</term>
<listitem>
<para>
syslog flag. Allowed values are:
+</para>
<variablelist>
<varlistentry>
<term>
0
-
+</term>
<listitem>
<para>
Messages to stdout/stderr.
+</para>
+</listitem>
+</varlistentry>
<varlistentry>
<term>
1
-
+</term>
<listitem>
<para>
Messages to stdout/stderr and syslog.
+</para>
+</listitem>
+</varlistentry>
<varlistentry>
<term>
2
-
+</term>
<listitem>
<para>
Messages only to syslog.
+</para>
+</listitem>
+</varlistentry>
</variablelist>
+</listitem>
+</varlistentry>
<varlistentry>
<term>
hostlookup
-
+</term>
<listitem>
<para>
Enable hostname lookup in ps_status.
+</para>
+</listitem>
+</varlistentry>
<varlistentry>
<term>
showportnumber
-
+</term>
<listitem>
<para>
Show port number in ps_status.
+</para>
+</listitem>
+</varlistentry>
<varlistentry>
<term>
notifyunlock
-
+</term>
<listitem>
<para>
Unlock of pg_listener after notify.
+</para>
+</listitem>
+</varlistentry>
<varlistentry>
<term>
notifyhack
-
+</term>
<listitem>
<para>
Remove duplicate tuples from pg_listener.
+</para>
+</listitem>
+</varlistentry>
</variablelist>
number of platforms. Check
<ulink url="http://www.postgresql.org/docs/admin/ports.htm">the web site</ulink>
for the latest information.
+</para>
<Sect1>
<Title>Currently Supported Platforms</Title>
</TBODY>
</TGROUP>
</TABLE>
-
+</para>
<para>
Platforms listed for v6.3.x should also work with v6.4, but we did not receive
confirmation of such at the time this list was compiled.
-
+</para>
<note>
<para>
For <productname>Windows NT</productname>,
for up to date information. You may also want to
look for possible patches on the
<ulink url="http://postgresql.org">Postgres web site</ulink>.
+</para>
</note>
+</sect1>
<Sect1>
<Title>Unsupported Platforms</Title>
</TBODY>
</TGROUP>
</TABLE>
+</para>
<Para>
Note that Windows ports of the frontend are apparently possible
Updates for protocol 2.0 by <ULink url="mailto:tgl@sss.pgh.pa.us">Tom Lane</ULink>.
</Para>
</Note>
+</para>
<Para>
<ProductName>Postgres</ProductName> uses a message-based protocol for communication between frontends
This was done in such
a way as to still allow connections from earlier versions of frontends, but
this document does not cover the protocol used by those earlier versions.
+</para>
<Para>
This document describes version 2.0 of the protocol, implemented in
<ProductName>Postgres</ProductName> v6.4 and later.
+</para>
<Para>
Higher level features built on this protocol (for example, how <FileName>libpq</FileName> passes
certain environment variables after the connection is established)
are covered elsewhere.
+</para>
<Sect1>
<Title>Overview</Title>
The three major components are the frontend (running on the client) and the
postmaster and backend (running on the server). The postmaster and backend
have different roles but may be implemented by the same executable.
+</para>
<Para>
A frontend sends a startup packet to the postmaster. This includes the names
uses this, and the information in the pg_hba.conf(5) file to determine what
further authentication information it requires the frontend to send (if any)
and responds to the frontend accordingly.
+</para>
<Para>
The frontend then sends any required authentication information. Once the
and hands over the connection to a backend. The backend then sends a message
indicating successful startup (normal case) or failure (for example, an
invalid database name).
+</para>
<Para>
Subsequent communications are query and result packets exchanged between the
query/result communication. (However, the postmaster is involved when the
frontend wishes to cancel a query currently being executed by its backend.
Further details about that appear below.)
+</para>
<Para>
When the frontend wishes to disconnect it sends an appropriate packet and
closes the connection without waiting for a response for the backend.
+</para>
<Para>
Packets are sent as a data stream. The first byte determines what should be
expected in the rest of the packet. The exception is packets sent from a
frontend to the postmaster, which comprise a packet length then the packet
itself. The difference is historical.
+</para>
+</sect1>
<Sect1>
<Title>Protocol</Title>
startup, query, function call, and termination.
There are also special provisions for notification responses and command
cancellation, which can occur at any time after the startup phase.
+</para>
<Sect2>
<Para>
Startup is divided into an authentication phase and a backend startup phase.
+</para>
<Para>
Initially, the frontend sends a StartupPacket. The postmaster uses this info
and the contents of the pg_hba.conf(5) file to determine what authentication
method the frontend must use. The postmaster then responds with one of the
following messages:
+</para>
<Para>
<VariableList>
<Para>
If the frontend does not support the authentication method requested by the
postmaster, then it should immediately close the connection.
+</para>
<Para>
After sending AuthenticationOk, the postmaster attempts to launch a backend
successful startup. The frontend should send no messages at this point.
The possible messages from the backend during this phase are:
-<Para>
<VariableList>
<VarListEntry>
<Term>
BackendKeyData indicates successful conclusion of the startup phase),
or to consider ReadyForQuery as ending the startup phase and each subsequent
query cycle.
-
+</para>
+</sect2>
<Sect2>
<Title>Query</Title>
on the contents of the query command string, and finally a ReadyForQuery
response message. ReadyForQuery informs the frontend that it may safely
send a new query or function call.
+</para>
<Para>
The possible response messages from the backend are:
-<Para>
<VariableList>
<VarListEntry>
<Term>
<Para>
A frontend must be prepared to accept ErrorResponse and NoticeResponse
messages whenever it is expecting any other type of message.
+</para>
<Para>
Actually, it is possible for NoticeResponse to arrive even when the frontend
In that case it will send a NoticeResponse before closing the connection.)
It is recommended that the frontend check for such asynchronous notices just
before issuing any new command.
+</para>
<Para>
Also, if the frontend issues any listen(l) commands then it must be prepared
to accept NotificationResponse messages at any time; see below.
-
+</para>
+</sect2>
<Sect2>
<Title>Function Call</Title>
depending on the results of the function call, and finally a ReadyForQuery
response message. ReadyForQuery informs the frontend that it may safely send
a new query or function call.
+</para>
<Para>
The possible response messages from the backend are:
-<Para>
<VariableList>
<VarListEntry>
<Term>
messages whenever it is expecting any other type of message. Also,
if it issues any listen(l) commands then it must be prepared to accept
NotificationResponse messages at any time; see below.
-
+</para>
+</sect2>
<Sect2>
<Title>Notification Responses</Title>
If a frontend issues a listen(l) command, then the backend will send a
NotificationResponse message (not to be confused with NoticeResponse!)
whenever a notify(l) command is executed for the same notification name.
+</para>
<Para>
Notification responses are permitted at any point in the protocol (after
expecting any message. Indeed, it should be able to handle
NotificationResponse messages even when it is not engaged in a query.
-<Para>
<VariableList>
<VarListEntry>
<Term>
commands need not have anything to do with names of relations (tables)
in the SQL database. Notification names are simply arbitrarily chosen
condition names.
-
+</para>
+</sect2>
<Sect2>
<Title>Cancelling Requests in Progress</Title>
the frontend during query processing. Cancel requests should be relatively
infrequent, so we make them slightly cumbersome in order to avoid a penalty
in the normal case.
+</para>
<Para>
To issue a cancel request, the frontend opens a new connection to the
message that would ordinarily be sent across a new connection. The postmaster
will process this request and then close the connection. For security
reasons, no direct reply is made to the cancel request message.
+</para>
<Para>
A CancelRequest message will be ignored unless it contains the same key data
(PID and secret key) passed to the frontend during connection startup. If the
request matches the PID and secret key for a currently executing backend, the
postmaster signals the backend to abort processing of the current query.
+</para>
<Para>
The cancellation signal may or may not have any effect --- for example, if it
arrives after the backend has finished processing the query, then it will have
no effect. If the cancellation is effective, it results in the current
command being terminated early with an error message.
+</para>
<Para>
The upshot of all this is that for reasons of both security and efficiency,
cancel simply improves the odds that the current query will finish soon,
and improves the odds that it will fail with an error message instead of
succeeding.
+</para>
<Para>
Since the cancel request is sent to the postmaster and not across the
unauthorized persons might try to cancel queries. The security risk is
addressed by requiring a dynamically generated secret key to be supplied
in cancel requests.
-
+</para>
+</sect2>
<Sect2>
<Title>Termination</Title>
The normal, graceful termination procedure is that the frontend sends a
Terminate message and immediately closes the connection. On receipt of the
message, the backend immediately closes the connection and terminates.
+</para>
<Para>
An ungraceful termination may occur due to software failure (i.e., core dump)
the connection, it should clean up and terminate. The frontend has the option
of launching a new backend by recontacting the postmaster, if it doesn't want
to terminate itself.
-
+</para>
+</sect2>
+</sect1>
<Sect1>
<Title>Message Data Types</Title>
<Para>
This section describes the base data types used in messages.
-<Para>
<VariableList>
<VarListEntry>
<Term>
</VarListEntry>
</VariableList>
</Para>
+</sect1>
<Sect1>
<Title>Message Formats</Title>
<Para>
This section describes the detailed format of each message. Each can be sent
by either a frontend (F), a postmaster/backend (B), or both (F & B).
-
-<Para>
+</para>
<VariableList>
<VarListEntry>
</VarListEntry>
</VariableList>
-<Para>
-
</Para>
+
</ListItem>
</VarListEntry>
<VarListEntry>
</ListItem>
</VarListEntry>
</VariableList>
-</Para>
+</sect1>
</Chapter>
set or unset your PAGER environment variable. I always have to set mine
before it will pause. And of course you have to do this before
starting the program.
+</para>
<Para>
In csh/tcsh or other C shells:
<ProgramListing>
unset PAGER
</ProgramListing>
-
+</para>
+</sect1>
</Chapter>
single <FileName>postmaster</FileName> process constitutes an installation
or site.
</Para>
+</sect1>
<Sect1>
<Title>Creating a New Class</Title>
date date
);
</ProgramListing>
+</para>
<Para>
Note that keywords are case-insensitive and identifiers
are usually case-insensitive.
<Acronym>Postgres</Acronym> allows <Acronym>SQL92</Acronym> <FirstTerm>delimited identifiers</FirstTerm>
(identifiers surrounded by double-quotes) to include mixed-case and spaces, tabs, etc.
+</para>
<Para>
<ProductName>Postgres</ProductName> <Acronym>SQL</Acronym> supports the usual
classes have properties that are extensions of the
relational model.
</Para>
+</sect1>
<Sect1>
<Title>Populating a Class with Instances</Title>
INSERT INTO weather
VALUES ('San Francisco', 46, 50, 0.25, '11/27/1994')
</ProgramListing>
+</para>
<Para>
You can also use the <Command>copy</Command> command to perform load large
where the path name for the source file must be available to the backend server
machine, not just the client.
+</para>
+</sect1>
<Sect1>
<Title>Querying a Class</Title>
<ProgramListing>
SELECT city, (temp_hi+temp_lo)/2 AS temp_avg, date FROM weather;
</ProgramListing>
+</para>
<Para>
Arbitrary Boolean operators
ORDER BY city;
</ProgramListing>
</Para>
+</sect1>
<Sect1>
<Title>Redirecting SELECT Queries</Title>
<ProgramListing>
SELECT * INTO TABLE temp FROM weather;
</ProgramListing>
+</para>
<Para>
This forms an implicit <Command>create</Command> command, creating a new
then, of course, perform any operations on the resulting
class that we can perform on other classes.
</Para>
+</sect1>
<Sect1>
<Title>Joins Between Classes</Title>
the <Command>select distinct</Command> statement.
</Para>
</Note>
+</para>
<Para>
In this case, both W1 and W2 are surrogates for an
A query can contain an arbitrary number of
class names and surrogates.
</Para>
+</sect1>
<Sect1>
<Title>Updates</Title>
WHERE date > '11/28/1994';
</ProgramListing>
</Para>
+</sect1>
<Sect1>
<Title>Deletions</Title>
empty. The system will not request confirmation before
doing this.
</Para>
+</sect1>
<Sect1>
<Title>Using Aggregate Functions</Title>
GROUP BY city;
</ProgramListing>
</Para>
-
+</sect1>
</Chapter>
Consult these commands for more details;
for a listing, type <Literal>\?</Literal> at the <Application>psql</Application> prompt.
</Para>
+</sect1>
<Sect1>
<Title>Concepts</Title>
single <Application>postmaster</Application> process constitutes an installation
or site.
</Para>
+</sect1>
<Sect1>
<Title>Creating a New Class</Title>
date date
);
</ProgramListing>
+</para>
<Para>
Note that both keywords and identifiers are case-insensitive; identifiers can become
classes have properties that are extensions of the
relational model.
</Para>
+</sect1>
<Sect1>
<Title>Populating a Class with Instances</Title>
INSERT INTO weather
VALUES ('San Francisco', 46, 50, 0.25, '11/27/1994')
</ProgramListing>
+</Para>
<Para>
You can also use the <Command>copy</Command> command to perform load large
amounts of data from flat (<Acronym>ASCII</Acronym>) files.
</Para>
+</sect1>
<Sect1>
<Title>Querying a Class</Title>
<ProgramListing>
SELECT city, (temp_hi+temp_lo)/2 AS temp_avg, date FROM weather;
</ProgramListing>
+</Para>
<Para>
Arbitrary Boolean operators
ORDER BY city;
</ProgramListing>
</Para>
+</sect1>
<Sect1>
<Title>Redirecting SELECT Queries</Title>
<ProgramListing>
SELECT * INTO TABLE temp FROM weather;
</ProgramListing>
+</Para>
<Para>
This forms an implicit <Command>create</Command> command, creating a new
then, of course, perform any operations on the resulting
class that we can perform on other classes.
</Para>
+</sect1>
<Sect1>
<Title>Joins Between Classes</Title>
the <Command>select distinct</Command> statement.
</Para>
</Note>
+</para>
<Para>
In this case, both W1 and W2 are surrogates for an
A query can contain an arbitrary number of
class names and surrogates.
</Para>
+</sect1>
<Sect1>
<Title>Updates</Title>
WHERE date > '11/28/1994';
</ProgramListing>
</Para>
+</sect1>
<Sect1>
<Title>Deletions</Title>
empty. The system will not request confirmation before
doing this.
</Para>
+</sect1>
<Sect1>
<Title>Using Aggregate Functions</Title>
GROUP BY city;
</ProgramListing>
</Para>
-
+</sect1>
</Chapter>
<REFPURPOSE>
Aborts the current transaction
</REFPURPOSE>
+</REFNAMEDIV>
<REFSYNOPSISDIV>
<REFSYNOPSISDIVINFO>
<DATE>1998-09-27</DATE>
</TITLE>
<PARA>
None.
+</para>
</REFSECT2>
<LISTITEM>
<PARA>
Message returned if successful.
-
+</para>
+</listitem>
+</VARLISTENTRY>
<VARLISTENTRY>
<TERM>
NOTICE: UserAbortTransactionBlock and not in in-progress state
<LISTITEM>
<PARA>
If there is not any transaction currently in progress.
-
+</para>
+</listitem>
</VARLISTENTRY>
</VARIABLELIST>
-
+</para>
</REFSECT2>
</REFSYNOPSISDIV>
This command is identical
in behavior to the <acronym>SQL92</acronym> command <command>ROLLBACK</command>,
and is present only for historical reasons.
-
+</para>
<REFSECT2 ID="R2-SQL-ABORT-3">
<REFSECT2INFO>
<DATE>1998-09-27</DATE>
<para>
Use the <command>COMMIT</command> statement to successfully
terminate a transaction.
-
+</para>
+</refsect2>
</REFSECT1>
<REFSECT1 ID="R1-SQL-ABORT-2">
--
ABORT WORK;
</ProgramListing>
+</para>
</REFSECT1>
<TITLE>
Compatibility
</TITLE>
-<PARA>
<REFSECT2 ID="R2-SQL-ABORT-4">
<REFSECT2INFO>
for historical reasons. <command>ROLLBACK</command> is the <acronym>SQL92</acronym>
equivalent command.
</PARA>
+</refsect2>
+</refsect1>
</REFENTRY>
<REFPURPOSE>
Modifies table properties
</REFPURPOSE>
+</refnamediv>
<REFSYNOPSISDIV>
<REFSYNOPSISDIVINFO>
<DATE>1998-04-15</DATE>
</LISTITEM>
</VARLISTENTRY>
</VARIABLELIST>
-
+</para>
</REFSECT2>
<REFSECT2 ID="R2-SQL-ALTERTABLE-2">
<LISTITEM>
<PARA>
Message returned if table or column is not available.
-
+</para>
+</listitem>
+</VARLISTENTRY>
</VARIABLELIST>
-
+</para>
</REFSECT2>
</REFSYNOPSISDIV>
the affected table. Thus, the table or column will
remain of the same type and size after this command is
executed.
+</para>
<PARA>
You must own the table in order to change its schema.
</PARA>
</TITLE>
<PARA>
The keyword COLUMN is noise and can be omitted.
-
+</para>
<PARA>
<Quote>[*]</Quote> following a name of a table indicates that statement
should be run over that table and all tables below it in the
inheritance hierarchy.
The <citetitle>PostgreSQL User's Guide</citetitle> has further
information on inheritance.
+</para>
<PARA>
Refer to CREATE TABLE for a further description
of valid arguments.
-
+</para>
</REFSECT2>
</REFSECT1>
<ProgramListing>
ALTER TABLE distributors ADD COLUMN address VARCHAR(30);
</ProgramListing>
+</para>
<PARA>
To rename an existing column:
<ProgramListing>
ALTER TABLE distributors RENAME COLUMN address TO city;
</ProgramListing>
+</para>
<PARA>
To rename an existing table:
<ProgramListing>
ALTER TABLE distributors RENAME TO suppliers;
</ProgramListing>
+</para>
</REFSECT1>
<PARA>
<command>ALTER TABLE/RENAME</command>
is a <productname>Postgres</productname> language extension.
+</para>
<PARA>
SQL92 specifies some additional capabilities for <command>ALTER TABLE</command>
statement which are not yet directly supported by
<ProductName>Postgres</ProductName>:
+</para>
<VARIABLELIST>
<VARLISTENTRY>
the new definition. If any constraints on this column already
exist, they will be retained using a boolean AND with the new
constraint.
+</para>
<PARA>
Currently, to set new default constraints on an existing column
constraints can be destroyed.
If CASCADE is specified, Any constraints that are dependent on
this constraint are also dropped.
+</para>
<PARA>
Currently, to remove a default value or constraints on an
CREATE TABLE distributors AS SELECT * FROM temp;
DROP TABLE temp;
</ProgramListing>
-
+</para>
+</listitem>
+</varlistentry>
+
<VARLISTENTRY>
<TERM>
<Synopsis>
objects can be destroyed.
If CASCADE is specified, all objects that are dependent on
this column are also dropped.
+</para>
<PARA>
Currently, to remove an existing column the table must be
DROP TABLE temp;
</ProgramListing>
</PARA>
+</listitem>
+</varlistentry>
</VARIABLELIST>
+</refsect2>
+</refsect1>
</REFENTRY>
<REFPURPOSE>
Modifies user account information
</REFPURPOSE>
+ </refnamediv>
<REFSYNOPSISDIV>
<REFSYNOPSISDIVINFO>
<DATE>1998-09-08</DATE>
<TITLE>
Outputs
</TITLE>
- <PARA>
- <VARIABLELIST>
- <VARLISTENTRY>
- <TERM>
- <returnvalue>ALTER USER</returnvalue>
- </TERM>
- <LISTITEM>
- <PARA>
- Message returned if the alteration was successful.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
-
- <VARLISTENTRY>
- <TERM>
- <returnvalue>ERROR: alterUser: user "username" does not exist</returnvalue>
- </TERM>
- <LISTITEM>
- <PARA>
- Error message returned if the user specified doesn't
- exist.
-
- </variablelist>
- </REFSECT2>
- </REFSYNOPSISDIV>
-
+ <PARA>
+ <VARIABLELIST>
+ <VARLISTENTRY>
+ <TERM>
+ <returnvalue>ALTER USER</returnvalue>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Message returned if the alteration was successful.
+ </PARA>
+ </LISTITEM>
+ </VARLISTENTRY>
+
+ <VARLISTENTRY>
+ <TERM>
+ <returnvalue>ERROR: alterUser: user "username" does not exist</returnvalue>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Error message returned if the user specified doesn't
+ exist.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </para>
+ </REFSECT2>
+ </REFSYNOPSISDIV>
+
<REFSECT1 ID="R1-SQL-ALTERUSER-1">
<REFSECT1INFO>
<DATE>1998-09-08</DATE>
The standard leaves
the definition of users to the implementation.
</PARA>
+ </refsect2>
</refsect1>
</REFENTRY>
Begins a transaction
</REFPURPOSE>
-
+ </refnamediv>
<REFSYNOPSISDIV>
<REFSYNOPSISDIVINFO>
<DATE>1998-09-08</DATE>
Inputs
</TITLE>
<PARA>
- None
+ None
+ </para>
</REFSECT2>
<REFSECT2 ID="R2-SQL-BEGINWORK-2">
<returnvalue>NOTICE: BeginTransactionBlock and not in default state</returnvalue>
</TERM>
<LISTITEM>
- <PARA>
- This indicates that a transaction was already in progress.
-The current transaction is not affected.
-
- </VARIABLELIST>
+ <PARA>
+ This indicates that a transaction was already in progress.
+ The current transaction is not affected.
+ </para>
+ </listitem>
+ </varlistentry>
+ </VARIABLELIST>
+ </para>
</REFSECT2>
</REFSYNOPSISDIV>
to terminate a transaction.
</PARA>
</REFSECT2>
+ </refsect1>
<REFSECT1 ID="R1-SQL-BEGINWORK-2">
<TITLE>
<ProgramListing>
BEGIN WORK;
</ProgramListing>
+ </para>
</REFSECT1>
<REFSECT1 ID="R1-SQL-BEGINWORK-3">
<PARA>
<command>BEGIN</command>
is a <productname>Postgres</productname> language extension.
-
+ </para>
<REFSECT2 ID="R2-SQL-BEGINWORK-4">
<REFSECT2INFO>
<DATE>1998-09-08</DATE>
<REFPURPOSE>
Close a cursor
</REFPURPOSE>
-
+ </refnamediv>
<REFSYNOPSISDIV>
<REFSYNOPSISDIVINFO>
<DATE>1998-09-08</DATE>
</LISTITEM>
</VARLISTENTRY>
</variablelist>
+ </para>
</REFSECT2>
<REFSECT2 ID="R2-SQL-CLOSE-2">
This warning is given if
<REPLACEABLE CLASS="PARAMETER">cursor</REPLACEABLE> is not
declared or has already been closed.
-
- </VARIABLELIST>
-
+ </para>
+ </listitem>
+ </varlistentry>
+ </VARIABLELIST>
+ </para>
</REFSECT2>
</REFSYNOPSISDIV>
<REFPURPOSE>
Gives storage clustering advice to the backend
</REFPURPOSE>
-
+ </refnamediv>
<REFSYNOPSISDIV>
- <REFSYNOPSISDIVINFO>
- <DATE>1998-09-08</DATE>
- </REFSYNOPSISDIVINFO>
- <SYNOPSIS>
-CLUSTER <REPLACEABLE CLASS="PARAMETER">indexname</REPLACEABLE> ON <REPLACEABLE CLASS="PARAMETER">table</REPLACEABLE>
- </SYNOPSIS>
+ <REFSYNOPSISDIVINFO>
+ <DATE>1998-09-08</DATE>
+ </REFSYNOPSISDIVINFO>
+ <SYNOPSIS>
+ CLUSTER <REPLACEABLE CLASS="PARAMETER">indexname</REPLACEABLE> ON <REPLACEABLE CLASS="PARAMETER">table</REPLACEABLE>
+ </SYNOPSIS>
<REFSECT2 ID="R2-SQL-CLUSTER-1">
<REFSECT2INFO>
</LISTITEM>
</VARLISTENTRY>
- </VARIABLELIST>
-
- </REFSECT2>
+ </VARIABLELIST>
+ </para>
+ </REFSECT2>
</REFSYNOPSISDIV>
<REFSECT1 ID="R1-SQL-CLUSTER-1">
<TITLE>
Notes
</TITLE>
- <PARA>
+
<para>
The table is actually copied to a temporary table in index
order, then renamed back to the original name. For this
will not be preserved. From then on, <command>CLUSTER</command> should be
fast because most of the heap data has already been
ordered, and the existing index is used.
- </para>
-
-
+ </para>
+ </refsect2>
+ </refsect1>
+
<REFSECT1 ID="R1-SQL-CLUSTER-2">
- <TITLE>
- Usage
- </TITLE>
- <PARA>
- Cluster the employees relation on the basis of its salary attribute
- </PARA>
- <ProgramListing>
-CLUSTER emp_ind ON emp
- </ProgramListing>
+ <TITLE>
+ Usage
+ </TITLE>
+ <PARA>
+ Cluster the employees relation on the basis of its salary attribute
+ </PARA>
+ <ProgramListing>
+ CLUSTER emp_ind ON emp
+ </ProgramListing>
</REFSECT1>
<REFSECT1 ID="R1-SQL-CLUSTER-3">
- <TITLE>
- Compatibility
- </TITLE>
- <PARA>
- </PARA>
-
- <REFSECT2 ID="R2-SQL-CLUSTER-4">
- <REFSECT2INFO>
- <DATE>1998-09-08</DATE>
- </REFSECT2INFO>
<TITLE>
- SQL92
+ Compatibility
</TITLE>
<PARA>
- There is no <command>CLUSTER</command> statement in SQL92.
</PARA>
- </refsect2>
+
+ <REFSECT2 ID="R2-SQL-CLUSTER-4">
+ <REFSECT2INFO>
+ <DATE>1998-09-08</DATE>
+ </REFSECT2INFO>
+ <TITLE>
+ SQL92
+ </TITLE>
+ <PARA>
+ There is no <command>CLUSTER</command> statement in SQL92.
+ </PARA>
+ </refsect2>
</refsect1>
</REFENTRY>
<REFPURPOSE>
Commits the current transaction
</REFPURPOSE>
-
+ </refnamediv>
<REFSYNOPSISDIV>
<REFSYNOPSISDIVINFO>
Inputs
</TITLE>
<PARA>
-None
-
+ None
+ </para>
</REFSECT2>
<REFSECT2 ID="R2-SQL-COMMIT-2">
<VARLISTENTRY>
<TERM>
<returnvalue>NOTICE EndTransactionBlock and not inprogress/abort state</returnvalue>
- </TERM>
- <LISTITEM>
- <PARA>
-If there is no transaction in progress.
-
- </VARIABLELIST>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ If there is no transaction in progress.
+ </para>
+ </listitem>
+ </varlistentry>
+ </VARIABLELIST>
+ </para>
</REFSECT2>
</REFSYNOPSISDIV>
<REFPURPOSE>
Copies data between files and tables
</REFPURPOSE>
+ </refnamediv>
<REFSYNOPSISDIV>
<REFSYNOPSISDIVINFO>
<DATE>1998-09-08</DATE>
<LISTITEM>
<PARA>
Specifies that output goes to a pipe or terminal.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
- <replaceable class="parameter">delimiter</replaceable>
- </TERM>
- <LISTITEM>
- <PARA>
- A character that delimits the input or output fields.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- </variablelist>
+ </PARA>
+ </LISTITEM>
+ </VARLISTENTRY>
+ <VARLISTENTRY>
+ <TERM>
+ <replaceable class="parameter">delimiter</replaceable>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ A character that delimits the input or output fields.
+ </PARA>
+ </LISTITEM>
+ </VARLISTENTRY>
+ </variablelist>
+ </para>
</REFSECT2>
<REFSECT2 ID="R2-SQL-COPY-2">
<VARLISTENTRY>
<TERM>
<ReturnValue>ERROR: <replaceable>error message</replaceable></ReturnValue>
- </TERM>
- <LISTITEM>
- <PARA>
- The copy failed for the reason stated in the error message.
-
- </VARIABLELIST>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ The copy failed for the reason stated in the error message.
+ </para>
+ </listitem>
+ </varlistentry>
+ </VARIABLELIST>
+ </para>
</REFSECT2>
</REFSYNOPSISDIV>
<TITLE>
Description
</TITLE>
- <PARA>
+ <para>
<command>COPY</command> moves data between
<productname>Postgres</productname> tables and
standard Unix files.
-<para>
-<command>COPY</command> instructs
- the <productname>Postgres</productname> backend
-to directly read from or write to a file. The file must be directly visible to
-the backend and the name must be specified from the viewpoint of the backend.
-If <filename>stdin</filename> or <filename>stdout</filename> are specified, data flows through the client frontend to
-the backend.
-
+ <command>COPY</command> instructs
+ the <productname>Postgres</productname> backend
+ to directly read from or write to a file. The file must be directly visible to
+ the backend and the name must be specified from the viewpoint of the backend.
+ If <filename>stdin</filename> or <filename>stdout</filename> are specified, data flows through the client frontend to
+ the backend.
+ </para>
<REFSECT2 ID="R2-SQL-COPY-3">
<REFSECT2INFO>
<DATE>1998-09-08</DATE>
<TITLE>
Notes
</TITLE>
- <para>
- The BINARY keyword will force all data to be
- stored/read as binary objects rather than as text. It is
- somewhat faster than the normal copy command, but is not
- generally portable, and the files generated are somewhat larger,
- although this factor is highly dependent on the data itself. By
- default, a text copy uses a tab ("\t") character as a delimiter.
- The delimiter may also be changed to any other single character
- with the keyword phrase USING DELIMITERS. Characters
- in data fields which happen to match the delimiter character will
- be quoted.
- </para>
-
- <para>
+ <para>
+ The BINARY keyword will force all data to be
+ stored/read as binary objects rather than as text. It is
+ somewhat faster than the normal copy command, but is not
+ generally portable, and the files generated are somewhat larger,
+ although this factor is highly dependent on the data itself. By
+ default, a text copy uses a tab ("\t") character as a delimiter.
+ The delimiter may also be changed to any other single character
+ with the keyword phrase USING DELIMITERS. Characters
+ in data fields which happen to match the delimiter character will
+ be quoted.
+ </para>
+
+ <para>
You must have select access on any table whose values are read by
<command>COPY</command>, and either insert or update access to a
table into which values are being inserted by <command>COPY</command>.
The backend also needs appropriate Unix permissions for any file read
or written by <command>COPY</command>.
- </para>
- <para>
+ </para>
+ <para>
The keyword phrase USING DELIMITERS specifies a single character
-to be used for all delimiters between columns. If multiple characters
-are specified in the delimiter string, only the first character is
+ to be used for all delimiters between columns. If multiple characters
+ are specified in the delimiter string, only the first character is
used.
-
- <tip>
-<para>
- Do not confuse <command>COPY</command> with the
- <application>psql</application> instruction <command>\copy</command>.
-</tip>
-
+
+ <tip>
+ <para>
+ Do not confuse <command>COPY</command> with the
+ <application>psql</application> instruction <command>\copy</command>.
+ </para>
+ </tip>
+ </para>
</REFSECT2>
</refsect1>
-
+
<refsect1 ID="R1-SQL-COPY-2">
<refsect1info>
<date>1998-05-04</date>
<REFPURPOSE>
Defines a new aggregate function
</REFPURPOSE>
+ </refnamediv>
<REFSYNOPSISDIV>
<REFSYNOPSISDIVINFO>
<DATE>1998-09-09</DATE>
The initial value for the second transition function argument.
</para>
</listitem>
- </varlistentry>
- </variablelist>
-
+ </varlistentry>
+ </variablelist>
+ </para>
</REFSECT2>
-
+
<REFSECT2 ID="R2-SQL-CREATEAGGREGATE-2">
<REFSECT2INFO>
<DATE>1998-09-09</DATE>
Outputs
</TITLE>
<PARA>
-
- <VARIABLELIST>
- <VARLISTENTRY>
- <TERM>
- <ReturnValue>CREATE</ReturnValue>
- </TERM>
- <LISTITEM>
- <PARA>
- Message returned if the command completes successfully.
- </VARIABLELIST>
-
+
+ <VARIABLELIST>
+ <VARLISTENTRY>
+ <TERM>
+ <ReturnValue>CREATE</ReturnValue>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Message returned if the command completes successfully.
+ </para>
+ </listitem>
+ </varlistentry>
+ </VARIABLELIST>
+ </para>
</REFSECT2>
</REFSYNOPSISDIV>
-
+
<REFSECT1 ID="R1-SQL-CREATEAGGREGATE-1">
<REFSECT1INFO>
<DATE>1998-09-09</DATE>
<TITLE>
Description
</TITLE>
-<para>
- <command>CREATE AGGREGATE</command>
-allows a user or programmer to extend <productname>Postgres</productname>
-functionality by defining new aggregate functions. Some aggregate functions
-for base types such as <function>min(int4)</function>
- and <function>avg(float8)</function> are already provided in the base
-distribution. If one defines new types or needs an aggregate function not
-already provided then <command>CREATE AGGREGATE</command>
-can be used to provide the desired features.
-
+ <para>
+ <command>CREATE AGGREGATE</command>
+ allows a user or programmer to extend <productname>Postgres</productname>
+ functionality by defining new aggregate functions. Some aggregate functions
+ for base types such as <function>min(int4)</function>
+ and <function>avg(float8)</function> are already provided in the base
+ distribution. If one defines new types or needs an aggregate function not
+ already provided then <command>CREATE AGGREGATE</command>
+ can be used to provide the desired features.
+ </para>
<PARA>
An aggregate function can require up to three functions, two
state transition functions,
-<REPLACEABLE CLASS="PARAMETER">sfunc1</REPLACEABLE>
- and <REPLACEABLE CLASS="PARAMETER">sfunc2</REPLACEABLE>:
-<programlisting>
-<REPLACEABLE CLASS="PARAMETER">sfunc1</REPLACEABLE>( internal-state1, next-data_item ) ---> next-internal-state1
-<REPLACEABLE CLASS="PARAMETER">sfunc2</REPLACEABLE>( internal-state2 ) ---> next-internal-state2
-</programlisting>
+ <REPLACEABLE CLASS="PARAMETER">sfunc1</REPLACEABLE>
+ and <REPLACEABLE CLASS="PARAMETER">sfunc2</REPLACEABLE>:
+ <programlisting>
+ <REPLACEABLE CLASS="PARAMETER">sfunc1</REPLACEABLE>( internal-state1, next-data_item ) ---> next-internal-state1
+ <REPLACEABLE CLASS="PARAMETER">sfunc2</REPLACEABLE>( internal-state2 ) ---> next-internal-state2
+ </programlisting>
and a final calculation function,
- <REPLACEABLE CLASS="PARAMETER">ffunc</REPLACEABLE>:
-<programlisting>
-<REPLACEABLE CLASS="PARAMETER">ffunc</REPLACEABLE>(internal-state1, internal-state2) ---> aggregate-value
-</programlisting>
-
-<para>
-<productname>Postgres</productname> creates up to two temporary variables
-(referred to here as <REPLACEABLE CLASS="PARAMETER">temp1</REPLACEABLE>
-and <REPLACEABLE CLASS="PARAMETER">temp2</REPLACEABLE>)
-to hold intermediate results used as arguments to the transition functions.
-
-<para>
+ <REPLACEABLE CLASS="PARAMETER">ffunc</REPLACEABLE>:
+ <programlisting>
+ <REPLACEABLE CLASS="PARAMETER">ffunc</REPLACEABLE>(internal-state1, internal-state2) ---> aggregate-value
+ </programlisting>
+ </para>
+ <para>
+ <productname>Postgres</productname> creates up to two temporary variables
+ (referred to here as <REPLACEABLE CLASS="PARAMETER">temp1</REPLACEABLE>
+ and <REPLACEABLE CLASS="PARAMETER">temp2</REPLACEABLE>)
+ to hold intermediate results used as arguments to the transition functions.
+ </para>
+ <para>
These transition functions are required to have the following properties:
<itemizedlist>
<listitem>
<para>
The arguments to
-<REPLACEABLE CLASS="PARAMETER">sfunc1</REPLACEABLE>
- must be
-<REPLACEABLE CLASS="PARAMETER">temp1</REPLACEABLE>
-of type
-<REPLACEABLE CLASS="PARAMETER">sfunc1_return_type</REPLACEABLE>
-and
-<REPLACEABLE CLASS="PARAMETER">column_value</REPLACEABLE>
-of type <REPLACEABLE CLASS="PARAMETER">data_type</REPLACEABLE>.
-The return value must be of type
-<REPLACEABLE CLASS="PARAMETER">sfunc1_return_type</REPLACEABLE>
-and will be used as the first argument in the next call to
-<REPLACEABLE CLASS="PARAMETER">sfunc1</REPLACEABLE>.
+ <REPLACEABLE CLASS="PARAMETER">sfunc1</REPLACEABLE>
+ must be
+ <REPLACEABLE CLASS="PARAMETER">temp1</REPLACEABLE>
+ of type
+ <REPLACEABLE CLASS="PARAMETER">sfunc1_return_type</REPLACEABLE>
+ and
+ <REPLACEABLE CLASS="PARAMETER">column_value</REPLACEABLE>
+ of type <REPLACEABLE CLASS="PARAMETER">data_type</REPLACEABLE>.
+ The return value must be of type
+ <REPLACEABLE CLASS="PARAMETER">sfunc1_return_type</REPLACEABLE>
+ and will be used as the first argument in the next call to
+ <REPLACEABLE CLASS="PARAMETER">sfunc1</REPLACEABLE>.
</para>
</listitem>
-
+
<listitem>
<para>
The argument and return value of
-<REPLACEABLE CLASS="PARAMETER">sfunc2</REPLACEABLE>
-must be
-<REPLACEABLE CLASS="PARAMETER">temp2</REPLACEABLE>
-of type
-<REPLACEABLE CLASS="PARAMETER">sfunc2_return_type</REPLACEABLE>.
+ <REPLACEABLE CLASS="PARAMETER">sfunc2</REPLACEABLE>
+ must be
+ <REPLACEABLE CLASS="PARAMETER">temp2</REPLACEABLE>
+ of type
+ <REPLACEABLE CLASS="PARAMETER">sfunc2_return_type</REPLACEABLE>.
</para>
</listitem>
<listitem>
<para>
The arguments to the final-calculation-function
must be
-<REPLACEABLE CLASS="PARAMETER">temp1</REPLACEABLE>
-and
-<REPLACEABLE CLASS="PARAMETER">temp2</REPLACEABLE>
-and its return value must
+ <REPLACEABLE CLASS="PARAMETER">temp1</REPLACEABLE>
+ and
+ <REPLACEABLE CLASS="PARAMETER">temp2</REPLACEABLE>
+ and its return value must
be a <productname>Postgres</productname>
- base type (not necessarily
- <REPLACEABLE CLASS="PARAMETER">data_type</REPLACEABLE>
-which had been specified for BASETYPE).
+ base type (not necessarily
+ <REPLACEABLE CLASS="PARAMETER">data_type</REPLACEABLE>
+ which had been specified for BASETYPE).
</para>
</listitem>
<listitem>
</listitem>
</itemizedlist>
</PARA>
-
+
<para>
An aggregate function may also require one or two initial conditions,
one for
well as a FINALFUNC (a division function) to produce its
answer. In any case, at least one state function must be
defined, and any SFUNC2 must have a corresponding INITCOND2.
- </para>
-
+ </para>
+
</REFSECT2>
-
+ </refsect1>
+
<REFSECT1 ID="R1-SQL-CREATEAGGREGATE-2">
<TITLE>
Usage
</TITLE>
<PARA>
-Refer to the chapter on aggregate functions
- in the <citetitle>PostgreSQL Programmer's Guide</citetitle>
- on aggregate functions for
-complete examples of usage.
-
+ Refer to the chapter on aggregate functions
+ in the <citetitle>PostgreSQL Programmer's Guide</citetitle>
+ on aggregate functions for
+ complete examples of usage.
+ </para>
</REFSECT1>
<REFSECT1 ID="R1-SQL-CREATEAGGREGATE-3">
<TITLE>
Compatibility
</TITLE>
- <PARA>
-
+
<REFSECT2 ID="R2-SQL-CREATEAGGREGATE-4">
<REFSECT2INFO>
-<DATE>1998-09-09</DATE>
+ <DATE>1998-09-09</DATE>
</REFSECT2INFO>
<TITLE>
SQL92
</TITLE>
<PARA>
<command>CREATE AGGREGATE</command>
-is a <productname>Postgres</productname> language extension.
+ is a <productname>Postgres</productname> language extension.
There is no <command>CREATE AGGREGATE</command> in SQL92.
</PARA>
-
+ </refsect2>
+ </refsect1>
</REFENTRY>
<!-- Keep this comment at the end of the file
<REFPURPOSE>
Creates a new database
</REFPURPOSE>
+ </refnamediv>
<REFSYNOPSISDIV>
<REFSYNOPSISDIVINFO>
<DATE>1998-04-15</DATE>
(e.g. '<filename>/usr/local/pgsql/data</filename>').
In either case, the location must be pre-configured
by <command>initlocation</command>.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- </VARIABLELIST>
+ </PARA>
+ </LISTITEM>
+ </VARLISTENTRY>
+ </VARIABLELIST>
+ </para>
</REFSECT2>
-
+
<REFSECT2 ID="R2-SQL-CREATEDATABASE-2">
<REFSECT2INFO>
<DATE>1998-04-15</DATE>
<VARLISTENTRY>
<TERM>
<ReturnValue>ERROR: Unable to create database directory <replaceable class="parameter">directory</replaceable>
-</ReturnValue>
- </TERM>
- <LISTITEM>
- <PARA>
-There was a problem with creating the required directory; this operation will
-need permissions for the <literal>postgres</literal> user on the specified location.
-
- </VARIABLELIST>
+ </ReturnValue>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ There was a problem with creating the required directory; this operation will
+ need permissions for the <literal>postgres</literal> user on the specified location.
+ </para>
+ </listitem>
+ </varlistentry>
+ </VARIABLELIST>
+ </para>
</REFSECT2>
</REFSYNOPSISDIV>
Use <command>DROP DATABASE</command> to remove a database.
</para>
</REFSECT2>
-
+ </refsect1>
+
<REFSECT1 ID="R1-SQL-CREATEDATABASE-2">
<TITLE>
Usage
To create a new database:
</PARA>
<ProgramListing>
-<prompt>olly=></prompt> <userinput>create database lusiadas;</userinput>
+ <prompt>olly=></prompt> <userinput>create database lusiadas;</userinput>
</ProgramListing>
<PARA>
To create a new database in an alternate area <filename>~/private_db</filename>:
</PARA>
<ProgramListing>
-<prompt>$</prompt> <userinput>mkdir private_db</userinput>
-<prompt>$</prompt> <userinput>initlocation ~/private_db</userinput>
-<computeroutput>Creating Postgres database system directory /home/olly/private_db/base</computeroutput>
-
-<prompt>$</prompt> <userinput>psql olly</userinput>
-<computeroutput>Welcome to the POSTGRESQL interactive sql monitor:
- Please read the file COPYRIGHT for copyright terms of POSTGRESQL
-
- type \? for help on slash commands
- type \q to quit
- type \g or terminate with semicolon to execute query
- You are currently connected to the database: template1
-
-<prompt>olly=></prompt></computeroutput> <userinput>create database elsewhere with location = '/home/olly/private_db';</userinput>
- <computeroutput>CREATEDB</computeroutput>
+ <prompt>$</prompt> <userinput>mkdir private_db</userinput>
+ <prompt>$</prompt> <userinput>initlocation ~/private_db</userinput>
+ <computeroutput>Creating Postgres database system directory /home/olly/private_db/base</computeroutput>
+
+ <prompt>$</prompt> <userinput>psql olly</userinput>
+ <computeroutput>Welcome to the POSTGRESQL interactive sql monitor:
+ Please read the file COPYRIGHT for copyright terms of POSTGRESQL
+
+ type \? for help on slash commands
+ type \q to quit
+ type \g or terminate with semicolon to execute query
+ You are currently connected to the database: template1
+
+ <prompt>olly=></prompt></computeroutput> <userinput>create database elsewhere with location = '/home/olly/private_db';</userinput>
+ <computeroutput>CREATEDB</computeroutput>
</ProgramListing>
</REFSECT1>
<TITLE>
Compatibility
</TITLE>
- <PARA>
<REFSECT2 ID="R2-SQL-CREATEDATABASE-4">
<REFSECT2INFO>
<REFPURPOSE>
Defines a new function
</REFPURPOSE>
-
+ </refnamediv>
<REFSYNOPSISDIV>
<REFSYNOPSISDIVINFO>
<DATE>1998-09-09</DATE>
<VARLISTENTRY>
<TERM>
<replaceable class="parameter">path</replaceable>
- </TERM>
- <LISTITEM>
- <PARA>
- May be either an SQL-query or an absolute path to an
- object file.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
- <replaceable class="parameter">langname</replaceable>
- </TERM>
- <LISTITEM>
- <PARA>
- may be '<literal>C</literal>', '<literal>sql</literal>',
- '<literal>internal</literal>'
- or '<replaceable class="parameter">plname</replaceable>',
- where '<replaceable class="parameter">plname</replaceable>'
- is the name of a created procedural
- language. See <command>CREATE LANGUAGE</command> for details.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- </variablelist>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ May be either an SQL-query or an absolute path to an
+ object file.
+ </PARA>
+ </LISTITEM>
+ </VARLISTENTRY>
+ <VARLISTENTRY>
+ <TERM>
+ <replaceable class="parameter">langname</replaceable>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ may be '<literal>C</literal>', '<literal>sql</literal>',
+ '<literal>internal</literal>'
+ or '<replaceable class="parameter">plname</replaceable>',
+ where '<replaceable class="parameter">plname</replaceable>'
+ is the name of a created procedural
+ language. See <command>CREATE LANGUAGE</command> for details.
+ </PARA>
+ </LISTITEM>
+ </VARLISTENTRY>
+ </variablelist>
+ </para>
</REFSECT2>
<REFSECT2 ID="R2-SQL-CREATEFUNCTION-2">
Outputs
</TITLE>
<PARA>
-
- <VARIABLELIST>
- <VARLISTENTRY>
- <TERM>
- <ReturnValue>CREATE</ReturnValue>
- </TERM>
- <LISTITEM>
- <PARA>
- This is returned if the command completes successfully.
- </VARIABLELIST>
+
+ <VARIABLELIST>
+ <VARLISTENTRY>
+ <TERM>
+ <ReturnValue>CREATE</ReturnValue>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ This is returned if the command completes successfully.
+ </para>
+ </listitem>
+ </varlistentry>
+ </VARIABLELIST>
+ </para>
</REFSECT2>
</REFSYNOPSISDIV>
</TITLE>
<PARA>
<command>CREATE FUNCTION</command> allows a
-<productname>Postgres</productname> user
-to register a function
+ <productname>Postgres</productname> user
+ to register a function
with a database. Subsequently, this user is treated as the
owner of the function.
</PARA>
<PARA>
Refer to the chapter on functions
in the <citetitle>PostgreSQL Programmer's Guide</citetitle>
- for further information.
+ for further information.
</PARA>
<PARA>
Use <command>DROP FUNCTION</command>
to drop user-defined functions.
</PARA>
</REFSECT2>
+ </refsect1>
<REFSECT1 ID="R1-SQL-CREATEFUNCTION-2">
<TITLE>
To create a simple SQL function:
</PARA>
<ProgramListing>
-CREATE FUNCTION one() RETURNS int4
- AS 'SELECT 1 AS RESULT'
- LANGUAGE 'sql';
-
-SELECT one() AS answer;
-
-<computeroutput>
-answer
-------
-1
-</computeroutput>
+ CREATE FUNCTION one() RETURNS int4
+ AS 'SELECT 1 AS RESULT'
+ LANGUAGE 'sql';
+
+ SELECT one() AS answer;
+
+ <computeroutput>
+ answer
+ ------
+ 1
+ </computeroutput>
</ProgramListing>
<para>
To create a C function, calling a routine from a user-created
is correct. It is intended for use in a CHECK contraint.
</para>
<programlisting>
-<userinput>
-CREATE FUNCTION ean_checkdigit(bpchar, bpchar) RETURNS bool
+ <userinput>
+ CREATE FUNCTION ean_checkdigit(bpchar, bpchar) RETURNS bool
AS '/usr1/proj/bray/sql/funcs.so' LANGUAGE 'c';
-
-CREATE TABLE product
-(
- id char(8) PRIMARY KEY,
- eanprefix char(8) CHECK (eanprefix ~ '[0-9]{2}-[0-9]{5}')
- REFERENCES brandname(ean_prefix),
- eancode char(6) CHECK (eancode ~ '[0-9]{6}'),
- CONSTRAINT ean CHECK (ean_checkdigit(eanprefix, eancode))
-);</userinput>
+
+ CREATE TABLE product
+ (
+ id char(8) PRIMARY KEY,
+ eanprefix char(8) CHECK (eanprefix ~ '[0-9]{2}-[0-9]{5}')
+ REFERENCES brandname(ean_prefix),
+ eancode char(6) CHECK (eancode ~ '[0-9]{6}'),
+ CONSTRAINT ean CHECK (ean_checkdigit(eanprefix, eancode))
+ );</userinput>
</programlisting>
</REFSECT1>
<REFPURPOSE>
Constructs a secondary index
</REFPURPOSE>
+ </refnamediv>
<REFSYNOPSISDIV>
<REFSYNOPSISDIVINFO>
<DATE>1998-09-09</DATE>
</programlisting>
</PARA>
- </LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
- <replaceable class="parameter">func_name</replaceable>
- </TERM>
- <LISTITEM>
- <PARA>
- A user-defined function, which returns a value that can
- be indexed.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- </variablelist>
-
+ </LISTITEM>
+ </VARLISTENTRY>
+ <VARLISTENTRY>
+ <TERM>
+ <replaceable class="parameter">func_name</replaceable>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ A user-defined function, which returns a value that can
+ be indexed.
+ </PARA>
+ </LISTITEM>
+ </VARLISTENTRY>
+ </variablelist>
+ </para>
</REFSECT2>
<REFSECT2 ID="R2-SQL-CREATEINDEX-2">
</VARLISTENTRY>
<VARLISTENTRY>
- <TERM>
- <ReturnValue>ERROR: Cannot create index: 'index_name' already exists.</ReturnValue>
- </TERM>
- <LISTITEM>
- <PARA>
- This error occurs if it is impossible to create the index.
-
- </VARIABLELIST>
-
+ <TERM>
+ <ReturnValue>ERROR: Cannot create index: 'index_name' already exists.</ReturnValue>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ This error occurs if it is impossible to create the index.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </para>
</REFSECT2>
</REFSYNOPSISDIV>
Description
</TITLE>
<PARA>
- <command>CREATE INDEX</command> constructs an index
- <replaceable class="parameter">index_name</replaceable>.
-on the specified
-<replaceable class="parameter">table</replaceable>.
-
-<tip>
-<para>
-Indexes are primarily used to enhance database performance.
-But inappropriate use will result in slower performance.
-</tip>
-
+ <command>CREATE INDEX</command> constructs an index
+ <replaceable class="parameter">index_name</replaceable>.
+ on the specified
+ <replaceable class="parameter">table</replaceable>.
+
+ <tip>
+ <para>
+ Indexes are primarily used to enhance database performance.
+ But inappropriate use will result in slower performance.
+ </para>
+ </tip>
+ </para>
<para>
In the first syntax shown above, the key fields for the
index are specified as column names; a column may also have
to remove an index.
</para>
</REFSECT2>
-
+ </refsect1>
+
<REFSECT1 ID="R1-SQL-CREATEINDEX-2">
<TITLE>
Usage
<REFPURPOSE>
Defines a new language for functions
</REFPURPOSE>
-
+ </refnamediv>
<REFSYNOPSISDIV>
<REFSYNOPSISDIVINFO>
<DATE>1998-09-09</DATE>
procedures.
</PARA>
</LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
- <replaceable class="parameter">comment</replaceable>
- </TERM>
- <LISTITEM>
- <PARA>
- The <function>LANCOMPILER</function> argument is the
- string that will be
- inserted in the <literal>LANCOMPILER</literal> attribute
- of the new
- <filename>pg_language</filename> entry. At present,
- <productname>Postgres</productname> does not use
- this attribute in any way.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- </variablelist>
-
+ </VARLISTENTRY>
+ <VARLISTENTRY>
+ <TERM>
+ <replaceable class="parameter">comment</replaceable>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ The <function>LANCOMPILER</function> argument is the
+ string that will be
+ inserted in the <literal>LANCOMPILER</literal> attribute
+ of the new
+ <filename>pg_language</filename> entry. At present,
+ <productname>Postgres</productname> does not use
+ this attribute in any way.
+ </PARA>
+ </LISTITEM>
+ </VARLISTENTRY>
+ </variablelist>
+ </para>
+
</REFSECT2>
<REFSECT2 ID="R2-SQL-CREATELANGUAGE-2">
</LISTITEM>
</VARLISTENTRY>
<VARLISTENTRY>
- <TERM>
- <ReturnValue>ERROR: PL handler function <replaceable class="parameter">funcname</replaceable>() doesn't exist</ReturnValue>
- </TERM>
- <LISTITEM>
- <PARA>
- This error is returned if the function
- <replaceable class="parameter">funcname</replaceable>()
- is not found.
- </VARIABLELIST>
+ <TERM>
+ <ReturnValue>ERROR: PL handler function <replaceable class="parameter">funcname</replaceable>() doesn't exist</ReturnValue>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ This error is returned if the function
+ <replaceable class="parameter">funcname</replaceable>()
+ is not found.
+ </para>
+ </listitem>
+ </varlistentry>
+ </VARIABLELIST>
+ </para>
</REFSECT2>
</REFSYNOPSISDIV>
file or anything else that tells the call handler what to
do in detail.
</para>
+ </refsect2>
<REFSECT2 ID="R2-SQL-CREATELANGUAGE-4">
<REFSECT2INFO>
of the dots to complete the PL call handler.
See <command>CREATE FUNCTION</command> for information on how to compile
it into a loadable module
-.</para>
+ .</para>
<para>
The following commands then register the sample procedural
language:
- <programlisting>
-CREATE FUNCTION plsample_call_handler () RETURNS opaque
+ <programlisting>
+ CREATE FUNCTION plsample_call_handler () RETURNS opaque
AS '/usr/local/pgsql/lib/plsample.so'
LANGUAGE 'C';
-
-CREATE PROCEDURAL LANGUAGE 'plsample'
+
+ CREATE PROCEDURAL LANGUAGE 'plsample'
HANDLER plsample_call_handler
LANCOMPILER 'PL/Sample';
- </programlisting>
+ </programlisting>
+ </para>
</REFSECT1>
<REFSECT1 ID="R1-SQL-CREATELANGUAGE-7">
<REFPURPOSE>
Defines a new user operator
</REFPURPOSE>
-
+ </refnamediv>
<REFSYNOPSISDIV>
<REFSYNOPSISDIVINFO>
<DATE>1998-09-09</DATE>
Outputs
</TITLE>
<PARA>
- <VARIABLELIST>
- <VARLISTENTRY>
- <TERM>
- <ReturnValue>CREATE</ReturnValue>
- </TERM>
- <LISTITEM>
- <PARA>
- Message returned if the operator is successfully created.
-
- </VARIABLELIST>
+ <VARIABLELIST>
+ <VARLISTENTRY>
+ <TERM>
+ <ReturnValue>CREATE</ReturnValue>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Message returned if the operator is successfully created.
+ </para>
+ </listitem>
+ </varlistentry>
+ </VARIABLELIST>
+ </para>
</REFSECT2>
</REFSYNOPSISDIV>
Description
</TITLE>
<PARA>
-<command>CREATE OPERATOR</command> defines a new operator,
- <replaceable class="parameter">name</replaceable>.
- The user who defines an operator becomes its owner.
- </para>
- <para>
- The operator <replaceable class="parameter">name</replaceable>
- is a sequence of up to thirty two (32) characters in any combination
-from the following:
-<literallayout>
- + - * / < > = ~ ! @ # % ^ & | ` ? $ :
-</literallayout>
-<note>
-<para>
-No alphabetic characters are allowed in an operator name.
-This enables <productname>Postgres</productname> to parse SQL input
-into tokens without requiring spaces between each token.
-</note>
-
- </para>
+ <command>CREATE OPERATOR</command> defines a new operator,
+ <replaceable class="parameter">name</replaceable>.
+ The user who defines an operator becomes its owner.
+ </para>
+ <para>
+ The operator <replaceable class="parameter">name</replaceable>
+ is a sequence of up to thirty two (32) characters in any combination
+ from the following:
+ <literallayout>
+ + - * / < > = ~ ! @ # % ^ & | ` ? $ :
+ </literallayout>
+ <note>
+ <para>
+ No alphabetic characters are allowed in an operator name.
+ This enables <productname>Postgres</productname> to parse SQL input
+ into tokens without requiring spaces between each token.
+ </para>
+ </note>
+ </para>
<para>
The operator "!=" is mapped to "<>" on input, so they are
therefore equivalent.
unary operators only RIGHTARG should be defined.
</para>
<para>
-Also, the
- <replaceable class="parameter">func_name</replaceable> procedure must have
+ Also, the
+ <replaceable class="parameter">func_name</replaceable> procedure must have
been previously defined using <command>CREATE FUNCTION</command> and must
be defined to accept the correct number of arguments
- (either one or two).
+ (either one or two).
</para>
<para>
The commutator operator is present so that
- <productname>Postgres</productname> can
+ <productname>Postgres</productname> can
reverse the order of the operands if it wishes.
- For example, the operator area-less-than, <<<,
- would have a commutator
- operator, area-greater-than, >>>.
- Hence, the query optimizer could freely convert:
+ For example, the operator area-less-than, <<<,
+ would have a commutator
+ operator, area-greater-than, >>>.
+ Hence, the query optimizer could freely convert:
<programlisting>
-"0,0,1,1"::box >>> MYBOXES.description
+ "0,0,1,1"::box >>> MYBOXES.description
</programlisting>
to
<programlisting>
-MYBOXES.description <<< "0,0,1,1"::box</programlisting>
+ MYBOXES.description <<< "0,0,1,1"::box</programlisting>
</para>
<para>
This allows the execution code to always use the latter
what.
</para>
<para>
- Suppose that an
+ Suppose that an
operator, area-equal, ===, exists, as well as an area not
equal, !==.
The negator operator allows the query optimizer to convert
<programlisting>
-NOT MYBOXES.description === "0,0,1,1"::box
+ NOT MYBOXES.description === "0,0,1,1"::box
</programlisting>
to
<programlisting>
-MYBOXES.description !== "0,0,1,1"::box
+ MYBOXES.description !== "0,0,1,1"::box
</programlisting>
</para>
<para>
If a commutator operator name is supplied,
-<productname>Postgres</productname>
+ <productname>Postgres</productname>
searches for it in the catalog. If it is found and it
does not yet have a commutator itself, then the commutator's
entry is updated to have the current (new) operator
<para>
The next two specifications are present to support the
query optimizer in performing joins.
-<productname>Postgres</productname> can always
+ <productname>Postgres</productname> can always
evaluate a join (i.e., processing a clause with two tuple
variables separated by an operator that returns a boolean)
by iterative substitution [WONG76].
-In addition, <productname>Postgres</productname>
+ In addition, <productname>Postgres</productname>
is planning on implementing a hash-join algorithm along
the lines of [SHAP86]; however, it must know whether this
strategy is applicable.
-For example, a hash-join
+ For example, a hash-join
algorithm is usable for a clause of the form:
<programlisting>
-MYBOXES.description === MYBOXES2.description
+ MYBOXES.description === MYBOXES2.description
</programlisting>
but not for a clause of the form:
<programlisting>
-MYBOXES.description <<< MYBOXES2.description.
+ MYBOXES.description <<< MYBOXES2.description.
</programlisting>
The HASHES flag gives the needed information to the query
optimizer concerning whether a hash join strategy is
sort both relations using the operator, <<<. On the other
hand, merge-sort is not usable with the clause:
<programlisting>
-MYBOXES.description <<< MYBOXES2.description
+ MYBOXES.description <<< MYBOXES2.description
</programlisting>
</para>
<para>
If other join strategies are found to be practical,
-<productname>Postgres</productname>
- will change the optimizer and run-time system to use
+ <productname>Postgres</productname>
+ will change the optimizer and run-time system to use
them and will require additional specification when an
operator is defined. Fortunately, the research community
invents new join strategies infrequently, and the added
the query optimizer can estimate result sizes. If a
clause of the form:
<programlisting>
-MYBOXES.description <<< "0,0,1,1"::box
+ MYBOXES.description <<< "0,0,1,1"::box
</programlisting>
is present in the qualification,
- then <productname>Postgres</productname> may have to
+ then <productname>Postgres</productname> may have to
estimate the fraction of the instances in MYBOXES that
satisfy the clause. The function
- <replaceable class="parameter">res_proc</replaceable>
- must be a registered function (meaning it is already defined using
+ <replaceable class="parameter">res_proc</replaceable>
+ must be a registered function (meaning it is already defined using
define function(l)) which accepts one argument of the correct
data type and returns a floating point number. The
query optimizer simply calls this function, passing the
<para>
The difference between the function
<programlisting>
-my_procedure_1 (MYBOXES.description, "0,0,1,1"::box)
+ my_procedure_1 (MYBOXES.description, "0,0,1,1"::box)
</programlisting>
and the operator
<programlisting>
-MYBOXES.description === "0,0,1,1"::box
+ MYBOXES.description === "0,0,1,1"::box
</programlisting>
is that <productname>Postgres</productname>
- attempts to optimize operators and can
+ attempts to optimize operators and can
decide to use an index to restrict the search space when
operators are involved. However, there is no attempt to
optimize functions, and they are performed by brute force.
</TITLE>
<PARA>
Refer to the chapter on operators in the
-<citetitle>PostgreSQL User's Guide</citetitle>
+ <citetitle>PostgreSQL User's Guide</citetitle>
for further information.
Refer to <command>DROP OPERATOR</command> to delete
-user-defined operators from a database.
-
+ user-defined operators from a database.
+ </para>
</REFSECT2>
+ </refsect1>
<REFSECT1 ID="R1-SQL-CREATEOPERATOR-2">
<TITLE>
area-equality, for the BOX data type.
</PARA>
<ProgramListing>
-CREATE OPERATOR === (
- LEFTARG = box,
- RIGHTARG = box,
- PROCEDURE = area_equal_procedure,
- COMMUTATOR = ===,
- NEGATOR = !==,
- RESTRICT = area_restriction_procedure,
- HASHES,
- JOIN = area-join-procedure,
- SORT = <<<, <<<)
- </ProgramListing>
-
-
+ CREATE OPERATOR === (
+ LEFTARG = box,
+ RIGHTARG = box,
+ PROCEDURE = area_equal_procedure,
+ COMMUTATOR = ===,
+ NEGATOR = !==,
+ RESTRICT = area_restriction_procedure,
+ HASHES,
+ JOIN = area-join-procedure,
+ SORT = <<<, <<<)
+ </ProgramListing>
</REFSECT1>
<REFSECT1 ID="R1-SQL-CREATEOPERATOR-3">
<REFPURPOSE>
Defines a new rule
</REFPURPOSE>
+ </refnamediv>
<REFSYNOPSISDIV>
<REFSYNOPSISDIVINFO>
<DATE>1998-09-11</DATE>
<LISTITEM>
<PARA>
Message returned if the rule is successfully created.
-
- </VARLISTENTRY>
- </VARIABLELIST>
-
+ </para>
+ </listitem>
+ </VARLISTENTRY>
+ </VARIABLELIST>
+ </para>
</REFSECT2>
</REFSYNOPSISDIV>
<para>
You must have rule definition access to a class in order
to define a rule on it. Use <command>GRANT</command>
-and <command>REVOKE</command> to change permissions.
-
+ and <command>REVOKE</command> to change permissions.
+
</PARA>
</REFSECT2>
</refsect1>
fail if the rule plus its various internal representations
exceed some value that is on the order of one page (8KB).
</PARA>
+ </refsect1>
<REFSECT1 ID="R1-SQL-CREATERULE-4">
<TITLE>
<REFPURPOSE>
Creates a new sequence number generator
</REFPURPOSE>
-
+ </refnamediv>
<REFSYNOPSISDIV>
<REFSYNOPSISDIVINFO>
<DATE>1998-04-15</DATE>
<LISTITEM>
<PARA>
If the minimum and maximum values are inconsistant.
-
- </VARIABLELIST>
+ </para>
+ </listitem>
+ </varlistentry>
+ </VARIABLELIST>
+ </para>
</REFSECT2>
</REFSYNOPSISDIV>
</para>
<caution>
-<para>
- Unexpected results may be obtained if a cache setting greater than one
- is used for a sequence object that will be used concurrently by multiple
- backends. Each backend will allocate "cache" successive sequence values
- during one access to the sequence object and increase the sequence
- object's last_value accordingly. Then, the next cache-1 uses of nextval
- within that backend simply return the preallocated values without touching
- the shared object. So, numbers allocated but not used in the current session
- will be lost. Furthermore, although multiple backends are guaranteed to
- allocate distinct sequence values, the values may be generated out of
- sequence when all the backends are considered. (For example, with a cache
- setting of 10, backend A might reserve values 1..10 and return nextval=1,
-then
- backend B might reserve values 11..20 and return nextval=11 before backend
- A has generated nextval=2.) Thus, with a cache setting of one it is safe
- to assume that nextval values are generated sequentially; with a cache
- setting greater than one you should only assume that the nextval values
- are all distinct, not that they are generated purely sequentially.
- Also, last_value will reflect the latest value reserved by any backend,
- whether or not it has yet been returned by nextval.
-</caution>
+ <para>
+ Unexpected results may be obtained if a cache setting greater than one
+ is used for a sequence object that will be used concurrently by multiple
+ backends. Each backend will allocate "cache" successive sequence values
+ during one access to the sequence object and increase the sequence
+ object's last_value accordingly. Then, the next cache-1 uses of nextval
+ within that backend simply return the preallocated values without touching
+ the shared object. So, numbers allocated but not used in the current session
+ will be lost. Furthermore, although multiple backends are guaranteed to
+ allocate distinct sequence values, the values may be generated out of
+ sequence when all the backends are considered. (For example, with a cache
+ setting of 10, backend A might reserve values 1..10 and return nextval=1,
+ then
+ backend B might reserve values 11..20 and return nextval=11 before backend
+ A has generated nextval=2.) Thus, with a cache setting of one it is safe
+ to assume that nextval values are generated sequentially; with a cache
+ setting greater than one you should only assume that the nextval values
+ are all distinct, not that they are generated purely sequentially.
+ Also, last_value will reflect the latest value reserved by any backend,
+ whether or not it has yet been returned by nextval.
+ </para>
+ </caution>
<REFSECT2 ID="R2-SQL-CREATESEQUENCE-3">
<REFSECT2INFO>
<para>
Set the sequence value after a COPY FROM:
<programlisting>
-CREATE FUNCTION distributors_id_max() RETURNS INT4
- AS 'SELECT max(id) FROM distributors'
- LANGUAGE 'sql';
-BEGIN;
-COPY distributors FROM 'input_file';
-SELECT setval('serial', distributors_id_max());
-END;
+ CREATE FUNCTION distributors_id_max() RETURNS INT4
+ AS 'SELECT max(id) FROM distributors'
+ LANGUAGE 'sql';
+ BEGIN;
+ COPY distributors FROM 'input_file';
+ SELECT setval('serial', distributors_id_max());
+ END;
</programlisting>
</para>
-
+
</REFSECT1>
<REFSECT1 ID="R1-SQL-CREATESEQUENCE-3">
</TITLE>
<PARA>
<command>CREATE SEQUENCE</command> is a <productname>Postgres</productname>
- language extension.
+ language extension.
</PARA>
<REFSECT2 ID="R2-SQL-CREATESEQUENCE-4">
<REFPURPOSE>
Creates a new table
</REFPURPOSE>
-
+ </refnamediv>
<REFSYNOPSISDIV>
<REFSYNOPSISDIVINFO>
<DATE>1998-09-11</DATE>
<SYNOPSIS>
CREATE TABLE <REPLACEABLE CLASS="PARAMETER">table</REPLACEABLE> (
<REPLACEABLE CLASS="PARAMETER">column</REPLACEABLE> <REPLACEABLE CLASS="PARAMETER">type</REPLACEABLE>
- [ DEFAULT <REPLACEABLE CLASS="PARAMETER">value</REPLACEABLE>]
- [, NOT NULL ] [ ,UNIQUE ]
+ [ NULL | NOT NULL ] [ UNIQUE ] [ DEFAULT <REPLACEABLE CLASS="PARAMETER">value</REPLACEABLE> ]
[<REPLACEABLE>column_constraint_clause</REPLACEABLE> | PRIMARY KEY } [ ... ] ]
[, ... ]
[, PRIMARY KEY ( <REPLACEABLE CLASS="PARAMETER">column</REPLACEABLE> [, ...] ) ]
</LISTITEM>
</VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
- INHERITS <REPLACEABLE CLASS="PARAMETER">inherited_table</REPLACEABLE>
- </TERM>
- <LISTITEM>
- <PARA>
- The optional INHERITS clause specifies a collection of table
- names from which this table automatically inherits all fields.
- If any inherited field name appears more than once,
-<productname>Postgres</productname>
- reports an error.
- <productname>Postgres</productname> automatically allows the created
- table to inherit functions on tables above it in the inheritance
- hierarchy.
-<note>
-<title>Aside</title>
-<para>
- Inheritance of functions is done according
- to the conventions of the Common Lisp Object System (CLOS).
-</note>
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
-
- </VARIABLELIST>
-
-
+ <VARLISTENTRY>
+ <TERM>
+ INHERITS <REPLACEABLE CLASS="PARAMETER">inherited_table</REPLACEABLE>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ The optional INHERITS clause specifies a collection of table
+ names from which this table automatically inherits all fields.
+ If any inherited field name appears more than once,
+ <productname>Postgres</productname>
+ reports an error.
+ <productname>Postgres</productname> automatically allows the created
+ table to inherit functions on tables above it in the inheritance
+ hierarchy.
+ <note>
+ <title>Aside</title>
+ <para>
+ Inheritance of functions is done according
+ to the conventions of the Common Lisp Object System (CLOS).
+ </para>
+ </note>
+ </PARA>
+ </LISTITEM>
+ </VARLISTENTRY>
+ </VARIABLELIST>
+ </para>
</REFSECT2>
<REFSECT2 ID="R2-SQL-CREATETABLE-2">
<PARA>
if data type of default value doesn't match the
column definition's data type.
-
- </VARIABLELIST>
+ </para>
+ </listitem>
+ </varlistentry>
+ </VARIABLELIST>
+ </para>
</REFSECT2>
</REFSYNOPSISDIV>
<command>CREATE TABLE</command> will enter a new table into the current data
base. The table will be "owned" by the user issuing the
command.
-
+ </para>
<PARA>
The new table is created as a heap with no initial data.
A table can have no more than 1600 columns (realistically,
lower at some sites. A table cannot have the same name as
a system catalog table.
</PARA>
-
+ </refsect1>
- <REFSECT1 ID="R1-SQL-DEFAULTCLAUSE-1">
+ <REFSECT1 ID="R1-SQL-DEFAULTCLAUSE-1">
<REFSECT1INFO>
<DATE>1998-09-11</DATE>
</REFSECT1INFO>
<SYNOPSIS>
DEFAULT <REPLACEABLE CLASS="PARAMETER">value</REPLACEABLE>
</SYNOPSIS>
-
+ </para>
<REFSECT2 ID="R2-SQL-DEFAULTCLAUSE-1">
<REFSECT2INFO>
<DATE>1998-09-11</DATE>
<listitem>
<simpara>
a niladic function
- </simpara>
- </listitem>
- </itemizedlist>
- </para>
+ </simpara>
</listitem>
- </VARLISTENTRY>
-
- </variablelist>
+ </itemizedlist>
+ </para>
+ </listitem>
+ </VARLISTENTRY>
+ </variablelist>
+ </para>
+ </refsect2>
+
<REFSECT2 ID="R2-SQL-DEFAULTCLAUSE-2">
<REFSECT2INFO>
<DATE>1998-09-11</DATE>
</REFSECT2INFO>
<TITLE>
- Outputs
- </TITLE>
- <PARA>
-
+ Outputs
+ </TITLE>
+ <para>
+ </para>
+ </refsect2>
+
<REFSECT2 ID="R2-SQL-DEFAULTCLAUSE-3">
<REFSECT2INFO>
<DATE>1998-09-11</DATE>
</listitem>
</varlistentry>
</variablelist>
+ </para>
<para>
In the current release (v6.4), <productname>Postgres</productname>
</quote>.
This forces <productname>Postgres</productname> to consider the constant a string
type and then to convert the value to <type>timestamp</type> at runtime.
-
+ </para>
+ </refsect2>
<REFSECT2 ID="R2-SQL-DEFAULTCLAUSE-4">
<REFSECT2INFO>
<DATE>1998-09-11</DATE>
total CASH DEFAULT '$0.0'
);
</ProgramListing>
-
+ </para>
<PARA>
To assign an existing sequence
as the default for the column <literal>did</literal>,
name VARCHAR(40) DEFAULT 'luso films'
);
</ProgramListing>
-
+ </para>
+ </refsect2>
</REFSECT1>
<REFSECT1 ID="R1-SQL-COLUMNCONSTRAINT-1">
</TITLE>
<para>
<SYNOPSIS>
-[ CONSTRAINT <replaceable class="parameter">name</replaceable> ] { NOT NULL | UNIQUE | PRIMARY KEY | CHECK <replaceable class="parameter">constraint</replaceable> } [, ...]
+[ CONSTRAINT <replaceable class="parameter">name</replaceable> ] { [ NULL | NOT NULL ] | UNIQUE | PRIMARY KEY | CHECK <replaceable class="parameter">constraint</replaceable> } [, ...]
</SYNOPSIS>
+ </para>
<REFSECT2 ID="R2-SQL-COLUMNCONSTRAINT-1">
<REFSECT2INFO>
</LISTITEM>
</VARLISTENTRY>
+ <VARLISTENTRY>
+ <TERM>
+ NULL
+ </TERM>
+ <LISTITEM>
+ <PARA>
+The column is allowed to contain NULL values. This is the default.
+ </PARA>
+ </LISTITEM>
+ </VARLISTENTRY>
+
<VARLISTENTRY>
<TERM>
NOT NULL
</LISTITEM>
</VARLISTENTRY>
</VARIABLELIST>
+ </para>
+ </refsect2>
<REFSECT2 ID="R2-SQL-COLUMNCONSTRAINT-2">
<REFSECT2INFO>
accepts the REFERENCES syntax but ignores the clause.
</para>
</note>
+ </refsect2>
<REFSECT2 ID="R2-SQL-NOTNULL-1">
<REFSECT2INFO>
as a table constraint.
</PARA>
- <REFSECT3 ID="R3-SQL-NOTNULL-1">
- <REFSECT3INFO>
- <DATE>1998-09-11</DATE>
- </REFSECT3INFO>
- <TITLE>
- Outputs
- </TITLE>
- <PARA>
- </PARA>
- <VARIABLELIST>
- <VARLISTENTRY>
- <TERM>
-<replaceable>status</replaceable>
- </TERM>
- <LISTITEM>
- <PARA>
- <VARIABLELIST>
- <VARLISTENTRY>
- <TERM>
- <ReturnValue>ERROR: ExecAppend: Fail to add null value in not
- null attribute "<replaceable class="parameter">column</replaceable>".</ReturnValue>
- </TERM>
- <LISTITEM>
- <PARA>
- This error occurs at runtime if one tries to insert a null value
- into a column which has a NOT NULL constraint.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- </variablelist>
- </LISTITEM>
- </VARLISTENTRY>
- </VARIABLELIST>
-
- <REFSECT3 ID="R3-SQL-NOTNULL-2">
- <REFSECT3INFO>
- <DATE>1998-09-11</DATE>
- </REFSECT3INFO>
- <TITLE>
-Description
-</title>
-<para>
-
- <REFSECT3 ID="R3-SQL-NOTNULL-3">
- <REFSECT3INFO>
- <DATE>1998-09-11</DATE>
- </REFSECT3INFO>
- <TITLE>
-Usage
-</title>
-
- <PARA>
- Define two NOT NULL column constraints on the table
- <classname>distributors</classname>,
-one of which being a named constraint:
- </PARA>
- <ProgramListing>
-CREATE TABLE distributors (
- did DECIMAL(3) CONSTRAINT no_null NOT NULL,
- name VARCHAR(40) NOT NULL
-);
- </ProgramListing>
+ <REFSECT3 ID="R3-SQL-NOTNULL-1">
+ <REFSECT3INFO>
+ <DATE>1998-09-11</DATE>
+ </REFSECT3INFO>
+ <TITLE>
+ Outputs
+ </TITLE>
+ <PARA>
+ </PARA>
+ <VARIABLELIST>
+ <VARLISTENTRY>
+ <TERM>
+ <replaceable>status</replaceable>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ <VARIABLELIST>
+ <VARLISTENTRY>
+ <TERM>
+ <ReturnValue>ERROR: ExecAppend: Fail to add null value in not
+ null attribute "<replaceable class="parameter">column</replaceable>".</ReturnValue>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ This error occurs at runtime if one tries to insert a null value
+ into a column which has a NOT NULL constraint.
+ </PARA>
+ </LISTITEM>
+ </VARLISTENTRY>
+ </variablelist>
+ </para>
+ </LISTITEM>
+ </VARLISTENTRY>
+ </VARIABLELIST>
+ </refsect3>
+ <REFSECT3 ID="R3-SQL-NOTNULL-2">
+ <REFSECT3INFO>
+ <DATE>1998-09-11</DATE>
+ </REFSECT3INFO>
+ <TITLE>
+ Description
+ </title>
+ <para>
+ </para>
+ </refsect3>
+
+ <REFSECT3 ID="R3-SQL-NOTNULL-3">
+ <REFSECT3INFO>
+ <DATE>1998-09-11</DATE>
+ </REFSECT3INFO>
+ <TITLE>
+ Usage
+ </title>
+
+ <PARA>
+ Define two NOT NULL column constraints on the table
+ <classname>distributors</classname>,
+ one of which being a named constraint:
+
+ <ProgramListing>
+ CREATE TABLE distributors (
+ did DECIMAL(3) CONSTRAINT no_null NOT NULL,
+ name VARCHAR(40) NOT NULL
+ );
+ </ProgramListing>
+ </para>
+ </refsect3>
+ </refsect2>
+
<REFSECT2 ID="R2-SQL-UNIQUECLAUSE-1">
<REFSECT2INFO>
<DATE>1998-09-11</DATE>
<refsect3>
<title>Inputs</title>
-<para>
- <variablelist>
- <varlistentry>
- <term>
- CONSTRAINT <replaceable class="parameter">name</replaceable>
- </term>
- <listitem>
- <para>
- An arbitrary label given to a constraint.
- </para>
- </listitem>
- </varlistentry>
- </variablelist>
+ <para>
+ <variablelist>
+ <varlistentry>
+ <term>
+ CONSTRAINT <replaceable class="parameter">name</replaceable>
+ </term>
+ <listitem>
+ <para>
+ An arbitrary label given to a constraint.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </para>
</refsect3>
-
+
<refsect3>
<title>Outputs</title>
<PARA>
<para>
This error occurs at runtime if one tries to insert a
duplicate value into a column.
- </para>
- </listitem>
- </varlistentry>
- </variablelist></para>
- </listitem>
- </varlistentry>
- </variablelist>
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </para>
</refsect3>
-
+
<refsect3>
<title>
Description
data integrity. See CREATE INDEX for more information.
</Para>
</Note>
+ </refsect3>
<REFSECT3 ID="R3-SQL-UNIQUECLAUSE-3">
<TITLE>
UNIQUE(name)
);
</ProgramListing>
+ </para>
+ </refsect3>
+ </refsect2>
<REFSECT2 ID="R2-SQL-CHECK-1">
<REFSECT2INFO>
<LISTITEM>
<PARA>
An arbitrary name given to a constraint.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
- <replaceable>condition</replaceable>
- </TERM>
- <LISTITEM>
- <PARA>
- Any valid conditional expression evaluating to a boolean result.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- </variablelist>
- </REFSECT3>
-
- <REFSECT3 ID="R3-SQL-CHECK-2">
- <REFSECT3INFO>
- <DATE>1998-09-11</DATE>
- </REFSECT3INFO>
- <TITLE>
- Outputs
- </TITLE>
- <PARA>
- <VARIABLELIST>
+ </PARA>
+ </LISTITEM>
+ </VARLISTENTRY>
<VARLISTENTRY>
<TERM>
-<replaceable>status</replaceable>
+ <replaceable>condition</replaceable>
</TERM>
<LISTITEM>
<PARA>
-
+ Any valid conditional expression evaluating to a boolean result.
+ </PARA>
+ </LISTITEM>
+ </VARLISTENTRY>
+ </variablelist>
+ </para>
+ </REFSECT3>
+
+ <REFSECT3 ID="R3-SQL-CHECK-2">
+ <REFSECT3INFO>
+ <DATE>1998-09-11</DATE>
+ </REFSECT3INFO>
+ <TITLE>
+ Outputs
+ </TITLE>
+ <PARA>
<VARIABLELIST>
<VARLISTENTRY>
<TERM>
- <ReturnValue>
- ERROR: ExecAppend: rejected due to CHECK constraint
- "<replaceable class="parameter">table_column</replaceable>".
- </ReturnValue>
+ <replaceable>status</replaceable>
</TERM>
<LISTITEM>
<PARA>
- This error occurs at runtime if one tries to insert an illegal
- value into a column subject to a CHECK constraint.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- </variablelist>
+
+ <VARIABLELIST>
+ <VARLISTENTRY>
+ <TERM>
+ <ReturnValue>
+ ERROR: ExecAppend: rejected due to CHECK constraint
+ "<replaceable class="parameter">table_column</replaceable>".
+ </ReturnValue>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ This error occurs at runtime if one tries to insert an illegal
+ value into a column subject to a CHECK constraint.
+ </PARA>
+ </LISTITEM>
+ </VARLISTENTRY>
+ </variablelist>
+ </para>
</LISTITEM>
</VARLISTENTRY>
</variablelist>
+ </para>
</REFSECT3>
-
+
<refsect3>
<title>Description</title>
<para>
The CHECK constraint specifies a restriction on allowed values
-within a column.
+ within a column.
The CHECK constraint is also allowed as a table constraint.
</PARA>
<PARA>
The SQL92 CHECK column constraints can only be defined on, and
refer to, one column of the table. <productname>Postgres</productname>
- does not have
+ does not have
this restriction.
</PARA>
</refsect3>
<para>
This occurs at run-time if one tries to insert a duplicate value into
a column subject to a PRIMARY KEY constraint.
- </PARA>
+ </PARA>
</listitem>
</varlistentry>
</variablelist>
disallow this.
</PARA>
</refsect3>
-
- <REFSECT1 ID="R1-SQL-TABLECONSTRAINT-1">
- <REFSECT1INFO>
- <DATE>1998-09-11</DATE>
- </REFSECT1INFO>
- <TITLE>
+ </refsect2>
+ </refsect1>
+
+ <REFSECT1 ID="R1-SQL-TABLECONSTRAINT-1">
+ <REFSECT1INFO>
+ <DATE>1998-09-11</DATE>
+ </REFSECT1INFO>
+ <TITLE>
Table CONSTRAINT Clause
- </TITLE>
- <para>
+ </TITLE>
+ <para>
<SYNOPSIS>
-[ CONSTRAINT name ] { PRIMARY KEY | UNIQUE } ( <replaceable class="parameter">column</replaceable> [, ...] )
-[ CONSTRAINT name ] CHECK ( <replaceable>constraint</replaceable> )
+ [ CONSTRAINT name ] { PRIMARY KEY | UNIQUE } ( <replaceable class="parameter">column</replaceable> [, ...] )
+ [ CONSTRAINT name ] CHECK ( <replaceable>constraint</replaceable> )
</SYNOPSIS>
- <PARA>
-
+ </para>
<REFSECT2 ID="R2-SQL-TABLECONSTRAINT-1">
<REFSECT2INFO>
<DATE>1998-09-11</DATE>
</REFSECT2INFO>
-<title>
-Inputs
-</title>
-
-<para>
- <VARIABLELIST>
- <VARLISTENTRY>
- <TERM>
- CONSTRAINT <replaceable class="parameter">name</replaceable>
- </TERM>
- <LISTITEM>
- <PARA>
- An arbitrary name given to an integrity constraint.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
- <replaceable class="parameter">column</replaceable> [, ...]
- </TERM>
- <LISTITEM>
- <PARA>
- The column name(s) for which to define a unique index
-and, for PRIMARY KEY, a NOT NULL constraint.
- </PARA>
- </LISTITEM>
- <VARLISTENTRY>
- <TERM>
- CHECK ( <replaceable class="parameter">constraint</replaceable> )
- </TERM>
- <LISTITEM>
- <PARA>
- A boolean expression to be evaluated as the constraint.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- </VARIABLELIST>
-
+ <title>
+ Inputs
+ </title>
+
+ <para>
+ <VARIABLELIST>
+ <VARLISTENTRY>
+ <TERM>
+ CONSTRAINT <replaceable class="parameter">name</replaceable>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ An arbitrary name given to an integrity constraint.
+ </PARA>
+ </LISTITEM>
+ </VARLISTENTRY>
+ <VARLISTENTRY>
+ <TERM>
+ <replaceable class="parameter">column</replaceable> [, ...]
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ The column name(s) for which to define a unique index
+ and, for PRIMARY KEY, a NOT NULL constraint.
+ </PARA>
+ </LISTITEM>
+ </varlistentry>
+ <VARLISTENTRY>
+ <TERM>
+ CHECK ( <replaceable class="parameter">constraint</replaceable> )
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ A boolean expression to be evaluated as the constraint.
+ </PARA>
+ </LISTITEM>
+ </VARLISTENTRY>
+ </VARIABLELIST>
+ </para>
+ </refsect2>
+
<REFSECT2 ID="R2-SQL-TABLECONSTRAINT-2">
<REFSECT2INFO>
<DATE>1998-09-11</DATE>
</REFSECT2INFO>
-<title>
-Outputs
-</title>
-
-<para>
-The possible outputs for the table constraint clause are the same
-as for the corresponding portions of the column constraint clause.
-
+ <title>
+ Outputs
+ </title>
+
+ <para>
+ The possible outputs for the table constraint clause are the same
+ as for the corresponding portions of the column constraint clause.
+ </para>
+ </refsect2>
+
<REFSECT2 ID="R2-SQL-TABLECONSTRAINT-3">
<REFSECT2INFO>
<DATE>1998-09-11</DATE>
</REFSECT2INFO>
-<title>
-Description
-</title>
-
+ <title>
+ Description
+ </title>
+
<para>
A table constraint is an integrity constraint defined on one or
more columns of a base table. The four variations of "Table
<note>
<para>
<productname>Postgres</productname> does not yet
-(as of version 6.4) support FOREIGN KEY
-integrity constraints. The parser understands the FOREIGN KEY syntax,
-but only prints a notice and otherwise ignores the clause.
+ (as of version 6.4) support FOREIGN KEY
+ integrity constraints. The parser understands the FOREIGN KEY syntax,
+ but only prints a notice and otherwise ignores the clause.
Foreign keys may be partially emulated by triggers (See the CREATE TRIGGER
statement).
</para>
</note>
-
+ </refsect2>
+
<REFSECT2 ID="R2-SQL-UNIQUECLAUSE-4">
<REFSECT2INFO>
<DATE>1998-09-11</DATE>
UNIQUE Constraint
</TITLE>
<para>
- <synopsis>
-[ CONSTRAINT <replaceable class="parameter">name</replaceable> ] UNIQUE ( <replaceable class="parameter">column</replaceable> [, ...] )
- </SYNOPSIS>
+ <synopsis>
+ [ CONSTRAINT <replaceable class="parameter">name</replaceable> ] UNIQUE ( <replaceable class="parameter">column</replaceable> [, ...] )
+ </SYNOPSIS>
+ </para>
<refsect3>
<title>Inputs</title>
<variablelist>
<varlistentry>
<term>
- CONSTRAINT <replaceable class="parameter">name</replaceable>
+ CONSTRAINT <replaceable class="parameter">name</replaceable>
</term>
<listitem>
<para>
</varlistentry>
</variablelist>
</refsect3>
+
<refsect3>
<title>Outputs</title>
<PARA>
- <VARIABLELIST>
- <VARLISTENTRY>
- <TERM>
-<replaceable>status</replaceable>
- </TERM>
- <LISTITEM>
- <PARA>
- <VARIABLELIST>
- <VARLISTENTRY>
- <TERM>
- ERROR: Cannot insert a duplicate key into a unique index.
- </term>
- <listitem>
- <para>
- This error occurs at runtime if one tries to insert a
- duplicate value into a column.
- </para>
- </listitem>
- </varlistentry>
- </variablelist>
- </listitem>
- </varlistentry>
- </variablelist>
+ <VARIABLELIST>
+ <VARLISTENTRY>
+ <TERM>
+ <replaceable>status</replaceable>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ <VARIABLELIST>
+ <VARLISTENTRY>
+ <TERM>
+ ERROR: Cannot insert a duplicate key into a unique index.
+ </term>
+ <listitem>
+ <para>
+ This error occurs at runtime if one tries to insert a
+ duplicate value into a column.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </para>
</refsect3>
-
+
<refsect3>
<title>
-Description
+ Description
</title>
-
+
<PARA>
The UNIQUE constraint specifies a rule that a group of one or
more distinct columns of a table may contain only unique values.
-The behavior of the UNIQUE table constraint is the same as that for column
-constraints, with the additional capability to span multiple columns.
+ The behavior of the UNIQUE table constraint is the same as that for column
+ constraints, with the additional capability to span multiple columns.
</para>
<para>
-See the section on the UNIQUE column constraint for more details.
-
- <REFSECT3 ID="R3-SQL-UNIQUECLAUSE-4">
- <TITLE>
-Usage
-</title>
-
- <PARA>
- Define a UNIQUE table constraint for the table distributors:
- <ProgramListing>
-CREATE TABLE distributors (
- did DECIMAL(03),
- name VARCHAR(40),
- UNIQUE(name)
-);
- </ProgramListing>
-
+ See the section on the UNIQUE column constraint for more details.
+ </para>
+ </refsect3>
+ <REFSECT3 ID="R3-SQL-UNIQUECLAUSE-4">
+ <TITLE>
+ Usage
+ </title>
+
+ <PARA>
+ Define a UNIQUE table constraint for the table distributors:
+ <ProgramListing>
+ CREATE TABLE distributors (
+ did DECIMAL(03),
+ name VARCHAR(40),
+ UNIQUE(name)
+ );
+ </ProgramListing>
+ </para>
+ </refsect3>
</REFSECT2>
<REFSECT2 ID="R2-SQL-PRIMARYKEY-4">
<TITLE>
PRIMARY KEY Constraint
</TITLE>
-<para>
- <SYNOPSIS>
- [ CONSTRAINT <REPLACEABLE CLASS="PARAMETER">name</REPLACEABLE> ] PRIMARY KEY ( <REPLACEABLE CLASS="PARAMETER">column</REPLACEABLE> [, ...] )
- </SYNOPSIS>
-
+ <para>
+ <SYNOPSIS>
+ [ CONSTRAINT <REPLACEABLE CLASS="PARAMETER">name</REPLACEABLE> ] PRIMARY KEY ( <REPLACEABLE CLASS="PARAMETER">column</REPLACEABLE> [, ...] )
+ </SYNOPSIS>
+ </para>
<refsect3>
<title>Inputs</title>
<PARA>
<VARIABLELIST>
<VARLISTENTRY>
<TERM>
-CONSTRAINT <ReturnValue><REPLACEABLE CLASS="PARAMETER">name</REPLACEABLE></ReturnValue>
+ CONSTRAINT <ReturnValue><REPLACEABLE CLASS="PARAMETER">name</REPLACEABLE></ReturnValue>
</TERM>
<LISTITEM>
<PARA>
</VARLISTENTRY>
<VARLISTENTRY>
<TERM>
-<REPLACEABLE CLASS="PARAMETER">column</REPLACEABLE> [, ...]
+ <REPLACEABLE CLASS="PARAMETER">column</REPLACEABLE> [, ...]
</TERM>
<LISTITEM>
<PARA>
</VARIABLELIST>
</para>
</refsect3>
-
+
<refsect3>
<title>Outputs</title>
<variablelist>
<varlistentry>
<term>
-<replaceable>status</replaceable>
-</term>
-<listitem>
-<para>
- <variablelist>
- <varlistentry>
- <term>ERROR: Cannot insert a duplicate key into a unique index.</term>
+ <replaceable>status</replaceable>
+ </term>
<listitem>
<para>
- This occurs at run-time if one tries to insert a duplicate value into
- a column subject to a PRIMARY KEY constraint.
- </PARA>
- </listitem>
- </varlistentry>
- </variablelist>
+ <variablelist>
+ <varlistentry>
+ <term>ERROR: Cannot insert a duplicate key into a unique index.</term>
+ <listitem>
+ <para>
+ This occurs at run-time if one tries to insert a duplicate value into
+ a column subject to a PRIMARY KEY constraint.
+ </PARA>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </para>
</listitem>
</varlistentry>
</variablelist>
</refsect3>
-
+
<refsect3>
<title>Description</title>
<PARA>
(non duplicate), non-null values. The column definitions of
the specified columns do not have to include a NOT NULL
constraint to be included in a PRIMARY KEY constraint.
-
-The PRIMARY KEY table constraint is similar to that for column constraints,
-with the additional capability of encompassing multiple columns.
+
+ The PRIMARY KEY table constraint is similar to that for column constraints,
+ with the additional capability of encompassing multiple columns.
</PARA>
<PARA>
-Refer to the section on the PRIMARY KEY column constraint for more
-information.
+ Refer to the section on the PRIMARY KEY column constraint for more
+ information.
+ </para>
</REFSECT3>
</REFSECT2>
-
+
</refsect1>
<REFSECT1 ID="R1-SQL-CREATETABLE-2">
</TITLE>
<PARA>
CREATE TABLE/INHERITS is a <productname>Postgres</productname>
- language extension.
+ language extension.
</PARA>
</refsect2>
<TITLE>
Compatibility
</TITLE>
- <PARA>
<REFSECT2 ID="R2-SQL-CREATETABLE-4">
<REFSECT2INFO>
) ON COMMIT DELETE ROWS
</programlisting>
<para>
-Temporary tables are not currently available
- in <productname>Postgres</productname>.
-<tip>
- <para>
- In the current release of <productname>Postgres</productname>
- (v6.4), to create a temporary
- table you must create and drop the table by explicit commands.
-</tip>
-
+ Temporary tables are not currently available
+ in <productname>Postgres</productname>.
+ <tip>
+ <para>
+ In the current release of <productname>Postgres</productname>
+ (v6.4), to create a temporary
+ table you must create and drop the table by explicit commands.
+ </para>
+ </tip>
+ </para>
+
<REFSECT3 ID="R3-SQL-UNIQUECLAUSE-1">
<REFSECT3INFO>
<DATE>1998-09-11</DATE>
</TITLE>
<PARA>
SQL92 specifies some additional capabilities for UNIQUE:
+ </para>
<para>
Table Constraint definition
</PARA>
</synopsis>
</refsect3>
+ <REFSECT3 ID="R3-SQL-NULL-1">
+ <REFSECT3INFO>
+ <DATE>1998-12-24</DATE>
+ </REFSECT3INFO>
+ <TITLE>
+ NULL clause
+ </TITLE>
+ <PARA>
+ The NULL "constraint" (actually a non-constraint)
+ is a <productname>Postgres</productname> extension to SQL92
+ is included for symmetry with the NOT NULL clause. Since it is the default
+ for any column, its presence is simply noise.
+ <synopsis>
+ [ CONSTRAINT name ] NULL
+ </synopsis>
+ </REFSECT3>
+
<REFSECT3 ID="R3-SQL-NOTNULL-4">
<REFSECT3INFO>
<DATE>1998-09-11</DATE>
SQL92 specifies some additional capabilities for NOT NULL:
</PARA>
<synopsis>
- [ CONSTRAINT name ] NOT NULL
- [ {INITIALLY DEFERRED | INITIALLY IMMEDIATE} ]
- [ [ NOT ] DEFERRABLE ]
+ [ CONSTRAINT name ] NOT NULL
+ [ {INITIALLY DEFERRED | INITIALLY IMMEDIATE} ]
+ [ [ NOT ] DEFERRABLE ]
</synopsis>
</REFSECT3>
<PARA>
SQL92 specifies some additional capabilities for constraints,
and also defines assertions and domain constraints.
- <note>
- <para>
- <productname>Postgres</productname> does not yet support
-either domains or assertions.
+ <note>
+ <para>
+ <productname>Postgres</productname> does not yet support
+ either domains or assertions.
+ </para>
+ </note>
</para>
- </note>
-
<PARA>
An assertion is a special type of integrity constraint and share
the same namespace as other constraints.
<REFPURPOSE>
Creates a new table
</REFPURPOSE>
-
+ </refnamediv>
<REFSYNOPSISDIV>
<REFSYNOPSISDIVINFO>
<DATE>1998-09-22</DATE>
<PARA>
A valid query statement. Refer to SELECT for a description of the
allowed syntax.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- </VARIABLELIST>
+ </PARA>
+ </LISTITEM>
+ </VARLISTENTRY>
+ </VARIABLELIST>
+ </para>
+ </refsect2>
<REFSECT2 ID="R2-SQL-CREATETABLEAS-2">
<REFSECT2INFO>
Outputs
</TITLE>
<PARA>
- Refer to CREATE TABLE and SELECT for a summary of possible output
-messages.
-
- <REFSECT1 ID="R1-SQL-CREATETABLEAS-1">
- <REFSECT1INFO>
- <DATE>1998-09-22</DATE>
- </REFSECT1INFO>
- <TITLE>
- Description
- </TITLE>
+ Refer to CREATE TABLE and SELECT for a summary of possible output
+ messages.
+ </para>
+ </refsect2>
+ </refsynopsisdiv>
+
+ <REFSECT1 ID="R1-SQL-CREATETABLEAS-1">
+ <REFSECT1INFO>
+ <DATE>1998-09-22</DATE>
+ </REFSECT1INFO>
+ <TITLE>
+ Description
+ </TITLE>
<PARA>
CREATE TABLE AS enables a table to be created from the contents of
an existing table. It has functionality equivalent to SELECT TABLE INTO,
but with perhaps a more obvious syntax.
-
-</refsect1>
+ </para>
+ </refsect1>
</refentry>
<!-- Keep this comment at the end of the file
<REFPURPOSE>
Creates a new trigger
</REFPURPOSE>
+ </refnamediv>
<REFSYNOPSISDIV>
<REFSYNOPSISDIVINFO>
<DATE>1998-09-21</DATE>
<LISTITEM>
<PARA>
This message is returned if the trigger is successfully created.
-
- </VARIABLELIST>
+ </para>
+ </listitem>
+ </varlistentry>
+ </VARIABLELIST>
+ </para>
</REFSECT2>
</REFSYNOPSISDIV>
<PARA>
Refer to <command>DROP TRIGGER</command> for information on how to
remove triggers.
- </PARA>
-
+ </PARA>
</REFSECT2>
-
+ </refsect1>
+
<REFSECT1 ID="R1-SQL-CREATETRIGGER-2">
<TITLE>
Usage
</TITLE>
<PARA>
- Check if the specified distributor code exists in the distributors
- table before appending or updating a row in the table films:
+ Check if the specified distributor code exists in the distributors
+ table before appending or updating a row in the table films:
</PARA>
<ProgramListing>
-CREATE TRIGGER if_dist_exists
- BEFORE INSERT OR UPDATE ON films FOR EACH ROW
- EXECUTE PROCEDURE check_primary_key ('did', 'distributors', 'did');
+ CREATE TRIGGER if_dist_exists
+ BEFORE INSERT OR UPDATE ON films FOR EACH ROW
+ EXECUTE PROCEDURE check_primary_key ('did', 'distributors', 'did');
</ProgramListing>
<PARA>
- Before cancelling a distributor or updating its code, remove every
- reference to the table films:
+ Before cancelling a distributor or updating its code, remove every
+ reference to the table films:
</PARA>
<ProgramListing>
-CREATE TRIGGER if_film_exists
- BEFORE DELETE OR UPDATE ON distributors FOR EACH ROW
- EXECUTE PROCEDURE check_foreign_key (1, 'CASCADE', 'did', 'films', 'did');
+ CREATE TRIGGER if_film_exists
+ BEFORE DELETE OR UPDATE ON distributors FOR EACH ROW
+ EXECUTE PROCEDURE check_foreign_key (1, 'CASCADE', 'did', 'films', 'did');
</ProgramListing>
</REFSECT1>
SQL92
</TITLE>
<PARA>
- There is no <command>CREATE TRIGGER</command> in <acronym>SQL92</acronym>.
+ There is no <command>CREATE TRIGGER</command> in <acronym>SQL92</acronym>.
</PARA>
<PARA>
The second example above may also be done by using a FOREIGN KEY
constraint as in:
</PARA>
<ProgramListing>
-CREATE TABLE distributors (
+ CREATE TABLE distributors (
did DECIMAL(3),
name VARCHAR(40),
CONSTRAINT if_film_exists
- FOREIGN KEY(did) REFERENCES films
- ON UPDATE CASCADE ON DELETE CASCADE
-);
- </ProgramListing>
+ FOREIGN KEY(did) REFERENCES films
+ ON UPDATE CASCADE ON DELETE CASCADE
+ );
+ </ProgramListing>
<PARA>
However, foreign keys are not yet implemented (as of version 6.4) in
<productname>Postgres</productname>.
</PARA>
+ </refsect2>
+ </refsect1>
</REFENTRY>
<!-- Keep this comment at the end of the file
<REFPURPOSE>
Defines a new base data type
</REFPURPOSE>
+ </refnamediv>
<REFSYNOPSISDIV>
<REFSYNOPSISDIVINFO>
<DATE>1998-09-21</DATE>
<LISTITEM>
<PARA>
Message returned if the type is successfully created.
-
+ </para>
+ </listitem>
+ </varlistentry>
</VARIABLELIST>
-
+ </para>
</REFSECT2>
</REFSYNOPSISDIV>
length. If you need a larger type you must create a Large
Object type. The interface for these types is discussed
at length in
-<comment>This section reference needs replacing</comment>
+ <comment>This section reference needs replacing</comment>
Section 7, the large object interface. The
length of all large object types is always VARIABLE.
+ </para>
</refsect2>
</refsect1>
+
<refsect1>
<title>Examples</title>
<para>
type in a class definition:
</para>
<programlisting>
- CREATE TYPE box (INTERNALLENGTH = 8,
- INPUT = my_procedure_1, OUTPUT = my_procedure_2)
-
- CREATE TABLE myboxes (id INT4, description box)
+ CREATE TYPE box (INTERNALLENGTH = 8,
+ INPUT = my_procedure_1, OUTPUT = my_procedure_2)
+
+ CREATE TABLE myboxes (id INT4, description box)
</programlisting>
<para>
This command creates a variable length array type with
with an underscore.
</para>
</refsect2>
+
<REFSECT2 ID="R2-SQL-CREATETYPE-3">
<REFSECT2INFO>
<DATE>1998-09-21</DATE>
</PARA>
<PARA>
See also <command>CREATE FUNCTION</command>,
- <command>CREATE OPERATOR</command> and the chapter on Large Objects
-in the <citetitle>PostgreSQL Programmer's Guide</citetitle>.
-</para>
+ <command>CREATE OPERATOR</command> and the chapter on Large Objects
+ in the <citetitle>PostgreSQL Programmer's Guide</citetitle>.
+ </para>
</REFSECT2>
</refsect1>
<TITLE>
Compatibility
</TITLE>
- <PARA>
<REFSECT2 ID="R2-SQL-CREATETYPE-4">
<REFSECT2INFO>
<command>CREATE TYPE</command> is an <acronym>SQL3</acronym> statement.
</PARA>
- </REFSECT2>
+ </REFSECT2>
+ </refsect1>
</REFENTRY>
<REFPURPOSE>
Creates account information for a new user
</REFPURPOSE>
+ </refnamediv>
<REFSYNOPSISDIV>
<REFSYNOPSISDIVINFO>
<DATE>1998-09-21</DATE>
a NULL value is stored in "<filename>pg_shadow</filename>"
for this attribute,
and the login will be valid for all time.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- </variablelist>
+ </PARA>
+ </LISTITEM>
+ </VARLISTENTRY>
+ </variablelist>
+ </para>
</REFSECT2>
<REFSECT2 ID="R2-SQL-CREATEUSER-2">
Message returned if the command completes successfully.
</PARA>
</LISTITEM>
- </VARLISTENTRY>
- <VARLISTENTRY>
- <TERM>
- <ReturnValue>ERROR: removeUser: user "<replaceable class="parameter">username</replaceable>" does not exist</ReturnValue>
- </TERM>
- <LISTITEM>
- <PARA>
- if "<replaceable class="parameter">username</replaceable>" not found.
- </PARA>
- <comment>I don't understand this and I don't know how to get
-this error message.</comment>
+ </VARLISTENTRY>
+ <VARLISTENTRY>
+ <TERM>
+ <ReturnValue>ERROR: removeUser: user "<replaceable class="parameter">username</replaceable>" does not exist</ReturnValue>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ if "<replaceable class="parameter">username</replaceable>" not found.
+ </PARA>
+ <comment>I don't understand this and I don't know how to get
+ this error message.</comment>
+ </listitem>
+ </varlistentry>
</VARIABLELIST>
</REFSECT2>
</REFSYNOPSISDIV>
+--------------------------+--------------------------+-------+
</programlisting>
</REFSECT2>
+ </refsect1>
<REFSECT1 ID="R1-SQL-CREATEUSER-2">
<TITLE>
SQL92
</TITLE>
<PARA>
- There is no CREATE USER statement in SQL92.
+ There is no CREATE USER statement in SQL92.
</PARA>
+ </refsect2>
+ </refsect1>
</REFENTRY>
<REFPURPOSE>
Constructs a virtual table
</REFPURPOSE>
+ </refnamediv>
<REFSYNOPSISDIV>
<REFSYNOPSISDIVINFO>
<DATE>1998-09-21</DATE>
</LISTITEM>
</VARLISTENTRY>
</variablelist>
+ </para>
</REFSECT2>
<REFSECT2 ID="R2-SQL-CREATEVIEW-2">
<programlisting>
CREATE VIEW vista AS SELECT 'Hello World'::text
</programlisting>
-
- </VARIABLELIST>
+ </para>
+ </listitem>
+ </varlistentry>
+ </VARIABLELIST>
+ </para>
</REFSECT2>
</REFSYNOPSISDIV>
Currently, views are read only.
</para>
</REFSECT2>
-
+ </refsect1>
+
<REFSECT1 ID="R1-SQL-CREATEVIEW-2">
<TITLE>
Usage
<REFENTRY ID="APP-CREATEDB">
-<REFMETA>
-<REFENTRYTITLE>
-<application>createdb</application>
-</REFENTRYTITLE>
-<REFMISCINFO>Application</REFMISCINFO>
-</REFMETA>
-<REFNAMEDIV>
-<REFNAME>
-<application>createdb</application>
-</REFNAME>
-<REFPURPOSE>
-Create a new <productname>Postgres</productname> database
-</REFPURPOSE>
-<REFSYNOPSISDIV>
-<REFSYNOPSISDIVINFO>
-<DATE>1998-10-02</DATE>
-</REFSYNOPSISDIVINFO>
-<SYNOPSIS>
-createdb [ <replaceable class="parameter">dbname</replaceable> ]
-createdb [ -h <replaceable class="parameter">host</replaceable> ] [ -p <replaceable class="parameter">port</replaceable> ]
- [ -D <replaceable class="parameter">datadir</replaceable> ]
- [ -u ] [ <replaceable class="parameter">dbname</replaceable> ]
-</SYNOPSIS>
-
-<REFSECT2 ID="R2-APP-CREATEDB-1">
-<REFSECT2INFO>
-<DATE>1998-10-02</DATE>
-</REFSECT2INFO>
-<TITLE>
-Inputs
-</TITLE>
-<PARA>
-
-<variablelist>
-<varlistentry>
-<term>
--h <replaceable class="parameter">host</replaceable>
-</term>
-<listitem>
-<para>
-Specifies the hostname of the machine on which the
-<application>postmaster</application>
-is running. Defaults to using a local Unix domain socket
- rather than an IP connection..
-
-<varlistentry>
-<term>
--p <replaceable class="parameter">port</replaceable>
-</term>
-<listitem>
-<para>
-Specifies the Internet TCP/IP port or local Unix domain socket file
-extension on which the <application>postmaster</application>
-is listening for connections. The port number defaults to 5432,
- or the value of the <envar>PGPORT</envar>
-environment variable (if set).
-
-<varlistentry>
-<term>
--u
-</term>
-<listitem>
-<para>
-Use password authentication.
-Prompts for
-<replaceable class="parameter">username</replaceable>
- and <replaceable class="parameter">password</replaceable>.
-
-<varlistentry>
-<term>
--D <replaceable class="parameter">datadir</replaceable>
-</term>
-<listitem>
-<para>
-Specifies the alternate database location for this database installation.
-This is the location of the installation system tables, not the location
-of this specific database, which may be different.
-
-<varlistentry>
-<term>
-<replaceable class="parameter">dbname</replaceable>
-</term>
-<listitem>
-<para>
-Specifies the name of the database to be created. The name must be
-unique among all <productname>Postgres</productname> databases in this installation.
-<replaceable class="parameter">dbname</replaceable>
-defaults to the value of the
-<envar>USER</envar>
-environment variable.
-
-</variablelist>
-
-<REFSECT2 ID="R2-APP-CREATEDB-2">
-<REFSECT2INFO>
-<DATE>1998-10-02</DATE>
-</REFSECT2INFO>
-<TITLE>
-Outputs
-</TITLE>
-<PARA>
-<application>createdb</application> will create files in the
-<filename><envar>PGDATA</envar>/<replaceable class="parameter">dbname</replaceable>/</filename>
-data area for the new database.
-
-<variablelist>
-<varlistentry>
-<term>
-Connection to database 'template1' failed.
-connectDB() failed: Is the postmaster running and accepting connections
- at 'UNIX Socket' on port '<replaceable class="parameter">port</replaceable>'?
-createdb: database creation failed on <replaceable class="parameter">dbname</replaceable>.
-<listitem>
-<para>
-<application>createdb</application> could not attach to the
-<application>postmaster</application>
-process on the specified host and port. If you see this message,
-ensure that the <application>postmaster</application>
-is running on the proper host and that you have specified the proper
-port. If your site uses an authentication system, ensure that you
-have obtained the required authentication credentials.
-
-<varlistentry>
-<term>
-Connection to database 'template1' failed.
-FATAL 1: SetUserId: user '<replaceable class="parameter">username</replaceable>' is not in 'pg_shadow'
-createdb: database creation failed on <replaceable class="parameter">dbname</replaceable>.
-<listitem>
-<para>
-You do not have a valid entry in the relation <literal>pg_shadow</literal>
-and and will not be allowed to access <productname>Postgres</productname>.
-Contact your <productname>Postgres</productname> administrator.
-
-<varlistentry>
-<term>
-ERROR: user '<replaceable class="parameter">username</replaceable>' is not allowed to create/destroy databases
-createdb: database creation failed on <replaceable class="parameter">dbname</replaceable>.
-<listitem>
-<para>
-You do not have permission to create new databases.
-Contact your <productname>Postgres</productname> site administrator.
-
-<varlistentry>
-<term>
-ERROR: createdb: database '<replaceable class="parameter">dbname</replaceable>' already exists.
-createdb: database creation failed on <replaceable class="parameter">dbname</replaceable>.
-<listitem>
-<para>
-The database already exists.
-
-<varlistentry>
-<term>
-createdb: database creation failed on <replaceable class="parameter">dbname</replaceable>.
-<listitem>
-<para>
-An internal error occurred in <application>psql</application>
-or in the backend server. Ensure that your site administrator has
-properly installed <productname>Postgres</productname>and initialized the site with
-<application>initdb</application>.
-
-</variablelist>
-
-<note>
-<para>
-<application>createdb</application> internally runs
-CREATE DATABASE from <application>psql</application>
-while connected to the <literal>template1</literal> database.
-</note>
-
-<REFSECT1 ID="R1-APP-CREATEDB-1">
-<REFSECT1INFO>
-<DATE>1998-10-02</DATE>
-</REFSECT1INFO>
-<TITLE>
-Description
-</TITLE>
-<PARA>
-<application>createdb</application> creates a new
-<productname>Postgres</productname> database.
-The person who executes this command becomes
-the database administrator, or <acronym>DBA</acronym>,
- for this database and is the only
-person, other than the <productname>Postgres</productname> super-user,
- who can destroy it.
-
-<para>
-<application>createdb</application> is a shell script that invokes
-<application>psql</application>.
-Hence, a <application>postmaster</application>
-process must be running on the database server host before
-<application>createdb</application>
-is executed. The
-<envar>PGOPTION</envar>
-and
-<envar>PGREALM</envar>
-environment variables will be passed on to
-<application>psql</application>
-and processed as described in <xref linkend="app-psql" endterm="psql-ref">.
-
-<REFSECT1 ID="R1-APP-CREATEDB-2">
-<REFSECT1INFO>
-<DATE>1998-10-02</DATE>
-</REFSECT1INFO>
-<TITLE>
-Usage
-</TITLE>
-<PARA>
-To create the database <literal>demo</literal>
- using the postmaster on the local host, port 5432:
-
-<programlisting>
-createdb demo
-</programlisting>
-
-To create the database <literal>demo</literal>
- using the postmaster on host eden, port 5000:
-
-<programlisting>
-createdb -p 5000 -h eden demo
-</programlisting>
+ <REFMETA>
+ <REFENTRYTITLE>
+ <application>createdb</application>
+ </REFENTRYTITLE>
+ <REFMISCINFO>Application</REFMISCINFO>
+ </REFMETA>
+ <REFNAMEDIV>
+ <REFNAME>
+ <application>createdb</application>
+ </REFNAME>
+ <REFPURPOSE>
+ Create a new <productname>Postgres</productname> database
+ </REFPURPOSE>
+ </refnamediv>
+ <REFSYNOPSISDIV>
+ <REFSYNOPSISDIVINFO>
+ <DATE>1998-10-02</DATE>
+ </REFSYNOPSISDIVINFO>
+ <SYNOPSIS>
+ createdb [ <replaceable class="parameter">dbname</replaceable> ]
+ createdb [ -h <replaceable class="parameter">host</replaceable> ] [ -p <replaceable class="parameter">port</replaceable> ]
+ [ -D <replaceable class="parameter">datadir</replaceable> ]
+ [ -u ] [ <replaceable class="parameter">dbname</replaceable> ]
+ </SYNOPSIS>
+
+ <REFSECT2 ID="R2-APP-CREATEDB-1">
+ <REFSECT2INFO>
+ <DATE>1998-10-02</DATE>
+ </REFSECT2INFO>
+ <TITLE>
+ Inputs
+ </TITLE>
+ <PARA>
+
+ <variablelist>
+ <varlistentry>
+ <term>
+ -h <replaceable class="parameter">host</replaceable>
+ </term>
+ <listitem>
+ <para>
+ Specifies the hostname of the machine on which the
+ <application>postmaster</application>
+ is running. Defaults to using a local Unix domain socket
+ rather than an IP connection..
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>
+ -p <replaceable class="parameter">port</replaceable>
+ </term>
+ <listitem>
+ <para>
+ Specifies the Internet TCP/IP port or local Unix domain socket file
+ extension on which the <application>postmaster</application>
+ is listening for connections. The port number defaults to 5432,
+ or the value of the <envar>PGPORT</envar>
+ environment variable (if set).
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ -u
+ </term>
+ <listitem>
+ <para>
+ Use password authentication.
+ Prompts for
+ <replaceable class="parameter">username</replaceable>
+ and <replaceable class="parameter">password</replaceable>.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ -D <replaceable class="parameter">datadir</replaceable>
+ </term>
+ <listitem>
+ <para>
+ Specifies the alternate database location for this database installation.
+ This is the location of the installation system tables, not the location
+ of this specific database, which may be different.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ <replaceable class="parameter">dbname</replaceable>
+ </term>
+ <listitem>
+ <para>
+ Specifies the name of the database to be created. The name must be
+ unique among all <productname>Postgres</productname> databases in this installation.
+ <replaceable class="parameter">dbname</replaceable>
+ defaults to the value of the
+ <envar>USER</envar>
+ environment variable.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </para>
+ </refsect2>
+ <REFSECT2 ID="R2-APP-CREATEDB-2">
+ <REFSECT2INFO>
+ <DATE>1998-10-02</DATE>
+ </REFSECT2INFO>
+ <TITLE>
+ Outputs
+ </TITLE>
+ <PARA>
+ <application>createdb</application> will create files in the
+ <filename><envar>PGDATA</envar>/<replaceable class="parameter">dbname</replaceable>/</filename>
+ data area for the new database.
+
+ <variablelist>
+ <varlistentry>
+ <term>
+ Connection to database 'template1' failed.
+ connectDB() failed: Is the postmaster running and accepting connections
+ at 'UNIX Socket' on port '<replaceable class="parameter">port</replaceable>'?
+ createdb: database creation failed on <replaceable class="parameter">dbname</replaceable>.
+ </term>
+ <listitem>
+ <para>
+ <application>createdb</application> could not attach to the
+ <application>postmaster</application>
+ process on the specified host and port. If you see this message,
+ ensure that the <application>postmaster</application>
+ is running on the proper host and that you have specified the proper
+ port. If your site uses an authentication system, ensure that you
+ have obtained the required authentication credentials.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ Connection to database 'template1' failed.
+ FATAL 1: SetUserId: user '<replaceable class="parameter">username</replaceable>' is not in 'pg_shadow'
+ createdb: database creation failed on <replaceable class="parameter">dbname</replaceable>.
+ </term>
+ <listitem>
+ <para>
+ You do not have a valid entry in the relation <literal>pg_shadow</literal>
+ and and will not be allowed to access <productname>Postgres</productname>.
+ Contact your <productname>Postgres</productname> administrator.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ ERROR: user '<replaceable class="parameter">username</replaceable>' is not allowed to create/destroy databases
+ createdb: database creation failed on <replaceable class="parameter">dbname</replaceable>.
+ </term>
+ <listitem>
+ <para>
+ You do not have permission to create new databases.
+ Contact your <productname>Postgres</productname> site administrator.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ ERROR: createdb: database '<replaceable class="parameter">dbname</replaceable>' already exists.
+ createdb: database creation failed on <replaceable class="parameter">dbname</replaceable>.
+ </term>
+ <listitem>
+ <para>
+ The database already exists.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ createdb: database creation failed on <replaceable class="parameter">dbname</replaceable>.
+ </term>
+ <listitem>
+ <para>
+ An internal error occurred in <application>psql</application>
+ or in the backend server. Ensure that your site administrator has
+ properly installed <productname>Postgres</productname>and initialized the site with
+ <application>initdb</application>.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </para>
+ <note>
+ <para>
+ <application>createdb</application> internally runs
+ CREATE DATABASE from <application>psql</application>
+ while connected to the <literal>template1</literal> database.
+ </para>
+ </note>
+ </refsect2>
+ </refsynopsisdiv>
+
+ <REFSECT1 ID="R1-APP-CREATEDB-1">
+ <REFSECT1INFO>
+ <DATE>1998-10-02</DATE>
+ </REFSECT1INFO>
+ <TITLE>
+ Description
+ </TITLE>
+ <PARA>
+ <application>createdb</application> creates a new
+ <productname>Postgres</productname> database.
+ The person who executes this command becomes
+ the database administrator, or <acronym>DBA</acronym>,
+ for this database and is the only
+ person, other than the <productname>Postgres</productname> super-user,
+ who can destroy it.
+ </para>
+ <para>
+ <application>createdb</application> is a shell script that invokes
+ <application>psql</application>.
+ Hence, a <application>postmaster</application>
+ process must be running on the database server host before
+ <application>createdb</application>
+ is executed. The
+ <envar>PGOPTION</envar>
+ and
+ <envar>PGREALM</envar>
+ environment variables will be passed on to
+ <application>psql</application>
+ and processed as described in <xref linkend="app-psql" endterm="psql-ref">.
+ </para>
+ </refsect1>
+
+ <REFSECT1 ID="R1-APP-CREATEDB-2">
+ <REFSECT1INFO>
+ <DATE>1998-10-02</DATE>
+ </REFSECT1INFO>
+ <TITLE>
+ Usage
+ </TITLE>
+ <PARA>
+ To create the database <literal>demo</literal>
+ using the postmaster on the local host, port 5432:
+
+ <programlisting>
+ createdb demo
+ </programlisting>
+
+ To create the database <literal>demo</literal>
+ using the postmaster on host eden, port 5000:
+
+ <programlisting>
+ createdb -p 5000 -h eden demo
+ </programlisting>
+ </para>
+ </refsect1>
</REFENTRY>
<REFPURPOSE>
Create a new <productname>Postgres</productname> user
</REFPURPOSE>
+ </refnamediv>
<REFSYNOPSISDIV>
<REFSYNOPSISDIVINFO>
<DATE>1998-10-02</DATE>
[ -d | -D ] [ -u | -U ] [ <replaceable class="parameter">username</replaceable> ]
</SYNOPSIS>
-<REFSECT2 ID="R2-APP-CREATEUSER-1">
-<REFSECT2INFO>
-<DATE>1998-10-02</DATE>
-</REFSECT2INFO>
-<TITLE>
-Inputs
-</TITLE>
-<PARA>
-
-<variablelist>
-<varlistentry>
-<term>
--h <replaceable class="parameter">host</replaceable>
-</term>
-<listitem>
-<para>
-Specifies the hostname of the machine on which the
-<application>postmaster</application>
-is running. Defaults to using a local Unix domain socket
- rather than an IP connection..
-
-<varlistentry>
-<term>
--p <replaceable class="parameter">port</replaceable>
-</term>
-<listitem>
-<para>
-Specifies the Internet TCP/IP port or local Unix domain socket file
-extension on which the <application>postmaster</application>
-is listening for connections. The port number defaults to 5432,
- or the value of the <envar>PGPORT</envar>
-environment variable (if set).
-
-<varlistentry>
-<term>
--d
-</term>
-<listitem>
-<para>
-Allows the user to create databases.
-
-<varlistentry>
-<term>
--D
-</term>
-<listitem>
-<para>
-Forbids the user to create databases.
-
-<varlistentry>
-<term>
--i <replaceable class="parameter">userid</replaceable>
-</term>
-<listitem>
-<para>
-Specifies the numeric identifier to be associated with this user.
-This identifier must be unique among all <productname>Postgres</productname> users, and is not required
-to match the operating system UID.
-You will be prompted for an identifier if none is specified on the command line,
-and it will suggest an identifier matching the UID.
-
-<varlistentry>
-<term>
--u
-</term>
-<listitem>
-<para>
-Allows the user to create other users.
-
-<varlistentry>
-<term>
--U
-</term>
-<listitem>
-<para>
-Forbids the user to create other users.
-
-<varlistentry>
-<term>
-<replaceable class="parameter">username</replaceable>
-</term>
-<listitem>
-<para>
-Specifies the name of the <productname>Postgres</productname> user to be created.
-This name must be unique among all <productname>Postgres</productname> users.
-You will be prompted for a name if none is specified on the command line.
-
-</variablelist>
-
-<REFSECT2 ID="R2-APP-CREATEUSER-2">
-<REFSECT2INFO>
-<DATE>1998-10-02</DATE>
-</REFSECT2INFO>
-<TITLE>
-Outputs
-</TITLE>
-<PARA>
-<application>createuser</application> will add an entry in the
-<literal>pg_user</literal> or <literal>pg_shadow</literal> system table.
-
-<variablelist>
-<varlistentry>
-<term>
-Connection to database 'template1' failed.
-connectDB() failed: Is the postmaster running and accepting connections
- at 'UNIX Socket' on port '<replaceable class="parameter">port</replaceable>'?
-createuser: database access failed.
-<listitem>
-<para>
-<application>createuser</application> could not attach to the
-<application>postmaster</application>
-process on the specified host and port. If you see this message,
-ensure that the <application>postmaster</application>
-is running on the proper host and that you have specified the proper
-port. If your site uses an authentication system, ensure that you
-have obtained the required authentication credentials.
-
-<varlistentry>
-<term>
-Connection to database 'template1' failed.
-FATAL 1: SetUserId: user '<replaceable class="parameter">username</replaceable>' is not in 'pg_shadow'
-createuser: database access failed.
-<listitem>
-<para>
-You do not have a valid entry in the relation <literal>pg_shadow</literal>
-and and will not be allowed to access <productname>Postgres</productname>. Contact your
-<productname>Postgres</productname> administrator.
-
-<varlistentry>
-<term>
-createuser: <replaceable class="parameter">username</replaceable> cannot create users.
-<listitem>
-<para>
-You do not have permission to create new users; contact your
-<productname>Postgres</productname> site administrator.
-
-<varlistentry>
-<term>
-createuser: user "<replaceable class="parameter">username</replaceable>" already exists
-<listitem>
-<para>
-The user to be added already has an entry in the <literal>pg_shadow</literal>
-class.
-
-<varlistentry>
-<term>
-database access failed
-<listitem>
-<para>
-An internal error occurred in <application>psql</application>
-or in the backend server. Ensure that your site administrator has
-properly installed <productname>Postgres</productname>and initialized the site with
-<application>initdb</application>.
-
-</variablelist>
-
-<note>
-<para>
-<application>createuser</application> internally runs
-CREATE USER from <application>psql</application>
-while connected to the <literal>template1</literal> database.
-</note>
-
-<REFSECT1 ID="R1-APP-CREATEUSER-1">
-<REFSECT1INFO>
-<DATE>1998-10-02</DATE>
-</REFSECT1INFO>
-<TITLE>
-Description
-</TITLE>
-<PARA>
-<application>createuser</application> creates a
-new <productname>Postgres</productname> user.
-Only users with <literal>usesuper</literal> set in
-the <literal>pg_shadow</literal> class can create
-new <productname>Postgres</productname> users. As shipped,
-the user <literal>postgres</literal> can create users.
-
-<para>
-<application>createuser</application> is a shell script that invokes
-<application>psql</application>.
-Hence, a <application>postmaster</application>
-process must be running on the database server host before
-<application>createuser</application> is executed.
- The
-<envar>PGOPTION</envar>
-and
-<envar>PGREALM</envar>
-environment variables will be passed on to
-<application>psql</application>
-and processed as described in <xref linkend="app-psql" endterm="psql-ref">.
-
-Once invoked, <application>createuser</application>
-will ask a series of questions to obtain parameters not specified on
-the command line. The new user's database login name and a numeric
-user identifier must be specified.
-
-<note>
-<para>
-The <productname>Postgres</productname> user identifier
-does not need to be the same as the user's Unix UID. However, typically
-they are assigned to be the same.
-</note>
-
-<para>
-You must also describe the privileges of the new user for security purposes.
-Specifically, you will be asked whether the new user should be able to
-act as <productname>Postgres</productname> super-user,
-whether the new user may create new databases and whether the new user
-is allowed to create other new users.
+ <REFSECT2 ID="R2-APP-CREATEUSER-1">
+ <REFSECT2INFO>
+ <DATE>1998-10-02</DATE>
+ </REFSECT2INFO>
+ <TITLE>
+ Inputs
+ </TITLE>
+ <PARA>
+
+ <variablelist>
+ <varlistentry>
+ <term>
+ -h <replaceable class="parameter">host</replaceable>
+ </term>
+ <listitem>
+ <para>
+ Specifies the hostname of the machine on which the
+ <application>postmaster</application>
+ is running. Defaults to using a local Unix domain socket
+ rather than an IP connection..
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ -p <replaceable class="parameter">port</replaceable>
+ </term>
+ <listitem>
+ <para>
+ Specifies the Internet TCP/IP port or local Unix domain socket file
+ extension on which the <application>postmaster</application>
+ is listening for connections. The port number defaults to 5432,
+ or the value of the <envar>PGPORT</envar>
+ environment variable (if set).
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ -d
+ </term>
+ <listitem>
+ <para>
+ Allows the user to create databases.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ -D
+ </term>
+ <listitem>
+ <para>
+ Forbids the user to create databases.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ -i <replaceable class="parameter">userid</replaceable>
+ </term>
+ <listitem>
+ <para>
+ Specifies the numeric identifier to be associated with this user.
+ This identifier must be unique among all <productname>Postgres</productname> users, and is not required
+ to match the operating system UID.
+ You will be prompted for an identifier if none is specified on the command line,
+ and it will suggest an identifier matching the UID.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ -u
+ </term>
+ <listitem>
+ <para>
+ Allows the user to create other users.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ -U
+ </term>
+ <listitem>
+ <para>
+ Forbids the user to create other users.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ <replaceable class="parameter">username</replaceable>
+ </term>
+ <listitem>
+ <para>
+ Specifies the name of the <productname>Postgres</productname> user to be created.
+ This name must be unique among all <productname>Postgres</productname> users.
+ You will be prompted for a name if none is specified on the command line.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </para>
+ </refsect2>
+ <REFSECT2 ID="R2-APP-CREATEUSER-2">
+ <REFSECT2INFO>
+ <DATE>1998-10-02</DATE>
+ </REFSECT2INFO>
+ <TITLE>
+ Outputs
+ </TITLE>
+ <PARA>
+ <application>createuser</application> will add an entry in the
+ <literal>pg_user</literal> or <literal>pg_shadow</literal> system table.
+
+ <variablelist>
+ <varlistentry>
+ <term>
+ Connection to database 'template1' failed.
+ connectDB() failed: Is the postmaster running and accepting connections
+ at 'UNIX Socket' on port '<replaceable class="parameter">port</replaceable>'?
+ createuser: database access failed.
+ </term>
+ <listitem>
+ <para>
+ <application>createuser</application> could not attach to the
+ <application>postmaster</application>
+ process on the specified host and port. If you see this message,
+ ensure that the <application>postmaster</application>
+ is running on the proper host and that you have specified the proper
+ port. If your site uses an authentication system, ensure that you
+ have obtained the required authentication credentials.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ Connection to database 'template1' failed.
+ FATAL 1: SetUserId: user '<replaceable class="parameter">username</replaceable>' is not in 'pg_shadow'
+ createuser: database access failed.
+ </term>
+ <listitem>
+ <para>
+ You do not have a valid entry in the relation <literal>pg_shadow</literal>
+ and and will not be allowed to access <productname>Postgres</productname>. Contact your
+ <productname>Postgres</productname> administrator.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ createuser: <replaceable class="parameter">username</replaceable> cannot create users.
+ </term>
+ <listitem>
+ <para>
+ You do not have permission to create new users; contact your
+ <productname>Postgres</productname> site administrator.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ createuser: user "<replaceable class="parameter">username</replaceable>" already exists
+ </term>
+ <listitem>
+ <para>
+ The user to be added already has an entry in the <literal>pg_shadow</literal>
+ class.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ database access failed
+ </term>
+ <listitem>
+ <para>
+ An internal error occurred in <application>psql</application>
+ or in the backend server. Ensure that your site administrator has
+ properly installed <productname>Postgres</productname>and initialized the site with
+ <application>initdb</application>.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </para>
+
+ <note>
+ <para>
+ <application>createuser</application> internally runs
+ CREATE USER from <application>psql</application>
+ while connected to the <literal>template1</literal> database.
+ </para>
+ </note>
+ </refsect2>
+ </refsynopsisdiv>
+
+ <REFSECT1 ID="R1-APP-CREATEUSER-1">
+ <REFSECT1INFO>
+ <DATE>1998-10-02</DATE>
+ </REFSECT1INFO>
+ <TITLE>
+ Description
+ </TITLE>
+ <PARA>
+ <application>createuser</application> creates a
+ new <productname>Postgres</productname> user.
+ Only users with <literal>usesuper</literal> set in
+ the <literal>pg_shadow</literal> class can create
+ new <productname>Postgres</productname> users. As shipped,
+ the user <literal>postgres</literal> can create users.
+ </para>
+ <para>
+ <application>createuser</application> is a shell script that invokes
+ <application>psql</application>.
+ Hence, a <application>postmaster</application>
+ process must be running on the database server host before
+ <application>createuser</application> is executed.
+ The
+ <envar>PGOPTION</envar>
+ and
+ <envar>PGREALM</envar>
+ environment variables will be passed on to
+ <application>psql</application>
+ and processed as described in <xref linkend="app-psql" endterm="psql-ref">.
+
+ Once invoked, <application>createuser</application>
+ will ask a series of questions to obtain parameters not specified on
+ the command line. The new user's database login name and a numeric
+ user identifier must be specified.
+ </para>
+ <note>
+ <para>
+ The <productname>Postgres</productname> user identifier
+ does not need to be the same as the user's Unix UID. However, typically
+ they are assigned to be the same.
+ </para>
+ </note>
+
+ <para>
+ You must also describe the privileges of the new user for security purposes.
+ Specifically, you will be asked whether the new user should be able to
+ act as <productname>Postgres</productname> super-user,
+ whether the new user may create new databases and whether the new user
+ is allowed to create other new users.
+ </para>
+ </refsect1>
</REFENTRY>
<REFPURPOSE>
Defines a cursor for table access
</REFPURPOSE>
+ </refnamediv>
<REFSYNOPSISDIV>
<REFSYNOPSISDIVINFO>
<DATE>1998-09-04</DATE>
<LISTITEM>
<PARA>
This error occurs if the cursor is not declared within a transaction block.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
-
- </VARIABLELIST>
+ </PARA>
+ </LISTITEM>
+ </VARLISTENTRY>
+ </VARIABLELIST>
+ </para>
</REFSECT2>
</REFSYNOPSISDIV>
BINARY cursors give you back the data in the native binary
representation. So binary cursors will tend to be a
little faster since they suffer less conversion overhead.
-<para>
+ </para>
+ <para>
As an example, if a query returns a value of one from an integer column,
you would get a string of '1' with a default cursor
whereas with a binary cursor you would get
a 4-byte value equal to control-A ('^A').
-
-<caution>
-<para>
-BINARY cursors should be used carefully. User applications such
-as <application>psql</application> are not aware of binary cursors
-and expect data to come back in a text format.
-</caution>
-
+ <caution>
+ <para>
+ BINARY cursors should be used carefully. User applications such
+ as <application>psql</application> are not aware of binary cursors
+ and expect data to come back in a text format.
+ </para>
+ </caution>
+ </para>
<PARA>
However, string representation is architecture-neutral whereas binary
representation can differ between different machine architectures.
representations (e.g. "big-endian" versus "little-endian"),
you will probably not want your data returned in
binary format.
-
-<tip>
-<para>
- If you intend to display the data in
- ASCII, getting it back in ASCII will save you some
- effort on the client side.
-</tip>
+
+ <tip>
+ <para>
+ If you intend to display the data in
+ ASCII, getting it back in ASCII will save you some
+ effort on the client side.
+ </para>
+ </tip>
</PARA>
<REFSECT2 ID="R2-SQL-DECLARE-3">
</PARA>
<PARA>
<productname>Postgres</productname>
- does not have an explicit <command>OPEN cursor</command>
+ does not have an explicit <command>OPEN cursor</command>
statement; a cursor is considered to be open when it is declared.
-
-<note>
-<para>
-In <acronym>SQL92</acronym> cursors are only available in
-embedded applications. <application>ecpg</application>, the
-embedded SQL preprocessor for <productname>Postgres</productname>,
-supports the <acronym>SQL92</acronym> conventions, including those
-involving DECLARE and OPEN statements.
-</note>
-
+
+ <note>
+ <para>
+ In <acronym>SQL92</acronym> cursors are only available in
+ embedded applications. <application>ecpg</application>, the
+ embedded SQL preprocessor for <productname>Postgres</productname>,
+ supports the <acronym>SQL92</acronym> conventions, including those
+ involving DECLARE and OPEN statements.
+ </para>
+ </note>
+
</PARA>
</REFSECT2>
</refsect1>
SQL92
</TITLE>
<PARA>
-<acronym>SQL92</acronym> allows cursors only in embedded <acronym>SQL</acronym>
-and in modules. <productname>Postgres</productname> permits cursors to be used
-interactively.
-<acronym>SQL92</acronym> allows embedded or modular cursors to
-update database information.
-All <productname>Postgres</productname> cursors are readonly.
-The BINARY keyword is a <productname>Postgres</productname> extension.
-
+ <acronym>SQL92</acronym> allows cursors only in embedded <acronym>SQL</acronym>
+ and in modules. <productname>Postgres</productname> permits cursors to be used
+ interactively.
+ <acronym>SQL92</acronym> allows embedded or modular cursors to
+ update database information.
+ All <productname>Postgres</productname> cursors are readonly.
+ The BINARY keyword is a <productname>Postgres</productname> extension.
+ </para>
+ </refsect2>
+ </refsect1>
</REFENTRY>
<!-- Keep this comment at the end of the file
Deletes rows from a table
</REFPURPOSE>
-
+ </refnamediv>
<REFSYNOPSISDIV>
<REFSYNOPSISDIVINFO>
<DATE>1998-04-15</DATE>
<PARA>
If <replaceable class="parameter">count</replaceable> is 0,
no rows were deleted.
-
- </VARIABLELIST>
+ </para>
+ </listitem>
+ </varlistentry>
+ </VARIABLELIST>
+ </para>
</REFSECT2>
-</REFSYNOPSISDIV>
+ </REFSYNOPSISDIV>
<REFSECT1 ID="R1-SQL-DELETE-1">
<REFSECT1INFO>
Remove all films but musicals:
</PARA>
<ProgramListing>
-DELETE FROM films WHERE kind <> 'Musical';
+DETETE FROM films WHERE kind <> 'Musical';
SELECT * FROM films;
</synopsis>
<para>
where <replaceable class="parameter">cursor</replaceable> identifies an open cursor. Interactive cursors in <productname>Postgres</productname> are read-only.
-</para>
+ </para>
</refsect2>
</refsect1>
</REFENTRY>
<REFPURPOSE>
Create a new <productname>Postgres</productname> database
</REFPURPOSE>
+ </refnamediv>
<REFSYNOPSISDIV>
<REFSYNOPSISDIVINFO>
<DATE>1998-10-02</DATE>
[ -i ] [ <replaceable class="parameter">dbname</replaceable> ]
</SYNOPSIS>
-<REFSECT2 ID="R2-APP-DESTROYDB-1">
-<REFSECT2INFO>
-<DATE>1998-10-02</DATE>
-</REFSECT2INFO>
-<TITLE>
-Inputs
-</TITLE>
-<PARA>
-
-<variablelist>
-<varlistentry>
-<term>
--h <replaceable class="parameter">host</replaceable>
-</term>
-<listitem>
-<para>
-Specifies the hostname of the machine on which the
-<application>postmaster</application>
-is running. Defaults to using a local Unix domain socket
- rather than an IP connection..
-
-<varlistentry>
-<term>
--p <replaceable class="parameter">port</replaceable>
-</term>
-<listitem>
-<para>
-Specifies the Internet TCP/IP port or local Unix domain socket file
-extension on which the <application>postmaster</application>
-is listening for connections. The port number defaults to 5432,
- or the value of the <envar>PGPORT</envar>
-environment variable (if set).
-
-<varlistentry>
-<term>
--i
-</term>
-<listitem>
-<para>
-Run in interactive mode.
-Prompts for confirmation before destroying a database.
-
-<varlistentry>
-<term>
-<replaceable class="parameter">dbname</replaceable>
-</term>
-<listitem>
-<para>
-Specifies the name of the database to be destroyed. The database
-must be one of the existing <productname>Postgres</productname> databases
- in this installation.
-<replaceable class="parameter">dbname</replaceable>
-defaults to the value of the
-<envar>USER</envar>
-environment variable.
-
-</variablelist>
-
-<REFSECT2 ID="R2-APP-DESTROYDB-2">
-<REFSECT2INFO>
-<DATE>1998-10-02</DATE>
-</REFSECT2INFO>
-<TITLE>
-Outputs
-</TITLE>
-<PARA>
-<application>destroydb</application> will remove files from the
-<filename><envar>PGDATA</envar>/<replaceable class="parameter">dbname</replaceable>/</filename>
-data area for the existing database.
-
-<variablelist>
-<varlistentry>
-<term>
-Connection to database 'template1' failed.
-connectDB() failed: Is the postmaster running and accepting connections
- at 'UNIX Socket' on port '<replaceable class="parameter">port</replaceable>'?
-destroydb: database destroy failed on <replaceable class="parameter">dbname</replaceable>.
-<listitem>
-<para>
-<application>destroydb</application> could not attach to the
-<application>postmaster</application>
-process on the specified host and port. If you see this message,
-ensure that the <application>postmaster</application>
-is running on the proper host and that you have specified the proper
-port. If your site uses an authentication system, ensure that you
-have obtained the required authentication credentials.
-
-<varlistentry>
-<term>
-Connection to database 'template1' failed.
-FATAL 1: SetUserId: user '<replaceable class="parameter">username</replaceable>' is not in 'pg_shadow'
-destroydb: database destroy failed on <replaceable class="parameter">dbname</replaceable>.
-<listitem>
-<para>
-You do not have a valid entry in the relation <literal>pg_shadow</literal>
-and and will not be allowed to access <productname>Postgres</productname>.
-Contact your <productname>Postgres</productname> administrator.
+ <REFSECT2 ID="R2-APP-DESTROYDB-1">
+ <REFSECT2INFO>
+ <DATE>1998-10-02</DATE>
+ </REFSECT2INFO>
+ <TITLE>
+ Inputs
+ </TITLE>
+ <PARA>
+
+ <variablelist>
+ <varlistentry>
+ <term>
+ -h <replaceable class="parameter">host</replaceable>
+ </term>
+ <listitem>
+ <para>
+ Specifies the hostname of the machine on which the
+ <application>postmaster</application>
+ is running. Defaults to using a local Unix domain socket
+ rather than an IP connection..
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ -p <replaceable class="parameter">port</replaceable>
+ </term>
+ <listitem>
+ <para>
+ Specifies the Internet TCP/IP port or local Unix domain socket file
+ extension on which the <application>postmaster</application>
+ is listening for connections. The port number defaults to 5432,
+ or the value of the <envar>PGPORT</envar>
+ environment variable (if set).
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ -i
+ </term>
+ <listitem>
+ <para>
+ Run in interactive mode.
+ Prompts for confirmation before destroying a database.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ <replaceable class="parameter">dbname</replaceable>
+ </term>
+ <listitem>
+ <para>
+ Specifies the name of the database to be destroyed. The database
+ must be one of the existing <productname>Postgres</productname> databases
+ in this installation.
+ <replaceable class="parameter">dbname</replaceable>
+ defaults to the value of the
+ <envar>USER</envar>
+ environment variable.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </para>
+ </refsect2>
-<varlistentry>
-<term>
-ERROR: user '<replaceable class="parameter">username</replaceable>' is not allowed to create/destroy databases
-destroydb: database destroy failed on <replaceable class="parameter">dbname</replaceable>.
-<listitem>
-<para>
-You do not have permission to destroy (or create) databases.
-Contact your <productname>Postgres</productname> site administrator.
+ <REFSECT2 ID="R2-APP-DESTROYDB-2">
+ <REFSECT2INFO>
+ <DATE>1998-10-02</DATE>
+ </REFSECT2INFO>
+ <TITLE>
+ Outputs
+ </TITLE>
+ <PARA>
+ <application>destroydb</application> will remove files from the
+ <filename><envar>PGDATA</envar>/<replaceable class="parameter">dbname</replaceable>/</filename>
+ data area for the existing database.
+
+ <variablelist>
+ <varlistentry>
+ <term>
+ Connection to database 'template1' failed.
+ connectDB() failed: Is the postmaster running and accepting connections
+ at 'UNIX Socket' on port '<replaceable class="parameter">port</replaceable>'?
+ destroydb: database destroy failed on <replaceable class="parameter">dbname</replaceable>.
+ </term>
+ <listitem>
+ <para>
+ <application>destroydb</application> could not attach to the
+ <application>postmaster</application>
+ process on the specified host and port. If you see this message,
+ ensure that the <application>postmaster</application>
+ is running on the proper host and that you have specified the proper
+ port. If your site uses an authentication system, ensure that you
+ have obtained the required authentication credentials.
+ </para>
+ </listitem>
+ </varlistentry>
-<varlistentry>
-<term>
-ERROR: destroydb: database '<replaceable class="parameter">dbname</replaceable>' does not exist.
-destroydb: database destroy failed on <replaceable class="parameter">dbname</replaceable>.
-<listitem>
-<para>
-The database to be removed does not have an entry in the
-<literal>pg_database</literal> class.
+ <varlistentry>
+ <term>
+ Connection to database 'template1' failed.
+ FATAL 1: SetUserId: user '<replaceable class="parameter">username</replaceable>' is not in 'pg_shadow'
+ destroydb: database destroy failed on <replaceable class="parameter">dbname</replaceable>.
+ </term>
+ <listitem>
+ <para>
+ You do not have a valid entry in the relation <literal>pg_shadow</literal>
+ and and will not be allowed to access <productname>Postgres</productname>.
+ Contact your <productname>Postgres</productname> administrator.
+ </para>
+ </listitem>
+ </varlistentry>
-<varlistentry>
-<term>
-ERROR: destroydb: database '<replaceable class="parameter">dbname</replaceable>' is not owned by you.
-destroydb: database destroy failed on <replaceable class="parameter">dbname</replaceable>.
-<listitem>
-<para>
-You are not the Database Administrator (DBA) for the specified database.
-
-<varlistentry>
-<term>
-destroydb: database destroy failed on <replaceable class="parameter">dbname</replaceable>.
-<listitem>
-<para>
-An internal error occurred in <application>psql</application>
-or in the backend server. Ensure that your site administrator has
-properly installed <productname>Postgres</productname>and initialized the site with
-<application>initdb</application>.
-
-</variablelist>
-
-<note>
-<para>
-<application>destroydb</application> internally runs
-<command>DESTROY DATABASE</command> from <application>psql</application>
-while connected to the <literal>template1</literal> database.
-</note>
-
-<REFSECT1 ID="R1-APP-DESTROYDB-1">
-<REFSECT1INFO>
-<DATE>1998-10-02</DATE>
-</REFSECT1INFO>
-<TITLE>
-Description
-</TITLE>
-<PARA>
-<application>destroydb</application> destroys an existing
-<productname>Postgres</productname> database.
-The person who executes this command must be
-the database administrator, or <acronym>DBA</acronym>,
-or must be the <productname>Postgres</productname> super-user.
-The program runs silently; no confirmation message will be displayed.
-After the database is destroyed, a Unix shell prompt will reappear.
-
-<para>
-All references to
-the database are removed, including the directory containing this
-database and its associated files.
-
-<para>
-<application>destroydb</application> is a shell script that invokes
-<application>psql</application>.
-Hence, a <application>postmaster</application>
-process must be running on the database server host before
-<application>destroydb</application>
-is executed. The
-<envar>PGOPTION</envar>
-and
-<envar>PGREALM</envar>
-environment variables will be passed on to
-<application>psql</application>
-and processed as described in <xref linkend="app-psql" endterm="psql-ref">.
-
-<REFSECT1 ID="R1-APP-DESTROYDB-2">
-<REFSECT1INFO>
-<DATE>1998-10-02</DATE>
-</REFSECT1INFO>
-<TITLE>
-Usage
-</TITLE>
-<PARA>
-To destroy the database <literal>demo</literal>
- using the postmaster on the local host, port 5432:
-<programlisting>
-destroydb demo
-</programlisting>
+ <varlistentry>
+ <term>
+ ERROR: user '<replaceable class="parameter">username</replaceable>' is not allowed to create/destroy databases
+ destroydb: database destroy failed on <replaceable class="parameter">dbname</replaceable>.
+ </term>
+ <listitem>
+ <para>
+ You do not have permission to destroy (or create) databases.
+ Contact your <productname>Postgres</productname> site administrator.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ ERROR: destroydb: database '<replaceable class="parameter">dbname</replaceable>' does not exist.
+ destroydb: database destroy failed on <replaceable class="parameter">dbname</replaceable>.
+ </term>
+ <listitem>
+ <para>
+ The database to be removed does not have an entry in the
+ <literal>pg_database</literal> class.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ ERROR: destroydb: database '<replaceable class="parameter">dbname</replaceable>' is not owned by you.
+ destroydb: database destroy failed on <replaceable class="parameter">dbname</replaceable>.
+ </term>
+ <listitem>
+ <para>
+ You are not the Database Administrator (DBA) for the specified database.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ destroydb: database destroy failed on <replaceable class="parameter">dbname</replaceable>.
+ </term>
+ <listitem>
+ <para>
+ An internal error occurred in <application>psql</application>
+ or in the backend server. Ensure that your site administrator has
+ properly installed <productname>Postgres</productname>and initialized the site with
+ <application>initdb</application>.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </para>
+ <note>
+ <para>
+ <application>destroydb</application> internally runs
+ <command>DESTROY DATABASE</command> from <application>psql</application>
+ while connected to the <literal>template1</literal> database.
+ </para>
+ </note>
+ </refsect2>
+ </refsynopsisdiv>
-<para>
-To destroy the database <literal>demo</literal>
- using the postmaster on host eden, port 5000:
-<programlisting>
-destroydb -p 5000 -h eden demo
-</programlisting>
+ <REFSECT1 ID="R1-APP-DESTROYDB-1">
+ <REFSECT1INFO>
+ <DATE>1998-10-02</DATE>
+ </REFSECT1INFO>
+ <TITLE>
+ Description
+ </TITLE>
+ <PARA>
+ <application>destroydb</application> destroys an existing
+ <productname>Postgres</productname> database.
+ The person who executes this command must be
+ the database administrator, or <acronym>DBA</acronym>,
+ or must be the <productname>Postgres</productname> super-user.
+ The program runs silently; no confirmation message will be displayed.
+ After the database is destroyed, a Unix shell prompt will reappear.
+ </para>
+ <para>
+ All references to
+ the database are removed, including the directory containing this
+ database and its associated files.
+ </para>
+ <para>
+ <application>destroydb</application> is a shell script that invokes
+ <application>psql</application>.
+ Hence, a <application>postmaster</application>
+ process must be running on the database server host before
+ <application>destroydb</application>
+ is executed. The
+ <envar>PGOPTION</envar>
+ and
+ <envar>PGREALM</envar>
+ environment variables will be passed on to
+ <application>psql</application>
+ and processed as described in <xref linkend="app-psql" endterm="psql-ref">.
+ </para>
+ </refsect1>
+ <REFSECT1 ID="R1-APP-DESTROYDB-2">
+ <REFSECT1INFO>
+ <DATE>1998-10-02</DATE>
+ </REFSECT1INFO>
+ <TITLE>
+ Usage
+ </TITLE>
+ <PARA>
+ To destroy the database <literal>demo</literal>
+ using the postmaster on the local host, port 5432:
+ <programlisting>
+ destroydb demo
+ </programlisting>
+ </para>
+ <para>
+ To destroy the database <literal>demo</literal>
+ using the postmaster on host eden, port 5000:
+ <programlisting>
+ destroydb -p 5000 -h eden demo
+ </programlisting>
+ </para>
+ </refsect1>
</REFENTRY>
<REFPURPOSE>
Destroy a <productname>Postgres</productname> user and associated databases
</REFPURPOSE>
+ </refnamediv>
<REFSYNOPSISDIV>
<REFSYNOPSISDIVINFO>
<DATE>1998-10-02</DATE>
[ <replaceable class="parameter">username</replaceable> ]
</SYNOPSIS>
-<REFSECT2 ID="R2-APP-DESTROYUSER-1">
-<REFSECT2INFO>
-<DATE>1998-10-02</DATE>
-</REFSECT2INFO>
-<TITLE>
-Inputs
-</TITLE>
-<PARA>
-
-<variablelist>
-<varlistentry>
-<term>
--h <replaceable class="parameter">host</replaceable>
-</term>
-<listitem>
-<para>
-Specifies the hostname of the machine on which the
-<application>postmaster</application>
-is running. Defaults to using a local Unix domain socket
- rather than an IP connection..
-
-<varlistentry>
-<term>
--p <replaceable class="parameter">port</replaceable>
-</term>
-<listitem>
-<para>
-Specifies the Internet TCP/IP port or local Unix domain socket file
-extension on which the <application>postmaster</application>
-is listening for connections. The port number defaults to 5432,
- or the value of the <envar>PGPORT</envar>
-environment variable (if set).
-
-<varlistentry>
-<term>
-<replaceable class="parameter">username</replaceable>
-</term>
-<listitem>
-<para>
-Specifies the name of the <productname>Postgres</productname> user to be removed.
-This name must exist in the <productname>Postgres</productname> installation.
-You will be prompted for a name if none is specified on the command line.
-
-</variablelist>
-
-<REFSECT2 ID="R2-APP-DESTROYUSER-2">
-<REFSECT2INFO>
-<DATE>1998-10-02</DATE>
-</REFSECT2INFO>
-<TITLE>
-Outputs
-</TITLE>
-<PARA>
-<application>destroyuser</application> will remove an entry in the
-<literal>pg_user</literal> or <literal>pg_shadow</literal> system table,
-and will remove all databases for which that user is the administrator
- (<acronym>DBA</acronym>).
-
-<variablelist>
-<varlistentry>
-<term>
-Connection to database 'template1' failed.
-connectDB() failed: Is the postmaster running and accepting connections
- at 'UNIX Socket' on port '<replaceable class="parameter">port</replaceable>'?
-destroyuser: database access failed.
-<listitem>
-<para>
-<application>destroyuser</application> could not attach to the
-<application>postmaster</application>
-process on the specified host and port. If you see this message,
-ensure that the <application>postmaster</application>
-is running on the proper host and that you have specified the proper
-port. If your site uses an authentication system, ensure that you
-have obtained the required authentication credentials.
-
-<varlistentry>
-<term>
-Connection to database 'template1' failed.
-FATAL 1: SetUserId: user '<replaceable class="parameter">username</replaceable>' is not in 'pg_shadow'
-destroyuser: database access failed.
-<listitem>
-<para>
-You do not have a valid entry in the relation <literal>pg_shadow</literal>
-and and will not be allowed to access <productname>Postgres</productname>. Contact your
-<productname>Postgres</productname> administrator.
-
-<varlistentry>
-<term>
-destroyuser: <replaceable class="parameter">username</replaceable> cannot delete users.
-<listitem>
-<para>
-You do not have permission to delete users; contact your
-<productname>Postgres</productname> site administrator.
-
-<varlistentry>
-<term>
-destroyuser: user "<replaceable class="parameter">username</replaceable>" already exists
-<listitem>
-<para>
-The user to be added already has an entry in the <literal>pg_shadow</literal>
-class.
-
-<varlistentry>
-<term>
-database access failed
-<listitem>
-<para>
-An internal error occurred in <application>psql</application>
-or in the backend server. Ensure that your site administrator has
-properly installed <productname>Postgres</productname>and initialized the site with
-<application>initdb</application>.
-
-<varlistentry>
-<term>
-destroydb on <replaceable class="parameter">dbname</replaceable> failed - exiting
-<listitem>
-<para>
-An internal error occurred in <application>psql</application>
-or in the backend server. There was possibly a Unix permissions problem with the
-specified database.
-
-
-<varlistentry>
-<term>
-delete of user <replaceable class="parameter">username</replaceable> was UNSUCCESSFUL
-<listitem>
-<para>
-An internal error occurred in <application>psql</application>
-or in the backend server.
-
-</variablelist>
-
-<note>
-<para>
-<application>destroyuser</application> internally runs
-DROP USER from <application>psql</application>
-while connected to the <literal>template1</literal> database.
-</note>
-
-<REFSECT1 ID="R1-APP-DESTROYUSER-1">
-<REFSECT1INFO>
-<DATE>1998-10-02</DATE>
-</REFSECT1INFO>
-<TITLE>
-Description
-</TITLE>
-<PARA>
-<application>destroyuser</application> removes an existing
- <productname>Postgres</productname> user
-and the databases for which that user
-is database administrator.
-Only users with <literal>usesuper</literal> set in
-the <literal>pg_shadow</literal> class can destroy
- <productname>Postgres</productname> users. As shipped,
-the user <literal>postgres</literal> can remove users.
-
-<para>
-<application>destroyuser</application> is a shell script that invokes
-<application>psql</application>.
-Hence, a <application>postmaster</application>
-process must be running on the database server host before
-<application>destroyuser</application> is executed.
- The
-<envar>PGOPTION</envar>
-and
-<envar>PGREALM</envar>
-environment variables will be passed on to
-<application>psql</application>
-and processed as described in <xref linkend="app-psql" endterm="psql-ref">.
-
-<para>
-Once invoked, <application>destroyuser</application>
-will warn you about the databases that will be destroyed in the
-process and permit you to abort the removal of the user if desired.
-
+ <REFSECT2 ID="R2-APP-DESTROYUSER-1">
+ <REFSECT2INFO>
+ <DATE>1998-10-02</DATE>
+ </REFSECT2INFO>
+ <TITLE>
+ Inputs
+ </TITLE>
+ <PARA>
+
+ <variablelist>
+ <varlistentry>
+ <term>
+ -h <replaceable class="parameter">host</replaceable>
+ </term>
+ <listitem>
+ <para>
+ Specifies the hostname of the machine on which the
+ <application>postmaster</application>
+ is running. Defaults to using a local Unix domain socket
+ rather than an IP connection..
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ -p <replaceable class="parameter">port</replaceable>
+ </term>
+ <listitem>
+ <para>
+ Specifies the Internet TCP/IP port or local Unix domain socket file
+ extension on which the <application>postmaster</application>
+ is listening for connections. The port number defaults to 5432,
+ or the value of the <envar>PGPORT</envar>
+ environment variable (if set).
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ <replaceable class="parameter">username</replaceable>
+ </term>
+ <listitem>
+ <para>
+ Specifies the name of the <productname>Postgres</productname> user to be removed.
+ This name must exist in the <productname>Postgres</productname> installation.
+ You will be prompted for a name if none is specified on the command line.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </para>
+ </refsect2>
+
+ <REFSECT2 ID="R2-APP-DESTROYUSER-2">
+ <REFSECT2INFO>
+ <DATE>1998-10-02</DATE>
+ </REFSECT2INFO>
+ <TITLE>
+ Outputs
+ </TITLE>
+ <PARA>
+ <application>destroyuser</application> will remove an entry in the
+ <literal>pg_user</literal> or <literal>pg_shadow</literal> system table,
+ and will remove all databases for which that user is the administrator
+ (<acronym>DBA</acronym>).
+
+ <variablelist>
+ <varlistentry>
+ <term>
+ Connection to database 'template1' failed.
+ connectDB() failed: Is the postmaster running and accepting connections
+ at 'UNIX Socket' on port '<replaceable class="parameter">port</replaceable>'?
+ destroyuser: database access failed.
+ </term>
+ <listitem>
+ <para>
+ <application>destroyuser</application> could not attach to the
+ <application>postmaster</application>
+ process on the specified host and port. If you see this message,
+ ensure that the <application>postmaster</application>
+ is running on the proper host and that you have specified the proper
+ port. If your site uses an authentication system, ensure that you
+ have obtained the required authentication credentials.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ Connection to database 'template1' failed.
+ FATAL 1: SetUserId: user '<replaceable class="parameter">username</replaceable>' is not in 'pg_shadow'
+ destroyuser: database access failed.
+ </term>
+ <listitem>
+ <para>
+ You do not have a valid entry in the relation <literal>pg_shadow</literal>
+ and and will not be allowed to access <productname>Postgres</productname>. Contact your
+ <productname>Postgres</productname> administrator.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ destroyuser: <replaceable class="parameter">username</replaceable> cannot delete users.
+ </term>
+ <listitem>
+ <para>
+ You do not have permission to delete users; contact your
+ <productname>Postgres</productname> site administrator.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ destroyuser: user "<replaceable class="parameter">username</replaceable>" already exists
+ </term>
+ <listitem>
+ <para>
+ The user to be added already has an entry in the <literal>pg_shadow</literal>
+ class.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ database access failed
+ </term>
+ <listitem>
+ <para>
+ An internal error occurred in <application>psql</application>
+ or in the backend server. Ensure that your site administrator has
+ properly installed <productname>Postgres</productname>and initialized the site with
+ <application>initdb</application>.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ destroydb on <replaceable class="parameter">dbname</replaceable> failed - exiting
+ </term>
+ <listitem>
+ <para>
+ An internal error occurred in <application>psql</application>
+ or in the backend server. There was possibly a Unix permissions problem with the
+ specified database.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ delete of user <replaceable class="parameter">username</replaceable> was UNSUCCESSFUL
+ </term>
+ <listitem>
+ <para>
+ An internal error occurred in <application>psql</application>
+ or in the backend server.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </para>
+
+ <note>
+ <para>
+ <application>destroyuser</application> internally runs
+ DROP USER from <application>psql</application>
+ while connected to the <literal>template1</literal> database.
+ </para>
+ </note>
+ </refsect2>
+ </refsynopsisdiv>
+
+ <REFSECT1 ID="R1-APP-DESTROYUSER-1">
+ <REFSECT1INFO>
+ <DATE>1998-10-02</DATE>
+ </REFSECT1INFO>
+ <TITLE>
+ Description
+ </TITLE>
+ <PARA>
+ <application>destroyuser</application> removes an existing
+ <productname>Postgres</productname> user
+ and the databases for which that user
+ is database administrator.
+ Only users with <literal>usesuper</literal> set in
+ the <literal>pg_shadow</literal> class can destroy
+ <productname>Postgres</productname> users. As shipped,
+ the user <literal>postgres</literal> can remove users.
+ </para>
+ <para>
+ <application>destroyuser</application> is a shell script that invokes
+ <application>psql</application>.
+ Hence, a <application>postmaster</application>
+ process must be running on the database server host before
+ <application>destroyuser</application> is executed.
+ The
+ <envar>PGOPTION</envar>
+ and
+ <envar>PGREALM</envar>
+ environment variables will be passed on to
+ <application>psql</application>
+ and processed as described in <xref linkend="app-psql" endterm="psql-ref">.
+ </para>
+ <para>
+ Once invoked, <application>destroyuser</application>
+ will warn you about the databases that will be destroyed in the
+ process and permit you to abort the removal of the user if desired.
+ </para>
+ </refsect1>
</REFENTRY>
<REFPURPOSE>
Removes the definition of an aggregate function
</REFPURPOSE>
+ </refnamediv>
<REFSYNOPSISDIV>
<REFSYNOPSISDIVINFO>
<DATE>1998-04-15</DATE>
<PARA>
This message occurs if the aggregate function specified does not
exist in the database.
-
- </VARIABLELIST>
+ </para>
+ </listitem>
+ </varlistentry>
+ </VARIABLELIST>
+ </para>
</REFSECT2>
</REFSYNOPSISDIV>
<REFPURPOSE>
Destroys an existing database
</REFPURPOSE>
+ </refnamediv>
<REFSYNOPSISDIV>
<REFSYNOPSISDIVINFO>
<DATE>1998-04-15</DATE>
<LISTITEM>
<PARA>
This message occurs if the specified database does not exist.
-
- </VARIABLELIST>
+ </para>
+ </listitem>
+ </varlistentry>
+ </VARIABLELIST>
+ </para>
</REFSECT2>
</REFSYNOPSISDIV>
<REFPURPOSE>
Removes a user-defined C function
</REFPURPOSE>
-
+ </refnamediv>
<REFSYNOPSISDIV>
<REFSYNOPSISDIVINFO>
<DATE>1998-04-15</DATE>
<PARA>
This message is given if the function specified does not
exist in the current database.
-
- </VARIABLELIST>
+ </para>
+ </listitem>
+ </varlistentry>
+ </VARIABLELIST>
+ </para>
</REFSECT2>
</REFSYNOPSISDIV>
to create aggregate functions.
</PARA>
</REFSECT2>
+ </refsect1>
<REFSECT1 ID="R1-SQL-DROPFUNCTION-2">
<TITLE>
DROP FUNCTION sqrt(int4);
</ProgramListing>
</REFSECT1>
+
<REFSECT1 ID="R1-SQL-DROPFUNCTION-3">
<TITLE>
Bugs
<REFPURPOSE>
Removes an index from a database
</REFPURPOSE>
+ </refnamediv>
<REFSYNOPSISDIV>
<REFSYNOPSISDIVINFO>
<DATE>1998-04-15</DATE>
<PARA>
This message occurs if <REPLACEABLE CLASS="PARAMETER">index_name</REPLACEABLE>
is not an index in the database.
-
- </VARIABLELIST>
+ </para>
+ </listitem>
+ </varlistentry>
+ </VARIABLELIST>
+ </para>
</REFSECT2>
</REFSYNOPSISDIV>
information on how to create indexes.
</PARA>
</REFSECT2>
+ </refsect1>
<REFSECT1 ID="R1-SQL-DROPINDEX-2">
<TITLE>
<REFPURPOSE>
Removes a user-defined procedural language
</REFPURPOSE>
+ </refnamediv>
<REFSYNOPSISDIV>
<REFSYNOPSISDIVINFO>
<DATE>1998-04-15</DATE>
This message occurs if the language
"<replaceable class="parameter">langname</replaceable>" is
not found.
-
- </VARIABLELIST>
+ </para>
+ </listitem>
+ </varlistentry>
+ </VARIABLELIST>
+ </para>
</REFSECT2>
</REFSYNOPSISDIV>
<REFPURPOSE>
Removes an operator from the database
</REFPURPOSE>
-
+ </refnamediv>
<REFSYNOPSISDIV>
<REFSYNOPSISDIVINFO>
<PARA>
This message occurs if the specified right unary operator
specified does not exist.
-
- </VARIABLELIST>
+ </para>
+ </listitem>
+ </varlistentry>
+ </VARIABLELIST>
+ </para>
</REFSECT2>
</REFSYNOPSISDIV>
operator classes that rely on the deleted operator.
</PARA>
</REFSECT2>
+ </refsect1>
<REFSECT1 ID="R1-SQL-DROPOPERATOR-2">
<TITLE>
<REFPURPOSE>
Removes an existing rule from the database
</REFPURPOSE>
+ </refnamediv>
<REFSYNOPSISDIV>
<REFSYNOPSISDIVINFO>
<DATE>1998-09-22</DATE>
<LISTITEM>
<PARA>
This message occurs if the specified rule does not exist.
- </VARIABLELIST>
+ </para>
+ </listitem>
+ </varlistentry>
+ </VARIABLELIST>
+ </para>
</REFSECT2>
</REFSYNOPSISDIV>
<REFPURPOSE>
Removes an existing sequence
</REFPURPOSE>
+ </refnamediv>
<REFSYNOPSISDIV>
<REFSYNOPSISDIVINFO>
<DATE>1998-09-22</DATE>
<LISTITEM>
<PARA>
This message occurs if the specified sequence does not exist.
- </VARIABLELIST>
+ </para>
+ </listitem>
+ </varlistentry>
+ </VARIABLELIST>
+ </para>
</REFSECT2>
</REFSYNOPSISDIV>
information on how to create a sequence.
</PARA>
</REFSECT2>
+ </refsect1>
<REFSECT1 ID="R1-SQL-DROPSEQUENCE-2">
<TITLE>
<REFPURPOSE>
Removes existing tables from a database
</REFPURPOSE>
-
+ </refnamediv>
<REFSYNOPSISDIV>
<REFSYNOPSISDIVINFO>
<DATE>1998-09-22</DATE>
<LISTITEM>
<PARA>
If the specified table or view does not exist in the database.
- </VARIABLELIST>
+ </para>
+ </listitem>
+ </varlistentry>
+ </VARIABLELIST>
+ </para>
</REFSECT2>
</REFSYNOPSISDIV>
</REFNAME>
<REFPURPOSE>
Removes the definition of a trigger
- </REFPURPOSE>
+ </REFPURPOSE>
+ </refnamediv>
<REFSYNOPSISDIV>
<REFSYNOPSISDIVINFO>
<DATE>1998-09-22</DATE>
<LISTITEM>
<PARA>
This message occurs if the trigger specified does not exist.
-
-</VARIABLELIST>
-
+ </para>
+ </listitem>
+ </varlistentry>
+ </VARIABLELIST>
+ </para>
</REFSECT2>
</REFSYNOPSISDIV>
information on how to create triggers.
</PARA>
</REFSECT2>
+ </refsect1>
<REFSECT1 ID="R1-SQL-DROPTRIGGER-2">
<TITLE>
<REFPURPOSE>
Removes a user-defined type from the system catalogs
</REFPURPOSE>
+ </refnamediv>
<REFSYNOPSISDIV>
<REFSYNOPSISDIVINFO>
<DATE>1998-09-22</DATE>
<LISTITEM>
<PARA>
This message occurs if the specified type is not found.
-
- </VARIABLELIST>
+ </para>
+ </listitem>
+ </varlistentry>
+ </VARIABLELIST>
+ </para>
</REFSECT2>
</REFSYNOPSISDIV>
is unpredictable.
</PARA>
</refsect2>
+ </refsect1>
<REFSECT1 ID="R1-SQL-DROPTYPE-2">
<TITLE>
<REFPURPOSE>
Removes an user account information
</REFPURPOSE>
-
+ </refnamediv>
<REFSYNOPSISDIV>
<REFSYNOPSISDIVINFO>
<DATE>1998-09-22</DATE>
<LISTITEM>
<PARA>
This message occurs if the username is not found.
- </PARA>
- </LISTITEM>
- </VARLISTENTRY>
- </VARIABLELIST>
+ </PARA>
+ </LISTITEM>
+ </VARLISTENTRY>
+ </VARIABLELIST>
+ </para>
</REFSECT2>
</REFSYNOPSISDIV>
how to create or modify user accounts.
</PARA>
</REFSECT2>
+ </refsect1>
<REFSECT1 ID="R1-SQL-DROPUSER-2">
<TITLE>
<REFPURPOSE>
Removes an existing view from a database
</REFPURPOSE>
+ </refnamediv>
<REFSYNOPSISDIV>
<REFSYNOPSISDIVINFO>
<DATE>1998-09-22</DATE>
<LISTITEM>
<PARA>
The message returned if the command is successful.
-
-<VARLISTENTRY>
-<TERM>
-<ReturnValue>
-ERROR: RewriteGetRuleEventRel: rule "_RET<REPLACEABLE CLASS="PARAMETER">view</REPLACEABLE>" not found</ReturnValue>
-</TERM>
-<LISTITEM>
-<PARA>
-This message occurs if the specified view does not exist in
-the database.
-</variablelist>
-
-</REFSECT2>
+ </para>
+ </listitem>
+ </varlistentry>
+ <VARLISTENTRY>
+ <TERM>
+ <ReturnValue>
+ ERROR: RewriteGetRuleEventRel: rule "_RET<REPLACEABLE CLASS="PARAMETER">view</REPLACEABLE>" not found</ReturnValue>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ This message occurs if the specified view does not exist in
+ the database.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </para>
+ </REFSECT2>
</REFSYNOPSISDIV>
<REFSECT1 ID="R1-SQL-DROPVIEW-1">
for information on how to create views.
</PARA>
</REFSECT2>
+ </refsect1>
<REFSECT1 ID="R1-SQL-DROPVIEW-2">
<TITLE>
<para>
Any referencing views and integrity constraints
will be dropped as well.
- </para>
- </listitem>
- </varlistentry>
- </variablelist>
-</refsect3>
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </para>
+ </refsect3>
<REFSECT3 ID="R3-SQL-DROPVIEW-2">
<REFSECT3INFO>
</REFSECT3INFO>
<TITLE>
Notes
- </TITLE>
-<para>
- <tip>
+ </TITLE>
<para>
- At present, to remove a referenced view from a
- <productname>Postgres</productname> database,
- you must drop it explicitly.
+ <tip>
+ <para>
+ At present, to remove a referenced view from a
+ <productname>Postgres</productname> database,
+ you must drop it explicitly.
+ </para>
+ </tip>
</para>
- </tip>
+ </refsect3>
</refsect2>
</refsect1>
</REFENTRY>
<REFPURPOSE>
Shows statement execution details
</REFPURPOSE>
+</refnamediv>
<REFSYNOPSISDIV>
<REFSYNOPSISDIVINFO>
<LISTITEM>
<PARA>
Flag to show detailed query plan.
-
+</para>
+</listitem>
+</varlistentry>
<VARLISTENTRY>
<TERM>
<REPLACEABLE CLASS="PARAMETER">query</REPLACEABLE>
<LISTITEM>
<PARA>
Any <REPLACEABLE CLASS="PARAMETER">query</REPLACEABLE>.
-
+</para>
+</listitem>
+</varlistentry>
</VARIABLELIST>
-
+</para>
</REFSECT2>
<REFSECT2 ID="R2-SQL-EXPLAIN-2">
<LISTITEM>
<PARA>
Explicit query plan from the <productname>Postgres</productname> backend.
-
+</para>
+</listitem>
+</varlistentry>
<VARLISTENTRY>
<TERM>
EXPLAIN
<LISTITEM>
<PARA>
Flag sent after query plan is shown.
-
+</para>
+</listitem>
+</varlistentry>
</VARIABLELIST>
-
+</para>
</REFSECT2>
</REFSYNOPSISDIV>
The default output is the computed query cost.
VERBOSE displays the full query plan and cost to your screen,
and pretty-prints the plan to the postmaster log file.
-
+</para>
<REFSECT2 ID="R2-SQL-EXPLAIN-3">
<REFSECT2INFO>
<DATE>1998-04-15</DATE>
Refer to the <citetitle>Programmer's Guide</citetitle>
in the chapters on indexes and the genetic query optimizer for
more information.
-
+</para>
</REFSECT2>
+</refsect1>
<REFSECT1 ID="R1-SQL-EXPLAIN-2">
<TITLE>
EXPLAIN
</ProgramListing>
-
+</para>
</REFSECT1>
<REFSECT1 ID="R1-SQL-EXPLAIN-3">
</TITLE>
<PARA>
There is no EXPLAIN statement defined in SQL92.
+</para>
+</refsect2>
+</refsect1>
</REFENTRY>
<!--
<REFPURPOSE>
Gets rows using a cursor
</REFPURPOSE>
+</refnamediv>
<REFSYNOPSISDIV>
<REFSYNOPSISDIVINFO>
<DATE>1998-09-01</DATE>
<REPLACEABLE CLASS="PARAMETER">selector</REPLACEABLE>
defines the fetch direction. It can be one
the following:
-
+</para>
+</listitem>
+</varlistentry>
+</variablelist>
<VARIABLELIST>
<VARLISTENTRY>
<TERM>
<PARA>
fetch next row(s). This is the default
if <REPLACEABLE CLASS="PARAMETER">selector</REPLACEABLE> is omitted.
-
+</para>
+</listitem>
+</varlistentry>
<VARLISTENTRY>
<TERM>
BACKWARD
<LISTITEM>
<PARA>
fetch previous row(s).
-
+</para>
+</listitem>
+</varlistentry>
<VARLISTENTRY>
<TERM>
RELATIVE
<LISTITEM>
<PARA>
Noise word for SQL92 compatibility.
+</para>
+</listitem>
+</varlistentry>
-</VARIABLELIST>
<VARLISTENTRY>
<TERM>
<PARA>
<REPLACEABLE CLASS="PARAMETER">count</REPLACEABLE>
determines how many rows to fetch. It can be one of the following:
+</para>
+</listitem>
+</varlistentry>
+
-<VARIABLELIST>
<VARLISTENTRY>
<TERM>
<REPLACEABLE CLASS="PARAMETER">#</REPLACEABLE>
A signed integer that specify how many rows to fetch.
Note that a negative integer is equivalent to changing the sense of
FORWARD and BACKWARD.
+</para>
+</listitem>
+</varlistentry>
<VARLISTENTRY>
<TERM>
<LISTITEM>
<PARA>
Retrieve all remaining rows.
+</para>
+</listitem>
+</varlistentry>
<VARLISTENTRY>
<TERM>
<LISTITEM>
<PARA>
Equivalent to specifying a count of <command>1</command>.
+</para>
+</listitem>
+</varlistentry>
<VARLISTENTRY>
<TERM>
<LISTITEM>
<PARA>
Equivalent to specifying a count of <command>-1</command>.
-
-</VARIABLELIST>
+</para>
+</listitem>
+</varlistentry>
<VARLISTENTRY>
<TERM>
<LISTITEM>
<PARA>
An open cursor's name.
-
+</para>
+</listitem>
+</varlistentry>
</variablelist>
-
+</para>
</REFSECT2>
<REFSECT2 ID="R2-SQL-FETCH-2">
<PARA>
FETCH returns the results of the query defined by the specified cursor.
The following messages will be returned if the query fails:
+</para>
<VARIABLELIST>
<VARLISTENTRY>
If <REPLACEABLE CLASS="PARAMETER">cursor</REPLACEABLE>
is not previously declared.
The cursor must be declared within a transaction block.
+</para>
+</listitem>
+</varlistentry>
<VARLISTENTRY>
<TERM>
<PARA>
<productname>Postgres</productname> does not support absolute
positioning of cursors.
+</para>
+</listitem>
+</varlistentry>
<VARLISTENTRY>
<TERM>
If the RELATIVE keyword has been used, the <productname>Postgres</productname>
assumes that the user intended <acronym>SQL92</acronym> behavior
and returns this error message.
+</para>
+</listitem>
+</varlistentry>
</variablelist>
row count. A negative number is equivalent to reversing
the sense of the FORWARD and BACKWARD keywords. For example,
<command>FORWARD -1</command> is the same as <command>BACKWARD 1</command>.
+</para>
</tip>
-
+</para>
<para>
Note that the FORWARD and BACKWARD keywords are
<productname>Postgres</productname> extensions.
The <acronym>SQL92</acronym> syntax is also supported, specified
in the second form of the command. See below for details
on compatibility issues.
-
+</para>
<para>
Once all rows are fetched, every other fetch access returns
no rows.
+</para>
<para>
Updating data in a cursor is not supported by
not generally possible, as is also the case with VIEW updates.
Consequently,
users must issue explicit UPDATE commands to replace data.
+</para>
<para>
Cursors may only be used inside of transactions because
the data that they store spans multiple user queries.
+</para>
<REFSECT2 ID="R2-SQL-FETCH-3">
<REFSECT2INFO>
Refer to DECLARE statements to declare a cursor.
Refer to BEGIN WORK, COMMIT WORK, ROLLBACK WORK statements
for further information about transactions.
-
+</para>
</REFSECT2>
+</refsect1>
<REFSECT1 ID="R1-SQL-FETCH-2">
<TITLE>
CLOSE liahona;
COMMIT WORK;
</ProgramListing>
-
+</para>
</REFSECT1>
<REFSECT1 ID="R1-SQL-FETCH-3">
The cursor should be positioned to the specified absolute
row number. All row numbers in <productname>Postgres</productname>
are relative numbers so this capability is not supported.
-
+</para>
+</listitem>
+</varlistentry>
<VARLISTENTRY>
<TERM>
:<REPLACEABLE CLASS="PARAMETER">variable</REPLACEABLE>
<LISTITEM>
<PARA>
Target host variable(s).
-
+</para>
+</listitem>
+</varlistentry>
</variablelist>
-
+</para>
+</refsect2>
+</refsect1>
</REFENTRY>
<!--
<REFENTRY ID="SQL-GRANT">
-<REFMETA>
-<REFENTRYTITLE>
-GRANT
-</REFENTRYTITLE>
-<REFMISCINFO>SQL - Language Statements</REFMISCINFO>
-</REFMETA>
-<REFNAMEDIV>
-<REFNAME>
-GRANT
-</REFNAME>
-<REFPURPOSE>
-Grants access privilege to a user, a group or all users
-</REFPURPOSE>
-
-<REFSYNOPSISDIV>
-<REFSYNOPSISDIVINFO>
-<DATE>1998-09-23</DATE>
-</REFSYNOPSISDIVINFO>
-<SYNOPSIS>
-GRANT <REPLACEABLE CLASS="PARAMETER">privilege</REPLACEABLE> [, ...]
- ON <REPLACEABLE CLASS="PARAMETER">object</REPLACEABLE> [, ...]
- TO { PUBLIC | GROUP <REPLACEABLE CLASS="PARAMETER">group</REPLACEABLE> | <REPLACEABLE CLASS="PARAMETER">username</REPLACEABLE> }
-</SYNOPSIS>
-
-<REFSECT2 ID="R2-SQL-GRANT-1">
-<REFSECT2INFO>
-<DATE>1998-09-23</DATE>
-</REFSECT2INFO>
-<TITLE>
-Inputs
-</TITLE>
-<PARA>
-
-<VARIABLELIST>
-<VARLISTENTRY>
-<TERM>
-<REPLACEABLE CLASS="PARAMETER">privilege</REPLACEABLE>
-</TERM>
-<LISTITEM>
-<PARA>
-The possible privileges are:
-
-<VARIABLELIST>
-<VARLISTENTRY>
-<TERM>
-SELECT
-</TERM>
-<LISTITEM>
-<PARA>
-Access all of the columns of a specific
- table/view.
-
-<VARLISTENTRY>
-<TERM>
-INSERT
-</TERM>
-<LISTITEM>
-<PARA>
-Insert data into all columns of a
- specific table.
-
-<VARLISTENTRY>
-<TERM>
-UPDATE
-</TERM>
-<LISTITEM>
-<PARA>
-Update all columns of a specific
- table.
-
-<VARLISTENTRY>
-<TERM>
-DELETE
-</TERM>
-<LISTITEM>
-<PARA>
-Delete rows from a specific table.
-
-<VARLISTENTRY>
-<TERM>
-RULE
-</TERM>
-<LISTITEM>
-<PARA>
-Define rules on the table/view
- (See CREATE RULE statement).
-
-<VARLISTENTRY>
-<TERM>
-ALL
-</TERM>
-<LISTITEM>
-<PARA>
-Grant all privileges.
-
-</VARIABLELIST>
-
-<VARLISTENTRY>
-<TERM>
-<REPLACEABLE CLASS="PARAMETER">object</REPLACEABLE>
-</TERM>
-<LISTITEM>
-<PARA>
-The name of an object to which to grant access.
- The possible objects are:
-
-<itemizedlist mark="bullet" spacing="compact">
-<listitem>
-<para>
-table
-
-<listitem>
-<para>
-view
-
-<listitem>
-<para>
-sequence
-
-<listitem>
-<para>
-index
-</itemizedlist>
-
-<VARLISTENTRY>
-<TERM>
-PUBLIC
-</TERM>
-<LISTITEM>
-<PARA>
-A short form representing all users.
-
-<VARLISTENTRY>
-<TERM>
-GROUP <REPLACEABLE CLASS="PARAMETER">group</REPLACEABLE>
-</TERM>
-<LISTITEM>
-<PARA>
-A <REPLACEABLE CLASS="PARAMETER">group</REPLACEABLE> to whom to grant privileges.
-In the current release, the group must be created explicitly as described below.
-
-<VARLISTENTRY>
-<TERM>
-<REPLACEABLE CLASS="PARAMETER">username</REPLACEABLE>
-</TERM>
-<LISTITEM>
-<PARA>
-The name of a user to whom grant privileges. PUBLIC is a short form
-representing all users.
-
-</VARIABLELIST>
-
-</REFSECT2>
-
-<REFSECT2 ID="R2-SQL-GRANT-2">
-<REFSECT2INFO>
-<DATE>1998-09-23</DATE>
-</REFSECT2INFO>
-<TITLE>
-Outputs
-</TITLE>
-<PARA>
-
-<VARIABLELIST>
-<VARLISTENTRY>
-<TERM>
-CHANGE
-</TERM>
-<LISTITEM>
-<PARA>
-Message returned if successful.
-
-<VARLISTENTRY>
-<TERM>
-ERROR: ChangeAcl: class "<REPLACEABLE CLASS="PARAMETER">object</REPLACEABLE>"
- not found
-</TERM>
-<LISTITEM>
-<PARA>
-Message returned if the specified object is not available or
-if it is impossible
- to give privileges to the specified group or users.
-
-</VARIABLELIST>
-
-</REFSECT2>
-</REFSYNOPSISDIV>
-
-<REFSECT1 ID="R1-SQL-GRANT-1">
-<REFSECT1INFO>
-<DATE>1998-09-23</DATE>
-</REFSECT1INFO>
-<TITLE>
-Description
-</TITLE>
-<PARA>
- GRANT allows the creator of an object to give specific permissions to
- all users (PUBLIC) or to a certain user or group.
- Users other than the creator don't have any access permission
- unless the creator GRANTs permissions, after the object
- is created.
-
-<para>
- Once a user has a privilege on an object, he is enabled to exercise
-that privilege.
-There is no need to GRANT privileges to the creator of
- an object, the creator automatically holds ALL privileges, and can
- also drop the object.
-
-<REFSECT2 ID="R2-SQL-GRANT-3">
-<REFSECT2INFO>
-<DATE>1998-09-23</DATE>
-</REFSECT2INFO>
-<TITLE>
-Notes
-</TITLE>
-<PARA>
-Use the <command>psql \z</command> command
- for further information about permissions
- on existing objects:
-<programlisting>
- Database = lusitania
+ <REFMETA>
+ <REFENTRYTITLE>
+ GRANT
+ </REFENTRYTITLE>
+ <REFMISCINFO>SQL - Language Statements</REFMISCINFO>
+ </REFMETA>
+ <REFNAMEDIV>
+ <REFNAME>
+ GRANT
+ </REFNAME>
+ <REFPURPOSE>
+ Grants access privilege to a user, a group or all users
+ </REFPURPOSE>
+ </refnamediv>
+ <REFSYNOPSISDIV>
+ <REFSYNOPSISDIVINFO>
+ <DATE>1998-09-23</DATE>
+ </REFSYNOPSISDIVINFO>
+ <SYNOPSIS>
+ GRANT <REPLACEABLE CLASS="PARAMETER">privilege</REPLACEABLE> [, ...]
+ ON <REPLACEABLE CLASS="PARAMETER">object</REPLACEABLE> [, ...]
+ TO { PUBLIC | GROUP <REPLACEABLE CLASS="PARAMETER">group</REPLACEABLE> | <REPLACEABLE CLASS="PARAMETER">username</REPLACEABLE> }
+ </SYNOPSIS>
+
+ <REFSECT2 ID="R2-SQL-GRANT-1">
+ <REFSECT2INFO>
+ <DATE>1998-09-23</DATE>
+ </REFSECT2INFO>
+ <TITLE>
+ Inputs
+ </TITLE>
+ <PARA>
+
+ <VARIABLELIST>
+ <VARLISTENTRY>
+ <TERM>
+ <REPLACEABLE CLASS="PARAMETER">privilege</REPLACEABLE>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ The possible privileges are:
+ </para>
+ </listitem>
+ </varlistentry>
+ <VARLISTENTRY>
+ <TERM>
+ SELECT
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Access all of the columns of a specific
+ table/view.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <VARLISTENTRY>
+ <TERM>
+ INSERT
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Insert data into all columns of a
+ specific table.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <VARLISTENTRY>
+ <TERM>
+ UPDATE
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Update all columns of a specific
+ table.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <VARLISTENTRY>
+ <TERM>
+ DELETE
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Delete rows from a specific table.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <VARLISTENTRY>
+ <TERM>
+ RULE
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Define rules on the table/view
+ (See CREATE RULE statement).
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <VARLISTENTRY>
+ <TERM>
+ ALL
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Grant all privileges.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <VARLISTENTRY>
+ <TERM>
+ <REPLACEABLE CLASS="PARAMETER">object</REPLACEABLE>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ The name of an object to which to grant access.
+ The possible objects are:
+ </para>
+
+ <para>
+ <itemizedlist mark="bullet" spacing="compact">
+ <listitem>
+ <para>
+ table
+ </para>
+ </listitem>
+
+ <listitem>
+ <para>
+ view
+ </para>
+ </listitem>
+
+ <listitem>
+ <para>
+ sequence
+ </para>
+ </listitem>
+
+ <listitem>
+ <para>
+ index
+ </para>
+ </listitem>
+ </itemizedlist>
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <VARLISTENTRY>
+ <TERM>
+ PUBLIC
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ A short form representing all users.
+ </para>
+ </listitem>
+ </varlistentry>
+ <VARLISTENTRY>
+ <TERM>
+ GROUP <REPLACEABLE CLASS="PARAMETER">group</REPLACEABLE>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ A <REPLACEABLE CLASS="PARAMETER">group</REPLACEABLE> to whom to grant privileges.
+ In the current release, the group must be created explicitly as described below.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <VARLISTENTRY>
+ <TERM>
+ <REPLACEABLE CLASS="PARAMETER">username</REPLACEABLE>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ The name of a user to whom grant privileges. PUBLIC is a short form
+ representing all users.
+ </para>
+ </listitem>
+ </varlistentry>
+ </VARIABLELIST>
+ </para>
+ </REFSECT2>
+
+ <REFSECT2 ID="R2-SQL-GRANT-2">
+ <REFSECT2INFO>
+ <DATE>1998-09-23</DATE>
+ </REFSECT2INFO>
+ <TITLE>
+ Outputs
+ </TITLE>
+ <PARA>
+
+ <VARIABLELIST>
+ <VARLISTENTRY>
+ <TERM>
+ CHANGE
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Message returned if successful.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <VARLISTENTRY>
+ <TERM>
+ ERROR: ChangeAcl: class "<REPLACEABLE CLASS="PARAMETER">object</REPLACEABLE>"
+ not found
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Message returned if the specified object is not available or
+ if it is impossible
+ to give privileges to the specified group or users.
+ </para>
+ </listitem>
+ </varlistentry>
+ </VARIABLELIST>
+ </para>
+ </REFSECT2>
+ </REFSYNOPSISDIV>
+
+ <REFSECT1 ID="R1-SQL-GRANT-1">
+ <REFSECT1INFO>
+ <DATE>1998-09-23</DATE>
+ </REFSECT1INFO>
+ <TITLE>
+ Description
+ </TITLE>
+ <PARA>
+ GRANT allows the creator of an object to give specific permissions to
+ all users (PUBLIC) or to a certain user or group.
+ Users other than the creator don't have any access permission
+ unless the creator GRANTs permissions, after the object
+ is created.
+ </para>
+
+ <para>
+ Once a user has a privilege on an object, he is enabled to exercise
+ that privilege.
+ There is no need to GRANT privileges to the creator of
+ an object, the creator automatically holds ALL privileges, and can
+ also drop the object.
+ </para>
+
+ <REFSECT2 ID="R2-SQL-GRANT-3">
+ <REFSECT2INFO>
+ <DATE>1998-09-23</DATE>
+ </REFSECT2INFO>
+ <TITLE>
+ Notes
+ </TITLE>
+ <PARA>
+ Use the <command>psql \z</command> command
+ for further information about permissions
+ on existing objects:
+ <programlisting>
+ Database = lusitania
+------------------+---------------------------------------------+
| Relation | Grant/Revoke Permissions |
+------------------+---------------------------------------------+
a -- INSERT
R -- RULE
arwR -- ALL
-</programlisting>
-
-<tip>
-<para>
-Currently, to create a GROUP you have to insert
- data manually into table pg_group as:
-<programlisting>
-INSERT INTO pg_group VALUES ('todos');
-CREATE USER miriam IN GROUP todos;
-</programlisting>
- Refer to REVOKE statements to revoke access privileges.
-</tip>
-
-</REFSECT2>
-
-<REFSECT1 ID="R1-SQL-GRANT-2">
-<TITLE>
-Usage
-</TITLE>
-<PARA>
-<ProgramListing>
--- grant insert privilege to all users on table films:
---
-GRANT INSERT ON films TO PUBLIC;
-</programlisting>
-
-<programlisting>
--- grant all privileges to user manuel on view kinds:
---
-GRANT ALL ON kinds TO manuel;
-</ProgramListing>
-
-</REFSECT1>
-
-<REFSECT1 ID="R1-SQL-GRANT-3">
-<TITLE>
-Compatibility
-</TITLE>
-<PARA>
-</PARA>
-
-<REFSECT2 ID="R2-SQL-GRANT-4">
-<REFSECT2INFO>
-<DATE>1998-09-23</DATE>
-</REFSECT2INFO>
-<TITLE>
-SQL92
-</TITLE>
-<PARA>
- The <acronym>SQL92</acronym> syntax for GRANT allows setting privileges
-for individual columns
-within a table, and allows setting a privilege to grant
-the same privileges to others.
-
-<SYNOPSIS>
-GRANT <REPLACEABLE CLASS="PARAMETER">privilege</REPLACEABLE> [, ...]
- ON <REPLACEABLE CLASS="PARAMETER">object</REPLACEABLE> [ ( <REPLACEABLE CLASS="PARAMETER">column</REPLACEABLE> [, ...] ) ] [, ...]
- TO { PUBLIC | <REPLACEABLE CLASS="PARAMETER">username</REPLACEABLE> [, ...] }
- [ WITH GRANT OPTION ]
-</SYNOPSIS>
-
-Fields are compatible with the those in the <acronym>Postgres</acronym>
-implementation, with the following additions:
-
-<VARIABLELIST>
-<VARLISTENTRY>
-<TERM>
-<REPLACEABLE CLASS="PARAMETER">privilege</REPLACEABLE>
-SELECT
-</TERM>
-<LISTITEM>
-<PARA>
-<acronym>SQL92</acronym> permits additional privileges to be specified:
-
-<VARIABLELIST>
-<VARLISTENTRY>
-<TERM>
-REFERENCES
-</TERM>
-<LISTITEM>
-<PARA>
-Allowed to reference some or all of the columns of a specific
-table/view in integrity constraints.
-
-<VARLISTENTRY>
-<TERM>
-USAGE
-</TERM>
-<LISTITEM>
-<PARA>
-Allowed to use a domain, character set, collation
- or translation.
- If an object specifies anything other than a table/view,
-<REPLACEABLE CLASS="PARAMETER">privilege</REPLACEABLE>
-must specify only USAGE.
-
-</variablelist>
-
-<tip>
-<para>
-Currently, to grant privileges in <productname>Postgres</productname>
-to only few columns, you must
- create a view having desired columns and then grant privileges
- to that view.
-</tip>
-
-<VARLISTENTRY>
-<TERM>
-<REPLACEABLE CLASS="PARAMETER">object</REPLACEABLE>
-</TERM>
-<LISTITEM>
-<PARA>
-
-<variablelist>
-<VARLISTENTRY>
-<TERM>
-<REPLACEABLE CLASS="PARAMETER">object</REPLACEABLE>
-</TERM>
-<LISTITEM>
-<PARA>
-<acronym>SQL92</acronym> allows an additional non-functional keyword:
-
-<simplelist>
-<member>
-[ TABLE ] table
-</simplelist>
-
-<VARLISTENTRY>
-<TERM>
-CHARACTER SET
-</TERM>
-<LISTITEM>
-<PARA>
-Allowed to use the specified character set.
-
-<VARLISTENTRY>
-<TERM>
-COLLATION
-</TERM>
-<LISTITEM>
-<PARA>
-Allowed to use the specified collation sequence.
-
-<VARLISTENTRY>
-<TERM>
-TRANSLATION
-</TERM>
-<LISTITEM>
-<PARA>
-Allowed to use the specified character set translation.
-
-<VARLISTENTRY>
-<TERM>
-DOMAIN
-</TERM>
-<LISTITEM>
-<PARA>
-Allowed to use the specified domain.
-
-</variablelist>
-
-
-<VARLISTENTRY>
-<TERM>
-WITH GRANT OPTION
-</TERM>
-<LISTITEM>
-<PARA>
-Allowed to grant the same privilege to others.
-
-</variablelist>
+ </programlisting>
+
+ <tip>
+ <para>
+ Currently, to create a GROUP you have to insert
+ data manually into table pg_group as:
+ <programlisting>
+ INSERT INTO pg_group VALUES ('todos');
+ CREATE USER miriam IN GROUP todos;
+ </programlisting>
+ Refer to REVOKE statements to revoke access privileges.
+ </para>
+ </tip>
+ </para>
+ </REFSECT2>
+ </refsect1>
+
+ <REFSECT1 ID="R1-SQL-GRANT-2">
+ <TITLE>
+ Usage
+ </TITLE>
+ <PARA>
+ <ProgramListing>
+ -- grant insert privilege to all users on table films:
+ --
+ GRANT INSERT ON films TO PUBLIC;
+ </programlisting>
+
+ <programlisting>
+ -- grant all privileges to user manuel on view kinds:
+ --
+ GRANT ALL ON kinds TO manuel;
+ </ProgramListing>
+ </para>
+ </REFSECT1>
+
+ <REFSECT1 ID="R1-SQL-GRANT-3">
+ <TITLE>
+ Compatibility
+ </TITLE>
+ <PARA>
+ </PARA>
+
+ <REFSECT2 ID="R2-SQL-GRANT-4">
+ <REFSECT2INFO>
+ <DATE>1998-09-23</DATE>
+ </REFSECT2INFO>
+ <TITLE>
+ SQL92
+ </TITLE>
+ <PARA>
+ The <acronym>SQL92</acronym> syntax for GRANT allows setting privileges
+ for individual columns
+ within a table, and allows setting a privilege to grant
+ the same privileges to others.
+
+ <SYNOPSIS>
+ GRANT <REPLACEABLE CLASS="PARAMETER">privilege</REPLACEABLE> [, ...]
+ ON <REPLACEABLE CLASS="PARAMETER">object</REPLACEABLE> [ ( <REPLACEABLE CLASS="PARAMETER">column</REPLACEABLE> [, ...] ) ] [, ...]
+ TO { PUBLIC | <REPLACEABLE CLASS="PARAMETER">username</REPLACEABLE> [, ...] }
+ [ WITH GRANT OPTION ]
+ </SYNOPSIS>
+
+ Fields are compatible with the those in the <acronym>Postgres</acronym>
+ implementation, with the following additions:
+
+ <VARIABLELIST>
+ <VARLISTENTRY>
+ <TERM>
+ <REPLACEABLE CLASS="PARAMETER">privilege</REPLACEABLE>
+ SELECT
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ <acronym>SQL92</acronym> permits additional privileges to be specified:
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <VARLISTENTRY>
+ <TERM>
+ REFERENCES
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Allowed to reference some or all of the columns of a specific
+ table/view in integrity constraints.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <VARLISTENTRY>
+ <TERM>
+ USAGE
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Allowed to use a domain, character set, collation
+ or translation.
+ If an object specifies anything other than a table/view,
+ <REPLACEABLE CLASS="PARAMETER">privilege</REPLACEABLE>
+ must specify only USAGE.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+
+ <tip>
+ <para>
+ Currently, to grant privileges in <productname>Postgres</productname>
+ to only few columns, you must
+ create a view having desired columns and then grant privileges
+ to that view.
+ </para>
+ </tip>
+
+ <variablelist>
+ <VARLISTENTRY>
+ <TERM>
+ <REPLACEABLE CLASS="PARAMETER">object</REPLACEABLE>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+
+ <variablelist>
+ <VARLISTENTRY>
+ <TERM>
+ <REPLACEABLE CLASS="PARAMETER">object</REPLACEABLE>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ <acronym>SQL92</acronym> allows an additional non-functional keyword:
+
+ <simplelist>
+ <member>
+ [ TABLE ] table
+ </member>
+ </simplelist>
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <VARLISTENTRY>
+ <TERM>
+ CHARACTER SET
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Allowed to use the specified character set.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <VARLISTENTRY>
+ <TERM>
+ COLLATION
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Allowed to use the specified collation sequence.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <VARLISTENTRY>
+ <TERM>
+ TRANSLATION
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Allowed to use the specified character set translation.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <VARLISTENTRY>
+ <TERM>
+ DOMAIN
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Allowed to use the specified domain.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <VARLISTENTRY>
+ <TERM>
+ WITH GRANT OPTION
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Allowed to grant the same privilege to others.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </para>
+ </refsect2>
+ </refsect1>
</REFENTRY>
<!--
<REFPURPOSE>
Create a new <productname>Postgres</productname> database installation
</REFPURPOSE>
+ </refnamediv>
<REFSYNOPSISDIV>
<REFSYNOPSISDIVINFO>
<DATE>1998-10-02</DATE>
[ --noclean | -n ] [ --debug | -d ]
</SYNOPSIS>
-<REFSECT2 ID="R2-APP-INITDB-1">
-<REFSECT2INFO>
-<DATE>1998-10-02</DATE>
-</REFSECT2INFO>
-<TITLE>
-Inputs
-</TITLE>
-<PARA>
-<variablelist>
-<varlistentry>
-<term>
---pglib=<replaceable class="parameter">libdir</replaceable>
-</term>
-<term>
--l <replaceable class="parameter">libdir</replaceable>
-</term>
-<term>
-<envar>PGLIB</envar>
-<listitem>
-<para>
-Where are the files that make up <productname>Postgres</productname>?
- Apart from files that
-have to go in particular directories because of their function, the
-files that make up the <productname>Postgres</productname> software
-were installed in a directory
-called the <replaceable class="parameter">libdir</replaceable> directory.
-An example of a file that will be found
-there that <application>initdb</application>
-needs is <filename>global1.bki.source</filename>,
- which contains all the information that goes
-into the shared catalog tables.
-
-<varlistentry>
-<term>
---pgdata=<replaceable class="parameter">dbdir</replaceable>
-</term>
-<term>
--r <replaceable class="parameter">dbdir</replaceable>
-</term>
-<term>
-<envar>PGDATA</envar>
-</term>
-<listitem>
-<para>
-Where in your Unix filesystem do you want the database data to go?
-The top level directory is called the <envar>PGDATA</envar> directory.
-
-<varlistentry>
-<term>
---username=<replaceable class="parameter">name</replaceable>
-</term>
-<term>
--u <replaceable class="parameter">name</replaceable>
-</term>
-<term>
-<envar>PGUSER</envar>
-</term>
-<listitem>
-<para>
-Who will be the <productname>Postgres</productname> superuser
- for this database system? The
-<productname>Postgres</productname> superuser is a Unix user
-who owns all files that store the database
-system and also owns the postmaster and backend processes that access them.
-Or just let it default to you (the Unix user who runs
-<application>initdb</application>).
-
-<note>
-<para>
-Only the Unix superuser (<literal>root</literal>)
- can create a database system with an owner
-different from the <productname>Postgres</productname> superuser.
-</note>
-
-</variablelist>
-
-<para>
-Other, less commonly used, parameters are also available:
-
-<variablelist>
-<varlistentry>
-<term>
---template=<replaceable class="parameter">template</replaceable>
-</term>
-<term>
--t <replaceable class="parameter">template</replaceable>
-</term>
-<listitem>
-<para>
-Replace the <literal>template1</literal>
-database in an existing database system, and don't touch anything else.
-This is useful when you need to upgrade your <literal>template1</literal>
-database using <application>initdb</application>
-from a newer release of <productname>Postgres</productname>,
-or when your <literal>template1</literal>
-database has become corrupted by some system problem. Normally the
-contents of <literal>template1</literal>
-remain constant throughout the life of the database system. You can't
-destroy anything by running <application>initdb</application>
-with the
-<option>--template</option>
-option.
-
-<varlistentry>
-<term>
---noclean
-</term>
-<term>
--n
-</term>
-<listitem>
-<para>
-By default, when <application>initdb</application>
-determines that error prevent it from completely creating the database
-system, it removes any files it may have created before determining
-that it can't finish the job. That includes any core files left by
-the programs it invokes. This option inhibits any tidying-up and is
-thus useful for debugging.
-
-<varlistentry>
-<term>
---debug
-</term>
-<term>
--d
-</term>
-<listitem>
-<para>
-Print debugging output from the bootstrap backend.
-The bootstrap backend is the program <application>initdb</application>
-uses to create the catalog tables. This option generates a tremendous
-amount of output. It also turns off the final vacuuming step.
-
-</variablelist>
-
-<para>
-Files are also input to <application>initdb</application>:
-
-<variablelist>
-<varlistentry>
-<term>
-<application>postconfig</application>
-</term>
-<listitem>
-<para>
-If appearing somewhere in the Unix command search path
-(defined by the PATH environment variable).
- This is a program that specifies defaults for some of the
-command options. See below.
-
-<varlistentry>
-<term>
-<filename><envar>PGLIB</envar>/global1.bki.source</filename>
-</term>
-<listitem>
-<para>
-Contents for the shared catalog tables in the new database system. This
-file is part of the <productname>Postgres</productname> software.
-
-<varlistentry>
-<term>
-<filename><envar>PGLIB</envar>/local1_template1.bki.source</filename>
-</term>
-<listitem>
-<para>
-Contents for the template1 tables in the new database system. This
-file is part of the <productname>Postgres</productname> software.
-
-</variablelist>
-
-<REFSECT2 ID="R2-APP-INITDB-2">
-<REFSECT2INFO>
-<DATE>1998-09-26</DATE>
-</REFSECT2INFO>
-<TITLE>
-Outputs
-</TITLE>
-<PARA>
-<application>initdb</application> will create files in the <envar>PGDATA</envar>
-data area which are the system tables and framework for a complete
-installation.
-
-<REFSECT1 ID="R1-APP-INITDB-1">
-<REFSECT1INFO>
-<DATE>1998-09-26</DATE>
-</REFSECT1INFO>
-<TITLE>
-Description
-</TITLE>
-<PARA>
-<application>initdb</application> creates a new
-<productname>Postgres</productname> database system.
-A database system is a
-collection of databases that are all administered by the same Unix user
-and managed by a single postmaster.
-
-<para>
-Creating a database system consists of creating the directories in which
-the database data will live, generating the shared catalog tables
-(tables that don't belong to any particular database), and
-creating the <literal>template1</literal>
-database. What is the <literal>template1</literal>
-database? When you create a database, <productname>Postgres</productname>
-does it by copying
-everything from the <literal>template1</literal>
-database. It contains catalog tables filled in for things like the
-builtin types.
-
-<para>
-After <application>initdb</application>
-creates the database, it completes the initialization by running
-<application>vacuum</application>, which resets some optimization parameters.
-
-<para>
-There are three ways to give parameters to <application>initdb</application>.
-
-First, you can use <application>initdb</application> command options.
- Second, you can set environment
-variables before invoking <application>initdb</application>.
-Third, you can have a program called <application>postconfig</application>
-in your Unix command search path.
-<application>initdb</application> invokes that program and that program then writes
-<application>initdb</application> parameters to its standard output stream.
-This third option is not a common thing to do, however.
-
-<para>
-Command options always override parameters specified any other way.
-The values returned by <application>postconfig</application>
-override any environment variables, but your
-<application>postconfig</application>
-program may base its output on the environment variables if you want
-their values to be used.
-
-<para>
-The value that <application>postconfig</application>
-outputs must have the format
-<programlisting>
- <replaceable>var1</replaceable>=<replaceable class="parameter">value1</replaceable> <replaceable>var2</replaceable>=<replaceable class="parameter">value2</replaceable> ...
-</programlisting>
+ <REFSECT2 ID="R2-APP-INITDB-1">
+ <REFSECT2INFO>
+ <DATE>1998-10-02</DATE>
+ </REFSECT2INFO>
+ <TITLE>
+ Inputs
+ </TITLE>
+ <PARA>
+ <variablelist>
+ <varlistentry>
+ <term>
+ --pglib=<replaceable class="parameter">libdir</replaceable>
+ </term>
+ <term>
+ -l <replaceable class="parameter">libdir</replaceable>
+ </term>
+ <term>
+ <envar>PGLIB</envar>
+ </term>
+ <listitem>
+ <para>
+ Where are the files that make up <productname>Postgres</productname>?
+ Apart from files that
+ have to go in particular directories because of their function, the
+ files that make up the <productname>Postgres</productname> software
+ were installed in a directory
+ called the <replaceable class="parameter">libdir</replaceable> directory.
+ An example of a file that will be found
+ there that <application>initdb</application>
+ needs is <filename>global1.bki.source</filename>,
+ which contains all the information that goes
+ into the shared catalog tables.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ --pgdata=<replaceable class="parameter">dbdir</replaceable>
+ </term>
+ <term>
+ -r <replaceable class="parameter">dbdir</replaceable>
+ </term>
+ <term>
+ <envar>PGDATA</envar>
+ </term>
+ <listitem>
+ <para>
+ Where in your Unix filesystem do you want the database data to go?
+ The top level directory is called the <envar>PGDATA</envar> directory.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ --username=<replaceable class="parameter">name</replaceable>
+ </term>
+ <term>
+ -u <replaceable class="parameter">name</replaceable>
+ </term>
+ <term>
+ <envar>PGUSER</envar>
+ </term>
+ <listitem>
+ <para>
+ Who will be the <productname>Postgres</productname> superuser
+ for this database system? The
+ <productname>Postgres</productname> superuser is a Unix user
+ who owns all files that store the database
+ system and also owns the postmaster and backend processes that access them.
+ Or just let it default to you (the Unix user who runs
+ <application>initdb</application>).
+ </para>
+ <note>
+ <para>
+ Only the Unix superuser (<literal>root</literal>)
+ can create a database system with an owner
+ different from the <productname>Postgres</productname> superuser.
+ </para>
+ </note>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </para>
+ <para>
+ Other, less commonly used, parameters are also available:
+
+ <variablelist>
+ <varlistentry>
+ <term>
+ --template=<replaceable class="parameter">template</replaceable>
+ </term>
+ <term>
+ -t <replaceable class="parameter">template</replaceable>
+ </term>
+ <listitem>
+ <para>
+ Replace the <literal>template1</literal>
+ database in an existing database system, and don't touch anything else.
+ This is useful when you need to upgrade your <literal>template1</literal>
+ database using <application>initdb</application>
+ from a newer release of <productname>Postgres</productname>,
+ or when your <literal>template1</literal>
+ database has become corrupted by some system problem. Normally the
+ contents of <literal>template1</literal>
+ remain constant throughout the life of the database system. You can't
+ destroy anything by running <application>initdb</application>
+ with the
+ <option>--template</option>
+ option.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ --noclean
+ </term>
+ <term>
+ -n
+ </term>
+ <listitem>
+ <para>
+ By default, when <application>initdb</application>
+ determines that error prevent it from completely creating the database
+ system, it removes any files it may have created before determining
+ that it can't finish the job. That includes any core files left by
+ the programs it invokes. This option inhibits any tidying-up and is
+ thus useful for debugging.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ --debug
+ </term>
+ <term>
+ -d
+ </term>
+ <listitem>
+ <para>
+ Print debugging output from the bootstrap backend.
+ The bootstrap backend is the program <application>initdb</application>
+ uses to create the catalog tables. This option generates a tremendous
+ amount of output. It also turns off the final vacuuming step.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </para>
+ <para>
+ Files are also input to <application>initdb</application>:
+
+ <variablelist>
+ <varlistentry>
+ <term>
+ <application>postconfig</application>
+ </term>
+ <listitem>
+ <para>
+ If appearing somewhere in the Unix command search path
+ (defined by the PATH environment variable).
+ This is a program that specifies defaults for some of the
+ command options. See below.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ <filename><envar>PGLIB</envar>/global1.bki.source</filename>
+ </term>
+ <listitem>
+ <para>
+ Contents for the shared catalog tables in the new database system. This
+ file is part of the <productname>Postgres</productname> software.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ <filename><envar>PGLIB</envar>/local1_template1.bki.source</filename>
+ </term>
+ <listitem>
+ <para>
+ Contents for the template1 tables in the new database system. This
+ file is part of the <productname>Postgres</productname> software.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </para>
+ </refsect2>
-It can output nothing if it doesn't want to supply any parameters.
-The <replaceable>var</replaceable> values are equal to
-the corresponding environment variable
-names. For example,
-<programlisting>
-PGDATA=/tmp/postgres_test
-</programlisting>
-has the
-same effect as invoking <application>initdb</application>
-with an environment variable called <envar>PGDATA</envar> whose value is
-<filename>/tmp/postgres_test</filename>.
+ <REFSECT2 ID="R2-APP-INITDB-2">
+ <REFSECT2INFO>
+ <DATE>1998-09-26</DATE>
+ </REFSECT2INFO>
+ <TITLE>
+ Outputs
+ </TITLE>
+ <PARA>
+ <application>initdb</application> will create files in the <envar>PGDATA</envar>
+ data area which are the system tables and framework for a complete
+ installation.
+ </para>
+ </refsect2>
+ </refsynopsisdiv>
+ <REFSECT1 ID="R1-APP-INITDB-1">
+ <REFSECT1INFO>
+ <DATE>1998-09-26</DATE>
+ </REFSECT1INFO>
+ <TITLE>
+ Description
+ </TITLE>
+ <PARA>
+ <application>initdb</application> creates a new
+ <productname>Postgres</productname> database system.
+ A database system is a
+ collection of databases that are all administered by the same Unix user
+ and managed by a single postmaster.
+ </para>
+ <para>
+ Creating a database system consists of creating the directories in which
+ the database data will live, generating the shared catalog tables
+ (tables that don't belong to any particular database), and
+ creating the <literal>template1</literal>
+ database. What is the <literal>template1</literal>
+ database? When you create a database, <productname>Postgres</productname>
+ does it by copying
+ everything from the <literal>template1</literal>
+ database. It contains catalog tables filled in for things like the
+ builtin types.
+ </para>
+ <para>
+ After <application>initdb</application>
+ creates the database, it completes the initialization by running
+ <application>vacuum</application>, which resets some optimization parameters.
+ </para>
+ <para>
+ There are three ways to give parameters to <application>initdb</application>.
+
+ First, you can use <application>initdb</application> command options.
+ Second, you can set environment
+ variables before invoking <application>initdb</application>.
+ Third, you can have a program called <application>postconfig</application>
+ in your Unix command search path.
+ <application>initdb</application> invokes that program and that program then writes
+ <application>initdb</application> parameters to its standard output stream.
+ This third option is not a common thing to do, however.
+ </para>
+ <para>
+ Command options always override parameters specified any other way.
+ The values returned by <application>postconfig</application>
+ override any environment variables, but your
+ <application>postconfig</application>
+ program may base its output on the environment variables if you want
+ their values to be used.
+ </para>
+ <para>
+ The value that <application>postconfig</application>
+ outputs must have the format
+ <programlisting>
+ <replaceable>var1</replaceable>=<replaceable class="parameter">value1</replaceable> <replaceable>var2</replaceable>=<replaceable class="parameter">value2</replaceable> ...
+ </programlisting>
+
+ It can output nothing if it doesn't want to supply any parameters.
+ The <replaceable>var</replaceable> values are equal to
+ the corresponding environment variable
+ names. For example,
+ <programlisting>
+ PGDATA=/tmp/postgres_test
+ </programlisting>
+ has the
+ same effect as invoking <application>initdb</application>
+ with an environment variable called <envar>PGDATA</envar> whose value is
+ <filename>/tmp/postgres_test</filename>.
+ </para>
+ </refsect1>
</REFENTRY>
<REFPURPOSE>
Create a secondary <productname>Postgres</productname> database storage area
</REFPURPOSE>
+ </refnamediv>
<REFSYNOPSISDIV>
<REFSYNOPSISDIVINFO>
<DATE>1998-10-02</DATE>
[ <replaceable class="parameter">altdir</replaceable> ]
</SYNOPSIS>
-<REFSECT2 ID="R2-APP-INITLOCATION-1">
-<REFSECT2INFO>
-<DATE>1998-10-02</DATE>
-</REFSECT2INFO>
-<TITLE>
-Inputs
-</TITLE>
-<PARA>
-
-<variablelist>
-<varlistentry>
-<term>
---location=<replaceable class="parameter">altdir</replaceable>
-</term>
-<term>
--D <replaceable class="parameter">altdir</replaceable>
-</term>
-<term>
-<replaceable class="parameter">altdir</replaceable>
-</term>
-<listitem>
-<para>
-Where in your Unix filesystem do you want alternate databases to go?
-The top level directory is called the <envar>PGDATA</envar> directory, so you
-might want to point your first alternate location at <envar>PGDATA2</envar>.
-
-<varlistentry>
-<term>
---username=<replaceable class="parameter">name</replaceable>
-</term>
-<term>
--u <replaceable class="parameter">name</replaceable>
-</term>
-<term>
-<envar>PGUSER</envar>
-</term>
-<listitem>
-<para>
-Who will be the Unix filesystem owner of this database storage area?
-The
-<productname>Postgres</productname> superuser is a Unix user
-who owns all files that store the database
-system and also owns the postmaster and backend processes that access them.
-Usually, this is the user who should run <application>initlocation</application>
-and who will thus have ownership of the directories and files.
-
-<note>
-<para>
-Only the Unix superuser can create a database system with a
-different user as the <productname>Postgres</productname> superuser.
-Specifying a user other than the <productname>Postgres</productname> superuser
-may lead to database security and data integrity problems. Refer to the
-<citetitle><productname>PostgreSQL</productname> Administrator's Guide</citetitle>
- for more information.
-</note>
-
-</variablelist>
-
-<REFSECT2 ID="R2-APP-INITLOCATION-2">
-<REFSECT2INFO>
-<DATE>1998-09-26</DATE>
-</REFSECT2INFO>
-<TITLE>
-Outputs
-</TITLE>
-<PARA>
-<application>initlocation</application> will create directories in
-the specified place.
-
-<variablelist>
-<varlistentry>
-<term>
-We are initializing the database area with username postgres (uid=500).
-This user will own all the files and must also own the server process.
-Creating Postgres database system directory <replaceable class="parameter">altdir</replaceable>
-Creating Postgres database system directory <replaceable class="parameter">altdir</replaceable>
-</term>
-<listitem>
-<para>
-Successful completion.
-
-<varlistentry>
-<term>
-We are initializing the database area with username postgres (uid=500).
-This user will own all the files and must also own the server process.
-Creating Postgres database system directory /usr/local/src/testlocation
-mkdir: cannot make directory `<replaceable class="parameter">altdir</replaceable>': Permission denied
-</term>
-<listitem>
-<para>
-You do not have filesystem permission to write to the specified directory area.
-
-<varlistentry>
-<term>
-Valid username not given. You must specify the username for
-the Postgres superuser for the database system you are
-initializing, either with the --username option or by default
-to the USER environment variable.
-</term>
-<listitem>
-<para>
-The username which you have specified is not the
-<productname>Postgres</productname> superuser.
-
-<varlistentry>
-<term>
-Can't tell what username to use. You don't have the USER
-environment variable set to your username and didn't specify the
---username option
-</term>
-<listitem>
-<para>
-Specify the <option>--username</option> command line option.
-
-</variablelist>
-
-<REFSECT1 ID="R1-APP-INITLOCATION-1">
-<REFSECT1INFO>
-<DATE>1998-09-26</DATE>
-</REFSECT1INFO>
-<TITLE>
-Description
-</TITLE>
-<PARA>
-<application>initlocation</application>
-creates a new <productname>Postgres</productname> secondary database storage area.
-A secondary storage area contains a required tree of directories with
-the correct file permissions on those directories.
-
-<para>
-Creating a database storage area consists of creating the directories in which
-database data might live.
-
-<para>
-There are two kinds of arguments for <application>initlocation</application>.
-First, you can specify an environment variable (e.g. <envar>PGDATA2</envar>).
-This environment variable should be known to the backend for later use in
-<command>CREATE DATABASE/WITH LOCATION</command>
- or
-<command>createdb -D <replaceable class="parameter">altdir</replaceable></command>.
-However, <emphasis>the backend daemon must have this variable in it's
-environment</emphasis> for this to succeed.
-
-Second, you may be able to specify an explicit
-absolute path to the top directory of the storage area. However,this second
-option is possible only if explicitly enabled during the
-<productname>Postgres</productname> installation. It is usually disabled
- to alleviate security and data integrity concerns.
-
-<note>
-<para>
-<productname>Postgres</productname> will add <filename>/base/</filename>
-to the specified path to create the storage area.
-
-<para>
-The backend requires that any argument to <option>WITH LOCATION</option> which is
-in all uppercase and which has no path delimiters is an environment variable.
-</note>
-
-<REFSECT1 ID="R1-APP-INITLOCATION-2">
-<REFSECT1INFO>
-<DATE>1998-09-26</DATE>
-</REFSECT1INFO>
-<TITLE>
-Usage
-</TITLE>
-<PARA>
-To create a database in an alternate location, using an environment variable:
-
-<programlisting>
-% setenv PGDATA2 /opt/postgres/data
-
-% initlocation PGDATA2
-% createdb -D PGDATA2
-</programlisting>
-
+ <REFSECT2 ID="R2-APP-INITLOCATION-1">
+ <REFSECT2INFO>
+ <DATE>1998-10-02</DATE>
+ </REFSECT2INFO>
+ <TITLE>
+ Inputs
+ </TITLE>
+ <PARA>
+
+ <variablelist>
+ <varlistentry>
+ <term>
+ --location=<replaceable class="parameter">altdir</replaceable>
+ </term>
+ <term>
+ -D <replaceable class="parameter">altdir</replaceable>
+ </term>
+ <term>
+ <replaceable class="parameter">altdir</replaceable>
+ </term>
+ <listitem>
+ <para>
+ Where in your Unix filesystem do you want alternate databases to go?
+ The top level directory is called the <envar>PGDATA</envar> directory, so you
+ might want to point your first alternate location at <envar>PGDATA2</envar>.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ --username=<replaceable class="parameter">name</replaceable>
+ </term>
+ <term>
+ -u <replaceable class="parameter">name</replaceable>
+ </term>
+ <term>
+ <envar>PGUSER</envar>
+ </term>
+ <listitem>
+ <para>
+ Who will be the Unix filesystem owner of this database storage area?
+ The
+ <productname>Postgres</productname> superuser is a Unix user
+ who owns all files that store the database
+ system and also owns the postmaster and backend processes that access them.
+ Usually, this is the user who should run <application>initlocation</application>
+ and who will thus have ownership of the directories and files.
+ </para>
+ <note>
+ <para>
+ Only the Unix superuser can create a database system with a
+ different user as the <productname>Postgres</productname> superuser.
+ Specifying a user other than the <productname>Postgres</productname> superuser
+ may lead to database security and data integrity problems. Refer to the
+ <citetitle><productname>PostgreSQL</productname> Administrator's Guide</citetitle>
+ for more information.
+ </para>
+ </note>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </para>
+ </refsect2>
+
+ <REFSECT2 ID="R2-APP-INITLOCATION-2">
+ <REFSECT2INFO>
+ <DATE>1998-09-26</DATE>
+ </REFSECT2INFO>
+ <TITLE>
+ Outputs
+ </TITLE>
+ <PARA>
+ <application>initlocation</application> will create directories in
+ the specified place.
+
+ <variablelist>
+ <varlistentry>
+ <term>
+ We are initializing the database area with username postgres (uid=500).
+ This user will own all the files and must also own the server process.
+ Creating Postgres database system directory <replaceable class="parameter">altdir</replaceable>
+ Creating Postgres database system directory <replaceable class="parameter">altdir</replaceable>
+ </term>
+ <listitem>
+ <para>
+ Successful completion.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ We are initializing the database area with username postgres (uid=500).
+ This user will own all the files and must also own the server process.
+ Creating Postgres database system directory /usr/local/src/testlocation
+ mkdir: cannot make directory `<replaceable class="parameter">altdir</replaceable>': Permission denied
+ </term>
+ <listitem>
+ <para>
+ You do not have filesystem permission to write to the specified directory area.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ Valid username not given. You must specify the username for
+ the Postgres superuser for the database system you are
+ initializing, either with the --username option or by default
+ to the USER environment variable.
+ </term>
+ <listitem>
+ <para>
+ The username which you have specified is not the
+ <productname>Postgres</productname> superuser.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ Can't tell what username to use. You don't have the USER
+ environment variable set to your username and didn't specify the
+ --username option
+ </term>
+ <listitem>
+ <para>
+ Specify the <option>--username</option> command line option.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </para>
+ </refsect2>
+ </refsynopsisdiv>
+
+ <REFSECT1 ID="R1-APP-INITLOCATION-1">
+ <REFSECT1INFO>
+ <DATE>1998-09-26</DATE>
+ </REFSECT1INFO>
+ <TITLE>
+ Description
+ </TITLE>
+ <PARA>
+ <application>initlocation</application>
+ creates a new <productname>Postgres</productname> secondary database storage area.
+ A secondary storage area contains a required tree of directories with
+ the correct file permissions on those directories.
+ </para>
+ <para>
+ Creating a database storage area consists of creating the directories in which
+ database data might live.
+ </para>
+ <para>
+ There are two kinds of arguments for <application>initlocation</application>.
+ First, you can specify an environment variable (e.g. <envar>PGDATA2</envar>).
+ This environment variable should be known to the backend for later use in
+ <command>CREATE DATABASE/WITH LOCATION</command>
+ or
+ <command>createdb -D <replaceable class="parameter">altdir</replaceable></command>.
+ However, <emphasis>the backend daemon must have this variable in it's
+ environment</emphasis> for this to succeed.
+
+ Second, you may be able to specify an explicit
+ absolute path to the top directory of the storage area. However,this second
+ option is possible only if explicitly enabled during the
+ <productname>Postgres</productname> installation. It is usually disabled
+ to alleviate security and data integrity concerns.
+ </para>
+ <note>
+ <para>
+ <productname>Postgres</productname> will add <filename>/base/</filename>
+ to the specified path to create the storage area.
+ </para>
+ <para>
+ The backend requires that any argument to <option>WITH LOCATION</option> which is
+ in all uppercase and which has no path delimiters is an environment variable.
+ </para>
+ </note>
+ </refsect1>
+
+ <REFSECT1 ID="R1-APP-INITLOCATION-2">
+ <REFSECT1INFO>
+ <DATE>1998-09-26</DATE>
+ </REFSECT1INFO>
+ <TITLE>
+ Usage
+ </TITLE>
+ <PARA>
+ To create a database in an alternate location, using an environment variable:
+
+ <programlisting>
+ % setenv PGDATA2 /opt/postgres/data
+
+ % initlocation PGDATA2
+ % createdb -D PGDATA2
+ </programlisting>
+ </para>
+ </refsect1>
</REFENTRY>
<REFPURPOSE>
Inserts new rows into a table
</REFPURPOSE>
-<REFSYNOPSISDIV>
-<REFSYNOPSISDIVINFO>
-<DATE>1998-09-23</DATE>
-</REFSYNOPSISDIVINFO>
-<SYNOPSIS>
-INSERT INTO <REPLACEABLE CLASS="PARAMETER">table</REPLACEABLE> [ ( <REPLACEABLE CLASS="PARAMETER">column</REPLACEABLE> [, ...] ) ]
- { VALUES ( <REPLACEABLE CLASS="PARAMETER">expression</REPLACEABLE> [, ...] ) | SELECT <REPLACEABLE CLASS="PARAMETER">query</REPLACEABLE> }
-</SYNOPSIS>
-
-<REFSECT2 ID="R2-SQL-INSERT-1">
-<REFSECT2INFO>
-<DATE>1998-09-23</DATE>
-</REFSECT2INFO>
-<TITLE>
-Inputs
-</TITLE>
-<PARA>
-</PARA>
-<VARIABLELIST>
-<VARLISTENTRY>
-<TERM>
-<REPLACEABLE CLASS="PARAMETER">table</REPLACEABLE>
-</TERM>
-<LISTITEM>
-<PARA>
-The name of an existing table.
-
-<VARLISTENTRY>
-<TERM>
-<REPLACEABLE CLASS="PARAMETER">column</REPLACEABLE>
-</TERM>
-<LISTITEM>
-<PARA>
-The name of a column in <REPLACEABLE CLASS="PARAMETER">table</REPLACEABLE>.
-
-<VARLISTENTRY>
-<TERM>
-<REPLACEABLE CLASS="PARAMETER">expression</REPLACEABLE>
-</TERM>
-<LISTITEM>
-<PARA>
-A valid expression or value to assign to <REPLACEABLE CLASS="PARAMETER">column</REPLACEABLE>.
-
-<VARLISTENTRY>
-<TERM>
-<REPLACEABLE CLASS="PARAMETER">query</REPLACEABLE>
-</TERM>
-<LISTITEM>
-<PARA>
-A valid query. Refer to the SELECT statement for a further description
- of valid arguments.
-
-</VARIABLELIST>
-
-</REFSECT2>
-
-<REFSECT2 ID="R2-SQL-INSERT-2">
-<REFSECT2INFO>
-<DATE>1998-09-23</DATE>
-</REFSECT2INFO>
-<TITLE>
-Outputs
-</TITLE>
-<PARA>
-
-<VARIABLELIST>
-<VARLISTENTRY>
-<TERM>
-<ReturnValue>INSERT <replaceable>oid</replaceable></ReturnValue> 1
-</TERM>
-<LISTITEM>
-<PARA>
-Message returned if only one row was inserted.
-<ReturnValue><replaceable>oid</replaceable></ReturnValue>
- is the row identifier.
-
-<VARLISTENTRY>
-<TERM>
-<ReturnValue>INSERT 0 <replaceable>#</replaceable></ReturnValue>
-</TERM>
-<LISTITEM>
-<PARA>
-Message returned if more than one rows were inserted.
-<ReturnValue><replaceable>#</replaceable></ReturnValue>
- is the number of rows inserted.
-
-</VARIABLELIST>
-
-</REFSECT2>
-</REFSYNOPSISDIV>
-
-<REFSECT1 ID="R1-SQL-INSERT-1">
-<REFSECT1INFO>
-<DATE>1998-09-02</DATE>
-</REFSECT1INFO>
-<TITLE>
-Description
-</TITLE>
-<PARA>
- INSERT allows one to insert new rows into a table. One can insert
- a single row at time or several rows as a result of a query.
- The columns in the target list may be listed in any order.
- In every column not present in the target list will be inserted
- the default value, if column has not a declared default value
- it will be assumed as NULL. If the expression for each column
- is not of the correct data type, automatic type coercion will be
- attempted.
-
-<para>
- You must have insert privilege to a table in order to append
- to it, as well as select privilege on any table specified
- in a WHERE clause.
-
-<REFSECT1 ID="R1-SQL-INSERT-2">
-<TITLE>
-Usage
-</TITLE>
-<PARA>
-<ProgramListing>
---Insert a single row into table films;
---(in the second example the column date_prod is omitted
---therefore will be stored in it a default value of NULL):
---
-INSERT INTO films VALUES
- ('UA502','Bananas',105,'1971-07-13','Comedy',INTERVAL '82 minute');
-
-INSERT INTO films (code, title, did, date_prod, kind)
- VALUES ('T_601', 'Yojimbo', 106, DATE '1961-06-16', 'Drama');
-</ProgramListing>
-
-<ProgramListing>
---Insert a single row into table distributors, note that
---only column "name" is specified, to the non specified
---column "did" will be assigned its default value:
---
-INSERT INTO distributors (name) VALUES ('British Lion');
-</ProgramListing>
-
-<ProgramListing>
---Insert several rows into table films from table tmp:
---
-INSERT INTO films
- SELECT * FROM tmp;
-</ProgramListing>
-
-<ProgramListing>
---Insert into arrays:
---Create an empty 3x3 gameboard for noughts-and-crosses
---(all of these queries create the same board attribute)
---(Refer to the <citetitle>PostgreSQL User's Guide</citetitle> for further
---information about arrays).
-
-INSERT INTO tictactoe (game, board[1:3][1:3])
- VALUES (1,'{{"","",""},{},{"",""}}');
-INSERT INTO tictactoe (game, board[3][3])
- VALUES (2,'{}');
-INSERT INTO tictactoe (game, board)
- VALUES (3,'{{,,},{,,},{,,}}');
-</ProgramListing>
-
-</REFSECT1>
-
-<REFSECT1 ID="R1-SQL-INSERT-3">
-<TITLE>
-Compatibility
-</TITLE>
-<PARA>
-</PARA>
-
-<REFSECT2 ID="R2-SQL-INSERT-4">
-<REFSECT2INFO>
-<DATE>1998-09-23</DATE>
-</REFSECT2INFO>
-<TITLE>
-SQL92
-</TITLE>
-<PARA>
-The INSERT statement is fully compatible with <acronym>SQL92</acronym>.
-Possible limitations in features of the
-<REPLACEABLE CLASS="PARAMETER">query</REPLACEABLE>
-clause are documented for the SELECT statement.
-
+ </refnamediv>
+ <REFSYNOPSISDIV>
+ <REFSYNOPSISDIVINFO>
+ <DATE>1998-09-23</DATE>
+ </REFSYNOPSISDIVINFO>
+ <SYNOPSIS>
+ INSERT INTO <REPLACEABLE CLASS="PARAMETER">table</REPLACEABLE> [ ( <REPLACEABLE CLASS="PARAMETER">column</REPLACEABLE> [, ...] ) ]
+ { VALUES ( <REPLACEABLE CLASS="PARAMETER">expression</REPLACEABLE> [, ...] ) | SELECT <REPLACEABLE CLASS="PARAMETER">query</REPLACEABLE> }
+ </SYNOPSIS>
+
+ <REFSECT2 ID="R2-SQL-INSERT-1">
+ <REFSECT2INFO>
+ <DATE>1998-09-23</DATE>
+ </REFSECT2INFO>
+ <TITLE>
+ Inputs
+ </TITLE>
+ <PARA>
+ </PARA>
+ <VARIABLELIST>
+ <VARLISTENTRY>
+ <TERM>
+ <REPLACEABLE CLASS="PARAMETER">table</REPLACEABLE>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ The name of an existing table.
+ </para>
+ </listitem>
+ </varlistentry>
+ <VARLISTENTRY>
+ <TERM>
+ <REPLACEABLE CLASS="PARAMETER">column</REPLACEABLE>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ The name of a column in <REPLACEABLE CLASS="PARAMETER">table</REPLACEABLE>.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <VARLISTENTRY>
+ <TERM>
+ <REPLACEABLE CLASS="PARAMETER">expression</REPLACEABLE>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ A valid expression or value to assign to <REPLACEABLE CLASS="PARAMETER">column</REPLACEABLE>.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <VARLISTENTRY>
+ <TERM>
+ <REPLACEABLE CLASS="PARAMETER">query</REPLACEABLE>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ A valid query. Refer to the SELECT statement for a further description
+ of valid arguments.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </VARIABLELIST>
+
+ </REFSECT2>
+
+ <REFSECT2 ID="R2-SQL-INSERT-2">
+ <REFSECT2INFO>
+ <DATE>1998-09-23</DATE>
+ </REFSECT2INFO>
+ <TITLE>
+ Outputs
+ </TITLE>
+ <PARA>
+
+ <VARIABLELIST>
+ <VARLISTENTRY>
+ <TERM>
+ <ReturnValue>INSERT <replaceable>oid</replaceable></ReturnValue> 1
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Message returned if only one row was inserted.
+ <ReturnValue><replaceable>oid</replaceable></ReturnValue>
+ is the numeric <acronym>OID</acronym> of the inserted row.
+ </para>
+ </listitem>
+ </varlistentry>
+ <VARLISTENTRY>
+ <TERM>
+ <ReturnValue>INSERT 0 <replaceable>#</replaceable></ReturnValue>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Message returned if more than one rows were inserted.
+ <ReturnValue><replaceable>#</replaceable></ReturnValue>
+ is the number of rows inserted.
+ </para>
+ </listitem>
+ </varlistentry>
+ </VARIABLELIST>
+ </para>
+ </REFSECT2>
+ </REFSYNOPSISDIV>
+
+ <REFSECT1 ID="R1-SQL-INSERT-1">
+ <REFSECT1INFO>
+ <DATE>1998-09-02</DATE>
+ </REFSECT1INFO>
+ <TITLE>
+ Description
+ </TITLE>
+ <PARA>
+ INSERT allows one to insert new rows into a table. One can insert
+ a single row at time or several rows as a result of a query.
+ The columns in the target list may be listed in any order.
+ In every column not present in the target list will be inserted
+ the default value, if column has not a declared default value
+ it will be assumed as NULL. If the expression for each column
+ is not of the correct data type, automatic type coercion will be
+ attempted.
+ </para>
+ <para>
+ You must have insert privilege to a table in order to append
+ to it, as well as select privilege on any table specified
+ in a WHERE clause.
+ </para>
+ </refsect1>
+
+ <REFSECT1 ID="R1-SQL-INSERT-2">
+ <TITLE>
+ Usage
+ </TITLE>
+ <PARA>
+ <ProgramListing>
+ --Insert a single row into table films;
+ --(in the second example the column date_prod is omitted
+ --therefore will be stored in it a default value of NULL):
+ --
+ INSERT INTO films VALUES
+ ('UA502','Bananas',105,'1971-07-13','Comedy',INTERVAL '82 minute');
+
+ INSERT INTO films (code, title, did, date_prod, kind)
+ VALUES ('T_601', 'Yojimbo', 106, DATE '1961-06-16', 'Drama');
+ </ProgramListing>
+
+ <ProgramListing>
+ --Insert a single row into table distributors, note that
+ --only column "name" is specified, to the non specified
+ --column "did" will be assigned its default value:
+ --
+ INSERT INTO distributors (name) VALUES ('British Lion');
+ </ProgramListing>
+
+ <ProgramListing>
+ --Insert several rows into table films from table tmp:
+ --
+ INSERT INTO films
+ SELECT * FROM tmp;
+ </ProgramListing>
+
+ <ProgramListing>
+ --Insert into arrays:
+ --Create an empty 3x3 gameboard for noughts-and-crosses
+ --(all of these queries create the same board attribute)
+ --(Refer to the <citetitle>PostgreSQL User's Guide</citetitle> for further
+ --information about arrays).
+
+ INSERT INTO tictactoe (game, board[1:3][1:3])
+ VALUES (1,'{{"","",""},{},{"",""}}');
+ INSERT INTO tictactoe (game, board[3][3])
+ VALUES (2,'{}');
+ INSERT INTO tictactoe (game, board)
+ VALUES (3,'{{,,},{,,},{,,}}');
+ </ProgramListing>
+ </para>
+ </REFSECT1>
+
+ <REFSECT1 ID="R1-SQL-INSERT-3">
+ <TITLE>
+ Compatibility
+ </TITLE>
+ <PARA>
+ </PARA>
+
+ <REFSECT2 ID="R2-SQL-INSERT-4">
+ <REFSECT2INFO>
+ <DATE>1998-09-23</DATE>
+ </REFSECT2INFO>
+ <TITLE>
+ SQL92
+ </TITLE>
+ <PARA>
+ The INSERT statement is fully compatible with <acronym>SQL92</acronym>.
+ Possible limitations in features of the
+ <REPLACEABLE CLASS="PARAMETER">query</REPLACEABLE>
+ clause are documented for the SELECT statement.
+ </para>
+ </refsect2>
+ </refsect1>
</REFENTRY>
<!--
<REFPURPOSE>
Listen for notification on a notify condition
</REFPURPOSE>
-
+ </refnamediv>
<REFSYNOPSISDIV>
<REFSYNOPSISDIVINFO>
<DATE>1998-10-07</DATE>
LISTEN <REPLACEABLE CLASS="PARAMETER">notifyname</REPLACEABLE>
</SYNOPSIS>
-<REFSECT2 ID="R2-SQL-LISTEN-1">
-<REFSECT2INFO>
-<DATE>1998-10-07</DATE>
-</REFSECT2INFO>
-<TITLE>
-Inputs
-</TITLE>
-<PARA>
-</PARA>
-<VARIABLELIST>
-<VARLISTENTRY>
-<TERM>
-<REPLACEABLE CLASS="PARAMETER">notifyname</REPLACEABLE>
-</TERM>
-<LISTITEM>
-<PARA>
-Name of notify condition.
-
-</VARIABLELIST>
-
-</REFSECT2>
-
-<REFSECT2 ID="R2-SQL-LISTEN-2">
-<REFSECT2INFO>
-<DATE>1998-09-24</DATE>
-</REFSECT2INFO>
-<TITLE>
-Outputs
-</TITLE>
-<PARA>
-
-<VARIABLELIST>
-<VARLISTENTRY>
-<TERM>
-<returnvalue>LISTEN</returnvalue>
-</TERM>
-<LISTITEM>
-<PARA>
-Message returned upon successful completion of registration.
-</PARA>
-</LISTITEM>
-</VARLISTENTRY>
-<VARLISTENTRY>
-<TERM>
-<returnvalue>NOTICE Async_Listen: We are already listening on notifyname</returnvalue>
-</TERM>
-<LISTITEM>
-<PARA>
-If this backend is already registered for that notify condition.
-</PARA>
-</VARIABLELIST>
-</REFSECT2>
-</REFSYNOPSISDIV>
-
-<REFSECT1 ID="R1-SQL-LISTEN-1">
-<REFSECT1INFO>
-<DATE>1998-10-07</DATE>
-</REFSECT1INFO>
-<TITLE>
-Description
-</TITLE>
-<PARA>
-LISTEN registers the current <productname>Postgres</productname> backend as a
-listener on the notify condition
-<REPLACEABLE CLASS="PARAMETER">notifyname</REPLACEABLE>.
-
-<para>
-Whenever the command
-<command>NOTIFY <REPLACEABLE CLASS="PARAMETER">notifyname</REPLACEABLE></command>
-is invoked, either by this backend or another one connected to
-the same database, all the backends currently listening on that notify
-condition are notified, and each will in turn notify its connected
-frontend application. See the discussion of <command>NOTIFY</command>
-for more information.
-
-<para>
-A backend can be deregistered for a given notify condition with the
-<command>UNLISTEN</command> command. Also, a backend's listen registrations
-are automatically cleared when the backend process exits.
-
-<para>
-The method a frontend application must use to detect notify events depends on
-which <productname>Postgres</productname> application programming interface it
-uses. With the basic libpq library, the application issues
-<command>LISTEN</command> as an ordinary SQL command, and then must
-periodically call the routine <function>PQnotifies</function> to find out
-whether any notify events have been received. Other interfaces such as
-libpgtcl provide higher-level methods for handling notify events; indeed,
-with libpgtcl the application programmer should not even issue
-<command>LISTEN</command> or <command>UNLISTEN</command> directly. See the
-documentation for the library you are using for more details.
-
-<para>
-The reference page for <command>NOTIFY</command> contains a more extensive
-discussion of the use of <command>LISTEN</command> and
-<command>NOTIFY</command>.
-
-<REFSECT2 ID="R2-SQL-LISTEN-3">
-<REFSECT2INFO>
-<DATE>1998-10-07</DATE>
-</REFSECT2INFO>
-<TITLE>
-Notes
-</TITLE>
-<para>
-<REPLACEABLE CLASS="PARAMETER">notifyname</REPLACEABLE>
-can be any string valid as a name;
-it need not correspond to the name of any actual table. If
-<REPLACEABLE CLASS="PARAMETER">notifyname</REPLACEABLE>
-is enclosed in double-quotes, it need not even be a syntactically
-valid name, but can be any string up to 31 characters long.
-
-<para>
-In some previous releases of
-<productname>Postgres</productname>,
-<REPLACEABLE CLASS="PARAMETER">notifyname</REPLACEABLE>
-had to be enclosed in double-quotes when it did not correspond to any existing
-table name, even if syntactically valid as a name. That is no longer required.
-
-</REFSECT2>
-
-<REFSECT1 ID="R1-SQL-LISTEN-2">
-<TITLE>
-Usage
-</TITLE>
-<PARA>
-<ProgramListing>
--- Configure and execute a listen/notify sequence from psql
-postgres=> listen virtual;
-LISTEN
-postgres=> notify virtual;
-NOTIFY
-ASYNC NOTIFY of 'virtual' from backend pid '11239' received
-</ProgramListing>
-
-</REFSECT1>
-
-<REFSECT1 ID="R1-SQL-LISTEN-3">
-<TITLE>
-Compatibility
-</TITLE>
-<PARA>
-
-<REFSECT2 ID="R2-SQL-LISTEN-4">
-<REFSECT2INFO>
-<DATE>1998-09-01</DATE>
-</REFSECT2INFO>
-<TITLE>
-SQL92
-</TITLE>
-<PARA>
- There is no <command>LISTEN</command> in <acronym>SQL92</acronym>.
+ <REFSECT2 ID="R2-SQL-LISTEN-1">
+ <REFSECT2INFO>
+ <DATE>1998-10-07</DATE>
+ </REFSECT2INFO>
+ <TITLE>
+ Inputs
+ </TITLE>
+ <PARA>
+ </PARA>
+ <VARIABLELIST>
+ <VARLISTENTRY>
+ <TERM>
+ <REPLACEABLE CLASS="PARAMETER">notifyname</REPLACEABLE>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Name of notify condition.
+ </para>
+ </listitem>
+ </varlistentry>
+ </VARIABLELIST>
+
+ </REFSECT2>
+
+ <REFSECT2 ID="R2-SQL-LISTEN-2">
+ <REFSECT2INFO>
+ <DATE>1998-09-24</DATE>
+ </REFSECT2INFO>
+ <TITLE>
+ Outputs
+ </TITLE>
+ <PARA>
+
+ <VARIABLELIST>
+ <VARLISTENTRY>
+ <TERM>
+ <returnvalue>LISTEN</returnvalue>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Message returned upon successful completion of registration.
+ </PARA>
+ </LISTITEM>
+ </VARLISTENTRY>
+ <VARLISTENTRY>
+ <TERM>
+ <returnvalue>NOTICE Async_Listen: We are already listening on notifyname</returnvalue>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ If this backend is already registered for that notify condition.
+ </PARA>
+ </listitem>
+ </varlistentry>
+ </VARIABLELIST>
+ </para>
+ </REFSECT2>
+ </REFSYNOPSISDIV>
+
+ <REFSECT1 ID="R1-SQL-LISTEN-1">
+ <REFSECT1INFO>
+ <DATE>1998-10-07</DATE>
+ </REFSECT1INFO>
+ <TITLE>
+ Description
+ </TITLE>
+ <PARA>
+ LISTEN registers the current <productname>Postgres</productname> backend as a
+ listener on the notify condition
+ <REPLACEABLE CLASS="PARAMETER">notifyname</REPLACEABLE>.
+ </para>
+ <para>
+ Whenever the command
+ <command>NOTIFY <REPLACEABLE CLASS="PARAMETER">notifyname</REPLACEABLE></command>
+ is invoked, either by this backend or another one connected to
+ the same database, all the backends currently listening on that notify
+ condition are notified, and each will in turn notify its connected
+ frontend application. See the discussion of <command>NOTIFY</command>
+ for more information.
+ </para>
+ <para>
+ A backend can be deregistered for a given notify condition with the
+ <command>UNLISTEN</command> command. Also, a backend's listen registrations
+ are automatically cleared when the backend process exits.
+ </para>
+ <para>
+ The method a frontend application must use to detect notify events depends on
+ which <productname>Postgres</productname> application programming interface it
+ uses. With the basic libpq library, the application issues
+ <command>LISTEN</command> as an ordinary SQL command, and then must
+ periodically call the routine <function>PQnotifies</function> to find out
+ whether any notify events have been received. Other interfaces such as
+ libpgtcl provide higher-level methods for handling notify events; indeed,
+ with libpgtcl the application programmer should not even issue
+ <command>LISTEN</command> or <command>UNLISTEN</command> directly. See the
+ documentation for the library you are using for more details.
+ </para>
+ <para>
+ The reference page for <command>NOTIFY</command> contains a more extensive
+ discussion of the use of <command>LISTEN</command> and
+ <command>NOTIFY</command>.
+ </para>
+
+ <REFSECT2 ID="R2-SQL-LISTEN-3">
+ <REFSECT2INFO>
+ <DATE>1998-10-07</DATE>
+ </REFSECT2INFO>
+ <TITLE>
+ Notes
+ </TITLE>
+ <para>
+ <REPLACEABLE CLASS="PARAMETER">notifyname</REPLACEABLE>
+ can be any string valid as a name;
+ it need not correspond to the name of any actual table. If
+ <REPLACEABLE CLASS="PARAMETER">notifyname</REPLACEABLE>
+ is enclosed in double-quotes, it need not even be a syntactically
+ valid name, but can be any string up to 31 characters long.
+ </para>
+ <para>
+ In some previous releases of
+ <productname>Postgres</productname>,
+ <REPLACEABLE CLASS="PARAMETER">notifyname</REPLACEABLE>
+ had to be enclosed in double-quotes when it did not correspond to any existing
+ table name, even if syntactically valid as a name. That is no longer required.
+ </para>
+ </REFSECT2>
+ </refsect1>
+
+ <REFSECT1 ID="R1-SQL-LISTEN-2">
+ <TITLE>
+ Usage
+ </TITLE>
+ <PARA>
+ <ProgramListing>
+ -- Configure and execute a listen/notify sequence from psql
+ postgres=> listen virtual;
+ LISTEN
+ postgres=> notify virtual;
+ NOTIFY
+ ASYNC NOTIFY of 'virtual' from backend pid '11239' received
+ </ProgramListing>
+ </para>
+ </REFSECT1>
+
+ <REFSECT1 ID="R1-SQL-LISTEN-3">
+ <TITLE>
+ Compatibility
+ </TITLE>
+
+ <REFSECT2 ID="R2-SQL-LISTEN-4">
+ <REFSECT2INFO>
+ <DATE>1998-09-01</DATE>
+ </REFSECT2INFO>
+ <TITLE>
+ SQL92
+ </TITLE>
+ <PARA>
+ There is no <command>LISTEN</command> in <acronym>SQL92</acronym>.
+ </para>
+ </refsect2>
+ </refsect1>
</REFENTRY>
<REFENTRY ID="SQL-LOAD">
-<REFMETA>
-<REFENTRYTITLE>
-LOAD
-</REFENTRYTITLE>
-<REFMISCINFO>SQL - Language Statements</REFMISCINFO>
-</REFMETA>
-<REFNAMEDIV>
-<REFNAME>
-LOAD
-</REFNAME>
-<REFPURPOSE>
-Dynamically loads an object file
-</REFPURPOSE>
-
-<REFSYNOPSISDIV>
-<REFSYNOPSISDIVINFO>
-<DATE>1998-09-24</DATE>
-</REFSYNOPSISDIVINFO>
-<SYNOPSIS>
-<REPLACEABLE CLASS="PARAMETER">
-</REPLACEABLE>
-LOAD '<REPLACEABLE CLASS="PARAMETER">filename</REPLACEABLE>'
-</SYNOPSIS>
-
-<REFSECT2 ID="R2-SQL-LOAD-1">
-<REFSECT2INFO>
-<DATE>1998-09-01</DATE>
-</REFSECT2INFO>
-<TITLE>
-Inputs
-</TITLE>
-<PARA>
-</PARA>
-<VARIABLELIST>
-<VARLISTENTRY>
-<TERM>
-<REPLACEABLE CLASS="PARAMETER">filename</REPLACEABLE>
-</TERM>
-<LISTITEM>
-<PARA>
-Object file for dynamic loading.
-
-</VARIABLELIST>
-
-</REFSECT2>
-
-<REFSECT2 ID="R2-SQL-LOAD-2">
-<REFSECT2INFO>
-<DATE>1998-09-24</DATE>
-</REFSECT2INFO>
-<TITLE>
-Outputs
-</TITLE>
-<PARA>
-
-<VARIABLELIST>
-<VARLISTENTRY>
-<TERM>
-<returnvalue>LOAD</returnvalue>
-</TERM>
-<LISTITEM>
-<PARA>
-Message returned on successful completion.
-
-<VARLISTENTRY>
-<TERM>
-<returnvalue>ERROR: LOAD: could not open file '<REPLACEABLE CLASS="PARAMETER">filename</REPLACEABLE>'</returnvalue>
-</TERM>
-<LISTITEM>
-<PARA>
-Message returned if the specified file is not found. The file must be visible
-<emphasis>to the <productname>Postgres</productname> backend</emphasis>,
-with the appropriate full path name specified, to avoid this message.
-
-</VARIABLELIST>
-
-</REFSECT2>
-</REFSYNOPSISDIV>
-
-<REFSECT1 ID="R1-SQL-LOAD-1">
-<REFSECT1INFO>
-<DATE>1998-09-24</DATE>
-</REFSECT1INFO>
-<TITLE>
-Description
-</TITLE>
-<PARA>
-Loads an object (or ".o") file into the
-<productname>Postgres</productname> backend address space. Once a
-file is loaded, all functions in that file can be accessed. This
-function is used in support of user-defined types and functions.
-
-<para>
-If a file is not loaded using
-<command>LOAD</command>,
-the file will be loaded automatically the first time the
-function is called by <productname>Postgres</productname>.
-<command>LOAD</command>
-can also be used to reload an object file if it has been edited and
-recompiled. Only objects created from C language files are supported
-at this time.
-
-<REFSECT2 ID="R2-SQL-LOAD-3">
-<REFSECT2INFO>
-<DATE>1998-09-24</DATE>
-</REFSECT2INFO>
-<TITLE>
-Notes
-</TITLE>
-<PARA>
-Functions in loaded object files should not call functions in other
-object files loaded through the
-<command>LOAD</command>
-command. For example, all functions in file <literal>A</literal> should
-call each other, functions in the standard or math libraries, or in
-Postgres itself. They should not call functions defined in a different
-loaded file <literal>B</literal>.
- This is because if <literal>B</literal> is reloaded, the Postgres loader is
-not able to relocate the calls from the functions in <literal>A</literal> into
-the new address space of <literal>B</literal>.
-If <literal>B</literal> is not reloaded, however, there will
-not be a problem.
-
-<para>
-Object files must be compiled to contain position independent code.
-For example,
-on DECstations you must use
-<application>/bin/cc</application>
-with the <literal>-G 0</literal> option when compiling object files to be
-loaded.
-
-<para>
-Note that if you are porting <productname>Postgres</productname>
- to a new platform, <command>LOAD</command>
-will have to work in order to support ADTs.
-
-</REFSECT2>
-
-<REFSECT1 ID="R1-SQL-LOAD-2">
-<TITLE>
-Usage
-</TITLE>
-<PARA>
-<ProgramListing>
---Load the file /usr/postgres/demo/circle.o
---
-LOAD '/usr/postgres/demo/circle.o'
-</ProgramListing>
-
-</REFSECT1>
-
-<REFSECT1 ID="R1-SQL-LOAD-3">
-<TITLE>
-Compatibility
-</TITLE>
-<PARA>
-</PARA>
-
-<REFSECT2 ID="R2-SQL-LOAD-4">
-<REFSECT2INFO>
-<DATE>1998-09-24</DATE>
-</REFSECT2INFO>
-<TITLE>
-SQL92
-</TITLE>
-<PARA>
-There is no <command>LOAD</command> in <acronym>SQL92</acronym>.
-
+ <REFMETA>
+ <REFENTRYTITLE>
+ LOAD
+ </REFENTRYTITLE>
+ <REFMISCINFO>SQL - Language Statements</REFMISCINFO>
+ </REFMETA>
+ <REFNAMEDIV>
+ <REFNAME>
+ LOAD
+ </REFNAME>
+ <REFPURPOSE>
+ Dynamically loads an object file
+ </REFPURPOSE>
+ </refnamediv>
+ <REFSYNOPSISDIV>
+ <REFSYNOPSISDIVINFO>
+ <DATE>1998-09-24</DATE>
+ </REFSYNOPSISDIVINFO>
+ <SYNOPSIS>
+ <REPLACEABLE CLASS="PARAMETER">
+ </REPLACEABLE>
+ LOAD '<REPLACEABLE CLASS="PARAMETER">filename</REPLACEABLE>'
+ </SYNOPSIS>
+
+ <REFSECT2 ID="R2-SQL-LOAD-1">
+ <REFSECT2INFO>
+ <DATE>1998-09-01</DATE>
+ </REFSECT2INFO>
+ <TITLE>
+ Inputs
+ </TITLE>
+ <PARA>
+ </PARA>
+ <VARIABLELIST>
+ <VARLISTENTRY>
+ <TERM>
+ <REPLACEABLE CLASS="PARAMETER">filename</REPLACEABLE>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Object file for dynamic loading.
+ </para>
+ </listitem>
+ </varlistentry>
+ </VARIABLELIST>
+
+ </REFSECT2>
+
+ <REFSECT2 ID="R2-SQL-LOAD-2">
+ <REFSECT2INFO>
+ <DATE>1998-09-24</DATE>
+ </REFSECT2INFO>
+ <TITLE>
+ Outputs
+ </TITLE>
+ <PARA>
+
+ <VARIABLELIST>
+ <VARLISTENTRY>
+ <TERM>
+ <returnvalue>LOAD</returnvalue>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Message returned on successful completion.
+ </para>
+ </listitem>
+ </varlistentry>
+ <VARLISTENTRY>
+ <TERM>
+ <returnvalue>ERROR: LOAD: could not open file '<REPLACEABLE CLASS="PARAMETER">filename</REPLACEABLE>'</returnvalue>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Message returned if the specified file is not found. The file must be visible
+ <emphasis>to the <productname>Postgres</productname> backend</emphasis>,
+ with the appropriate full path name specified, to avoid this message.
+ </para>
+ </listitem>
+ </varlistentry>
+ </VARIABLELIST>
+ </para>
+ </REFSECT2>
+ </REFSYNOPSISDIV>
+
+ <REFSECT1 ID="R1-SQL-LOAD-1">
+ <REFSECT1INFO>
+ <DATE>1998-09-24</DATE>
+ </REFSECT1INFO>
+ <TITLE>
+ Description
+ </TITLE>
+ <PARA>
+ Loads an object (or ".o") file into the
+ <productname>Postgres</productname> backend address space. Once a
+ file is loaded, all functions in that file can be accessed. This
+ function is used in support of user-defined types and functions.
+ </para>
+ <para>
+ If a file is not loaded using
+ <command>LOAD</command>,
+ the file will be loaded automatically the first time the
+ function is called by <productname>Postgres</productname>.
+ <command>LOAD</command>
+ can also be used to reload an object file if it has been edited and
+ recompiled. Only objects created from C language files are supported
+ at this time.
+ </para>
+ <REFSECT2 ID="R2-SQL-LOAD-3">
+ <REFSECT2INFO>
+ <DATE>1998-09-24</DATE>
+ </REFSECT2INFO>
+ <TITLE>
+ Notes
+ </TITLE>
+ <PARA>
+ Functions in loaded object files should not call functions in other
+ object files loaded through the
+ <command>LOAD</command>
+ command. For example, all functions in file <literal>A</literal> should
+ call each other, functions in the standard or math libraries, or in
+ Postgres itself. They should not call functions defined in a different
+ loaded file <literal>B</literal>.
+ This is because if <literal>B</literal> is reloaded, the Postgres loader is
+ not able to relocate the calls from the functions in <literal>A</literal> into
+ the new address space of <literal>B</literal>.
+ If <literal>B</literal> is not reloaded, however, there will
+ not be a problem.
+ </para>
+ <para>
+ Object files must be compiled to contain position independent code.
+ For example,
+ on DECstations you must use
+ <application>/bin/cc</application>
+ with the <literal>-G 0</literal> option when compiling object files to be
+ loaded.
+ </para>
+ <para>
+ Note that if you are porting <productname>Postgres</productname>
+ to a new platform, <command>LOAD</command>
+ will have to work in order to support ADTs.
+ </para>
+ </REFSECT2>
+ </refsect1>
+
+ <REFSECT1 ID="R1-SQL-LOAD-2">
+ <TITLE>
+ Usage
+ </TITLE>
+ <PARA>
+ <ProgramListing>
+ --Load the file /usr/postgres/demo/circle.o
+ --
+ LOAD '/usr/postgres/demo/circle.o'
+ </ProgramListing>
+ </para>
+ </REFSECT1>
+
+ <REFSECT1 ID="R1-SQL-LOAD-3">
+ <TITLE>
+ Compatibility
+ </TITLE>
+ <PARA>
+ </PARA>
+
+ <REFSECT2 ID="R2-SQL-LOAD-4">
+ <REFSECT2INFO>
+ <DATE>1998-09-24</DATE>
+ </REFSECT2INFO>
+ <TITLE>
+ SQL92
+ </TITLE>
+ <PARA>
+ There is no <command>LOAD</command> in <acronym>SQL92</acronym>.
+ </para>
+ </refsect2>
+ </refsect1>
</REFENTRY>
<REFPURPOSE>
Explicit lock of a table inside a transaction
</REFPURPOSE>
-
+ </refnamediv>
<REFSYNOPSISDIV>
<REFSYNOPSISDIVINFO>
<DATE>1998-09-24</DATE>
LOCK [ TABLE ] <REPLACEABLE CLASS="PARAMETER">table</REPLACEABLE>
</SYNOPSIS>
-<REFSECT2 ID="R2-SQL-LOCK-1">
-<REFSECT2INFO>
-<DATE>1998-09-01</DATE>
-</REFSECT2INFO>
-<TITLE>
-Inputs
-</TITLE>
-<PARA>
-</PARA>
-<VARIABLELIST>
-<VARLISTENTRY>
-<TERM>
-<REPLACEABLE CLASS="PARAMETER">table</REPLACEABLE>
-</TERM>
-<LISTITEM>
-<PARA>
- The name of an existing table to lock.
-</VARIABLELIST>
-
-</REFSECT2>
-
-<REFSECT2 ID="R2-SQL-LOCK-2">
-<REFSECT2INFO>
-<DATE>1998-09-24</DATE>
-</REFSECT2INFO>
-<TITLE>
-Outputs
-</TITLE>
-<PARA>
-
-<VARIABLELIST>
-<VARLISTENTRY>
-<TERM>
-DELETE 0
-</TERM>
-<LISTITEM>
-<PARA>
-Message returned on a successful lock.
-<command>LOCK</command> is implemented as a
-<command>DELETE FROM <REPLACEABLE CLASS="PARAMETER">table</REPLACEABLE></command>
-which is guaranteed to not delete any rows.
-
-<VARLISTENTRY>
-<TERM>
-ERROR <REPLACEABLE CLASS="PARAMETER">table</REPLACEABLE>: Table does not exist.
-</TERM>
-<LISTITEM>
-<PARA>
-Message returned if <REPLACEABLE CLASS="PARAMETER">table</REPLACEABLE>
- does not exist.
-
-</VARIABLELIST>
-
-</REFSECT2>
-</REFSYNOPSISDIV>
-
-<REFSECT1 ID="R1-SQL-LOCK-1">
-<REFSECT1INFO>
-<DATE>1998-09-24</DATE>
-</REFSECT1INFO>
-<TITLE>
-Description
-</TITLE>
-<PARA>
- <command>LOCK</command> locks in exclusive mode a table inside
- a transaction. The classic use for this is
- the case where you want to select some data, then
- update it inside a transaction.
- If you don't explicit lock a table using LOCK statement, it will be
- implicit locked only at the first
- <command>UPDATE</command>, <command>INSERT</command>,
- or <command>DELETE</command> operation.
- If you don't exclusive lock the table before the select, some
- other user may also read the selected data, and try and do
- their own update, causing a deadlock while you both wait
- for the other to release the select-induced shared lock so
- you can get an exclusive lock to do the update.
-
-<para>
- Another example of deadlock is where one user locks one
- table, and another user locks a second table. While both
- keep their existing locks, the first user tries to lock
- the second user's table, and the second user tries to lock
- the first user's table. Both users deadlock waiting for
- the tables to become available. The only solution to this
- is for both users to lock tables in the same order, so
- user's lock acquisitions and requests to not form a deadlock.
-
-<note>
-<para>
-<productname>Postgres</productname> does detect deadlocks and will
-rollback transactions to resolve the deadlock. Usually, at least one
-of the deadlocked transactions will complete successfully.
-</note>
-
-<REFSECT2 ID="R2-SQL-LOCK-3">
-<REFSECT2INFO>
-<DATE>1998-09-24</DATE>
-</REFSECT2INFO>
-<TITLE>
-Notes
-</TITLE>
-<PARA>
-<command>LOCK</command> is a <productname>Postgres</productname>
- language extension.
-<para>
-<command>LOCK</command> works only inside transactions.
-
-<note>
-<title>Bug</title>
-<para>
-If the locked table is dropped then it will be automatically
- unlocked even if a transaction is still in progress.
-</note>
-
-</REFSECT2>
-
-<REFSECT1 ID="R1-SQL-LOCK-2">
-<TITLE>
-Usage
-</TITLE>
-<PARA>
-</PARA>
-<ProgramListing>
---Explicit locking to prevent deadlock:
---
-BEGIN WORK;
- LOCK films;
- SELECT * FROM films;
- UPDATE films SET len = INTERVAL '100 minute'
- WHERE len = INTERVAL '117 minute';
-COMMIT WORK;
-</ProgramListing>
-
-</REFSECT1>
-
-<REFSECT1 ID="R1-SQL-LOCK-3">
-<TITLE>
-Compatibility
-</TITLE>
-<PARA>
-
-<REFSECT2 ID="R2-SQL-LOCK-4">
-<REFSECT2INFO>
-<DATE>1998-09-24</DATE>
-</REFSECT2INFO>
-<TITLE>
-SQL92
-</TITLE>
-<PARA>
- There is no <command>LOCK TABLE</command> in <acronym>SQL92</acronym>,
- which instead uses <command>SET TRANSACTION</command> to specify
- concurrency level on transactions.
-
+ <REFSECT2 ID="R2-SQL-LOCK-1">
+ <REFSECT2INFO>
+ <DATE>1998-09-01</DATE>
+ </REFSECT2INFO>
+ <TITLE>
+ Inputs
+ </TITLE>
+ <PARA>
+ </PARA>
+ <VARIABLELIST>
+ <VARLISTENTRY>
+ <TERM>
+ <REPLACEABLE CLASS="PARAMETER">table</REPLACEABLE>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ The name of an existing table to lock.
+ </para>
+ </listitem>
+ </varlistentry>
+ </VARIABLELIST>
+
+ </REFSECT2>
+
+ <REFSECT2 ID="R2-SQL-LOCK-2">
+ <REFSECT2INFO>
+ <DATE>1998-09-24</DATE>
+ </REFSECT2INFO>
+ <TITLE>
+ Outputs
+ </TITLE>
+ <PARA>
+
+ <VARIABLELIST>
+ <VARLISTENTRY>
+ <TERM>
+ DELETE 0
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Message returned on a successful lock.
+ <command>LOCK</command> is implemented as a
+ <command>DELETE FROM <REPLACEABLE CLASS="PARAMETER">table</REPLACEABLE></command>
+ which is guaranteed to not delete any rows.
+ </para>
+ </listitem>
+ </varlistentry>
+ <VARLISTENTRY>
+ <TERM>
+ ERROR <REPLACEABLE CLASS="PARAMETER">table</REPLACEABLE>: Table does not exist.
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Message returned if <REPLACEABLE CLASS="PARAMETER">table</REPLACEABLE>
+ does not exist.
+ </para>
+ </listitem>
+ </varlistentry>
+ </VARIABLELIST>
+ </para>
+ </REFSECT2>
+ </REFSYNOPSISDIV>
+
+ <REFSECT1 ID="R1-SQL-LOCK-1">
+ <REFSECT1INFO>
+ <DATE>1998-09-24</DATE>
+ </REFSECT1INFO>
+ <TITLE>
+ Description
+ </TITLE>
+ <PARA>
+ <command>LOCK</command> locks in exclusive mode a table inside
+ a transaction. The classic use for this is
+ the case where you want to select some data, then
+ update it inside a transaction.
+ If you don't explicit lock a table using LOCK statement, it will be
+ implicit locked only at the first
+ <command>UPDATE</command>, <command>INSERT</command>,
+ or <command>DELETE</command> operation.
+ If you don't exclusive lock the table before the select, some
+ other user may also read the selected data, and try and do
+ their own update, causing a deadlock while you both wait
+ for the other to release the select-induced shared lock so
+ you can get an exclusive lock to do the update.
+ </para>
+ <para>
+ Another example of deadlock is where one user locks one
+ table, and another user locks a second table. While both
+ keep their existing locks, the first user tries to lock
+ the second user's table, and the second user tries to lock
+ the first user's table. Both users deadlock waiting for
+ the tables to become available. The only solution to this
+ is for both users to lock tables in the same order, so
+ user's lock acquisitions and requests to not form a deadlock.
+ </para>
+ <note>
+ <para>
+ <productname>Postgres</productname> does detect deadlocks and will
+ rollback transactions to resolve the deadlock. Usually, at least one
+ of the deadlocked transactions will complete successfully.
+ </para>
+ </note>
+
+ <REFSECT2 ID="R2-SQL-LOCK-3">
+ <REFSECT2INFO>
+ <DATE>1998-09-24</DATE>
+ </REFSECT2INFO>
+ <TITLE>
+ Notes
+ </TITLE>
+ <para>
+ <command>LOCK</command> is a <productname>Postgres</productname>
+ language extension.
+ </para>
+ <para>
+ <command>LOCK</command> works only inside transactions.
+
+ <note>
+ <title>Bug</title>
+ <para>
+ If the locked table is dropped then it will be automatically
+ unlocked even if a transaction is still in progress.
+ </para>
+ </note>
+ </para>
+ </REFSECT2>
+ </refsect1>
+
+ <REFSECT1 ID="R1-SQL-LOCK-2">
+ <TITLE>
+ Usage
+ </TITLE>
+ <PARA>
+ </PARA>
+ <ProgramListing>
+ --Explicit locking to prevent deadlock:
+ --
+ BEGIN WORK;
+ LOCK films;
+ SELECT * FROM films;
+ UPDATE films SET len = INTERVAL '100 minute'
+ WHERE len = INTERVAL '117 minute';
+ COMMIT WORK;
+ </ProgramListing>
+
+ </REFSECT1>
+
+ <REFSECT1 ID="R1-SQL-LOCK-3">
+ <TITLE>
+ Compatibility
+ </TITLE>
+
+ <REFSECT2 ID="R2-SQL-LOCK-4">
+ <REFSECT2INFO>
+ <DATE>1998-09-24</DATE>
+ </REFSECT2INFO>
+ <TITLE>
+ SQL92
+ </TITLE>
+ <PARA>
+ There is no <command>LOCK TABLE</command> in <acronym>SQL92</acronym>,
+ which instead uses <command>SET TRANSACTION</command> to specify
+ concurrency level on transactions.
+ </para>
+ </refsect2>
+ </refsect1>
</REFENTRY>
<REFPURPOSE>
Moves cursor position
</REFPURPOSE>
-
+ </refnamediv>
<REFSYNOPSISDIV>
<REFSYNOPSISDIVINFO>
<DATE>1998-09-24</DATE>
MOVE [ <REPLACEABLE CLASS="PARAMETER">selector</REPLACEABLE> ] [ <REPLACEABLE CLASS="PARAMETER">count</REPLACEABLE> ]
{ IN | FROM } <REPLACEABLE CLASS="PARAMETER">cursor</REPLACEABLE>
FETCH [ RELATIVE ] [ { [ <REPLACEABLE CLASS="PARAMETER">#</REPLACEABLE> | ALL | NEXT | PRIOR ] } ] FROM ] <REPLACEABLE CLASS="PARAMETER">cursor</REPLACEABLE>
-</SYNOPSIS>
+ </SYNOPSIS>
+ </refsynopsisdiv>
-<REFSECT1 ID="R1-SQL-MOVE-1">
-<REFSECT1INFO>
-<DATE>1998-09-24</DATE>
-</REFSECT1INFO>
-<TITLE>
-Description
-</TITLE>
-<PARA>
- <command>MOVE</command> allows a user to move cursor position a specified
- number of rows.
- <command>MOVE</command> works like the <command>FETCH</command> command,
- but only positions the cursor and does
-not return rows.
-
-<para>
-Refer to the <command>FETCH</command> command for details on syntax and usage.
-
-<REFSECT2 ID="R2-SQL-MOVE-3">
-<REFSECT2INFO>
-<DATE>1998-09-24</DATE>
-</REFSECT2INFO>
-<TITLE>
-Notes
-</TITLE>
-<PARA>
-<command>MOVE</command> is a <productname>Postgres</productname>
- language extension.
-
-<para>
- Refer to <command>FETCH</command> for a description
- of valid arguments.
- Refer to <command>DECLARE</command> to declare a cursor.
- Refer to <command>BEGIN WORK</command>, <command>COMMIT WORK</command>,
- <command>ROLLBACK WORK</command> statements
- for further information about transactions.
-
-</REFSECT2>
-
-<REFSECT1 ID="R1-SQL-MOVE-2">
-<TITLE>
-Usage
-</TITLE>
-<PARA>
-<ProgramListing>
---set up and use a cursor:
---
-BEGIN WORK;
- DECLARE liahona CURSOR FOR SELECT * FROM films;
-
- --Skip first 5 rows:
- --
- MOVE FORWARD 5 IN liahona;
-<computeroutput>
-MOVE
-</computeroutput>
- --Fetch 6th row in the cursor liahona:
- --
- FETCH 1 IN liahona;
-<computeroutput>
-FETCH
-code |title |did| date_prod|kind |len
------+------+---+----------+----------+------
-P_303|48 Hrs|103|1982-10-22|Action | 01:37
-(1 row)
-</computeroutput>
- -- close the cursor liahona and commit work:
- --
- CLOSE liahona;
-COMMIT WORK;
-</ProgramListing>
-
-</REFSECT1>
+ <REFSECT1 ID="R1-SQL-MOVE-1">
+ <REFSECT1INFO>
+ <DATE>1998-09-24</DATE>
+ </REFSECT1INFO>
+ <TITLE>
+ Description
+ </TITLE>
+ <PARA>
+ <command>MOVE</command> allows a user to move cursor position a specified
+ number of rows.
+ <command>MOVE</command> works like the <command>FETCH</command> command,
+ but only positions the cursor and does
+ not return rows.
+ </para>
+ <para>
+ Refer to the <command>FETCH</command> command for details on syntax and usage.
+ </para>
-<REFSECT1 ID="R1-SQL-MOVE-3">
-<TITLE>
-Compatibility
-</TITLE>
-<PARA>
-</PARA>
+ <REFSECT2 ID="R2-SQL-MOVE-3">
+ <REFSECT2INFO>
+ <DATE>1998-09-24</DATE>
+ </REFSECT2INFO>
+ <TITLE>
+ Notes
+ </TITLE>
+ <PARA>
+ <command>MOVE</command> is a <productname>Postgres</productname>
+ language extension.
+ </para>
+ <para>
+ Refer to <command>FETCH</command> for a description
+ of valid arguments.
+ Refer to <command>DECLARE</command> to declare a cursor.
+ Refer to <command>BEGIN WORK</command>, <command>COMMIT WORK</command>,
+ <command>ROLLBACK WORK</command> statements
+ for further information about transactions.
+ </para>
+ </REFSECT2>
+ </refsect1>
-<REFSECT2 ID="R2-SQL-MOVE-4">
-<REFSECT2INFO>
-<DATE>1998-09-01</DATE>
-</REFSECT2INFO>
-<TITLE>
-SQL92
-</TITLE>
-<PARA>
- There is no SQL92 <command>MOVE</command> statement.
-Instead, <acronym>SQL92</acronym> allows
-one to <command>FETCH</command> rows from an absolute cursor position,
-implicitly moving the cursor to the correct place.
+ <REFSECT1 ID="R1-SQL-MOVE-2">
+ <TITLE>
+ Usage
+ </TITLE>
+ <PARA>
+ <ProgramListing>
+ --set up and use a cursor:
+ --
+ BEGIN WORK;
+ DECLARE liahona CURSOR FOR SELECT * FROM films;
+
+ --Skip first 5 rows:
+ --
+ MOVE FORWARD 5 IN liahona;
+ <computeroutput>
+ MOVE
+ </computeroutput>
+ --Fetch 6th row in the cursor liahona:
+ --
+ FETCH 1 IN liahona;
+ <computeroutput>
+ FETCH
+ code |title |did| date_prod|kind |len
+ -----+------+---+----------+----------+------
+ P_303|48 Hrs|103|1982-10-22|Action | 01:37
+ (1 row)
+ </computeroutput>
+ -- close the cursor liahona and commit work:
+ --
+ CLOSE liahona;
+ COMMIT WORK;
+ </ProgramListing>
+ </para>
+ </REFSECT1>
+ <REFSECT1 ID="R1-SQL-MOVE-3">
+ <TITLE>
+ Compatibility
+ </TITLE>
+ <PARA>
+ </PARA>
+
+ <REFSECT2 ID="R2-SQL-MOVE-4">
+ <REFSECT2INFO>
+ <DATE>1998-09-01</DATE>
+ </REFSECT2INFO>
+ <TITLE>
+ SQL92
+ </TITLE>
+ <PARA>
+ There is no SQL92 <command>MOVE</command> statement.
+ Instead, <acronym>SQL92</acronym> allows
+ one to <command>FETCH</command> rows from an absolute cursor position,
+ implicitly moving the cursor to the correct place.
+ </para>
+ </refsect2>
+ </refsect1>
</REFENTRY>
<REFPURPOSE>
Signals all frontends and backends listening on a notify condition
</REFPURPOSE>
-
+ </refnamediv>
<REFSYNOPSISDIV>
<REFSYNOPSISDIVINFO>
<DATE>1998-10-07</DATE>
NOTIFY <REPLACEABLE CLASS="PARAMETER">notifyname</REPLACEABLE>
</SYNOPSIS>
-<REFSECT2 ID="R2-SQL-NOTIFY-1">
-<REFSECT2INFO>
-<DATE>1998-10-07</DATE>
-</REFSECT2INFO>
-<TITLE>
-Inputs
-</TITLE>
-<PARA>
-
-<VARIABLELIST>
-<VARLISTENTRY>
-<TERM>
-<REPLACEABLE CLASS="PARAMETER">notifyname</REPLACEABLE>
-</TERM>
-<LISTITEM>
-<PARA>
-Notify condition to be signaled.
-
-</VARIABLELIST>
-
-</REFSECT2>
-
-<REFSECT2 ID="R2-SQL-NOTIFY-2">
-<REFSECT2INFO>
-<DATE>1998-10-07</DATE>
-</REFSECT2INFO>
-<TITLE>
-Outputs
-</TITLE>
-<PARA>
-
-<VARIABLELIST>
-<VARLISTENTRY>
-<TERM>
-NOTIFY
-</TERM>
-<LISTITEM>
-<PARA>
-Acknowledgement that notify command has executed.
-
-<VARLISTENTRY>
-<TERM>
-Notify events
-</TERM>
-<LISTITEM>
-<PARA>
-Events are delivered to listening frontends; whether and how each frontend
-application reacts depends on its programming.
-</PARA>
-</LISTITEM>
-</VARLISTENTRY>
-</VARIABLELIST>
-</REFSECT2>
-</REFSYNOPSISDIV>
-
-<REFSECT1 ID="R1-SQL-NOTIFY-1">
-<REFSECT1INFO>
-<DATE>1998-10-07</DATE>
-</REFSECT1INFO>
-<TITLE>
-Description
-</TITLE>
-<PARA>
-The <command>NOTIFY</command> command sends a notify event to each
-frontend application that has previously executed
-<command>LISTEN <replaceable class="parameter">notifyname</replaceable></command>
-for the specified notify condition in the current database.
-
-<para>
-The information passed to the frontend for a notify event includes the notify
-condition name and the notifying backend process's PID. It is up to the
-database designer to define the condition names that will be used in a given
-database and what each one means.
-
-<para>
-Commonly, the notify condition name is the same as the name of some table in
-the database, and the notify event essentially means "I changed this table,
-take a look at it to see what's new". But no such association is enforced by
-the <command>NOTIFY</command> and <command>LISTEN</command> commands. For
-example, a database designer could use several different condition names
-to signal different sorts of changes to a single table.
-
-<para>
-<command>NOTIFY</command> provides a simple form of signal or
-IPC (interprocess communication) mechanism for a collection of processes
-accessing the same <productname>Postgres</productname> database.
-Higher-level mechanisms can be built by using tables in the database to
-pass additional data (beyond a mere condition name) from notifier to
-listener(s).
-
-<para>
-When <command>NOTIFY</command> is used to signal the occurrence of changes
-to a particular table, a useful programming technique is to put the
-<command>NOTIFY</command> in a rule that is triggered by table updates.
-In this way, notification happens automatically when the table is changed,
-and the application programmer can't accidentally forget to do it.
-
-<para>
-<command>NOTIFY</command> interacts with SQL transactions in some important
-ways. Firstly, if a <command>NOTIFY</command> is executed inside a
-transaction, the notify events are not delivered until and unless the
-transaction is committed. This is appropriate, since if the transaction
-is aborted we would like all the commands within it to have had no effect
---- including <command>NOTIFY</command>. But it can be disconcerting if one
-is expecting the notify events to be delivered immediately. Secondly, if
-a listening backend receives a notify signal while it is within a transaction,
-the notify event will not be delivered to its connected frontend until just
-after the transaction is completed (either committed or aborted). Again, the
-reasoning is that if a notify were delivered within a transaction that was
-later aborted, one would want the notification to be undone somehow --- but
-the backend cannot "take back" a notify once it has sent it to the frontend.
-So notify events are only delivered between transactions. The upshot of this
-is that applications using <command>NOTIFY</command> for real-time signaling
-should try to keep their transactions short.
-
-<para>
-<command>NOTIFY</command> behaves like Unix signals in one important
-respect: if the same condition name is signaled multiple times in quick
-succession, recipients may get only one notify event for several executions
-of <command>NOTIFY</command>. So it is a bad idea to depend on the number
-of notifies received. Instead, use <command>NOTIFY</command> to wake up
-applications that need to pay attention to something, and use a database
-object (such as a sequence) to keep track of what happened or how many times
-it happened.
-
-<para>
-It is common for a frontend that sends <command>NOTIFY</command> to be
-listening on the same notify name itself. In that case it will get back a
-notify event, just like all the other listening frontends. Depending on the
-application logic, this could result in useless work --- for example,
-re-reading a database table to find the same updates that that frontend just
-wrote out. In <productname>Postgres</productname> 6.4 and later, it is
-possible to avoid such extra work by noticing whether the notifying backend
-process's PID (supplied in the notify event message) is the same as one's own
-backend's PID (available from libpq). When they are the same, the notify
-event is one's own work bouncing back, and can be ignored. (Despite what was
-said in the preceding paragraph, this is a safe technique.
-<productname>Postgres</productname> keeps self-notifies separate from notifies
-arriving from other backends, so you cannot miss an outside notify by ignoring
-your own notifies.)
-
-<REFSECT2 ID="R2-SQL-NOTIFY-3">
-<REFSECT2INFO>
-<DATE>1998-10-07</DATE>
-</REFSECT2INFO>
-<TITLE>
-Notes
-</TITLE>
-<para>
-<REPLACEABLE CLASS="PARAMETER">notifyname</REPLACEABLE>
-can be any string valid as a name;
-it need not correspond to the name of any actual table. If
-<REPLACEABLE CLASS="PARAMETER">notifyname</REPLACEABLE>
-is enclosed in double-quotes, it need not even be a syntactically
-valid name, but can be any string up to 31 characters long.
-
-<para>
-In some previous releases of
-<productname>Postgres</productname>,
-<REPLACEABLE CLASS="PARAMETER">notifyname</REPLACEABLE>
-had to be enclosed in double-quotes when it did not correspond to any existing
-table name, even if syntactically valid as a name. That is no longer required.
-
-<para>
-In <productname>Postgres</productname> releases prior to 6.4, the backend
-PID delivered in a notify message was always the PID of the frontend's own
-backend. So it was not possible to distinguish one's own notifies from other
-clients' notifies in those earlier releases.
-
-</REFSECT2>
-
-<REFSECT1 ID="R1-SQL-NOTIFY-2">
-<TITLE>
-Usage
-</TITLE>
-<PARA>
-<ProgramListing>
--- Configure and execute a listen/notify sequence from psql
-postgres=> listen virtual;
-LISTEN
-postgres=> notify virtual;
-NOTIFY
-ASYNC NOTIFY of 'virtual' from backend pid '11239' received
-</ProgramListing>
-
-</REFSECT1>
-
-<REFSECT1 ID="R1-SQL-NOTIFY-3">
-<TITLE>
-Compatibility
-</TITLE>
-<PARA>
-
-
-<REFSECT2 ID="R2-SQL-NOTIFY-4">
-<REFSECT2INFO>
-<DATE>1998-09-24</DATE>
-</REFSECT2INFO>
-<TITLE>
-SQL92
-</TITLE>
-<PARA>
-There is no <command>NOTIFY</command> statement in <acronym>SQL92</acronym>.
-
+ <REFSECT2 ID="R2-SQL-NOTIFY-1">
+ <REFSECT2INFO>
+ <DATE>1998-10-07</DATE>
+ </REFSECT2INFO>
+ <TITLE>
+ Inputs
+ </TITLE>
+ <PARA>
+
+ <VARIABLELIST>
+ <VARLISTENTRY>
+ <TERM>
+ <REPLACEABLE CLASS="PARAMETER">notifyname</REPLACEABLE>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Notify condition to be signaled.
+ </para>
+ </listitem>
+ </varlistentry>
+ </VARIABLELIST>
+ </para>
+ </REFSECT2>
+
+ <REFSECT2 ID="R2-SQL-NOTIFY-2">
+ <REFSECT2INFO>
+ <DATE>1998-10-07</DATE>
+ </REFSECT2INFO>
+ <TITLE>
+ Outputs
+ </TITLE>
+ <PARA>
+
+ <VARIABLELIST>
+ <VARLISTENTRY>
+ <TERM>
+ NOTIFY
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Acknowledgement that notify command has executed.
+ </para>
+ </listitem>
+ </varlistentry>
+ <VARLISTENTRY>
+ <TERM>
+ Notify events
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Events are delivered to listening frontends; whether and how each frontend
+ application reacts depends on its programming.
+ </PARA>
+ </LISTITEM>
+ </VARLISTENTRY>
+ </VARIABLELIST>
+ </para>
+ </REFSECT2>
+ </REFSYNOPSISDIV>
+
+ <REFSECT1 ID="R1-SQL-NOTIFY-1">
+ <REFSECT1INFO>
+ <DATE>1998-10-07</DATE>
+ </REFSECT1INFO>
+ <TITLE>
+ Description
+ </TITLE>
+ <PARA>
+ The <command>NOTIFY</command> command sends a notify event to each
+ frontend application that has previously executed
+ <command>LISTEN <replaceable class="parameter">notifyname</replaceable></command>
+ for the specified notify condition in the current database.
+ </para>
+ <para>
+ The information passed to the frontend for a notify event includes the notify
+ condition name and the notifying backend process's PID. It is up to the
+ database designer to define the condition names that will be used in a given
+ database and what each one means.
+ </para>
+ <para>
+ Commonly, the notify condition name is the same as the name of some table in
+ the database, and the notify event essentially means "I changed this table,
+ take a look at it to see what's new". But no such association is enforced by
+ the <command>NOTIFY</command> and <command>LISTEN</command> commands. For
+ example, a database designer could use several different condition names
+ to signal different sorts of changes to a single table.
+ </para>
+ <para>
+ <command>NOTIFY</command> provides a simple form of signal or
+ IPC (interprocess communication) mechanism for a collection of processes
+ accessing the same <productname>Postgres</productname> database.
+ Higher-level mechanisms can be built by using tables in the database to
+ pass additional data (beyond a mere condition name) from notifier to
+ listener(s).
+ </para>
+ <para>
+ When <command>NOTIFY</command> is used to signal the occurrence of changes
+ to a particular table, a useful programming technique is to put the
+ <command>NOTIFY</command> in a rule that is triggered by table updates.
+ In this way, notification happens automatically when the table is changed,
+ and the application programmer can't accidentally forget to do it.
+ </para>
+ <para>
+ <command>NOTIFY</command> interacts with SQL transactions in some important
+ ways. Firstly, if a <command>NOTIFY</command> is executed inside a
+ transaction, the notify events are not delivered until and unless the
+ transaction is committed. This is appropriate, since if the transaction
+ is aborted we would like all the commands within it to have had no effect
+ --- including <command>NOTIFY</command>. But it can be disconcerting if one
+ is expecting the notify events to be delivered immediately. Secondly, if
+ a listening backend receives a notify signal while it is within a transaction,
+ the notify event will not be delivered to its connected frontend until just
+ after the transaction is completed (either committed or aborted). Again, the
+ reasoning is that if a notify were delivered within a transaction that was
+ later aborted, one would want the notification to be undone somehow --- but
+ the backend cannot "take back" a notify once it has sent it to the frontend.
+ So notify events are only delivered between transactions. The upshot of this
+ is that applications using <command>NOTIFY</command> for real-time signaling
+ should try to keep their transactions short.
+ </para>
+ <para>
+ <command>NOTIFY</command> behaves like Unix signals in one important
+ respect: if the same condition name is signaled multiple times in quick
+ succession, recipients may get only one notify event for several executions
+ of <command>NOTIFY</command>. So it is a bad idea to depend on the number
+ of notifies received. Instead, use <command>NOTIFY</command> to wake up
+ applications that need to pay attention to something, and use a database
+ object (such as a sequence) to keep track of what happened or how many times
+ it happened.
+ </para>
+ <para>
+ It is common for a frontend that sends <command>NOTIFY</command> to be
+ listening on the same notify name itself. In that case it will get back a
+ notify event, just like all the other listening frontends. Depending on the
+ application logic, this could result in useless work --- for example,
+ re-reading a database table to find the same updates that that frontend just
+ wrote out. In <productname>Postgres</productname> 6.4 and later, it is
+ possible to avoid such extra work by noticing whether the notifying backend
+ process's PID (supplied in the notify event message) is the same as one's own
+ backend's PID (available from libpq). When they are the same, the notify
+ event is one's own work bouncing back, and can be ignored. (Despite what was
+ said in the preceding paragraph, this is a safe technique.
+ <productname>Postgres</productname> keeps self-notifies separate from notifies
+ arriving from other backends, so you cannot miss an outside notify by ignoring
+ your own notifies.)
+ </para>
+
+ <REFSECT2 ID="R2-SQL-NOTIFY-3">
+ <REFSECT2INFO>
+ <DATE>1998-10-07</DATE>
+ </REFSECT2INFO>
+ <TITLE>
+ Notes
+ </TITLE>
+ <para>
+ <REPLACEABLE CLASS="PARAMETER">notifyname</REPLACEABLE>
+ can be any string valid as a name;
+ it need not correspond to the name of any actual table. If
+ <REPLACEABLE CLASS="PARAMETER">notifyname</REPLACEABLE>
+ is enclosed in double-quotes, it need not even be a syntactically
+ valid name, but can be any string up to 31 characters long.
+ </para>
+ <para>
+ In some previous releases of
+ <productname>Postgres</productname>,
+ <REPLACEABLE CLASS="PARAMETER">notifyname</REPLACEABLE>
+ had to be enclosed in double-quotes when it did not correspond to any existing
+ table name, even if syntactically valid as a name. That is no longer required.
+ </para>
+ <para>
+ In <productname>Postgres</productname> releases prior to 6.4, the backend
+ PID delivered in a notify message was always the PID of the frontend's own
+ backend. So it was not possible to distinguish one's own notifies from other
+ clients' notifies in those earlier releases.
+ </para>
+ </REFSECT2>
+ </refsect1>
+
+ <REFSECT1 ID="R1-SQL-NOTIFY-2">
+ <TITLE>
+ Usage
+ </TITLE>
+ <PARA>
+ <ProgramListing>
+ -- Configure and execute a listen/notify sequence from psql
+ postgres=> listen virtual;
+ LISTEN
+ postgres=> notify virtual;
+ NOTIFY
+ ASYNC NOTIFY of 'virtual' from backend pid '11239' received
+ </ProgramListing>
+ </para>
+ </REFSECT1>
+
+ <REFSECT1 ID="R1-SQL-NOTIFY-3">
+ <TITLE>
+ Compatibility
+ </TITLE>
+
+ <REFSECT2 ID="R2-SQL-NOTIFY-4">
+ <REFSECT2INFO>
+ <DATE>1998-09-24</DATE>
+ </REFSECT2INFO>
+ <TITLE>
+ SQL92
+ </TITLE>
+ <PARA>
+ There is no <command>NOTIFY</command> statement in <acronym>SQL92</acronym>.
+ </para>
+ </refsect2>
+ </refsect1>
</REFENTRY>
<REFPURPOSE>
Extract a <productname>Postgres</productname> database into a script file
</REFPURPOSE>
+ </refnamediv>
<REFSYNOPSISDIV>
<REFSYNOPSISDIVINFO>
<DATE>1998-11-05</DATE>
[ <replaceable class="parameter">dbname</replaceable> ]
</SYNOPSIS>
-<REFSECT2 ID="R2-APP-PG-DUMP-1">
-<REFSECT2INFO>
-<DATE>1998-11-05</DATE>
-</REFSECT2INFO>
-<TITLE>
-Inputs
-</TITLE>
-<PARA>
-<application>pg_dump</application> accepts the following command line arguments:
-
-<variablelist>
-<varlistentry>
-<term>
-<replaceable class="parameter">dbname</replaceable>
-</term>
-<listitem>
-<para>
-Specifies the name of the database to be extracted.
-<replaceable class="parameter">dbname</replaceable>
-defaults to the value of the
-<envar>USER</envar>
-environment variable.
-
-<varlistentry>
-<term>
--a
-</term>
-<listitem>
-<para>
-Dump out only the data, no schema (definitions).
-
-<varlistentry>
-<term>
--d
-</term>
-<listitem>
-<para>
-Dump data as proper insert strings.
-
-<varlistentry>
-<term>
--D
-</term>
-<listitem>
-<para>
-Dump data as inserts with attribute names
-
-<varlistentry>
-<term>
--f <replaceable class="parameter">filename</replaceable>
-</term>
-<listitem>
-<para>
-Specifies the output file. Defaults to <filename>stdout</filename>.
-
-<varlistentry>
-<term>
--n
-</term>
-<listitem>
-<para>
-Suppress double quotes around identifiers unless absolutely necessary.
-This may cause trouble loading this dumped data if there are reserved words
-used for identifiers.
-This was the default behavior in pre-v6.4 <application>pg_dump</application>.
-
-<varlistentry>
-<term>
--N
-</term>
-<listitem>
-<para>
-Include double quotes around identifiers.
-This is the default.
-
-<varlistentry>
-<term>
--o
-</term>
-<listitem>
-<para>
-Dump object identifiers (<acronym>OID</acronym>s) for every table.
-
-<varlistentry>
-<term>
--s
-</term>
-<listitem>
-<para>
-Dump out only the schema (definitions), no data.
-
-<varlistentry>
-<term>
--t <replaceable class="parameter">table</replaceable>
-</term>
-<listitem>
-<para>
-Dump data for <replaceable class="parameter">table</replaceable> only.
-
-<varlistentry>
-<term>
--u
-</term>
-<listitem>
-<para>
-Use password authentication. Prompts for username and password.
-
-<varlistentry>
-<term>
--v
-</term>
-<listitem>
-<para>
-Specifies verbose mode
-
-<varlistentry>
-<term>
--z
-</term>
-<listitem>
-<para>
-Include ACLs (grant/revoke commands) and table ownership information.
-
-</variablelist>
-
-<para>
-<application>pg_dump</application> also accepts
-the following command line arguments for connection parameters:
-
-<variablelist>
-<varlistentry>
-<term>
--h <replaceable class="parameter">host</replaceable>
-</term>
-<listitem>
-<para>
-Specifies the hostname of the machine on which the
-<application>postmaster</application>
-is running. Defaults to using a local Unix domain socket
- rather than an IP connection..
-
-<varlistentry>
-<term>
--p <replaceable class="parameter">port</replaceable>
-</term>
-<listitem>
-<para>
-Specifies the Internet TCP/IP port or local Unix domain socket file
-extension on which the <application>postmaster</application>
-is listening for connections. The port number defaults to 5432,
- or the value of the <envar>PGPORT</envar>
-environment variable (if set).
-
-<varlistentry>
-<term>
--u
-</term>
-<listitem>
-<para>
-Use password authentication.
-Prompts for
-<replaceable class="parameter">username</replaceable>
- and <replaceable class="parameter">password</replaceable>.
-
-</variablelist>
-
-<REFSECT2 ID="R2-APP-PG-DUMP-2">
-<REFSECT2INFO>
-<DATE>1998-11-05</DATE>
-</REFSECT2INFO>
-<TITLE>
-Outputs
-</TITLE>
-<PARA>
-<application>pg_dump</application> will create a file or
- write to <filename>stdout</filename>.
-
-<variablelist>
-<varlistentry>
-<term>
-Connection to database 'template1' failed.
-connectDB() failed: Is the postmaster running and accepting connections
- at 'UNIX Socket' on port '<replaceable class="parameter">port</replaceable>'?
-<listitem>
-<para>
-<application>pg_dump</application> could not attach to the
-<application>postmaster</application>
-process on the specified host and port. If you see this message,
-ensure that the <application>postmaster</application>
-is running on the proper host and that you have specified the proper
-port. If your site uses an authentication system, ensure that you
-have obtained the required authentication credentials.
-
-<varlistentry>
-<term>
-Connection to database '<replaceable class="parameter">dbname</replaceable>' failed.
-FATAL 1: SetUserId: user '<replaceable class="parameter">username</replaceable>' is not in 'pg_shadow'
-<listitem>
-<para>
-You do not have a valid entry in the relation <literal>pg_shadow</literal>
-and and will not be allowed to access <productname>Postgres</productname>.
-Contact your <productname>Postgres</productname> administrator.
-
-<varlistentry>
-<term>
-dumpSequence(<replaceable class="parameter">table</replaceable>): SELECT failed
-<listitem>
-<para>
-You do not have permission to read the database.
-Contact your <productname>Postgres</productname> site administrator.
-
-</variablelist>
-
-<note>
-<para>
-<application>pg_dump</application> internally executes
-<command>SELECT</command> statements. If you have problems running
-<application>pg_dump</application>,
-make sure you are able to select information from the database using, for
-example, <application>psql</application>.
-</note>
-
-<REFSECT1 ID="R1-APP-PG-DUMP-1">
-<REFSECT1INFO>
-<DATE>1998-11-05</DATE>
-</REFSECT1INFO>
-<TITLE>
-Description
-</TITLE>
-<PARA>
-<application>pg_dump</application> is a utility for dumping out a
-<productname>Postgres</productname> database into a script file
- containing query commands. The script
-files are in text format and can be used to reconstruct the database,
-even on other machines and other architectures.
-<application>pg_dump</application>
-will produce the queries necessary to re-generate all
-user-defined types, functions, tables, indices, aggregates, and
-operators. In addition, all the data is copied out in text format so
-that it can be readily copied in again, as well as imported into tools
-for editing.
-
-<para>
-<application>pg_dump</application>
-is useful for dumping out the contents of a database to move from one
-<productname>Postgres</productname> installation to another. After running
-<application>pg_dump</application>,
- one should examine the output script file for any warnings, especially
-in light of the limitations listed below.
-
-<REFSECT1 ID="R1-APP-PG-DUMP-2">
-<REFSECT1INFO>
-<DATE>1998-11-05</DATE>
-</REFSECT1INFO>
-<TITLE>
-Notes
-</TITLE>
-<PARA>
-<application>pg_dump</application> has a few limitations.
-The limitations mostly stem from
-difficulty in extracting certain meta-information from the system
-catalogs.
-
-<variablelist>
-<varlistentry>
-<term>
-partial indices
-<listitem>
-<para>
-<application>pg_dump</application>
-does not understand partial indices. The reason is
-the same as above; partial index predicates are stored as plans.
-
-<varlistentry>
-<term>
-large objects
-<listitem>
-<para>
-<application>pg_dump</application> does not handle large objects.
-Large objects are ignored and must be dealt with manually.
-
-</variablelist>
-
-<REFSECT1 ID="R1-APP-PG-DUMP-3">
-<REFSECT1INFO>
-<DATE>1998-11-05</DATE>
-</REFSECT1INFO>
-<TITLE>
-Usage
-</TITLE>
-<PARA>
-To dump a database of the same name as the user:
-
-<programlisting>
-% pg_dump > db.out
-</programlisting>
-
-<para>
-To reload this database:
-
-<programlisting>
-psql -e database < db.out
-</programlisting>
-
+ <REFSECT2 ID="R2-APP-PG-DUMP-1">
+ <REFSECT2INFO>
+ <DATE>1998-11-05</DATE>
+ </REFSECT2INFO>
+ <TITLE>
+ Inputs
+ </TITLE>
+ <PARA>
+ <application>pg_dump</application> accepts the following command line arguments:
+
+ <variablelist>
+ <varlistentry>
+ <term>
+ <replaceable class="parameter">dbname</replaceable>
+ </term>
+ <listitem>
+ <para>
+ Specifies the name of the database to be extracted.
+ <replaceable class="parameter">dbname</replaceable>
+ defaults to the value of the
+ <envar>USER</envar>
+ environment variable.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ -a
+ </term>
+ <listitem>
+ <para>
+ Dump out only the data, no schema (definitions).
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ -d
+ </term>
+ <listitem>
+ <para>
+ Dump data as proper insert strings.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ -D
+ </term>
+ <listitem>
+ <para>
+ Dump data as inserts with attribute names
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ -f <replaceable class="parameter">filename</replaceable>
+ </term>
+ <listitem>
+ <para>
+ Specifies the output file. Defaults to <filename>stdout</filename>.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ -n
+ </term>
+ <listitem>
+ <para>
+ Suppress double quotes around identifiers unless absolutely necessary.
+ This may cause trouble loading this dumped data if there are reserved words
+ used for identifiers.
+ This was the default behavior in pre-v6.4 <application>pg_dump</application>.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ -N
+ </term>
+ <listitem>
+ <para>
+ Include double quotes around identifiers.
+ This is the default.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ -o
+ </term>
+ <listitem>
+ <para>
+ Dump object identifiers (<acronym>OID</acronym>s) for every table.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ -s
+ </term>
+ <listitem>
+ <para>
+ Dump out only the schema (definitions), no data.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ -t <replaceable class="parameter">table</replaceable>
+ </term>
+ <listitem>
+ <para>
+ Dump data for <replaceable class="parameter">table</replaceable> only.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ -u
+ </term>
+ <listitem>
+ <para>
+ Use password authentication. Prompts for username and password.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ -v
+ </term>
+ <listitem>
+ <para>
+ Specifies verbose mode
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ -z
+ </term>
+ <listitem>
+ <para>
+ Include ACLs (grant/revoke commands) and table ownership information.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </para>
+ <para>
+ <application>pg_dump</application> also accepts
+ the following command line arguments for connection parameters:
+
+ <variablelist>
+ <varlistentry>
+ <term>
+ -h <replaceable class="parameter">host</replaceable>
+ </term>
+ <listitem>
+ <para>
+ Specifies the hostname of the machine on which the
+ <application>postmaster</application>
+ is running. Defaults to using a local Unix domain socket
+ rather than an IP connection..
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ -p <replaceable class="parameter">port</replaceable>
+ </term>
+ <listitem>
+ <para>
+ Specifies the Internet TCP/IP port or local Unix domain socket file
+ extension on which the <application>postmaster</application>
+ is listening for connections. The port number defaults to 5432,
+ or the value of the <envar>PGPORT</envar>
+ environment variable (if set).
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ -u
+ </term>
+ <listitem>
+ <para>
+ Use password authentication.
+ Prompts for
+ <replaceable class="parameter">username</replaceable>
+ and <replaceable class="parameter">password</replaceable>.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </para>
+ </refsect2>
+
+ <REFSECT2 ID="R2-APP-PG-DUMP-2">
+ <REFSECT2INFO>
+ <DATE>1998-11-05</DATE>
+ </REFSECT2INFO>
+ <TITLE>
+ Outputs
+ </TITLE>
+ <PARA>
+ <application>pg_dump</application> will create a file or
+ write to <filename>stdout</filename>.
+
+ <variablelist>
+ <varlistentry>
+ <term>
+ Connection to database 'template1' failed.
+ connectDB() failed: Is the postmaster running and accepting connections
+ at 'UNIX Socket' on port '<replaceable class="parameter">port</replaceable>'?
+ </term>
+ <listitem>
+ <para>
+ <application>pg_dump</application> could not attach to the
+ <application>postmaster</application>
+ process on the specified host and port. If you see this message,
+ ensure that the <application>postmaster</application>
+ is running on the proper host and that you have specified the proper
+ port. If your site uses an authentication system, ensure that you
+ have obtained the required authentication credentials.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ Connection to database '<replaceable class="parameter">dbname</replaceable>' failed.
+ FATAL 1: SetUserId: user '<replaceable class="parameter">username</replaceable>' is not in 'pg_shadow'
+ </term>
+ <listitem>
+ <para>
+ You do not have a valid entry in the relation <literal>pg_shadow</literal>
+ and and will not be allowed to access <productname>Postgres</productname>.
+ Contact your <productname>Postgres</productname> administrator.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ dumpSequence(<replaceable class="parameter">table</replaceable>): SELECT failed
+ </term>
+ <listitem>
+ <para>
+ You do not have permission to read the database.
+ Contact your <productname>Postgres</productname> site administrator.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </para>
+ <note>
+ <para>
+ <application>pg_dump</application> internally executes
+ <command>SELECT</command> statements. If you have problems running
+ <application>pg_dump</application>,
+ make sure you are able to select information from the database using, for
+ example, <application>psql</application>.
+ </para>
+ </note>
+ </refsect2>
+ </refsynopsisdiv>
+
+ <REFSECT1 ID="R1-APP-PG-DUMP-1">
+ <REFSECT1INFO>
+ <DATE>1998-11-05</DATE>
+ </REFSECT1INFO>
+ <TITLE>
+ Description
+ </TITLE>
+ <PARA>
+ <application>pg_dump</application> is a utility for dumping out a
+ <productname>Postgres</productname> database into a script file
+ containing query commands. The script
+ files are in text format and can be used to reconstruct the database,
+ even on other machines and other architectures.
+ <application>pg_dump</application>
+ will produce the queries necessary to re-generate all
+ user-defined types, functions, tables, indices, aggregates, and
+ operators. In addition, all the data is copied out in text format so
+ that it can be readily copied in again, as well as imported into tools
+ for editing.
+ </para>
+ <para>
+ <application>pg_dump</application>
+ is useful for dumping out the contents of a database to move from one
+ <productname>Postgres</productname> installation to another. After running
+ <application>pg_dump</application>,
+ one should examine the output script file for any warnings, especially
+ in light of the limitations listed below.
+ </para>
+ </refsect1>
+
+ <REFSECT1 ID="R1-APP-PG-DUMP-2">
+ <REFSECT1INFO>
+ <DATE>1998-11-05</DATE>
+ </REFSECT1INFO>
+ <TITLE>
+ Notes
+ </TITLE>
+ <PARA>
+ <application>pg_dump</application> has a few limitations.
+ The limitations mostly stem from
+ difficulty in extracting certain meta-information from the system
+ catalogs.
+
+ <variablelist>
+ <varlistentry>
+ <term>
+ partial indices
+ </term>
+ <listitem>
+ <para>
+ <application>pg_dump</application>
+ does not understand partial indices. The reason is
+ the same as above; partial index predicates are stored as plans.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ large objects
+ </term>
+ <listitem>
+ <para>
+ <application>pg_dump</application> does not handle large objects.
+ Large objects are ignored and must be dealt with manually.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </para>
+ </refsect1>
+
+ <REFSECT1 ID="R1-APP-PG-DUMP-3">
+ <REFSECT1INFO>
+ <DATE>1998-11-05</DATE>
+ </REFSECT1INFO>
+ <TITLE>
+ Usage
+ </TITLE>
+ <PARA>
+ To dump a database of the same name as the user:
+
+ <programlisting>
+ % pg_dump > db.out
+ </programlisting>
+ </para>
+ <para>
+ To reload this database:
+
+ <programlisting>
+ psql -e database < db.out
+ </programlisting>
+ </para>
+ </refsect1>
</REFENTRY>
<REFPURPOSE>
Extract all <productname>Postgres</productname> databases into a script file
</REFPURPOSE>
+ </refnamediv>
<REFSYNOPSISDIV>
<REFSYNOPSISDIVINFO>
<DATE>1998-10-04</DATE>
[ -a ] [ -d ] [ -D ] [ -o ] [ -s ] [ -u ] [ -v ] [ -z ]
</SYNOPSIS>
-<REFSECT2 ID="R2-APP-PG-DUMPALL-1">
-<REFSECT2INFO>
-<DATE>1998-10-04</DATE>
-</REFSECT2INFO>
-<TITLE>
-Inputs
-</TITLE>
-<PARA>
-<application>pg_dumpall</application> accepts the following command line arguments:
-
-<variablelist>
-<varlistentry>
-<term>
--a
-</term>
-<listitem>
-<para>
-Dump out only the data, no schema (definitions).
-
-<varlistentry>
-<term>
--d
-</term>
-<listitem>
-<para>
-Dump data as proper insert strings.
-
-<varlistentry>
-<term>
--D
-</term>
-<listitem>
-<para>
-Dump data as inserts with attribute names
-
-<varlistentry>
-<term>
--n
-</term>
-<listitem>
-<para>
-Suppress double quotes around identifiers unless absolutely necessary.
-This may cause trouble loading this dumped data if there are reserved words
-used for identifiers.
-
-<varlistentry>
-<term>
--o
-</term>
-<listitem>
-<para>
-Dump object identifiers (<acronym>OID</acronym>s) for every table.
-
-<varlistentry>
-<term>
--s
-</term>
-<listitem>
-<para>
-Dump out only the schema (definitions), no data.
-
-<varlistentry>
-<term>
--u
-</term>
-<listitem>
-<para>
-Use password authentication. Prompts for username and password.
-
-<varlistentry>
-<term>
--v
-</term>
-<listitem>
-<para>
-Specifies verbose mode
-
-<varlistentry>
-<term>
--z
-</term>
-<listitem>
-<para>
-Include ACLs (grant/revoke commands) and table ownership information.
-
-</variablelist>
-
-<para>
-<application>pg_dumpall</application> also accepts
-the following command line arguments for connection parameters:
-
-<variablelist>
-<varlistentry>
-<term>
--h <replaceable class="parameter">host</replaceable>
-</term>
-<listitem>
-<para>
-Specifies the hostname of the machine on which the
-<application>postmaster</application>
-is running. Defaults to using a local Unix domain socket
- rather than an IP connection..
-
-<varlistentry>
-<term>
--p <replaceable class="parameter">port</replaceable>
-</term>
-<listitem>
-<para>
-Specifies the Internet TCP/IP port or local Unix domain socket file
-extension on which the <application>postmaster</application>
-is listening for connections. The port number defaults to 5432,
- or the value of the <envar>PGPORT</envar>
-environment variable (if set).
-
-<varlistentry>
-<term>
--u
-</term>
-<listitem>
-<para>
-Use password authentication.
-Prompts for
-<replaceable class="parameter">username</replaceable>
- and <replaceable class="parameter">password</replaceable>.
-
-</variablelist>
-
-<REFSECT2 ID="R2-APP-PG-DUMPALL-2">
-<REFSECT2INFO>
-<DATE>1998-10-04</DATE>
-</REFSECT2INFO>
-<TITLE>
-Outputs
-</TITLE>
-<PARA>
-<application>pg_dumpall</application> will create a file or
- write to <filename>stdout</filename>.
-
-<variablelist>
-<varlistentry>
-<term>
-Connection to database 'template1' failed.
-connectDB() failed: Is the postmaster running and accepting connections
- at 'UNIX Socket' on port '<replaceable class="parameter">port</replaceable>'?
-<listitem>
-<para>
-<application>pg_dumpall</application> could not attach to the
-<application>postmaster</application>
-process on the specified host and port. If you see this message,
-ensure that the <application>postmaster</application>
-is running on the proper host and that you have specified the proper
-port. If your site uses an authentication system, ensure that you
-have obtained the required authentication credentials.
-
-<varlistentry>
-<term>
-Connection to database '<replaceable class="parameter">dbname</replaceable>' failed.
-FATAL 1: SetUserId: user '<replaceable class="parameter">username</replaceable>' is not in 'pg_shadow'
-<listitem>
-<para>
-You do not have a valid entry in the relation <literal>pg_shadow</literal>
-and and will not be allowed to access <productname>Postgres</productname>.
-Contact your <productname>Postgres</productname> administrator.
-
-<varlistentry>
-<term>
-dumpSequence(<replaceable class="parameter">table</replaceable>): SELECT failed
-<listitem>
-<para>
-You do not have permission to read the database.
-Contact your <productname>Postgres</productname> site administrator.
-
-</variablelist>
-
-<note>
-<para>
-<application>pg_dumpall</application> internally executes
-<command>SELECT</command> statements. If you have problems running
-<application>pg_dumpall</application>,
-make sure you are able to select information from the database using, for
-example, <application>psql</application>.
-</note>
-
-<REFSECT1 ID="R1-APP-PG-DUMPALL-1">
-<REFSECT1INFO>
-<DATE>1998-10-04</DATE>
-</REFSECT1INFO>
-<TITLE>
-Description
-</TITLE>
-<PARA>
-<application>pg_dumpall</application>
-is a utility for dumping out all Postgres databases into one file.
-It also dumps the pg_shadow table, which is global to all databases.
-<application>pg_dumpall</application> includes in this file the proper commands
-to automatically create each dumped database before loading.
-
-<para>
-<application>pg_dumpall</application> takes all <application>pg_dump</application>
- options, but <option>-f</option>, <option>-t</option> and
-<replaceable class="parameter">dbname</replaceable>
-should be omitted.
-
-<para>
-Refer to
-<xref linkend="app-pg-dump" endterm="pg-dump">
- for more information on this capability.
-
-<REFSECT1 ID="R1-APP-PG-DUMPALL-2">
-<REFSECT1INFO>
-<DATE>1998-10-04</DATE>
-</REFSECT1INFO>
-<TITLE>
-Usage
-</TITLE>
-<PARA>
-To dump all databases:
-
-<programlisting>
-% pg_dumpall -o > db.out
-</programlisting>
-
-<tip>
-<para>
-You can use most <application>pg_dump</application> options
-for <application>pg_dumpall</application>.
-</tip>
-
-<para>
-To reload this database:
-
-<programlisting>
-psql -e template1 < db.out
-</programlisting>
-
-<tip>
-<para>
-You can use most <application>psql</application> options
-when reloading.
-</tip>
-
+ <REFSECT2 ID="R2-APP-PG-DUMPALL-1">
+ <REFSECT2INFO>
+ <DATE>1998-10-04</DATE>
+ </REFSECT2INFO>
+ <TITLE>
+ Inputs
+ </TITLE>
+ <PARA>
+ <application>pg_dumpall</application> accepts the following command line arguments:
+
+ <variablelist>
+ <varlistentry>
+ <term>
+ -a
+ </term>
+ <listitem>
+ <para>
+ Dump out only the data, no schema (definitions).
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>
+ -d
+ </term>
+ <listitem>
+ <para>
+ Dump data as proper insert strings.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ -D
+ </term>
+ <listitem>
+ <para>
+ Dump data as inserts with attribute names
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ -n
+ </term>
+ <listitem>
+ <para>
+ Suppress double quotes around identifiers unless absolutely necessary.
+ This may cause trouble loading this dumped data if there are reserved words
+ used for identifiers.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ -o
+ </term>
+ <listitem>
+ <para>
+ Dump object identifiers (<acronym>OID</acronym>s) for every table.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ -s
+ </term>
+ <listitem>
+ <para>
+ Dump out only the schema (definitions), no data.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ -u
+ </term>
+ <listitem>
+ <para>
+ Use password authentication. Prompts for username and password.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ -v
+ </term>
+ <listitem>
+ <para>
+ Specifies verbose mode
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ -z
+ </term>
+ <listitem>
+ <para>
+ Include ACLs (grant/revoke commands) and table ownership information.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </para>
+ <para>
+ <application>pg_dumpall</application> also accepts
+ the following command line arguments for connection parameters:
+
+ <variablelist>
+ <varlistentry>
+ <term>
+ -h <replaceable class="parameter">host</replaceable>
+ </term>
+ <listitem>
+ <para>
+ Specifies the hostname of the machine on which the
+ <application>postmaster</application>
+ is running. Defaults to using a local Unix domain socket
+ rather than an IP connection..
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ -p <replaceable class="parameter">port</replaceable>
+ </term>
+ <listitem>
+ <para>
+ Specifies the Internet TCP/IP port or local Unix domain socket file
+ extension on which the <application>postmaster</application>
+ is listening for connections. The port number defaults to 5432,
+ or the value of the <envar>PGPORT</envar>
+ environment variable (if set).
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ -u
+ </term>
+ <listitem>
+ <para>
+ Use password authentication.
+ Prompts for
+ <replaceable class="parameter">username</replaceable>
+ and <replaceable class="parameter">password</replaceable>.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </para>
+ </refsect2>
+
+ <REFSECT2 ID="R2-APP-PG-DUMPALL-2">
+ <REFSECT2INFO>
+ <DATE>1998-10-04</DATE>
+ </REFSECT2INFO>
+ <TITLE>
+ Outputs
+ </TITLE>
+ <PARA>
+ <application>pg_dumpall</application> will create a file or
+ write to <filename>stdout</filename>.
+
+ <variablelist>
+ <varlistentry>
+ <term>
+ Connection to database 'template1' failed.
+ connectDB() failed: Is the postmaster running and accepting connections
+ at 'UNIX Socket' on port '<replaceable class="parameter">port</replaceable>'?
+ </term>
+ <listitem>
+ <para>
+ <application>pg_dumpall</application> could not attach to the
+ <application>postmaster</application>
+ process on the specified host and port. If you see this message,
+ ensure that the <application>postmaster</application>
+ is running on the proper host and that you have specified the proper
+ port. If your site uses an authentication system, ensure that you
+ have obtained the required authentication credentials.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ Connection to database '<replaceable class="parameter">dbname</replaceable>' failed.
+ FATAL 1: SetUserId: user '<replaceable class="parameter">username</replaceable>' is not in 'pg_shadow'
+ </term>
+ <listitem>
+ <para>
+ You do not have a valid entry in the relation <literal>pg_shadow</literal>
+ and and will not be allowed to access <productname>Postgres</productname>.
+ Contact your <productname>Postgres</productname> administrator.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ dumpSequence(<replaceable class="parameter">table</replaceable>): SELECT failed
+ </term>
+ <listitem>
+ <para>
+ You do not have permission to read the database.
+ Contact your <productname>Postgres</productname> site administrator.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </para>
+
+ <note>
+ <para>
+ <application>pg_dumpall</application> internally executes
+ <command>SELECT</command> statements. If you have problems running
+ <application>pg_dumpall</application>,
+ make sure you are able to select information from the database using, for
+ example, <application>psql</application>.
+ </para>
+ </note>
+ </refsect2>
+ </refsynopsisdiv>
+
+ <REFSECT1 ID="R1-APP-PG-DUMPALL-1">
+ <REFSECT1INFO>
+ <DATE>1998-10-04</DATE>
+ </REFSECT1INFO>
+ <TITLE>
+ Description
+ </TITLE>
+ <PARA>
+ <application>pg_dumpall</application>
+ is a utility for dumping out all Postgres databases into one file.
+ It also dumps the pg_shadow table, which is global to all databases.
+ <application>pg_dumpall</application> includes in this file the proper commands
+ to automatically create each dumped database before loading.
+ </para>
+ <para>
+ <application>pg_dumpall</application> takes all <application>pg_dump</application>
+ options, but <option>-f</option>, <option>-t</option> and
+ <replaceable class="parameter">dbname</replaceable>
+ should be omitted.
+ </para>
+ <para>
+ Refer to
+ <xref linkend="app-pg-dump" endterm="pg-dump">
+ for more information on this capability.
+ </para
+ </refsect1>
+
+ <REFSECT1 ID="R1-APP-PG-DUMPALL-2">
+ <REFSECT1INFO>
+ <DATE>1998-10-04</DATE>
+ </REFSECT1INFO>
+ <TITLE>
+ Usage
+ </TITLE>
+ <PARA>
+ To dump all databases:
+
+ <programlisting>
+ % pg_dumpall -o > db.out
+ </programlisting>
+
+ <tip>
+ <para>
+ You can use most <application>pg_dump</application> options
+ for <application>pg_dumpall</application>.
+ </para>
+ </tip>
+ </para>
+ <para>
+ To reload this database:
+
+ <programlisting>
+ psql -e template1 < db.out
+ </programlisting>
+ </para>
+ <tip>
+ <para>
+ You can use most <application>psql</application> options
+ when reloading.
+ </para>
+ </tip>
+ </refsect1>
</REFENTRY>
<REFPURPOSE>
<productname>Postgres</productname> interactive client
</REFPURPOSE>
+ </refnamediv>
<REFSYNOPSISDIV>
<REFSYNOPSISDIVINFO>
<DATE>1998-09-26</DATE>
[ -o <replaceable class="parameter">filename</replaceable> ] [ -p <replaceable class="parameter">port</replaceable> ] -qsSt ] [ -T <replaceable class="parameter">table_options</replaceable> ] -ux [ <replaceable class="parameter">dbname</replaceable> ]
</SYNOPSIS>
-<REFSECT2 ID="R2-APP-PSQL-1">
-<REFSECT2INFO>
-<DATE>1998-09-26</DATE>
-</REFSECT2INFO>
-<TITLE>
-Inputs
-</TITLE>
-<PARA>
-<application>psql</application> accepts many command-line arguments,
-a rich set of meta-commands, and the full <acronym>SQL</acronym> language
-supported by <productname>Postgres</productname>. The most common
-command-line arguments are:
-
-<VARIABLELIST>
-<VARLISTENTRY>
-<TERM>
-<REPLACEABLE CLASS="PARAMETER">dbname</REPLACEABLE>
-</TERM>
-<LISTITEM>
-<PARA>
-The name of an existing database to access.
-<replaceable class="parameter">dbname</replaceable>
-defaults to the value of the
-<envar>USER</envar>
-environment variable or, if that's not set, to the Unix account name of the
-current user.
-
-</PARA>
-</LISTITEM>
-</VARLISTENTRY>
-
-<VARLISTENTRY>
-<TERM>
--c <replaceable class="parameter">query</replaceable>
-</TERM>
-<LISTITEM>
-<PARA>
-A single query to run. <application>psql</application> will exit on completion.
-</PARA>
-</LISTITEM>
-</VARLISTENTRY>
-
-</variablelist>
-
-<para>
-The full set of command-line arguments and meta-commands are described in a subsequent
-section.
-
-<para>
-There are some environment variables which can be used in liu of
-command line arguments.
-Additionally, the <productname>Postgres</productname> frontend library used by
-the <application>psql</application> application
-looks for other optional environment variables to configure, for example,
-the style of date/time representation and the local time zone. Refer
-to the chapter on <filename>libpq</filename> in the
-<citetitle>Programmer's Guide</citetitle> for more details.
-
-<para>
-You may set any of the following environment variables to avoid
-specifying command-line options:
-
-<VARIABLELIST>
-<VARLISTENTRY>
-<TERM>
-<envar>PGHOST</envar>
-</TERM>
-<LISTITEM>
-<PARA>
-The <acronym>DNS</acronym> host name of the database server.
-Setting <envar>PGHOST</envar> to a non-zero-length string causes
-<acronym>TCP/IP</acronym> communication
-to be used, rather than the default local Unix domain sockets.
-</PARA>
-</LISTITEM>
-</VARLISTENTRY>
-
-<VARLISTENTRY>
-<TERM>
-<envar>PGPORT</envar>
-</TERM>
-<LISTITEM>
-<PARA>
-The port number on which a <productname>Postgres</productname> server is listening.
-Defaults to <literal>5432</literal>.
-</PARA>
-</LISTITEM>
-</VARLISTENTRY>
-
-<VARLISTENTRY>
-<TERM>
-<envar>PGTTY</envar>
-</TERM>
-<LISTITEM>
-<PARA>
-The target for display of messages from the client support library.
-Not required.
-</PARA>
-</LISTITEM>
-</VARLISTENTRY>
-
-<VARLISTENTRY>
-<TERM>
-<envar>PGOPTION</envar>
-</TERM>
-<LISTITEM>
-<PARA>
-If <envar>PGOPTION</envar>
-is specified, then the options it contains are parsed
-<emphasis>before</emphasis>
-any command-line options.
-</PARA>
-</LISTITEM>
-</VARLISTENTRY>
-
-<VARLISTENTRY>
-<TERM>
-<envar>PGREALM</envar>
-</TERM>
-<LISTITEM>
-<PARA>
-<envar>PGREALM</envar>
-only applies if
-<productname>Kerberos</productname>
-authentication is in use.
-If this environment variable is set, <productname>Postgres</productname>
-will attempt authentication with servers for this realm and will use
-separate ticket files to avoid conflicts with local ticket files.
-See the <citetitle>PostgreSQL Administrator's Guide</citetitle>
-for additional information on
-<productname>Kerberos</productname>.
-
-</variablelist>
-
-<REFSECT2 ID="R2-APP-PSQL-2">
-<REFSECT2INFO>
-<DATE>1998-09-26</DATE>
-</REFSECT2INFO>
-<TITLE>
-Outputs
-</TITLE>
-<PARA>
-
-<application>psql</application>
-returns 0 to the shell on successful completion of all queries,
-1 for errors, 2 for abrupt disconnection from the backend.
-The default TAB delimiter is used.
-<application>psql</application>
-will also return 1 if the connection to a database could not be made for
-any reason.
-
-<REFSECT1 ID="R1-APP-PSQL-1">
-<REFSECT1INFO>
-<DATE>1998-09-26</DATE>
-</REFSECT1INFO>
-<TITLE>
-Description
-</TITLE>
-<PARA>
-<application>psql</application> is a character-based front-end to
-<productname>Postgres</productname>.
-It enables you to
-type in queries interactively, issue them to <productname>Postgres</productname>,
-and see the query
-results.
-
-<para>
-<application>psql</application>
-is a <productname>Postgres</productname> client application. Hence, a
-<application>postmaster</application> process
- must be running on the database server host before
-<application>psql</application>
-is executed. In addition, the correct parameters to identify
-the database server, such as the
-<application>postmaster</application> host name,
- may need to be specified
-as described below.
-
-<para>
-When
-<application>psql</application>
-starts, it reads SQL commands from
-<filename>/etc/psqlrc</filename>
-and then from
-<filename>$(<envar>HOME</envar>)/.psqlrc</filename>
-This allows SQL commands like
-<command>SET</command>
-which can be used to set the date style to be run at the start of
-every session.
-
-<REFSECT2 ID="R2-APP-PSQL-3">
-<REFSECT2INFO>
-<DATE>1998-09-26</DATE>
-</REFSECT2INFO>
-<TITLE>
-Connecting To A Database
-</TITLE>
-<para>
-<application>psql</application>
-attempts to make a connection to the database at the hostname and
-port number specified on the command line. If the connection could not
-be made for any reason (e.g. insufficient privileges, postmaster is not
-running on the server, etc)
-.IR <application>psql</application>
-will return an error that says
-<programlisting>
-Connection to database failed.
-</programlisting>
-The reason for the connection failure is not provided.
-
-<REFSECT2 ID="R2-APP-PSQL-4">
-<REFSECT2INFO>
-<DATE>1998-09-26</DATE>
-</REFSECT2INFO>
-<TITLE>
-Entering Queries
-</TITLE>
-<para>
-In normal operation,
-<application>psql</application> provides a prompt with the name of the
-database that <application>psql</application> is current connected to
-followed by the string "=>".
-For example,
-<programlisting>
-$ <userinput>psql testdb</userinput>
-Welcome to the POSTGRESQL interactive sql monitor:
- Please read the file COPYRIGHT for copyright terms of POSTGRESQL
-
- type \e? for help on slash commands
- type \eq to quit
- type \eg or terminate with semicolon to execute query
- You are currently connected to the database: testdb
-
-testdb=>
-</programlisting>
-
-<para>
-At the prompt, the user may type in <acronym>SQL</acronym> queries.
-Unless the -S option
-is set, input lines are sent to the backend when a query-terminating
-semicolon is reached.
-
-<para>
-Whenever a query is executed,
-<application>psql</application> also polls for asynchronous notification
-events generated by <command>LISTEN</command> and <command>NOTIFY</command>.
-
-<para>
-<application>psql</application>
-can be used in a pipe sequence, and automatically detects when it
-is not listening or talking to a real tty.
-
-<REFSECT1 ID="R1-APP-PSQL-2">
-<REFSECT1INFO>
-<DATE>1998-09-26</DATE>
-</REFSECT1INFO>
-<TITLE>
-Command-line Options
-</TITLE>
-<para>
-<application>psql</application>
-understands the following command-line options:
-
-<VARIABLELIST>
-<VARLISTENTRY>
-<TERM>
--A
-</TERM>
-<LISTITEM>
-<PARA>
-Turn off fill justification when printing out table elements.
-
-<VARLISTENTRY>
-<TERM>
--c <replaceable class="parameter">query</replaceable>
-</TERM>
-<LISTITEM>
-<PARA>
-Specifies that
-<application>psql</application>
-is to execute one query string,
-<replaceable class="parameter">query</replaceable>,
-and then exit. This is useful for shell scripts, typically in
-conjunction with the <option>-q</option> option in shell scripts.
-
-<VARLISTENTRY>
-<TERM>
--d <replaceable class="parameter">dbname</replaceable>
-</TERM>
-<LISTITEM>
-<PARA>
-Specifies the name of the database to connect to. This is equivalent to specifying
-<replaceable class="parameter">dbname</replaceable> as the last field in the
-command line.
-
-<VARLISTENTRY>
-<TERM>
--e
-</TERM>
-<LISTITEM>
-<PARA>
-Echo the query sent to the backend
-
-<VARLISTENTRY>
-<TERM>
--f <replaceable class="parameter">filename</replaceable>
-</TERM>
-<LISTITEM>
-<PARA>
-Use the file <replaceable class="parameter">filename</replaceable>
-as the source of queries instead of reading queries interactively.
-This file must be specified for and visible to the client frontend.
-
-<VARLISTENTRY>
-<TERM>
--F <replaceable class="parameter">separator</replaceable>
-</TERM>
-<LISTITEM>
-<PARA>
-Use <replaceable class="parameter">separator</replaceable>
-as the field separator.
-The default is an ASCII vertical bar ("|").
-
-<VARLISTENTRY>
-<TERM>
--h <replaceable class="parameter">hostname</replaceable>
-</TERM>
-<LISTITEM>
-<PARA>
-Specifies the host name of the machine on which the
-<application>postmaster</application>
-is running.
-Without this option, communication is performed using
-local Unix domain sockets.
-
-<VARLISTENTRY>
-<TERM>
--H
-</TERM>
-<LISTITEM>
-<PARA>
-Turns on
-<acronym>HTML 3.0</acronym>
-tabular output.
-
-<VARLISTENTRY>
-<TERM>
--l
-</TERM>
-<LISTITEM>
-<PARA>
-Lists all available databases, then exit. Other non-connection options are ignored.
-
-<VARLISTENTRY>
-<TERM>
--n
-</TERM>
-<LISTITEM>
-<PARA>
-Do not use the readline library for input line editing and command history.
-
-<VARLISTENTRY>
-<TERM>
--o <replaceable class="parameter">filename</replaceable>
-</TERM>
-<LISTITEM>
-<PARA>
-Put all output into file <replaceable class="parameter">filename</replaceable>.
-The path must be writable by the client.
-
-<VARLISTENTRY>
-<TERM>
--p <replaceable class="parameter">port</replaceable>
-</TERM>
-<LISTITEM>
-<PARA>
-Specifies the TCP/IP port or, by omission, the local Unix domain socket file
-extension on which the
-<application>postmaster</application>
-is listening for connections. Defaults to the value of the
-<envar>PGPORT</envar>
-environment variable, if set, or to 5432.
-
-<VARLISTENTRY>
-<TERM>
--q
-</TERM>
-<LISTITEM>
-<PARA>
-Specifies that
-<application>psql</application>
-should do its work quietly. By default, it
-prints welcome and exit messages and prompts for each query, and prints
-out the number of rows returned from a query.
-If this option is used, none of this happens. This is useful with the
-<option>-c</option> option.
-
-<VARLISTENTRY>
-<TERM>
--s
-</TERM>
-<LISTITEM>
-<PARA>
-Run in single-step mode where the user is prompted for each query before
-it is sent to the backend.
-
-<VARLISTENTRY>
-<TERM>
--S
-</TERM>
-<LISTITEM>
-<PARA>
-Runs in single-line mode where each query is terminated by a newline,
-instead of a semicolon.
-
-<VARLISTENTRY>
-<TERM>
--t
-</TERM>
-<LISTITEM>
-<PARA>
-Turn off printing of column names.
-This is useful with the
-<option>-c</option>
-option in shell scripts.
-
-<VARLISTENTRY>
-<TERM>
--T <replaceable class="parameter">table_options</replaceable>
-</TERM>
-<LISTITEM>
-<PARA>
-Allows you to specify options to be placed within the
- <sgmltag>table ...</sgmltag> tag for <acronym>HTML 3.0</acronym>
-tabular output.For example, <literal>border</literal>
-will give you tables with borders.
-This must be used in conjunction with the <option>-H</option> option.
-
-<VARLISTENTRY>
-<TERM>
--u
-</TERM>
-<LISTITEM>
-<PARA>
-Asks the user for the user name and password before connecting to the database.
-If the database does not require password authentication then these are
-ignored. If the option is not used (and the PGPASSWORD environment variable
-is not set) and the database requires password authentication, then the
-connection will fail. The user name is ignored anyway.
-
-<VARLISTENTRY>
-<TERM>
--x
-</TERM>
-<LISTITEM>
-<PARA>
-Turns on extended row format mode. When enabled each row will have its column
-names printed on the left with the column values printed on the right.
-This is useful for rows which are otherwise too long to fit into
-one screen line. HTML row output supports this mode also.
-</variablelist>
-
-<para>
-You may set environment variables to avoid typing some of the above
-options. See the section on environment variables below.
-
-
-<REFSECT1 ID="R1-APP-PSQL-3">
-<REFSECT1INFO>
-<DATE>1998-09-26</DATE>
-</REFSECT1INFO>
-<TITLE>
-<application>psql</application> Meta-Commands
-</TITLE>
-<para>
-Anything you enter in <application>psql</application>
-that begins with an unquoted backslash is a <application>psql</application>
-meta-command. Anything else is <acronym>SQL</acronym>
- and simply goes into the current query buffer
-(and once you have at least one complete query, it gets automatically
-submitted to the backend).
-<Application>psql</Application> meta-commands are also called slash commands.
-
-<para>
-The format of a <application>psql</application> command is the backslash,
-followed immediately by
-a command verb, then any arguments. The arguments are separated from the
-command verb and each other by any number of white space characters.
-
-<para>
-With single character command verbs, you don't actually need to separate the
-command verb from the argument with white space, for historical reasons.
-You should anyway.
-
-<para>
-The following meta-commands are defined:
-
-<VARIABLELIST>
-<VARLISTENTRY>
-<TERM>
-<literal>\a</literal>
-</TERM>
-<LISTITEM>
-<PARA>
-Toggle field alignment when printing out table elements.
-
-<VARLISTENTRY>
-<TERM>
-<literal>\C</literal> <replaceable class="parameter">caption</replaceable>
-</TERM>
-<LISTITEM>
-<PARA>
-Set the HTML3.0 table caption to
-<quote><replaceable class="parameter">caption</replaceable></quote>.
-
-<VARLISTENTRY>
-<TERM>
-<literal>\connect</literal> <replaceable class="parameter">dbname</replaceable> [ <replaceable class="parameter">username</replaceable> ]
-</TERM>
-<LISTITEM>
-<PARA>
-Establish a connection to a new database, using the default
-<replaceable class="parameter">username</replaceable> if none is specified.
-The previous connection is closed.
-
-<VARLISTENTRY>
-<TERM>
-<literal>\copy</literal> <replaceable class="parameter">dbname</replaceable> { FROM | TO } <replaceable class="parameter">filename</replaceable>
-</TERM>
-<LISTITEM>
-<PARA>
-Perform a frontend (client) copy. This is an operation that runs a SQL COPY command,
-but instead of the backend reading or writing the specified file, and
-consequently requiring backend access and special user privilege,
-<application>psql</application> reads or writes the
-file and routes the data to or from the backend. The default <literal>tab</literal>
-delimiter is used.
-<tip>
-<para>
-This operation is not as efficient as the <acronym>SQL</acronym>
-<command>COPY</command> command because all data must pass through the
-client/server IP or socket connection. For large amounts of data this other
-technique may be preferable.
-</tip>
-
-<VARLISTENTRY>
-<TERM>
-<literal>\d</literal> [ <replaceable class="parameter">table</replaceable> ]
-</TERM>
-<LISTITEM>
-<PARA>
-List tables in the database, or if <replaceable class="parameter">table</replaceable>
-is specified, list the columns in that table.
-If table name is specified as an asterisk (<quote>*</quote>),
-list all tables and column information for each tables.
-
-<VARLISTENTRY>
-<TERM>
-<literal>\da</literal>
-</TERM>
-<LISTITEM>
-<PARA>
-List all available aggregates.
-
-<VARLISTENTRY>
-<TERM>
-<literal>\dd</literal> <replaceable class="parameter">object</replaceable>
-</TERM>
-<LISTITEM>
-<PARA>
-List the description from <literal>pg_description</literal>
-of the specified object, which can be a
-table, table.column, type, operator, or aggregate.
-<tip>
-<para>
-Not all objects have a description in <literal>pg_description</literal>.
-This meta-command can be useful to get a quick description of a native
-<productname>Postgres</productname> feature.
-</tip>
-
-<VARLISTENTRY>
-<TERM>
-<literal>\df</literal>
-</TERM>
-<LISTITEM>
-<PARA>
-List functions.
-
-<VARLISTENTRY>
-<TERM>
-<literal>\di</literal>
-</TERM>
-<LISTITEM>
-<PARA>
-List only indexes.
-
-<VARLISTENTRY>
-<TERM>
-<literal>\do</literal>
-</TERM>
-<LISTITEM>
-<PARA>
-List only operators.
-
-<VARLISTENTRY>
-<TERM>
-<literal>\ds</literal>
-</TERM>
-<LISTITEM>
-<PARA>
-List only sequences.
-
-<VARLISTENTRY>
-<TERM>
-<literal>\dS</literal>
-</TERM>
-<LISTITEM>
-<PARA>
-List system tables and indexes.
-
-<VARLISTENTRY>
-<TERM>
-<literal>\dt</literal>
-</TERM>
-<LISTITEM>
-<PARA>
-List only non-system tables.
-
-<VARLISTENTRY>
-<TERM>
-<literal>\dT</literal>
-</TERM>
-<LISTITEM>
-<PARA>
-List types.
-
-<VARLISTENTRY>
-<TERM>
-<literal>\e</literal> [ <replaceable class="parameter">filename</replaceable> ]
-</TERM>
-<LISTITEM>
-<PARA>
-Edit the current query buffer or the contents of the file
-<replaceable class="parameter">filename</replaceable>.
-
-<VARLISTENTRY>
-<TERM>
-<literal>\E</literal> [ <replaceable class="parameter">filename</replaceable> ]
-</TERM>
-<LISTITEM>
-<PARA>
-Edit the current query buffer or the contents of the file
-<replaceable class="parameter">filename</replaceable>
-and execute it upon editor exit.
-
-<VARLISTENTRY>
-<TERM>
-<literal>\f</literal> [ <replaceable class="parameter">separator</replaceable> ]
-</TERM>
-<LISTITEM>
-<PARA>
-Set the field separator. Default is a single blank space.
-
-<VARLISTENTRY>
-<TERM>
-<literal>\g</literal> [ { <replaceable class="parameter">filename</replaceable> | <literal>|</literal><replaceable class="parameter">command</replaceable> } ]
-</TERM>
-<LISTITEM>
-<PARA>
-Send the current query input buffer to the backend and optionally
-save the output in <replaceable class="parameter">filename</replaceable>
-or pipe the output into a separate Unix shell to execute
-<replaceable class="parameter">command</replaceable>.
-
-<VARLISTENTRY>
-<TERM>
-<literal>\h</literal> [ <replaceable class="parameter">command</replaceable> ]
-</TERM>
-<LISTITEM>
-<PARA>
-Give syntax help on the specified SQL command.
-If <replaceable class="parameter">command</replaceable> is not a defined SQL command
-(or is not documented in <application>psql</application>), or if
-<replaceable class="parameter">command</replaceable> is not specified,
-then <application>psql</application> will
-list all the commands for which syntax help is
-available. If <replaceable class="parameter">command</replaceable>
-is an asterisk (<quote>*</quote>), then
-give syntax help on all SQL commands.
-
-<VARLISTENTRY>
-<TERM>
-<literal>\H</literal>
-</TERM>
-<LISTITEM>
-<PARA>
-Toggle <acronym>HTML3</acronym> output. This is equivalent to the <option>-H</option>
-command-line option.
-
-<VARLISTENTRY>
-<TERM>
-<literal>\i</literal> <replaceable class="parameter">filename</replaceable>
-</TERM>
-<LISTITEM>
-<PARA>
-Read queries from the file <replaceable class="parameter">filename</replaceable>
-into the query input buffer.
-
-<VARLISTENTRY>
-<TERM>
-<literal>\l</literal>
-</TERM>
-<LISTITEM>
-<PARA>
-List all the databases in the server.
-
-<VARLISTENTRY>
-<TERM>
-<literal>\m</literal>
-</TERM>
-<LISTITEM>
-<PARA>
-Toggle the old monitor-like table display, which includes border characters
-surrounding the table.
-This is standard SQL output.
-By default, <application>psql</application> includes only field separators
-between columns.
-
-<VARLISTENTRY>
-<TERM>
-<literal>\o</literal> [ { <replaceable class="parameter">filename</replaceable> | <literal>|</literal><replaceable class="parameter">command</replaceable> } ]
-</TERM>
-<LISTITEM>
-<PARA>
-Save future query results to the file
-<replaceable class="parameter">filename</replaceable> or pipe future
-results into a separate Unix shell to execute
-<replaceable class="parameter">command</replaceable>.
-If no arguments are specified, send query results to
-<filename>stdout</filename>.
-
-<VARLISTENTRY>
-<TERM>
-<literal>\p</literal>
-</TERM>
-<LISTITEM>
-<PARA>
-Print the current query buffer.
-
-<VARLISTENTRY>
-<TERM>
-<literal>\q</literal>
-</TERM>
-<LISTITEM>
-<PARA>
-Quit the <application>psql</application> program.
-
-<VARLISTENTRY>
-<TERM>
-<literal>\r</literal>
-</TERM>
-<LISTITEM>
-<PARA>
-Reset(clear) the query buffer.
-
-<VARLISTENTRY>
-<TERM>
-<literal>\s</literal> [ <replaceable class="parameter">filename</replaceable> ]
-</TERM>
-<LISTITEM>
-<PARA>
-Print or save the command line history to
-<replaceable class="parameter">filename</replaceable>.
-If <replaceable class="parameter">filename</replaceable> is omitted,
-do not save subsequent commands to a history file.
-This option is only available if <application>psql</application> is
-configured to use readline.
-
-<VARLISTENTRY>
-<TERM>
-<literal>\t</literal>
-</TERM>
-<LISTITEM>
-<PARA>
-Toggle display of output column name headings and row count footer (defaults to on).
-
-<VARLISTENTRY>
-<TERM>
-<literal>\T</literal> <replaceable class="parameter">table_options</replaceable>
-</TERM>
-<LISTITEM>
-<PARA>
-Allows you to specify options to be placed within the
- <sgmltag>table ...</sgmltag> tag
-for <acronym>HTML 3.0</acronym>
-tabular output.For example, <literal>border</literal>
-will give you tables with borders.
-This must be used in conjunction with the <command>\H</command> meta-command.
-
-<VARLISTENTRY>
-<TERM>
-<literal>\x</literal>
-</TERM>
-<LISTITEM>
-<PARA>
-Toggles extended row format mode. When enabled each row will have its column
-names printed on the left with the column values printed on the right.
-This is useful for rows which are otherwise too long to fit into
-one screen line. <acronym>HTML</acronym> row output mode supports this flag too.
-
-<VARLISTENTRY>
-<TERM>
-<literal>\w</literal> <replaceable class="parameter">filename</replaceable>
-</TERM>
-<LISTITEM>
-<PARA>
-Outputs the current query buffer to the file
-<replaceable class="parameter">filename</replaceable>.
-
-<VARLISTENTRY>
-<TERM>
-<literal>\z</literal>
-</TERM>
-<LISTITEM>
-<PARA>
-Produces a list of all tables in the database with their appropriate ACLs
-(grant/revoke permissions) listed.
-
-<VARLISTENTRY>
-<TERM>
-<literal>\!</literal> [ <replaceable class="parameter">command</replaceable> ]
-</TERM>
-<LISTITEM>
-<PARA>
-Escape to a separate Unix shell or execute the Unix command
-<replaceable class="parameter">command</replaceable>.
-
-<VARLISTENTRY>
-<TERM>
-<literal>\?</literal>
-</TERM>
-<LISTITEM>
-<PARA>
-Get help information about the slash (<quote>\</quote>) commands.
-
-</variablelist>
-
+ <REFSECT2 ID="R2-APP-PSQL-1">
+ <REFSECT2INFO>
+ <DATE>1998-09-26</DATE>
+ </REFSECT2INFO>
+ <TITLE>
+ Inputs
+ </TITLE>
+ <PARA>
+ <application>psql</application> accepts many command-line arguments,
+ a rich set of meta-commands, and the full <acronym>SQL</acronym> language
+ supported by <productname>Postgres</productname>. The most common
+ command-line arguments are:
+
+ <VARIABLELIST>
+ <VARLISTENTRY>
+ <TERM>
+ <REPLACEABLE CLASS="PARAMETER">dbname</REPLACEABLE>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ The name of an existing database to access.
+ <replaceable class="parameter">dbname</replaceable>
+ defaults to the value of the
+ <envar>USER</envar>
+ environment variable or, if that's not set, to the Unix account name of the
+ current user.
+
+ </PARA>
+ </LISTITEM>
+ </VARLISTENTRY>
+
+ <VARLISTENTRY>
+ <TERM>
+ -c <replaceable class="parameter">query</replaceable>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ A single query to run. <application>psql</application> will exit on completion.
+ </PARA>
+ </LISTITEM>
+ </VARLISTENTRY>
+
+ </variablelist>
+ </para>
+ <para>
+ The full set of command-line arguments and meta-commands are described in a subsequent
+ section.
+ </para>
+ <para>
+ There are some environment variables which can be used in liu of
+ command line arguments.
+ Additionally, the <productname>Postgres</productname> frontend library used by
+ the <application>psql</application> application
+ looks for other optional environment variables to configure, for example,
+ the style of date/time representation and the local time zone. Refer
+ to the chapter on <filename>libpq</filename> in the
+ <citetitle>Programmer's Guide</citetitle> for more details.
+ </para>
+ <para>
+ You may set any of the following environment variables to avoid
+ specifying command-line options:
+
+ <VARIABLELIST>
+ <VARLISTENTRY>
+ <TERM>
+ <envar>PGHOST</envar>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ The <acronym>DNS</acronym> host name of the database server.
+ Setting <envar>PGHOST</envar> to a non-zero-length string causes
+ <acronym>TCP/IP</acronym> communication
+ to be used, rather than the default local Unix domain sockets.
+ </PARA>
+ </LISTITEM>
+ </VARLISTENTRY>
+
+ <VARLISTENTRY>
+ <TERM>
+ <envar>PGPORT</envar>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ The port number on which a <productname>Postgres</productname> server is listening.
+ Defaults to <literal>5432</literal>.
+ </PARA>
+ </LISTITEM>
+ </VARLISTENTRY>
+
+ <VARLISTENTRY>
+ <TERM>
+ <envar>PGTTY</envar>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ The target for display of messages from the client support library.
+ Not required.
+ </PARA>
+ </LISTITEM>
+ </VARLISTENTRY>
+
+ <VARLISTENTRY>
+ <TERM>
+ <envar>PGOPTION</envar>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ If <envar>PGOPTION</envar>
+ is specified, then the options it contains are parsed
+ <emphasis>before</emphasis>
+ any command-line options.
+ </PARA>
+ </LISTITEM>
+ </VARLISTENTRY>
+
+ <VARLISTENTRY>
+ <TERM>
+ <envar>PGREALM</envar>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ <envar>PGREALM</envar>
+ only applies if
+ <productname>Kerberos</productname>
+ authentication is in use.
+ If this environment variable is set, <productname>Postgres</productname>
+ will attempt authentication with servers for this realm and will use
+ separate ticket files to avoid conflicts with local ticket files.
+ See the <citetitle>PostgreSQL Administrator's Guide</citetitle>
+ for additional information on
+ <productname>Kerberos</productname>.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </para>
+ </refsect2>
+
+ <REFSECT2 ID="R2-APP-PSQL-2">
+ <REFSECT2INFO>
+ <DATE>1998-09-26</DATE>
+ </REFSECT2INFO>
+ <TITLE>
+ Outputs
+ </TITLE>
+ <PARA>
+
+ <application>psql</application>
+ returns 0 to the shell on successful completion of all queries,
+ 1 for errors, 2 for abrupt disconnection from the backend.
+ The default TAB delimiter is used.
+ <application>psql</application>
+ will also return 1 if the connection to a database could not be made for
+ any reason.
+ </para>
+ </refsect2>
+ </refsynopsisdiv>
+
+ <REFSECT1 ID="R1-APP-PSQL-1">
+ <REFSECT1INFO>
+ <DATE>1998-09-26</DATE>
+ </REFSECT1INFO>
+ <TITLE>
+ Description
+ </TITLE>
+ <PARA>
+ <application>psql</application> is a character-based front-end to
+ <productname>Postgres</productname>.
+ It enables you to
+ type in queries interactively, issue them to <productname>Postgres</productname>,
+ and see the query
+ results.
+ </para>
+ <para>
+ <application>psql</application>
+ is a <productname>Postgres</productname> client application. Hence, a
+ <application>postmaster</application> process
+ must be running on the database server host before
+ <application>psql</application>
+ is executed. In addition, the correct parameters to identify
+ the database server, such as the
+ <application>postmaster</application> host name,
+ may need to be specified
+ as described below.
+ </para>
+ <para>
+ When
+ <application>psql</application>
+ starts, it reads SQL commands from
+ <filename>/etc/psqlrc</filename>
+ and then from
+ <filename>$(<envar>HOME</envar>)/.psqlrc</filename>
+ This allows SQL commands like
+ <command>SET</command>
+ which can be used to set the date style to be run at the start of
+ every session.
+ </para>
+
+ <REFSECT2 ID="R2-APP-PSQL-3">
+ <REFSECT2INFO>
+ <DATE>1998-09-26</DATE>
+ </REFSECT2INFO>
+ <TITLE>
+ Connecting To A Database
+ </TITLE>
+ <para>
+ <application>psql</application>
+ attempts to make a connection to the database at the hostname and
+ port number specified on the command line. If the connection could not
+ be made for any reason (e.g. insufficient privileges, postmaster is not
+ running on the server, etc)
+ .IR <application>psql</application>
+ will return an error that says
+ <programlisting>
+ Connection to database failed.
+ </programlisting>
+ The reason for the connection failure is not provided.
+ </para>
+ </refsect2>
+
+ <REFSECT2 ID="R2-APP-PSQL-4">
+ <REFSECT2INFO>
+ <DATE>1998-09-26</DATE>
+ </REFSECT2INFO>
+ <TITLE>
+ Entering Queries
+ </TITLE>
+ <para>
+ In normal operation,
+ <application>psql</application> provides a prompt with the name of the
+ database that <application>psql</application> is current connected to
+ followed by the string "=>".
+ For example,
+ <programlisting>
+ $ <userinput>psql testdb</userinput>
+ Welcome to the POSTGRESQL interactive sql monitor:
+ Please read the file COPYRIGHT for copyright terms of POSTGRESQL
+
+ type \e? for help on slash commands
+ type \eq to quit
+ type \eg or terminate with semicolon to execute query
+ You are currently connected to the database: testdb
+
+ testdb=>
+ </programlisting>
+ </para>
+ <para>
+ At the prompt, the user may type in <acronym>SQL</acronym> queries.
+ Unless the -S option
+ is set, input lines are sent to the backend when a query-terminating
+ semicolon is reached.
+ </para>
+ <para>
+ Whenever a query is executed,
+ <application>psql</application> also polls for asynchronous notification
+ events generated by <command>LISTEN</command> and <command>NOTIFY</command>.
+ </para>
+ <para>
+ <application>psql</application>
+ can be used in a pipe sequence, and automatically detects when it
+ is not listening or talking to a real tty.
+ </para>
+ </refsect2>
+ </refsect1>
+
+ <REFSECT1 ID="R1-APP-PSQL-2">
+ <REFSECT1INFO>
+ <DATE>1998-09-26</DATE>
+ </REFSECT1INFO>
+ <TITLE>
+ Command-line Options
+ </TITLE>
+ <para>
+ <application>psql</application>
+ understands the following command-line options:
+
+ <VARIABLELIST>
+ <VARLISTENTRY>
+ <TERM>
+ -A
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Turn off fill justification when printing out table elements.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <VARLISTENTRY>
+ <TERM>
+ -c <replaceable class="parameter">query</replaceable>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Specifies that
+ <application>psql</application>
+ is to execute one query string,
+ <replaceable class="parameter">query</replaceable>,
+ and then exit. This is useful for shell scripts, typically in
+ conjunction with the <option>-q</option> option in shell scripts.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <VARLISTENTRY>
+ <TERM>
+ -d <replaceable class="parameter">dbname</replaceable>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Specifies the name of the database to connect to. This is equivalent to specifying
+ <replaceable class="parameter">dbname</replaceable> as the last field in the
+ command line.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <VARLISTENTRY>
+ <TERM>
+ -e
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Echo the query sent to the backend
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <VARLISTENTRY>
+ <TERM>
+ -f <replaceable class="parameter">filename</replaceable>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Use the file <replaceable class="parameter">filename</replaceable>
+ as the source of queries instead of reading queries interactively.
+ This file must be specified for and visible to the client frontend.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <VARLISTENTRY>
+ <TERM>
+ -F <replaceable class="parameter">separator</replaceable>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Use <replaceable class="parameter">separator</replaceable>
+ as the field separator.
+ The default is an ASCII vertical bar ("|").
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <VARLISTENTRY>
+ <TERM>
+ -h <replaceable class="parameter">hostname</replaceable>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Specifies the host name of the machine on which the
+ <application>postmaster</application>
+ is running.
+ Without this option, communication is performed using
+ local Unix domain sockets.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <VARLISTENTRY>
+ <TERM>
+ -H
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Turns on
+ <acronym>HTML 3.0</acronym>
+ tabular output.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <VARLISTENTRY>
+ <TERM>
+ -l
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Lists all available databases, then exit. Other non-connection options are ignored.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <VARLISTENTRY>
+ <TERM>
+ -n
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Do not use the readline library for input line editing and command history.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <VARLISTENTRY>
+ <TERM>
+ -o <replaceable class="parameter">filename</replaceable>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Put all output into file <replaceable class="parameter">filename</replaceable>.
+ The path must be writable by the client.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <VARLISTENTRY>
+ <TERM>
+ -p <replaceable class="parameter">port</replaceable>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Specifies the TCP/IP port or, by omission, the local Unix domain socket file
+ extension on which the
+ <application>postmaster</application>
+ is listening for connections. Defaults to the value of the
+ <envar>PGPORT</envar>
+ environment variable, if set, or to 5432.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <VARLISTENTRY>
+ <TERM>
+ -q
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Specifies that
+ <application>psql</application>
+ should do its work quietly. By default, it
+ prints welcome and exit messages and prompts for each query, and prints
+ out the number of rows returned from a query.
+ If this option is used, none of this happens. This is useful with the
+ <option>-c</option> option.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <VARLISTENTRY>
+ <TERM>
+ -s
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Run in single-step mode where the user is prompted for each query before
+ it is sent to the backend.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <VARLISTENTRY>
+ <TERM>
+ -S
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Runs in single-line mode where each query is terminated by a newline,
+ instead of a semicolon.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <VARLISTENTRY>
+ <TERM>
+ -t
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Turn off printing of column names.
+ This is useful with the
+ <option>-c</option>
+ option in shell scripts.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <VARLISTENTRY>
+ <TERM>
+ -T <replaceable class="parameter">table_options</replaceable>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Allows you to specify options to be placed within the
+ <sgmltag>table ...</sgmltag> tag for <acronym>HTML 3.0</acronym>
+ tabular output.For example, <literal>border</literal>
+ will give you tables with borders.
+ This must be used in conjunction with the <option>-H</option> option.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <VARLISTENTRY>
+ <TERM>
+ -u
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Asks the user for the user name and password before connecting to the database.
+ If the database does not require password authentication then these are
+ ignored. If the option is not used (and the PGPASSWORD environment variable
+ is not set) and the database requires password authentication, then the
+ connection will fail. The user name is ignored anyway.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <VARLISTENTRY>
+ <TERM>
+ -x
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Turns on extended row format mode. When enabled each row will have its column
+ names printed on the left with the column values printed on the right.
+ This is useful for rows which are otherwise too long to fit into
+ one screen line. HTML row output supports this mode also.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </para>
+ <para>
+ You may set environment variables to avoid typing some of the above
+ options. See the section on environment variables below.
+ </para>
+ </refsect1>
+
+ <REFSECT1 ID="R1-APP-PSQL-3">
+ <REFSECT1INFO>
+ <DATE>1998-09-26</DATE>
+ </REFSECT1INFO>
+ <TITLE>
+ <application>psql</application> Meta-Commands
+ </TITLE>
+ <para>
+ Anything you enter in <application>psql</application>
+ that begins with an unquoted backslash is a <application>psql</application>
+ meta-command. Anything else is <acronym>SQL</acronym>
+ and simply goes into the current query buffer
+ (and once you have at least one complete query, it gets automatically
+ submitted to the backend).
+ <Application>psql</Application> meta-commands are also called slash commands.
+ </para>
+ <para>
+ The format of a <application>psql</application> command is the backslash,
+ followed immediately by
+ a command verb, then any arguments. The arguments are separated from the
+ command verb and each other by any number of white space characters.
+ </para>
+ <para>
+ With single character command verbs, you don't actually need to separate the
+ command verb from the argument with white space, for historical reasons.
+ You should anyway.
+ </para>
+ <para>
+ The following meta-commands are defined:
+
+ <VARIABLELIST>
+ <VARLISTENTRY>
+ <TERM>
+ <literal>\a</literal>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Toggle field alignment when printing out table elements.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <VARLISTENTRY>
+ <TERM>
+ <literal>\C</literal> <replaceable class="parameter">caption</replaceable>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Set the HTML3.0 table caption to
+ <quote><replaceable class="parameter">caption</replaceable></quote>.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <VARLISTENTRY>
+ <TERM>
+ <literal>\connect</literal> <replaceable class="parameter">dbname</replaceable> [ <replaceable class="parameter">username</replaceable> ]
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Establish a connection to a new database, using the default
+ <replaceable class="parameter">username</replaceable> if none is specified.
+ The previous connection is closed.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <VARLISTENTRY>
+ <TERM>
+ <literal>\copy</literal> <replaceable class="parameter">dbname</replaceable> { FROM | TO } <replaceable class="parameter">filename</replaceable>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Perform a frontend (client) copy. This is an operation that runs a SQL COPY command,
+ but instead of the backend reading or writing the specified file, and
+ consequently requiring backend access and special user privilege,
+ <application>psql</application> reads or writes the
+ file and routes the data to or from the backend. The default <literal>tab</literal>
+ delimiter is used.
+ </para>
+ <tip>
+ <para>
+ This operation is not as efficient as the <acronym>SQL</acronym>
+ <command>COPY</command> command because all data must pass through the
+ client/server IP or socket connection. For large amounts of data this other
+ technique may be preferable.
+ </para>
+ </tip>
+ </listitem>
+ </varlistentry>
+
+ <VARLISTENTRY>
+ <TERM>
+ <literal>\d</literal> [ <replaceable class="parameter">table</replaceable> ]
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ List tables in the database, or if <replaceable class="parameter">table</replaceable>
+ is specified, list the columns in that table.
+ If table name is specified as an asterisk (<quote>*</quote>),
+ list all tables and column information for each tables.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <VARLISTENTRY>
+ <TERM>
+ <literal>\da</literal>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ List all available aggregates.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <VARLISTENTRY>
+ <TERM>
+ <literal>\dd</literal> <replaceable class="parameter">object</replaceable>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ List the description from <literal>pg_description</literal>
+ of the specified object, which can be a
+ table, table.column, type, operator, or aggregate.
+ </para>
+ <tip>
+ <para>
+ Not all objects have a description in <literal>pg_description</literal>.
+ This meta-command can be useful to get a quick description of a native
+ <productname>Postgres</productname> feature.
+ </para>
+ </tip>
+ </listitem>
+ </varlistentry>
+
+ <VARLISTENTRY>
+ <TERM>
+ <literal>\df</literal>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ List functions.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <VARLISTENTRY>
+ <TERM>
+ <literal>\di</literal>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ List only indexes.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <VARLISTENTRY>
+ <TERM>
+ <literal>\do</literal>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ List only operators.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <VARLISTENTRY>
+ <TERM>
+ <literal>\ds</literal>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ List only sequences.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <VARLISTENTRY>
+ <TERM>
+ <literal>\dS</literal>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ List system tables and indexes.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <VARLISTENTRY>
+ <TERM>
+ <literal>\dt</literal>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ List only non-system tables.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <VARLISTENTRY>
+ <TERM>
+ <literal>\dT</literal>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ List types.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <VARLISTENTRY>
+ <TERM>
+ <literal>\e</literal> [ <replaceable class="parameter">filename</replaceable> ]
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Edit the current query buffer or the contents of the file
+ <replaceable class="parameter">filename</replaceable>.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <VARLISTENTRY>
+ <TERM>
+ <literal>\E</literal> [ <replaceable class="parameter">filename</replaceable> ]
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Edit the current query buffer or the contents of the file
+ <replaceable class="parameter">filename</replaceable>
+ and execute it upon editor exit.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <VARLISTENTRY>
+ <TERM>
+ <literal>\f</literal> [ <replaceable class="parameter">separator</replaceable> ]
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Set the field separator. Default is a single blank space.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <VARLISTENTRY>
+ <TERM>
+ <literal>\g</literal> [ { <replaceable class="parameter">filename</replaceable> | <literal>|</literal><replaceable class="parameter">command</replaceable> } ]
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Send the current query input buffer to the backend and optionally
+ save the output in <replaceable class="parameter">filename</replaceable>
+ or pipe the output into a separate Unix shell to execute
+ <replaceable class="parameter">command</replaceable>.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <VARLISTENTRY>
+ <TERM>
+ <literal>\h</literal> [ <replaceable class="parameter">command</replaceable> ]
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Give syntax help on the specified SQL command.
+ If <replaceable class="parameter">command</replaceable> is not a defined SQL command
+ (or is not documented in <application>psql</application>), or if
+ <replaceable class="parameter">command</replaceable> is not specified,
+ then <application>psql</application> will
+ list all the commands for which syntax help is
+ available. If <replaceable class="parameter">command</replaceable>
+ is an asterisk (<quote>*</quote>), then
+ give syntax help on all SQL commands.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <VARLISTENTRY>
+ <TERM>
+ <literal>\H</literal>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Toggle <acronym>HTML3</acronym> output. This is equivalent to the <option>-H</option>
+ command-line option.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <VARLISTENTRY>
+ <TERM>
+ <literal>\i</literal> <replaceable class="parameter">filename</replaceable>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Read queries from the file <replaceable class="parameter">filename</replaceable>
+ into the query input buffer.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <VARLISTENTRY>
+ <TERM>
+ <literal>\l</literal>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ List all the databases in the server.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <VARLISTENTRY>
+ <TERM>
+ <literal>\m</literal>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Toggle the old monitor-like table display, which includes border characters
+ surrounding the table.
+ This is standard SQL output.
+ By default, <application>psql</application> includes only field separators
+ between columns.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <VARLISTENTRY>
+ <TERM>
+ <literal>\o</literal> [ { <replaceable class="parameter">filename</replaceable> | <literal>|</literal><replaceable class="parameter">command</replaceable> } ]
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Save future query results to the file
+ <replaceable class="parameter">filename</replaceable> or pipe future
+ results into a separate Unix shell to execute
+ <replaceable class="parameter">command</replaceable>.
+ If no arguments are specified, send query results to
+ <filename>stdout</filename>.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <VARLISTENTRY>
+ <TERM>
+ <literal>\p</literal>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Print the current query buffer.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <VARLISTENTRY>
+ <TERM>
+ <literal>\q</literal>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Quit the <application>psql</application> program.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <VARLISTENTRY>
+ <TERM>
+ <literal>\r</literal>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Reset(clear) the query buffer.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <VARLISTENTRY>
+ <TERM>
+ <literal>\s</literal> [ <replaceable class="parameter">filename</replaceable> ]
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Print or save the command line history to
+ <replaceable class="parameter">filename</replaceable>.
+ If <replaceable class="parameter">filename</replaceable> is omitted,
+ do not save subsequent commands to a history file.
+ This option is only available if <application>psql</application> is
+ configured to use readline.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <VARLISTENTRY>
+ <TERM>
+ <literal>\t</literal>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Toggle display of output column name headings and row count footer (defaults to on).
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <VARLISTENTRY>
+ <TERM>
+ <literal>\T</literal> <replaceable class="parameter">table_options</replaceable>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Allows you to specify options to be placed within the
+ <sgmltag>table ...</sgmltag> tag
+ for <acronym>HTML 3.0</acronym>
+ tabular output.For example, <literal>border</literal>
+ will give you tables with borders.
+ This must be used in conjunction with the <command>\H</command> meta-command.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <VARLISTENTRY>
+ <TERM>
+ <literal>\x</literal>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Toggles extended row format mode. When enabled each row will have its column
+ names printed on the left with the column values printed on the right.
+ This is useful for rows which are otherwise too long to fit into
+ one screen line. <acronym>HTML</acronym> row output mode supports this flag too.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <VARLISTENTRY>
+ <TERM>
+ <literal>\w</literal> <replaceable class="parameter">filename</replaceable>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Outputs the current query buffer to the file
+ <replaceable class="parameter">filename</replaceable>.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <VARLISTENTRY>
+ <TERM>
+ <literal>\z</literal>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Produces a list of all tables in the database with their appropriate ACLs
+ (grant/revoke permissions) listed.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <VARLISTENTRY>
+ <TERM>
+ <literal>\!</literal> [ <replaceable class="parameter">command</replaceable> ]
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Escape to a separate Unix shell or execute the Unix command
+ <replaceable class="parameter">command</replaceable>.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <VARLISTENTRY>
+ <TERM>
+ <literal>\?</literal>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Get help information about the slash (<quote>\</quote>) commands.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </para>
+ </refsect1>
</refentry>
<REFPURPOSE>
Restores run-time parameters for session to default values
</REFPURPOSE>
-
+ </refnamediv>
<REFSYNOPSISDIV>
<REFSYNOPSISDIVINFO>
<DATE>1998-09-24</DATE>
RESET <REPLACEABLE CLASS="PARAMETER">variable</REPLACEABLE>
</SYNOPSIS>
-<REFSECT2 ID="R2-SQL-RESET-1">
-<REFSECT2INFO>
-<DATE>1998-09-24</DATE>
-</REFSECT2INFO>
-<TITLE>
-Inputs
-</TITLE>
-<PARA>
-
-<VARIABLELIST>
-<VARLISTENTRY>
-<TERM>
-<REPLACEABLE CLASS="PARAMETER">variable</REPLACEABLE>
-</TERM>
-<LISTITEM>
-<PARA>
- Refer to the SET statement for more information on available
- variables.
-</variablelist>
-
-</REFSECT2>
-
-<REFSECT2 ID="R2-SQL-RESET-2">
-<REFSECT2INFO>
-<DATE>1998-09-24</DATE>
-</REFSECT2INFO>
-<TITLE>
-Outputs
-</TITLE>
-<PARA>
-
-<VARIABLELIST>
-<VARLISTENTRY>
-<TERM>
-RESET VARIABLE
-</TERM>
-<LISTITEM>
-<PARA>
- Message returned if
-<REPLACEABLE CLASS="PARAMETER">variable</REPLACEABLE> is successfully reset
-to its default value..
-
-</VARIABLELIST>
-
-</REFSECT2>
-</REFSYNOPSISDIV>
-
-<REFSECT1 ID="R1-SQL-RESET-1">
-<REFSECT1INFO>
-<DATE>1998-09-24</DATE>
-</REFSECT1INFO>
-<TITLE>
-Description
-</TITLE>
-<PARA>
- <command>RESET</command> restores variables to the
- default values.
-Refer to the <command>SET</command> command for details on
- allowed values and defaults.
-<command>RESET</command> is an alternate form for
-<synopsis>
-<command>SET <replaceable class="parameter">variable</replaceable> = DEFAULT</command>
-</synopsis>
-
-<REFSECT2 ID="R2-SQL-RESET-3">
-<REFSECT2INFO>
-<DATE>1998-09-24</DATE>
-</REFSECT2INFO>
-<TITLE>
-Notes
-</TITLE>
-<PARA>
-The RESET statement is a <productname>Postgres</productname> language extension.
-<para>
- Refer to SET/SHOW statements to set/show variable values.
-
-</REFSECT2>
-</refsect1>
-
-<REFSECT1 ID="R1-SQL-RESET-2">
-<TITLE>
-Usage
-</TITLE>
-<PARA>
-<ProgramListing>
--- reset DateStyle to its default;
-RESET DateStyle;
-</programlisting>
-<programlisting>
--- reset Geqo to its default;
-RESET GEQO;
-</ProgramListing>
-
-</REFSECT1>
-
-<REFSECT1 ID="R1-SQL-RESET-3">
-<TITLE>
-Compatibility
-</TITLE>
-<PARA>
-
-<REFSECT2 ID="R2-SQL-RESET-4">
-<REFSECT2INFO>
-<DATE>1998-09-24</DATE>
-</REFSECT2INFO>
-<TITLE>
-SQL92
-</TITLE>
-<PARA>
- There is no <command>RESET</command> in <acronym>SQL92</acronym>.
-
+ <REFSECT2 ID="R2-SQL-RESET-1">
+ <REFSECT2INFO>
+ <DATE>1998-09-24</DATE>
+ </REFSECT2INFO>
+ <TITLE>
+ Inputs
+ </TITLE>
+ <PARA>
+ <VARIABLELIST>
+ <VARLISTENTRY>
+ <TERM>
+ <REPLACEABLE CLASS="PARAMETER">variable</REPLACEABLE>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Refer to the SET statement for more information on available
+ variables.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </para>
+ </REFSECT2>
+
+ <REFSECT2 ID="R2-SQL-RESET-2">
+ <REFSECT2INFO>
+ <DATE>1998-09-24</DATE>
+ </REFSECT2INFO>
+ <TITLE>
+ Outputs
+ </TITLE>
+ <PARA>
+
+ <VARIABLELIST>
+ <VARLISTENTRY>
+ <TERM>
+ RESET VARIABLE
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Message returned if
+ <REPLACEABLE CLASS="PARAMETER">variable</REPLACEABLE> is successfully reset
+ to its default value..
+ </para>
+ </listitem>
+ </varlistentry>
+ </VARIABLELIST>
+ </para>
+ </REFSECT2>
+ </REFSYNOPSISDIV>
+
+ <REFSECT1 ID="R1-SQL-RESET-1">
+ <REFSECT1INFO>
+ <DATE>1998-09-24</DATE>
+ </REFSECT1INFO>
+ <TITLE>
+ Description
+ </TITLE>
+ <PARA>
+ <command>RESET</command> restores variables to the
+ default values.
+ Refer to the <command>SET</command> command for details on
+ allowed values and defaults.
+ <command>RESET</command> is an alternate form for
+ <synopsis>
+ <command>SET <replaceable class="parameter">variable</replaceable> = DEFAULT</command>
+ </synopsis>
+ </para>
+
+ <REFSECT2 ID="R2-SQL-RESET-3">
+ <REFSECT2INFO>
+ <DATE>1998-09-24</DATE>
+ </REFSECT2INFO>
+ <TITLE>
+ Notes
+ </TITLE>
+ <PARA>
+ The RESET statement is a <productname>Postgres</productname> language extension.
+ </para>
+ <para>
+ Refer to SET/SHOW statements to set/show variable values.
+ </para>
+ </REFSECT2>
+ </refsect1>
+
+ <REFSECT1 ID="R1-SQL-RESET-2">
+ <TITLE>
+ Usage
+ </TITLE>
+ <PARA>
+ <ProgramListing>
+ -- reset DateStyle to its default;
+ RESET DateStyle;
+ </programlisting>
+ <programlisting>
+ -- reset Geqo to its default;
+ RESET GEQO;
+ </ProgramListing>
+ </para>
+ </REFSECT1>
+
+ <REFSECT1 ID="R1-SQL-RESET-3">
+ <TITLE>
+ Compatibility
+ </TITLE>
+
+ <REFSECT2 ID="R2-SQL-RESET-4">
+ <REFSECT2INFO>
+ <DATE>1998-09-24</DATE>
+ </REFSECT2INFO>
+ <TITLE>
+ SQL92
+ </TITLE>
+ <PARA>
+ There is no <command>RESET</command> in <acronym>SQL92</acronym>.
+ </para>
+ </refsect2>
+ </refsect1>
</REFENTRY>
<REFPURPOSE>
Revokes access privilege from a user, a group or all users.
</REFPURPOSE>
-
+ </refnamediv>
<REFSYNOPSISDIV>
<REFSYNOPSISDIVINFO>
<DATE>1998-09-24</DATE>
FROM { PUBLIC | GROUP <REPLACEABLE CLASS="PARAMETER">group</REPLACEABLE> | <REPLACEABLE CLASS="PARAMETER">username</REPLACEABLE> }
</SYNOPSIS>
-<REFSECT2 ID="R2-SQL-REVOKE-1">
-<REFSECT2INFO>
-<DATE>1998-09-24</DATE>
-</REFSECT2INFO>
-<TITLE>
-Inputs
-</TITLE>
-<PARA>
-
-<VARIABLELIST>
-<VARLISTENTRY>
-<TERM>
-<REPLACEABLE CLASS="PARAMETER">privilege</REPLACEABLE>
-</TERM>
-<LISTITEM>
-<PARA>
- The possible privileges are:
-
-<VARIABLELIST>
-<VARLISTENTRY>
-<TERM>
-SELECT
-</TERM>
-<LISTITEM>
-<PARA>
-Privilege to access all of the columns of a specific
- table/view.
-</PARA>
-</LISTITEM>
-</VARLISTENTRY>
-
-<VARLISTENTRY>
-<TERM>
-INSERT
-</TERM>
-<LISTITEM>
-<PARA>
-Privilege to insert data into all columns of a
- specific table.
-
-<VARLISTENTRY>
-<TERM>
-UPDATE
-</TERM>
-<LISTITEM>
-<PARA>
-Privilege to update all columns of a specific
- table.
-
-<VARLISTENTRY>
-<TERM>
-DELETE
-</TERM>
-<LISTITEM>
-<PARA>
-Privilege to delete rows from a specific table.
-
-<VARLISTENTRY>
-<TERM>
-RULE
-</TERM>
-<LISTITEM>
-<PARA>
-Privilege to define rules on table/view.
-(See <command>CREATE RULE</command>).
-
-<VARLISTENTRY>
-<TERM>
-ALL
-</TERM>
-<LISTITEM>
-<PARA>
-Rescind all privileges.
-
-</VARIABLELIST>
-
-<VARLISTENTRY>
-<TERM>
-<REPLACEABLE CLASS="PARAMETER">object</REPLACEABLE>
-</TERM>
-<LISTITEM>
-<PARA>
-The name of an object from which to revoke access.
- The possible objects are:
-<itemizedlist mark="bullet" spacing="compact">
-<listitem>
-<para>
-table
-
-<listitem>
-<para>
-view
-
-<listitem>
-<para>
-sequence
-
-<listitem>
-<para>
-index
-</itemizedlist>
-
-<VARLISTENTRY>
-<TERM>
-<REPLACEABLE CLASS="PARAMETER">group</REPLACEABLE>
-</TERM>
-<LISTITEM>
-<PARA>
- The name of a group from whom to revoke privileges.
-</PARA>
-</LISTITEM>
-</VARLISTENTRY>
-
-<VARLISTENTRY>
-<TERM>
-<REPLACEABLE CLASS="PARAMETER">username</REPLACEABLE>
-</TERM>
-<LISTITEM>
-<PARA>
-The name of a user from whom revoke privileges. Use the PUBLIC keyword
-to specify all users.
-</PARA>
-</LISTITEM>
-</VARLISTENTRY>
-
-<VARLISTENTRY>
-<TERM>
-PUBLIC
-</TERM>
-<LISTITEM>
-<PARA>
-Rescind the specified privilege(s) for all users.
-
-</LISTITEM>
-</VARLISTENTRY>
-</VARIABLELIST>
-
-</REFSECT2>
-
-<REFSECT2 ID="R2-SQL-REVOKE-2">
-<REFSECT2INFO>
-<DATE>1998-09-24</DATE>
-</REFSECT2INFO>
-<TITLE>
-Outputs
-</TITLE>
-<PARA>
-
-<VARIABLELIST>
-<VARLISTENTRY>
-<TERM>
-CHANGE
-</TERM>
-<LISTITEM>
-<PARA>
- Message returned if successfully.
-
-<VARLISTENTRY>
-<TERM>
-ERROR
-</TERM>
-<LISTITEM>
-<PARA>
- Message returned if object is not available or impossible
- to revoke privileges from a group or users.
-
-</VARIABLELIST>
-
-</REFSECT2>
-</REFSYNOPSISDIV>
-
-<REFSECT1 ID="R1-SQL-REVOKE-1">
-<REFSECT1INFO>
-<DATE>1998-09-24</DATE>
-</REFSECT1INFO>
-<TITLE>
-Description
-</TITLE>
-<PARA>
- REVOKE allows creator of an object to revoke permissions granted
- before, from all users (via PUBLIC) or a certain user or group.
-
-<REFSECT2 ID="R2-SQL-REVOKE-3">
-<REFSECT2INFO>
-<DATE>1998-09-24</DATE>
-</REFSECT2INFO>
-<TITLE>
-Notes
-</TITLE>
-<PARA>
- Refer to psql \z command for further information about permissions
- on existing objects:
-
-<programlisting>
- Database = lusitania
- +------------------+---------------------------------------------+
- | Relation | Grant/Revoke Permissions |
- +------------------+---------------------------------------------+
- | mytable | {"=rw","miriam=arwR","group todos=rw"} |
- +------------------+---------------------------------------------+
- Legend:
- uname=arwR -- privileges granted to a user
- group gname=arwR -- privileges granted to a GROUP
- =arwR -- privileges granted to PUBLIC
-
- r -- SELECT
- w -- UPDATE/DELETE
- a -- INSERT
- R -- RULE
- arwR -- ALL
-</programlisting>
-
-<tip>
-<para>
-Currently, to create a GROUP you have to insert
+ <REFSECT2 ID="R2-SQL-REVOKE-1">
+ <REFSECT2INFO>
+ <DATE>1998-09-24</DATE>
+ </REFSECT2INFO>
+ <TITLE>
+ Inputs
+ </TITLE>
+ <PARA>
+
+ <VARIABLELIST>
+ <VARLISTENTRY>
+ <TERM>
+ <REPLACEABLE CLASS="PARAMETER">privilege</REPLACEABLE>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ The possible privileges are:
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <VARLISTENTRY>
+ <TERM>
+ SELECT
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Privilege to access all of the columns of a specific
+ table/view.
+ </PARA>
+ </LISTITEM>
+ </VARLISTENTRY>
+
+ <VARLISTENTRY>
+ <TERM>
+ INSERT
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Privilege to insert data into all columns of a
+ specific table.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <VARLISTENTRY>
+ <TERM>
+ UPDATE
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Privilege to update all columns of a specific
+ table.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <VARLISTENTRY>
+ <TERM>
+ DELETE
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Privilege to delete rows from a specific table.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <VARLISTENTRY>
+ <TERM>
+ RULE
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Privilege to define rules on table/view.
+ (See <command>CREATE RULE</command>).
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <VARLISTENTRY>
+ <TERM>
+ ALL
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Rescind all privileges.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <VARLISTENTRY>
+ <TERM>
+ <REPLACEABLE CLASS="PARAMETER">object</REPLACEABLE>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ The name of an object from which to revoke access.
+ The possible objects are:
+ <itemizedlist mark="bullet" spacing="compact">
+ <listitem>
+ <para>
+ table
+ </para>
+ </listitem>
+
+ <listitem>
+ <para>
+ view
+ </para>
+ </listitem>
+
+ <listitem>
+ <para>
+ sequence
+ </para>
+ </listitem>
+
+ <listitem>
+ <para>
+ index
+ </para>
+ </listitem>
+ </itemizedlist>
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <VARLISTENTRY>
+ <TERM>
+ <REPLACEABLE CLASS="PARAMETER">group</REPLACEABLE>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ The name of a group from whom to revoke privileges.
+ </PARA>
+ </LISTITEM>
+ </VARLISTENTRY>
+
+ <VARLISTENTRY>
+ <TERM>
+ <REPLACEABLE CLASS="PARAMETER">username</REPLACEABLE>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ The name of a user from whom revoke privileges. Use the PUBLIC keyword
+ to specify all users.
+ </PARA>
+ </LISTITEM>
+ </VARLISTENTRY>
+
+ <VARLISTENTRY>
+ <TERM>
+ PUBLIC
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Rescind the specified privilege(s) for all users.
+ </para>
+ </LISTITEM>
+ </VARLISTENTRY>
+ </VARIABLELIST>
+ </para>
+ </REFSECT2>
+
+ <REFSECT2 ID="R2-SQL-REVOKE-2">
+ <REFSECT2INFO>
+ <DATE>1998-09-24</DATE>
+ </REFSECT2INFO>
+ <TITLE>
+ Outputs
+ </TITLE>
+ <PARA>
+
+ <VARIABLELIST>
+ <VARLISTENTRY>
+ <TERM>
+ CHANGE
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Message returned if successfully.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <VARLISTENTRY>
+ <TERM>
+ ERROR
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Message returned if object is not available or impossible
+ to revoke privileges from a group or users.
+ </para>
+ </listitem>
+ </varlistentry>
+ </VARIABLELIST>
+ </para>
+ </REFSECT2>
+ </REFSYNOPSISDIV>
+
+ <REFSECT1 ID="R1-SQL-REVOKE-1">
+ <REFSECT1INFO>
+ <DATE>1998-09-24</DATE>
+ </REFSECT1INFO>
+ <TITLE>
+ Description
+ </TITLE>
+ <PARA>
+ REVOKE allows creator of an object to revoke permissions granted
+ before, from all users (via PUBLIC) or a certain user or group.
+ </para>
+
+ <REFSECT2 ID="R2-SQL-REVOKE-3">
+ <REFSECT2INFO>
+ <DATE>1998-09-24</DATE>
+ </REFSECT2INFO>
+ <TITLE>
+ Notes
+ </TITLE>
+ <PARA>
+ Refer to psql \z command for further information about permissions
+ on existing objects:
+
+ <programlisting>
+ Database = lusitania
+ +------------------+---------------------------------------------+
+ | Relation | Grant/Revoke Permissions |
+ +------------------+---------------------------------------------+
+ | mytable | {"=rw","miriam=arwR","group todos=rw"} |
+ +------------------+---------------------------------------------+
+ Legend:
+ uname=arwR -- privileges granted to a user
+ group gname=arwR -- privileges granted to a GROUP
+ =arwR -- privileges granted to PUBLIC
+
+ r -- SELECT
+ w -- UPDATE/DELETE
+ a -- INSERT
+ R -- RULE
+ arwR -- ALL
+ </programlisting>
+ </para>
+ <tip>
+ <para>
+ Currently, to create a GROUP you have to insert
data manually into table pg_group as:
-<programlisting>
- INSERT INTO pg_group VALUES ('todos');
- CREATE USER miriam IN GROUP todos;
-</programlisting>
-</tip>
-
-</REFSECT2>
-
-<REFSECT1 ID="R1-SQL-REVOKE-2">
-<TITLE>
-Usage
-</TITLE>
-<PARA>
-<ProgramListing>
--- revoke insert privilege from all users on table films:
---
-REVOKE INSERT ON films FROM PUBLIC;
-
--- revoke all privileges from user manuel on view kinds:
---
-REVOKE ALL ON kinds FROM manuel;
-</ProgramListing>
-
-</REFSECT1>
-
-<REFSECT1 ID="R1-SQL-REVOKE-3">
-<TITLE>
-Compatibility
-</TITLE>
-<PARA>
-
-<REFSECT2 ID="R2-SQL-REVOKE-4">
-<REFSECT2INFO>
-<DATE>1998-09-01</DATE>
-</REFSECT2INFO>
-<TITLE>
-SQL92
-</TITLE>
-<PARA>
- The SQL92 syntax for <command>REVOKE</command>
- has additional capabilities for rescinding
-privileges, including those on individual columns in tables:
-
-<variablelist>
-<varlistentry>
-<term>
-<synopsis>
-REVOKE { SELECT | DELETE | USAGE | ALL PRIVILEGES } [, ...]
- ON <replaceable class="parameter">object</replaceable>
- FROM { PUBLIC | <replaceable class="parameter">username</replaceable> [, ...] } { RESTRICT | CASCADE }
-REVOKE { INSERT | UPDATE | REFERENCES } [, ...] [ ( <replaceable class="parameter">column</replaceable> [, ...] ) ]
- ON <replaceable class="parameter">object</replaceable>
- FROM { PUBLIC | <replaceable class="parameter">username</replaceable> [, ...] } { RESTRICT | CASCADE }
-</synopsis>
-<listitem>
-<para>
-Refer to the <command>GRANT</command> command for details on individual fields.
-
-<varlistentry>
-<term>
-<synopsis>
-REVOKE GRANT OPTION FOR <replaceable class="parameter">privilege</replaceable> [, ...]
- ON <replaceable class="parameter">object</replaceable>
- FROM { PUBLIC | <replaceable class="parameter">username</replaceable> [, ...] } { RESTRICT | CASCADE }
-</synopsis>
-<listitem>
-<para>
-Rescinds authority for a user to grant the specified privilege to others.
-Refer to the <command>GRANT</command> command for details on individual fields.
-
-</variablelist>
-
-<para>
- The possible objects are:
-<simplelist>
-<member> [ TABLE ] table/view
-<member> CHARACTER SET character-set
-<member> COLLATION collation
-<member> TRANSLATION translation
-<member> DOMAIN domain
-</simplelist>
-
-<para>
-If user1 gives a privilege WITH GRANT OPTION to user2,
- and user2 gives it to user3 then user1 can revoke
- this privilege in cascade using the CASCADE keyword.
-
-<para>
-If user1 gives a privilege WITH GRANT OPTION to user2,
- and user2 gives it to user3 then if user1 try revoke
- this privilege it fails if he/she specify the RESTRICT
- keyword.
+ <programlisting>
+ INSERT INTO pg_group VALUES ('todos');
+ CREATE USER miriam IN GROUP todos;
+ </programlisting>
+ </para>
+ </tip>
+
+ </REFSECT2>
+ </refsect1>
+
+ <REFSECT1 ID="R1-SQL-REVOKE-2">
+ <TITLE>
+ Usage
+ </TITLE>
+ <PARA>
+ <ProgramListing>
+ -- revoke insert privilege from all users on table films:
+ --
+ REVOKE INSERT ON films FROM PUBLIC;
+
+ -- revoke all privileges from user manuel on view kinds:
+ --
+ REVOKE ALL ON kinds FROM manuel;
+ </ProgramListing>
+ </para>
+ </REFSECT1>
+
+ <REFSECT1 ID="R1-SQL-REVOKE-3">
+ <TITLE>
+ Compatibility
+ </TITLE>
+
+ <REFSECT2 ID="R2-SQL-REVOKE-4">
+ <REFSECT2INFO>
+ <DATE>1998-09-01</DATE>
+ </REFSECT2INFO>
+ <TITLE>
+ SQL92
+ </TITLE>
+ <PARA>
+ The SQL92 syntax for <command>REVOKE</command>
+ has additional capabilities for rescinding
+ privileges, including those on individual columns in tables:
+
+ <variablelist>
+ <varlistentry>
+ <term>
+ <synopsis>
+ REVOKE { SELECT | DELETE | USAGE | ALL PRIVILEGES } [, ...]
+ ON <replaceable class="parameter">object</replaceable>
+ FROM { PUBLIC | <replaceable class="parameter">username</replaceable> [, ...] } { RESTRICT | CASCADE }
+ REVOKE { INSERT | UPDATE | REFERENCES } [, ...] [ ( <replaceable class="parameter">column</replaceable> [, ...] ) ]
+ ON <replaceable class="parameter">object</replaceable>
+ FROM { PUBLIC | <replaceable class="parameter">username</replaceable> [, ...] } { RESTRICT | CASCADE }
+ </synopsis>
+ </term>
+ <listitem>
+ <para>
+ Refer to the <command>GRANT</command> command for details on individual fields.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ <synopsis>
+ REVOKE GRANT OPTION FOR <replaceable class="parameter">privilege</replaceable> [, ...]
+ ON <replaceable class="parameter">object</replaceable>
+ FROM { PUBLIC | <replaceable class="parameter">username</replaceable> [, ...] } { RESTRICT | CASCADE }
+ </synopsis>
+ </term>
+ <listitem>
+ <para>
+ Rescinds authority for a user to grant the specified privilege to others.
+ Refer to the <command>GRANT</command> command for details on individual fields.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </para>
+ <para>
+ The possible objects are:
+ <simplelist>
+ <member> [ TABLE ] table/view
+ </member>
+ <member> CHARACTER SET character-set
+ </member>
+ <member> COLLATION collation
+ </member>
+ <member> TRANSLATION translation
+ </member>
+ <member> DOMAIN domain
+ </member>
+ </simplelist>
+ </para>
+ <para>
+ If user1 gives a privilege WITH GRANT OPTION to user2,
+ and user2 gives it to user3 then user1 can revoke
+ this privilege in cascade using the CASCADE keyword.
+ </para>
+ <para>
+ If user1 gives a privilege WITH GRANT OPTION to user2,
+ and user2 gives it to user3 then if user1 try revoke
+ this privilege it fails if he/she specify the RESTRICT
+ keyword.
+ </para>
+ </refsect2>
+ </refsect1>
</REFENTRY>
<REFPURPOSE>
Aborts the current transaction
</REFPURPOSE>
+ </refnamediv>
<REFSYNOPSISDIV>
<REFSYNOPSISDIVINFO>
<DATE>1998-09-24</DATE>
ROLLBACK [ WORK ]
</SYNOPSIS>
-<REFSECT2 ID="R2-SQL-ROLLBACK-1">
-<REFSECT2INFO>
-<DATE>1998-09-24</DATE>
-</REFSECT2INFO>
-<TITLE>
-Inputs
-</TITLE>
-<PARA>
-None.
-
-</REFSECT2>
-
-<REFSECT2 ID="R2-SQL-ROLLBACK-2">
-<REFSECT2INFO>
-<DATE>1998-09-24</DATE>
-</REFSECT2INFO>
-<TITLE>
-Outputs
-</TITLE>
-<PARA>
-
-<VARIABLELIST>
-<VARLISTENTRY>
-<TERM>
- ABORT
-</TERM>
-<LISTITEM>
-<PARA>
- Message returned if successful.
-
-<VARLISTENTRY>
-<TERM>
-NOTICE: UserAbortTransactionBlock and not in in-progress state
-ABORT
-</TERM>
-<LISTITEM>
-<PARA>
- If there is not any transaction currently in progress.
-
-</VARLISTENTRY>
-</VARIABLELIST>
-
-</REFSECT2>
-</REFSYNOPSISDIV>
+ <REFSECT2 ID="R2-SQL-ROLLBACK-1">
+ <REFSECT2INFO>
+ <DATE>1998-09-24</DATE>
+ </REFSECT2INFO>
+ <TITLE>
+ Inputs
+ </TITLE>
+ <PARA>
+ None.
+ </para>
+ </REFSECT2>
-<REFSECT1 ID="R1-SQL-ROLLBACK-1">
-<REFSECT1INFO>
-<DATE>1998-09-24</DATE>
-</REFSECT1INFO>
-<TITLE>
-Description
-</TITLE>
-<PARA>
- <command>ROLLBACK</command> rolls back the current transaction and causes
- all the updates made by the transaction to be discarded.
-
-<REFSECT2 ID="R2-SQL-ROLLBACK-3">
-<REFSECT2INFO>
-<DATE>1998-09-24</DATE>
-</REFSECT2INFO>
-<TITLE>
-Notes
-</TITLE>
-<PARA>
-The keyword WORK is noise and can be omitted.
-
-<para>
-Use the <command>COMMIT</command> statement to successfully
- terminate a transaction.
+ <REFSECT2 ID="R2-SQL-ROLLBACK-2">
+ <REFSECT2INFO>
+ <DATE>1998-09-24</DATE>
+ </REFSECT2INFO>
+ <TITLE>
+ Outputs
+ </TITLE>
+ <PARA>
+
+ <VARIABLELIST>
+ <VARLISTENTRY>
+ <TERM>
+ ABORT
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Message returned if successful.
+ </para>
+ </listitem>
+ </VARLISTENTRY>
+
+ <VARLISTENTRY>
+ <TERM>
+ NOTICE: UserAbortTransactionBlock and not in in-progress state
+ ABORT
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ If there is not any transaction currently in progress.
+ </para>
+ </listitem>
+ </VARLISTENTRY>
+ </VARIABLELIST>
+ </para>
+ </REFSECT2>
+ </REFSYNOPSISDIV>
-</REFSECT1>
+ <REFSECT1 ID="R1-SQL-ROLLBACK-1">
+ <REFSECT1INFO>
+ <DATE>1998-09-24</DATE>
+ </REFSECT1INFO>
+ <TITLE>
+ Description
+ </TITLE>
+ <PARA>
+ <command>ROLLBACK</command> rolls back the current transaction and causes
+ all the updates made by the transaction to be discarded.
+ </para>
+ <REFSECT2 ID="R2-SQL-ROLLBACK-3">
+ <REFSECT2INFO>
+ <DATE>1998-09-24</DATE>
+ </REFSECT2INFO>
+ <TITLE>
+ Notes
+ </TITLE>
+ <PARA>
+ The keyword WORK is noise and can be omitted.
+ </para>
+ <para>
+ Use the <command>COMMIT</command> statement to successfully
+ terminate a transaction.
+ </para>
+ </refsect2>
+ </REFSECT1>
-<REFSECT1 ID="R1-SQL-ROLLBACK-2">
-<TITLE>
-Usage
-</TITLE>
-<PARA>
-<ProgramListing>
---To abort all changes:
---
-ROLLBACK WORK;
-</ProgramListing>
-
-</REFSECT1>
-
-<REFSECT1 ID="R1-SQL-ROLLBACK-3">
-<TITLE>
-Compatibility
-</TITLE>
-<PARA>
-</PARA>
-
-<REFSECT2 ID="R2-SQL-ROLLBACK-4">
-<REFSECT2INFO>
-<DATE>1998-09-24</DATE>
-</REFSECT2INFO>
-<TITLE>
-SQL92
-</TITLE>
-<PARA>
- Full compatibility.
+ <REFSECT1 ID="R1-SQL-ROLLBACK-2">
+ <TITLE>
+ Usage
+ </TITLE>
+ <PARA>
+ <ProgramListing>
+ --To abort all changes:
+ --
+ ROLLBACK WORK;
+ </ProgramListing>
+ </para>
+ </REFSECT1>
+
+ <REFSECT1 ID="R1-SQL-ROLLBACK-3">
+ <TITLE>
+ Compatibility
+ </TITLE>
+ <PARA>
+ </PARA>
+
+ <REFSECT2 ID="R2-SQL-ROLLBACK-4">
+ <REFSECT2INFO>
+ <DATE>1998-09-24</DATE>
+ </REFSECT2INFO>
+ <TITLE>
+ SQL92
+ </TITLE>
+ <PARA>
+ Full compatibility.
+ </para>
+ </refsect2>
+ </refsect1>
</REFENTRY>
<title>
Outputs
</title>
-<para>
-
- <variablelist>
- <varlistentry>
- <term>
- Rows
- </term>
- <listitem>
- <para>
- The complete set of rows resulting from the query specification.
- </para>
- </listitem>
- </varlistentry>
-
- <varlistentry>
- <term>
- <returnvalue><replaceable>count</replaceable></returnvalue>
- </term>
- <listitem>
- <para>
- The count of rows returned by the query.
- </variablelist>
-
+ <para>
+
+ <variablelist>
+ <varlistentry>
+ <term>
+ Rows
+ </term>
+ <listitem>
+ <para>
+ The complete set of rows resulting from the query specification.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ <returnvalue><replaceable>count</replaceable></returnvalue>
+ </term>
+ <listitem>
+ <para>
+ The count of rows returned by the query.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </para>
</refsect2>
</refsynopsisdiv>
108|Westward
</programlisting>
</para>
+ </refsect2>
<refsect2 id="R2-SQL-SELECT-5">
<refsect2info>
</title>
<para>
All input fields are described in detail for SELECT.
+ </para>
+ </refsect2>
<refsect2 id="R2-SQL-SELECTINTO-2">
<refsect2info>
</title>
<para>
All output fields are described in detail for SELECT.
+ </para>
+ </refsect2>
+ </refsynopsisdiv>
- <refsect1 id="R1-SQL-SELECTINTO-1">
- <refsect1info>
- <date>1998-09-22</date>
- </refsect1info>
- <title>
- Description
- </title>
- <para>
-SELECT INTO creates a new table from the results of a query. Typically, this
-query draws data from an existing table, but any SQL query is allowed.
-<note>
-<para>
-CREATE TABLE AS is functionally equivalent to the SELECT INTO command.
-</note>
-
+ <refsect1 id="R1-SQL-SELECTINTO-1">
+ <refsect1info>
+ <date>1998-09-22</date>
+ </refsect1info>
+ <title>
+ Description
+ </title>
+ <para>
+ SELECT INTO creates a new table from the results of a query. Typically, this
+ query draws data from an existing table, but any SQL query is allowed.
+ <note>
+ <para>
+ CREATE TABLE AS is functionally equivalent to the SELECT INTO command.
+ </para>
+ </note>
+ </para>
</refsect1>
</refentry>
<REFPURPOSE>
Set run-time parameters for session
</REFPURPOSE>
+ </refnamediv>
<REFSYNOPSISDIV>
<REFSYNOPSISDIVINFO>
<DATE>1998-09-24</DATE>
SET TIME ZONE { '<REPLACEABLE CLASS="PARAMETER">timezone</REPLACEABLE>' | LOCAL };
</SYNOPSIS>
-<REFSECT2 ID="R2-SQL-SET-1">
-<REFSECT2INFO>
-<DATE>1998-09-24</DATE>
-</REFSECT2INFO>
-<TITLE>
-Inputs
-</TITLE>
-<PARA>
-
-<VARIABLELIST>
-<VARLISTENTRY>
-<TERM>
-<REPLACEABLE CLASS="PARAMETER">variable</REPLACEABLE>
-</TERM>
-<LISTITEM>
-<para>
-Settable global parameter.
-
-<varlistentry>
-<term>
-<REPLACEABLE CLASS="PARAMETER">value</REPLACEABLE>
-</term>
-<listitem>
-<PARA>
-New value of parameter.
-</variablelist>
-
-<para>
-The possible variables and allowed values are:
-
-<VARIABLELIST>
-<VARLISTENTRY>
-<TERM>
-DateStyle
-</TERM>
-<LISTITEM>
-<PARA>
-
-<VARIABLELIST>
-<VARLISTENTRY>
-<TERM>
-ISO
-</TERM>
-<LISTITEM>
-<PARA>
-use ISO 8601-style dates and times
-<VARLISTENTRY>
-<TERM>
-SQL
-</TERM>
-<LISTITEM>
-<PARA>
-use Oracle/Ingres-style dates and times
-<VARLISTENTRY>
-<TERM>
-Postgres
-</TERM>
-<LISTITEM>
-<PARA>
-use traditional <productname>Postgres</productname> format
-<VARLISTENTRY>
-<TERM>
-European
-</TERM>
-<LISTITEM>
-<PARA>
-use dd/mm/yyyy for numeric date representations.
-<VARLISTENTRY>
-<TERM>
-NonEuropean
-</TERM>
-<LISTITEM>
-<PARA>
-use mm/dd/yyyy for numeric date representations.
-<VARLISTENTRY>
-<TERM>
-German
-</TERM>
-<LISTITEM>
-<PARA>
-use dd.mm.yyyy for numeric date representations.
-<VARLISTENTRY>
-<TERM>
-US
-</TERM>
-<LISTITEM>
-<PARA>
-same as 'NonEuropean'
-<VARLISTENTRY>
-<TERM>
-default
-</TERM>
-<LISTITEM>
-<PARA>
-restores the default values ('US,Postgres')
-</varlistentry>
-</variablelist>
-
-<para>
- Date format initialization my be done by:
-<simplelist>
-<member>
-Setting PGDATESTYLE environment variable.
-
-<member>
-Running postmaster using -oe parameter to set
- dates to the 'European' convention.
-Note that this affects only the some combinations of date styles; for example
-the ISO style is not affected by this parameter.
-<member>
-Changing variables in
-<filename>src/backend/utils/init/globals.c</filename>.
-</simplelist>
-
-<para>
-The variables in <filename>globals.c</filename> which can be changed are:
-<programlisting>
-bool EuroDates = false
- true
-int DateStyle = USE_ISO_DATES
- USE_POSTGRES_DATES
- USE_ISO_DATES
- USE_SQL_DATES
- USE_GERMAN_DATES
-</programlisting>
-
-</varlistentry>
-
-<varlistentry>
-<term>
-TIMEZONE
-</term>
-<listitem>
-<para>
- The possible values for timezone depends on your operating
- system. For example on Linux /usr/lib/zoneinfo contains the
- database of timezones.
-<para>
- Here are some valid values for timezone:
-
-<variablelist>
-<varlistentry>
-<term>
-'PST8PDT'
-</term>
-<listitem>
-<para>
-set the timezone for California
-<varlistentry>
-<term>
-'Portugal'
-</term>
-<listitem>
-<para>
-set time zone for Portugal.
-<varlistentry>
-<term>
-'Europe/Rome'
-</term>
-<listitem>
-<para>
-set time zone for Italy.
-<varlistentry>
-<term>
-DEFAULT
-</term>
-<listitem>
-<para>
-set time zone to your local timezone
-(value of the TZ environment variable).
-</variablelist>
-
-<para>
-If an invalid time zone is specified, the time zone
-becomes GMT (on most systems anyway).
-
-<para>
-A frontend which uses libpq may be initialized by setting the PGTZ
-environment variable.
-
-<para>
-The second syntax shown above, allows one to set the timezone
-with a syntax similar to SQL92 <command>SET TIME ZONE</command>.
-The LOCAL keyword is just an alternate form
-of DEFAULT for SQL92 compatibility.
-
-</varlistentry>
-</variablelist>
-
-There are also several internal or optimization
- parameters which can be specified
-by the <command>SET</command> command:
-
-<variablelist>
-<varlistentry>
-<term>
-COST_HEAP
-</term>
-<listitem>
-<para>
-Sets the default cost of a heap scan for use by the optimizer.
-
-<variablelist>
-<varlistentry>
-<term>
-<replaceable class="parameter">float4</replaceable>
-</term>
-<listitem>
-<para>
-Set the cost of a heap scan to the specified floating point value.
-
-<varlistentry>
-<term>
-DEFAULT
-</term>
-<listitem>
-<para>
-Sets the cost of a heap scan to the default value.
-</variablelist>
-
-<para>
- The frontend may be initialized by setting the PGCOSTHEAP
- environment variable.
-
-<varlistentry>
-<term>
-COST_INDEX
-</term>
-<listitem>
-<para>
-Sets the default cost of an index scan for use by the optimizer.
-
-<variablelist>
-<varlistentry>
-<term>
-<replaceable class="parameter">float4</replaceable>
-</term>
-<listitem>
-<para>
-Set the cost of an index scan to the specified floating point value.
-
-<varlistentry>
-<term>
-DEFAULT
-</term>
-<listitem>
-<para>
-Sets the cost of an index scan to the default value.
-</variablelist>
-
-<para>
- The frontend may be initialized by setting the PGCOSTINDEX
- environment variable.
-
-<varlistentry>
-<term>
-GEQO
-</term>
-<listitem>
-<para>
-Sets the threshold for using the genetic optimizer algorithm.
-
-<variablelist>
-<varlistentry>
-<term>
-On
-</term>
-<listitem>
-<para>
-enables the genetic optimizer algorithm
- for statements with 8 or more tables.
-<varlistentry>
-<term>
-On=<replaceable class="parameter">#</replaceable>
-</term>
-<listitem>
-<para>
-Takes an integer argument to enable the genetic optimizer algorithm
- for statements with <replaceable class="parameter">#</replaceable>
- or more tables in the query.
-<varlistentry>
-<term>
-Off
-</term>
-<listitem>
-<para>
-disables the genetic optimizer algorithm.
-<varlistentry>
-<term>
-DEFAULT
-</term>
-<listitem>
-<para>
-Equivalent to specifying <command>SET GEQO='on'</command>
-</varlistentry>
-</variablelist>
-
-<para>
- This algorithm is on by default, which used GEQO for
- statements of eight or more tables.
- (See the chapter on GEQO in the Programmer's Guide
-for more information).
-
-<para>
- The frontend may be initialized by setting PGGEQO
- environment variable.
-</varlistentry>
-
-<varlistentry>
-<term>
-R_PLANS
-</term>
-<listitem>
-<para>
-Determines whether right-hand plan evaluation is allowed:
-
-<variablelist>
-<varlistentry>
-<term>
-On
-</term>
-<listitem>
-<para>
-enables right-hand evaluation of plans.
-
-<varlistentry>
-<term>
-Off
-</term>
-<listitem>
-<para>
-disables right-hand evaluation of plans.
-
-<varlistentry>
-<term>
-DEFAULT
-</term>
-<listitem>
-<para>
-Equivalent to specifying <command>SET R_PLANS='off'</command>.
-</variablelist>
-
-<para>
- It may be useful when joining big relations with
- small ones. This algorithm is off by default.
- It's not used by GEQO anyway.
-<para>
- The frontend may be initialized by setting the PGRPLANS
- environment variable.
-</varlistentry>
-
-<varlistentry>
-<term>
-KSQO
-</term>
-<listitem>
-<para>
-<firstterm>Key Set Query Optimizer</firstterm> forces the query optimizer
-to optimize repetative OR clauses such as generated by
-<productname>MicroSoft Access</productname>:
-
-<variablelist>
-<varlistentry>
-<term>
-On
-</term>
-<listitem>
-<para>
-enables this optimization.
-
-<varlistentry>
-<term>
-Off
-</term>
-<listitem>
-<para>
-disables this optimization.
-
-<varlistentry>
-<term>
-DEFAULT
-</term>
-<listitem>
-<para>
-Equivalent to specifying <command>SET KSQO='off'</command>.
-</variablelist>
-
-<para>
- It may be useful when joining big relations with
- small ones. This algorithm is off by default.
- It's not used by GEQO anyway.
-<para>
- The frontend may be initialized by setting the PGRPLANS
- environment variable.
-
-<varlistentry>
-<term>
-QUERY_LIMIT
-</term>
-<listitem>
-<para>
-Sets the number of rows returned by a query.
-
-<variablelist>
-<varlistentry>
-<term>
-Value
-</term>
-<listitem>
-<para>
-Maximum number of rows to return for a query. The default is to allow
-an unlimited number of rows.
-<varlistentry>
-<term>
-<replaceable class="parameter">#</replaceable>
-</term>
-<listitem>
-<para>
-Sets the maximum number of rows returned by a
-query to <replaceable class="parameter">#</replaceable>.
-<varlistentry>
-<term>
-DEFAULT
-</term>
-<listitem>
-<para>
-Sets the maximum number of rows returned by a query to be unlimited.
-<para>
-By default, there is no limit to the number of rows
-returned by a query.
-</varlistentry>
-
-</variablelist>
-
-</VARLISTENTRY>
-</VARIABLELIST>
-</REFSECT2>
-
-<REFSECT2 ID="R2-SQL-SET-2">
-<REFSECT2INFO>
-<DATE>1998-09-24</DATE>
-</REFSECT2INFO>
-<TITLE>
-Outputs
-</TITLE>
-<PARA>
-
-<VARIABLELIST>
-<VARLISTENTRY>
-<TERM>
-<returnvalue>SET VARIABLE</returnvalue>
-</TERM>
-<LISTITEM>
-<PARA>
- Message returned if successfully.
-
-<VARLISTENTRY>
-<TERM>
-<returnvalue>WARN: Bad value for <replaceable class="parameter">variable</replaceable> (<replaceable class="parameter">value</replaceable>)</returnvalue>
-</TERM>
-<LISTITEM>
-<PARA>
- If the command fails to set variable.
-
-</VARIABLELIST>
-
-</REFSECT2>
-</REFSYNOPSISDIV>
-
-<REFSECT1 ID="R1-SQL-SET-1">
-<REFSECT1INFO>
-<DATE>1998-09-24</DATE>
-</REFSECT1INFO>
-<TITLE>
-Description
-</TITLE>
-<PARA>
-<command>SET</command> will modify configuration parameters for variable during
+ <REFSECT2 ID="R2-SQL-SET-1">
+ <REFSECT2INFO>
+ <DATE>1998-09-24</DATE>
+ </REFSECT2INFO>
+ <TITLE>
+ Inputs
+ </TITLE>
+ <PARA>
+
+ <VARIABLELIST>
+ <VARLISTENTRY>
+ <TERM>
+ <REPLACEABLE CLASS="PARAMETER">variable</REPLACEABLE>
+ </TERM>
+ <LISTITEM>
+ <para>
+ Settable global parameter.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>
+ <REPLACEABLE CLASS="PARAMETER">value</REPLACEABLE>
+ </term>
+ <listitem>
+ <PARA>
+ New value of parameter.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </para>
+ <para>
+ The possible variables and allowed values are:
+
+ <VARIABLELIST>
+ <VARLISTENTRY>
+ <TERM>
+ DateStyle
+ </TERM>
+ <LISTITEM>
+ <PARA>
+
+ <VARIABLELIST>
+ <VARLISTENTRY>
+ <TERM>
+ ISO
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ use ISO 8601-style dates and times
+ </para>
+ </listitem>
+ </varlistentry>
+ <VARLISTENTRY>
+ <TERM>
+ SQL
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ use Oracle/Ingres-style dates and times
+ </para>
+ </listitem>
+ </varlistentry>
+ <VARLISTENTRY>
+ <TERM>
+ Postgres
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ use traditional <productname>Postgres</productname> format
+ </para>
+ </listitem>
+ </varlistentry>
+ <VARLISTENTRY>
+ <TERM>
+ European
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ use dd/mm/yyyy for numeric date representations.
+ </para>
+ </listitem>
+ </varlistentry>
+ <VARLISTENTRY>
+ <TERM>
+ NonEuropean
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ use mm/dd/yyyy for numeric date representations.
+ </para>
+ </listitem>
+ </varlistentry>
+ <VARLISTENTRY>
+ <TERM>
+ German
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ use dd.mm.yyyy for numeric date representations.
+ </para>
+ </listitem>
+ </varlistentry>
+ <VARLISTENTRY>
+ <TERM>
+ US
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ same as 'NonEuropean'
+ </para>
+ </listitem>
+ </varlistentry>
+ <VARLISTENTRY>
+ <TERM>
+ default
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ restores the default values ('US,Postgres')
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </para>
+ <para>
+ Date format initialization my be done by:
+ <simplelist>
+ <member>
+ Setting PGDATESTYLE environment variable.
+ </member>
+ <member>
+ Running postmaster using -oe parameter to set
+ dates to the 'European' convention.
+ Note that this affects only the some combinations of date styles; for example
+ the ISO style is not affected by this parameter.
+ </member>
+ <member>
+ Changing variables in
+ <filename>src/backend/utils/init/globals.c</filename>.
+ </member>
+ </simplelist>
+ </para>
+ <para>
+ The variables in <filename>globals.c</filename> which can be changed are:
+ <programlisting>
+ bool EuroDates = false
+ true
+ int DateStyle = USE_ISO_DATES
+ USE_POSTGRES_DATES
+ USE_ISO_DATES
+ USE_SQL_DATES
+ USE_GERMAN_DATES
+ </programlisting>
+ </para>
+ <para>
+ <variablelist>
+ <varlistentry>
+ <term>
+ TIMEZONE
+ </term>
+ <listitem>
+ <para>
+ The possible values for timezone depends on your operating
+ system. For example on Linux /usr/lib/zoneinfo contains the
+ database of timezones.
+ </para>
+ <para>
+ Here are some valid values for timezone:
+
+ <variablelist>
+ <varlistentry>
+ <term>
+ 'PST8PDT'
+ </term>
+ <listitem>
+ <para>
+ set the timezone for California
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>
+ 'Portugal'
+ </term>
+ <listitem>
+ <para>
+ set time zone for Portugal.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>
+ 'Europe/Rome'
+ </term>
+ <listitem>
+ <para>
+ set time zone for Italy.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>
+ DEFAULT
+ </term>
+ <listitem>
+ <para>
+ set time zone to your local timezone
+ (value of the TZ environment variable).
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </para>
+ <para>
+ If an invalid time zone is specified, the time zone
+ becomes GMT (on most systems anyway).
+ </para>
+ <para>
+ A frontend which uses libpq may be initialized by setting the PGTZ
+ environment variable.
+ </para>
+ <para>
+ The second syntax shown above, allows one to set the timezone
+ with a syntax similar to SQL92 <command>SET TIME ZONE</command>.
+ The LOCAL keyword is just an alternate form
+ of DEFAULT for SQL92 compatibility.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </para>
+ <para>
+ There are also several internal or optimization
+ parameters which can be specified
+ by the <command>SET</command> command:
+
+ <variablelist>
+ <varlistentry>
+ <term>
+ COST_HEAP
+ </term>
+ <listitem>
+ <para>
+ Sets the default cost of a heap scan for use by the optimizer.
+
+ <variablelist>
+ <varlistentry>
+ <term>
+ <replaceable class="parameter">float4</replaceable>
+ </term>
+ <listitem>
+ <para>
+ Set the cost of a heap scan to the specified floating point value.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ DEFAULT
+ </term>
+ <listitem>
+ <para>
+ Sets the cost of a heap scan to the default value.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </para>
+ <para>
+ The frontend may be initialized by setting the PGCOSTHEAP
+ environment variable.
+ </para>
+ <variablelist>
+ <varlistentry>
+ <term>
+ COST_INDEX
+ </term>
+ <listitem>
+ <para>
+ Sets the default cost of an index scan for use by the optimizer.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ <replaceable class="parameter">float4</replaceable>
+ </term>
+ <listitem>
+ <para>
+ Set the cost of an index scan to the specified floating point value.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ DEFAULT
+ </term>
+ <listitem>
+ <para>
+ Sets the cost of an index scan to the default value.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </para>
+ <para>
+ The frontend may be initialized by setting the PGCOSTINDEX
+ environment variable.
+
+ <variablelist>
+ <varlistentry>
+ <term>
+ GEQO
+ </term>
+ <listitem>
+ <para>
+ Sets the threshold for using the genetic optimizer algorithm.
+ </para>
+
+ <variablelist>
+ <varlistentry>
+ <term>
+ On
+ </term>
+ <listitem>
+ <para>
+ enables the genetic optimizer algorithm
+ for statements with 8 or more tables.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>
+ On=<replaceable class="parameter">#</replaceable>
+ </term>
+ <listitem>
+ <para>
+ Takes an integer argument to enable the genetic optimizer algorithm
+ for statements with <replaceable class="parameter">#</replaceable>
+ or more tables in the query.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>
+ Off
+ </term>
+ <listitem>
+ <para>
+ disables the genetic optimizer algorithm.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>
+ DEFAULT
+ </term>
+ <listitem>
+ <para>
+ Equivalent to specifying <command>SET GEQO='on'</command>
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </para>
+ <para>
+ This algorithm is on by default, which used GEQO for
+ statements of eight or more tables.
+ (See the chapter on GEQO in the Programmer's Guide
+ for more information).
+ </para>
+ <para>
+ The frontend may be initialized by setting PGGEQO
+ environment variable.
+
+ <variablelist>
+
+ <varlistentry>
+ <term>
+ R_PLANS
+ </term>
+ <listitem>
+ <para>
+ Determines whether right-hand plan evaluation is allowed:
+ </para>
+
+ <variablelist>
+ <varlistentry>
+ <term>
+ On
+ </term>
+ <listitem>
+ <para>
+ enables right-hand evaluation of plans.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ Off
+ </term>
+ <listitem>
+ <para>
+ disables right-hand evaluation of plans.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ DEFAULT
+ </term>
+ <listitem>
+ <para>
+ Equivalent to specifying <command>SET R_PLANS='off'</command>.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </para>
+ <para>
+ It may be useful when joining big relations with
+ small ones. This algorithm is off by default.
+ It's not used by GEQO anyway.
+ </para>
+ <para>
+ The frontend may be initialized by setting the PGRPLANS
+ environment variable.
+ <variablelist>
+ <varlistentry>
+ <term>
+ KSQO
+ </term>
+ <listitem>
+ <para>
+ <firstterm>Key Set Query Optimizer</firstterm> forces the query optimizer
+ to optimize repetative OR clauses such as generated by
+ <productname>MicroSoft Access</productname>:
+ </para>
+
+ <variablelist>
+ <varlistentry>
+ <term>
+ On
+ </term>
+ <listitem>
+ <para>
+ enables this optimization.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ Off
+ </term>
+ <listitem>
+ <para>
+ disables this optimization.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ DEFAULT
+ </term>
+ <listitem>
+ <para>
+ Equivalent to specifying <command>SET KSQO='off'</command>.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </para>
+ <para>
+ It may be useful when joining big relations with
+ small ones. This algorithm is off by default.
+ It's not used by GEQO anyway.
+ </para>
+ <para>
+ The frontend may be initialized by setting the PGRPLANS
+ environment variable.
+ <variablelist>
+ <varlistentry>
+ <term>
+ QUERY_LIMIT
+ </term>
+ <listitem>
+ <para>
+ Sets the number of rows returned by a query.
+ </para>
+
+ <variablelist>
+ <varlistentry>
+ <term>
+ Value
+ </term>
+ <listitem>
+ <para>
+ Maximum number of rows to return for a query. The default is to allow
+ an unlimited number of rows.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>
+ <replaceable class="parameter">#</replaceable>
+ </term>
+ <listitem>
+ <para>
+ Sets the maximum number of rows returned by a
+ query to <replaceable class="parameter">#</replaceable>.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>
+ DEFAULT
+ </term>
+ <listitem>
+ <para>
+ Sets the maximum number of rows returned by a query to be unlimited.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ <para>
+ By default, there is no limit to the number of rows
+ returned by a query.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </para>
+ </REFSECT2>
+
+ <REFSECT2 ID="R2-SQL-SET-2">
+ <REFSECT2INFO>
+ <DATE>1998-09-24</DATE>
+ </REFSECT2INFO>
+ <TITLE>
+ Outputs
+ </TITLE>
+ <PARA>
+
+ <VARIABLELIST>
+ <VARLISTENTRY>
+ <TERM>
+ <returnvalue>SET VARIABLE</returnvalue>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Message returned if successfully.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <VARLISTENTRY>
+ <TERM>
+ <returnvalue>WARN: Bad value for <replaceable class="parameter">variable</replaceable> (<replaceable class="parameter">value</replaceable>)</returnvalue>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ If the command fails to set variable.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </VARIABLELIST>
+ </para>
+ </REFSECT2>
+ </REFSYNOPSISDIV>
+
+ <REFSECT1 ID="R1-SQL-SET-1">
+ <REFSECT1INFO>
+ <DATE>1998-09-24</DATE>
+ </REFSECT1INFO>
+ <TITLE>
+ Description
+ </TITLE>
+ <PARA>
+ <command>SET</command> will modify configuration parameters for variable during
a session.
-
-<para>
- Current values can be obtained using <command>SHOW</command>, and values
- can be restored to the defaults using <command>RESET</command>.
- Parameters and values are case-insensitive. Note that the value
- field is always specified as a string, so is enclosed in
- single-quotes.
-<para>
- <command>SET TIME ZONE</command> changes the session's
- default time zone offset.
- A SQL-session always begins with an initial default time zone
- offset.
- The <command>SET TIME ZONE</command> statement is used to change the default
- time zone offset for the current SQL session.
-
-<REFSECT2 ID="R2-SQL-SET-3">
-<REFSECT2INFO>
-<DATE>1998-09-24</DATE>
-</REFSECT2INFO>
-<TITLE>
-Notes
-</TITLE>
-<PARA>
-The <command>SET <replaceable class="parameter">variable</replaceable></command>
- statement is a <productname>Postgres</productname> language extension.
-
-<para>
- Refer to <command>SHOW</command> and <command>RESET</command> to
-display or reset the current values.
-
-</REFSECT2>
-</REFSECT1>
-
-<REFSECT1 ID="R1-SQL-SET-2">
-<TITLE>
-Usage
-</TITLE>
-<PARA>
-</PARA>
-<ProgramListing>
---Set the style of date to ISO:
---
-SET DATESTYLE TO 'ISO';
-</programlisting>
-<programlisting>
---Set GEQO to default:
---
-SET GEQO = DEFAULT;
-</programlisting>
-<programlisting>
---Turn on right-hand evaluation of plans:
---
-SET R_PLANS TO 'on';
-</programlisting>
-<programlisting>
---set the timezone for Berkeley, California:
-SET TIME ZONE 'PST8PDT';
-
-SELECT CURRENT_TIMESTAMP AS today;
-
- today
- ----------------------
- 1998-03-31 07:41:21-08
-</programlisting>
-<programlisting>
---set the timezone for Italy:
-SET TIME ZONE 'Europe/Rome';
-
-SELECT CURRENT_TIMESTAMP AS today;
-
- today
- ----------------------
- 1998-03-31 17:41:31+02
-</ProgramListing>
-
-</REFSECT1>
-
-<REFSECT1 ID="R1-SQL-SET-3">
-<TITLE>
-Compatibility
-</TITLE>
-<PARA>
-</PARA>
-
-<REFSECT2 ID="R2-SQL-SET-4">
-<REFSECT2INFO>
-<DATE>1998-09-24</DATE>
-</REFSECT2INFO>
-<TITLE>
-SQL92
-</TITLE>
-<PARA>
- There is no
-<command>SET <replaceable class="parameter">variable</replaceable></command>
- in <acronym>SQL92</acronym>.
-
- The <acronym>SQL92</acronym> syntax for <command>SET TIME ZONE</command>
- is slightly different,
- allowing only a single integer value for time zone specification:
-
-<programlisting>
-SET TIME ZONE { interval_value_expression | LOCAL }
-</programlisting>
-
+ </para>
+ <para>
+ Current values can be obtained using <command>SHOW</command>, and values
+ can be restored to the defaults using <command>RESET</command>.
+ Parameters and values are case-insensitive. Note that the value
+ field is always specified as a string, so is enclosed in
+ single-quotes.
+ </para>
+ <para>
+ <command>SET TIME ZONE</command> changes the session's
+ default time zone offset.
+ A SQL-session always begins with an initial default time zone
+ offset.
+ The <command>SET TIME ZONE</command> statement is used to change the default
+ time zone offset for the current SQL session.
+ </para>
+
+ <REFSECT2 ID="R2-SQL-SET-3">
+ <REFSECT2INFO>
+ <DATE>1998-09-24</DATE>
+ </REFSECT2INFO>
+ <TITLE>
+ Notes
+ </TITLE>
+ <PARA>
+ The <command>SET <replaceable class="parameter">variable</replaceable></command>
+ statement is a <productname>Postgres</productname> language extension.
+ </para>
+ <para>
+ Refer to <command>SHOW</command> and <command>RESET</command> to
+ display or reset the current values.
+ </para>
+ </REFSECT2>
+ </REFSECT1>
+
+ <REFSECT1 ID="R1-SQL-SET-2">
+ <TITLE>
+ Usage
+ </TITLE>
+ <PARA>
+ </PARA>
+ <ProgramListing>
+ --Set the style of date to ISO:
+ --
+ SET DATESTYLE TO 'ISO';
+ </programlisting>
+ <programlisting>
+ --Set GEQO to default:
+ --
+ SET GEQO = DEFAULT;
+ </programlisting>
+ <programlisting>
+ --Turn on right-hand evaluation of plans:
+ --
+ SET R_PLANS TO 'on';
+ </programlisting>
+ <programlisting>
+ --set the timezone for Berkeley, California:
+ SET TIME ZONE 'PST8PDT';
+
+ SELECT CURRENT_TIMESTAMP AS today;
+
+ today
+ ----------------------
+ 1998-03-31 07:41:21-08
+ </programlisting>
+ <programlisting>
+ --set the timezone for Italy:
+ SET TIME ZONE 'Europe/Rome';
+
+ SELECT CURRENT_TIMESTAMP AS today;
+
+ today
+ ----------------------
+ 1998-03-31 17:41:31+02
+ </ProgramListing>
+
+ </REFSECT1>
+
+ <REFSECT1 ID="R1-SQL-SET-3">
+ <TITLE>
+ Compatibility
+ </TITLE>
+ <PARA>
+ </PARA>
+
+ <REFSECT2 ID="R2-SQL-SET-4">
+ <REFSECT2INFO>
+ <DATE>1998-09-24</DATE>
+ </REFSECT2INFO>
+ <TITLE>
+ SQL92
+ </TITLE>
+ <PARA>
+ There is no
+ <command>SET <replaceable class="parameter">variable</replaceable></command>
+ in <acronym>SQL92</acronym>.
+
+ The <acronym>SQL92</acronym> syntax for <command>SET TIME ZONE</command>
+ is slightly different,
+ allowing only a single integer value for time zone specification:
+
+ <programlisting>
+ SET TIME ZONE { interval_value_expression | LOCAL }
+ </programlisting>
+ </para>
+ </refsect2>
+ </refsect1>
</REFENTRY>
<REFPURPOSE>
Shows run-time parameters for session
</REFPURPOSE>
+ </refnamediv>
<REFSYNOPSISDIV>
<REFSYNOPSISDIVINFO>
<DATE>1998-09-24</DATE>
SHOW <REPLACEABLE CLASS="PARAMETER">variable</REPLACEABLE>
</SYNOPSIS>
-<REFSECT2 ID="R2-SQL-SHOW-1">
-<REFSECT2INFO>
-<DATE>1998-09-24</DATE>
-</REFSECT2INFO>
-<TITLE>
-Inputs
-</TITLE>
-<PARA>
-
-<VARIABLELIST>
-<VARLISTENTRY>
-<TERM>
-<REPLACEABLE CLASS="PARAMETER">variable</REPLACEABLE>
-</TERM>
-<LISTITEM>
-<PARA>
- Refer to <command>SET</command> for more information on available
- variables.
-</VARLISTENTRY>
-</VARIABLELIST>
-
-</REFSECT2>
-
-<REFSECT2 ID="R2-SQL-SHOW-2">
-<REFSECT2INFO>
-<DATE>1998-09-24</DATE>
-</REFSECT2INFO>
-<TITLE>
-Outputs
-</TITLE>
-<PARA>
-
-<VARIABLELIST>
-<VARLISTENTRY>
-<TERM>
-<returnvalue>NOTICE: <REPLACEABLE CLASS="PARAMETER">variable</REPLACEABLE> is <replaceable>value</replaceable></ReturnValue>
-SHOW VARIABLE
-</TERM>
-<LISTITEM>
-<PARA>
- Message returned if successfully.
-</listitem>
-
-<VARLISTENTRY>
-<TERM>
-<returnvalue>NOTICE: Unrecognized variable <replaceable>value</replaceable></ReturnValue>
-</TERM>
-<LISTITEM>
-<PARA>
-Message returned if <ReturnValue>value</ReturnValue> does not exist.
-</PARA>
-</LISTITEM>
-</VARLISTENTRY>
-
-<VARLISTENTRY>
-<TERM>
-NOTICE: Time zone is unknown
-SHOW VARIABLE
-</TERM>
-<LISTITEM>
-<PARA>
- If the TZ environment variable is not set.
-
-</VARIABLELIST>
-
-</REFSECT2>
-</REFSYNOPSISDIV>
-
-<REFSECT1 ID="R1-SQL-SHOW-1">
-<REFSECT1INFO>
-<DATE>1998-09-24</DATE>
-</REFSECT1INFO>
-<TITLE>
-Description
-</TITLE>
-<PARA>
- <command>SHOW</command> will display the current
- configuration parameters for
- variable during a session.
-
-<para>
- The session can be configured using <command>SET</command> statement,
- and values
- can be restored to the defaults using <command>RESET</command> statement.
- Parameters and values are case-insensitive.
-
-<REFSECT2 ID="R2-SQL-SHOW-3">
-<REFSECT2INFO>
-<DATE>1998-09-24</DATE>
-</REFSECT2INFO>
-<TITLE>
-Notes
-</TITLE>
-<PARA>
- The <command>SHOW</command> is a <productname>Postgres</productname>
- language extension.
-
-<para>
- Refer to <command>SET</command>/<command>RESET</command>
- to set/reset variable values.
- See also <command>SET TIME ZONE</command>.
-
-</REFSECT2>
-</REFSECT1>
-
-<REFSECT1 ID="R1-SQL-SHOW-2">
-<TITLE>
-Usage
-</TITLE>
-<PARA>
-<ProgramListing>
--- show DateStyle;
-SHOW DateStyle;
-NOTICE:DateStyle is Postgres with US (NonEuropean) conventions
-
--- show Geqo;
-SHOW GEQO;
-NOTICE:GEQO is ON
-</ProgramListing>
-
-</REFSECT1>
-
-<REFSECT1 ID="R1-SQL-SHOW-3">
-<TITLE>
-Compatibility
-</TITLE>
-<PARA>
-</PARA>
-
-<REFSECT2 ID="R2-SQL-SHOW-4">
-<REFSECT2INFO>
-<DATE>1998-09-24</DATE>
-</REFSECT2INFO>
-<TITLE>
-SQL92
-</TITLE>
-<PARA>
- There is no <command>SET</command> defined in <acronym>SQL92</acronym>.
-</refsect2>
-</refsect1>
+ <REFSECT2 ID="R2-SQL-SHOW-1">
+ <REFSECT2INFO>
+ <DATE>1998-09-24</DATE>
+ </REFSECT2INFO>
+ <TITLE>
+ Inputs
+ </TITLE>
+ <PARA>
+
+ <VARIABLELIST>
+ <VARLISTENTRY>
+ <TERM>
+ <REPLACEABLE CLASS="PARAMETER">variable</REPLACEABLE>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Refer to <command>SET</command> for more information on available
+ variables.
+ </para>
+ </listitem>
+ </VARLISTENTRY>
+ </VARIABLELIST>
+ </para>
+ </REFSECT2>
+
+ <REFSECT2 ID="R2-SQL-SHOW-2">
+ <REFSECT2INFO>
+ <DATE>1998-09-24</DATE>
+ </REFSECT2INFO>
+ <TITLE>
+ Outputs
+ </TITLE>
+ <PARA>
+
+ <VARIABLELIST>
+ <VARLISTENTRY>
+ <TERM>
+ <returnvalue>NOTICE: <REPLACEABLE CLASS="PARAMETER">variable</REPLACEABLE> is <replaceable>value</replaceable></ReturnValue>
+ SHOW VARIABLE
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Message returned if successfully.
+ </para>
+ </listitem>
+ </varlistentry>
+ <VARLISTENTRY>
+ <TERM>
+ <returnvalue>NOTICE: Unrecognized variable <replaceable>value</replaceable></ReturnValue>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Message returned if <ReturnValue>value</ReturnValue> does not exist.
+ </PARA>
+ </LISTITEM>
+ </VARLISTENTRY>
+
+ <VARLISTENTRY>
+ <TERM>
+ NOTICE: Time zone is unknown
+ SHOW VARIABLE
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ If the TZ environment variable is not set.
+ </para>
+ </listitem>
+ </varlistentry>
+ </VARIABLELIST>
+ </para>
+ </REFSECT2>
+ </REFSYNOPSISDIV>
+
+ <REFSECT1 ID="R1-SQL-SHOW-1">
+ <REFSECT1INFO>
+ <DATE>1998-09-24</DATE>
+ </REFSECT1INFO>
+ <TITLE>
+ Description
+ </TITLE>
+ <PARA>
+ <command>SHOW</command> will display the current
+ configuration parameters for
+ variable during a session.
+ </para>
+ <para>
+ The session can be configured using <command>SET</command> statement,
+ and values
+ can be restored to the defaults using <command>RESET</command> statement.
+ Parameters and values are case-insensitive.
+ </para>
+
+ <REFSECT2 ID="R2-SQL-SHOW-3">
+ <REFSECT2INFO>
+ <DATE>1998-09-24</DATE>
+ </REFSECT2INFO>
+ <TITLE>
+ Notes
+ </TITLE>
+ <PARA>
+ The <command>SHOW</command> is a <productname>Postgres</productname>
+ language extension.
+ </para>
+ <para>
+ Refer to <command>SET</command>/<command>RESET</command>
+ to set/reset variable values.
+ See also <command>SET TIME ZONE</command>.
+ </para>
+ </REFSECT2>
+ </REFSECT1>
+
+ <REFSECT1 ID="R1-SQL-SHOW-2">
+ <TITLE>
+ Usage
+ </TITLE>
+ <PARA>
+ <ProgramListing>
+ -- show DateStyle;
+ SHOW DateStyle;
+ NOTICE:DateStyle is Postgres with US (NonEuropean) conventions
+
+ -- show Geqo;
+ SHOW GEQO;
+ NOTICE:GEQO is ON
+ </ProgramListing>
+ </para>
+ </REFSECT1>
+
+ <REFSECT1 ID="R1-SQL-SHOW-3">
+ <TITLE>
+ Compatibility
+ </TITLE>
+ <PARA>
+ </PARA>
+
+ <REFSECT2 ID="R2-SQL-SHOW-4">
+ <REFSECT2INFO>
+ <DATE>1998-09-24</DATE>
+ </REFSECT2INFO>
+ <TITLE>
+ SQL92
+ </TITLE>
+ <PARA>
+ There is no <command>SET</command> defined in <acronym>SQL92</acronym>.
+ </para>
+ </refsect2>
+ </refsect1>
</REFENTRY>
<REFPURPOSE>
Stop listening for notification
</REFPURPOSE>
-
+</refnamediv>
<REFSYNOPSISDIV>
<REFSYNOPSISDIVINFO>
<DATE>1998-10-19</DATE>
<LISTITEM>
<PARA>
Name of previously registered notify condition.
-
+</para>
+</listitem>
+</varlistentry>
<VARLISTENTRY>
<TERM>
<literal>*</literal>
<LISTITEM>
<PARA>
All current listen registrations for this backend are cleared.
+</para>
+</listitem>
+</varlistentry>
</VARIABLELIST>
<LISTITEM>
<PARA>
Acknowledgement that statement has executed.
+</para>
+</listitem>
+</varlistentry>
</VARIABLELIST>
+</para>
</REFSECT2>
</REFSYNOPSISDIV>
condition <REPLACEABLE CLASS="PARAMETER">notifyname</REPLACEABLE>.
The special condition wildcard "*" cancels all listener registrations
for the current session.
-
+</para>
<para>
<xref linkend="sql-notify" endterm="sql-notify-ref">
contains a more extensive
discussion of the use of <command>LISTEN</command> and
<command>NOTIFY</command>.
+</para>
<REFSECT2 ID="R2-SQL-UNLISTEN-3">
<REFSECT2INFO>
<REPLACEABLE CLASS="PARAMETER">classname</REPLACEABLE>
needs not to be a valid class name but can be any string valid
as a name up to 32 characters long.
-
+</para>
<para>
The backend does not complain if you UNLISTEN something you were not
listening for.
Each backend will automatically execute <command>UNLISTEN *</command> when
exiting.
-
+</para>
<para>
A restriction in some previous releases of
<productname>Postgres</productname> that a
<REPLACEABLE CLASS="PARAMETER">classname</REPLACEABLE>
which does not correspond to an actual table must be enclosed in double-quotes
is no longer present.
-
+</para>
</REFSECT2>
+</refsect1>
<REFSECT1 ID="R1-SQL-UNLISTEN-2">
<TITLE>
-- notice no NOTIFY event is received
postgres=>
</programlisting>
-
+</para>
</REFSECT1>
<REFSECT1 ID="R1-SQL-UNLISTEN-3">
<TITLE>
Compatibility
</TITLE>
-<PARA>
<REFSECT2 ID="R2-SQL-UNLISTEN-4">
<REFSECT2INFO>
</TITLE>
<PARA>
There is no <command>UNLISTEN</command> in <acronym>SQL92</acronym>.
-
+</para>
+</refsect2>
+</refsect1>
</REFENTRY>
<REFPURPOSE>
Replaces values of columns in a table
</REFPURPOSE>
-
+</refnamediv>
<REFSYNOPSISDIV>
<REFSYNOPSISDIVINFO>
<DATE>1998-09-24</DATE>
[ WHERE <REPLACEABLE CLASS="PARAMETER">condition</REPLACEABLE> ]
</SYNOPSIS>
-<REFSECT2 ID="R2-SQL-UPDATE-1">
-<REFSECT2INFO>
-<DATE>1998-09-24</DATE>
-</REFSECT2INFO>
-<TITLE>
-Inputs
-</TITLE>
-<PARA>
-
-<VARIABLELIST>
-<VARLISTENTRY>
-<TERM>
-<REPLACEABLE CLASS="PARAMETER">table</replaceable>
-</TERM>
-<LISTITEM>
-<PARA>
- The name of an existing table.
-</LISTITEM>
-</VARLISTENTRY>
-<VARLISTENTRY>
-<TERM>
-<REPLACEABLE CLASS="PARAMETER">column</replaceable>
-</TERM>
-<LISTITEM>
-<PARA>
-The name of a column in <REPLACEABLE CLASS="PARAMETER">table</replaceable>.
-</LISTITEM>
-</VARLISTENTRY>
-<VARLISTENTRY>
-<TERM>
-<REPLACEABLE CLASS="PARAMETER">expression</replaceable>
-</TERM>
-<LISTITEM>
-<PARA>
- A valid expression or value to assign to column.
-</LISTITEM>
-</VARLISTENTRY>
-<VARLISTENTRY>
-<TERM>
-<REPLACEABLE CLASS="PARAMETER">fromlist</REPLACEABLE>
-</TERM>
-<LISTITEM>
-<PARA>
- A <productname>Postgres</productname>
- non-standard extension to allow columns
- from other tables to appear in the WHERE condition.
-</LISTITEM>
-</VARLISTENTRY>
-<VARLISTENTRY>
-<TERM>
-<REPLACEABLE CLASS="PARAMETER">condition</REPLACEABLE>
-</TERM>
-<LISTITEM>
-<PARA>
- Refer to the SELECT statement for a further description
- of the WHERE clause.
-</LISTITEM>
-</VARLISTENTRY>
-</VARIABLELIST>
-</REFSECT2>
-
-<REFSECT2 ID="R2-SQL-UPDATE-2">
-<REFSECT2INFO>
-<DATE>1998-09-24</DATE>
-</REFSECT2INFO>
-<TITLE>
-Outputs
-</TITLE>
-<PARA>
-
-<VARIABLELIST>
-<VARLISTENTRY>
-<TERM>
-UPDATE <replaceable class="parameter">#</replaceable>
-</TERM>
-<LISTITEM>
-<PARA>
- Message returned if successful.
-The <replaceable class="parameter">#</replaceable>
- means the number of rows updated.
-If <replaceable class="parameter">#</replaceable>
- is equal 0 no rows are updated.
-</LISTITEM>
-</VARLISTENTRY>
-</VARIABLELIST>
-
-</REFSECT2>
-</REFSYNOPSISDIV>
-
-<REFSECT1 ID="R1-SQL-UPDATE-1">
-<REFSECT1INFO>
-<DATE>1998-09-24</DATE>
-</REFSECT1INFO>
-<TITLE>
-Description
-</TITLE>
-<PARA>
- UPDATE changes the values of the columns specified for
- all rows which satisfy condition. Only the columns
- to be modified need appear as column.
-
-<PARA>
- Array references use the same syntax found in SELECT.
- That is, either single array elements, a range of array
- elements or the entire array may be replaced with a single
- query.
-
-<PARA>
- You must have write access to the table in order to modify
- it, as well as read access to any table whose values are
- mentioned in the WHERE condition.
-
-</REFSECT1>
-
-<REFSECT1 ID="R1-SQL-UPDATE-2">
-<TITLE>
-Usage
-</TITLE>
-<PARA>
-</PARA>
-<ProgramListing>
+ <REFSECT2 ID="R2-SQL-UPDATE-1">
+ <REFSECT2INFO>
+ <DATE>1998-09-24</DATE>
+ </REFSECT2INFO>
+ <TITLE>
+ Inputs
+ </TITLE>
+ <PARA>
+
+ <VARIABLELIST>
+ <VARLISTENTRY>
+ <TERM>
+ <REPLACEABLE CLASS="PARAMETER">table</replaceable>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ The name of an existing table.
+ </para>
+ </LISTITEM>
+ </VARLISTENTRY>
+ <VARLISTENTRY>
+ <TERM>
+ <REPLACEABLE CLASS="PARAMETER">column</replaceable>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ The name of a column in <REPLACEABLE CLASS="PARAMETER">table</replaceable>.
+ </para>
+ </LISTITEM>
+ </VARLISTENTRY>
+ <VARLISTENTRY>
+ <TERM>
+ <REPLACEABLE CLASS="PARAMETER">expression</replaceable>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ A valid expression or value to assign to column.
+ </para>
+ </LISTITEM>
+ </VARLISTENTRY>
+ <VARLISTENTRY>
+ <TERM>
+ <REPLACEABLE CLASS="PARAMETER">fromlist</REPLACEABLE>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ A <productname>Postgres</productname>
+ non-standard extension to allow columns
+ from other tables to appear in the WHERE condition.
+ </para>
+ </LISTITEM>
+ </VARLISTENTRY>
+ <VARLISTENTRY>
+ <TERM>
+ <REPLACEABLE CLASS="PARAMETER">condition</REPLACEABLE>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Refer to the SELECT statement for a further description
+ of the WHERE clause.
+ </para>
+ </LISTITEM>
+ </VARLISTENTRY>
+ </VARIABLELIST>
+ </para>
+ </REFSECT2>
+
+ <REFSECT2 ID="R2-SQL-UPDATE-2">
+ <REFSECT2INFO>
+ <DATE>1998-09-24</DATE>
+ </REFSECT2INFO>
+ <TITLE>
+ Outputs
+ </TITLE>
+ <PARA>
+
+ <VARIABLELIST>
+ <VARLISTENTRY>
+ <TERM>
+ UPDATE <replaceable class="parameter">#</replaceable>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ Message returned if successful.
+ The <replaceable class="parameter">#</replaceable>
+ means the number of rows updated.
+ If <replaceable class="parameter">#</replaceable>
+ is equal 0 no rows are updated.
+ </para>
+ </LISTITEM>
+ </VARLISTENTRY>
+ </VARIABLELIST>
+ </para>
+ </REFSECT2>
+ </REFSYNOPSISDIV>
+
+ <REFSECT1 ID="R1-SQL-UPDATE-1">
+ <REFSECT1INFO>
+ <DATE>1998-09-24</DATE>
+ </REFSECT1INFO>
+ <TITLE>
+ Description
+ </TITLE>
+ <PARA>
+ UPDATE changes the values of the columns specified for
+ all rows which satisfy condition. Only the columns
+ to be modified need appear as column.
+ </para>
+ <PARA>
+ Array references use the same syntax found in SELECT.
+ That is, either single array elements, a range of array
+ elements or the entire array may be replaced with a single
+ query.
+ </para>
+ <PARA>
+ You must have write access to the table in order to modify
+ it, as well as read access to any table whose values are
+ mentioned in the WHERE condition.
+ </para>
+ </REFSECT1>
+
+ <REFSECT1 ID="R1-SQL-UPDATE-2">
+ <TITLE>
+ Usage
+ </TITLE>
+ <PARA>
+ </PARA>
+ <ProgramListing>
--Change word "Drama" with "Dramatic" on column kind:
--
UPDATE films
M_401|War and Peace|104|1967-02-12|Dramatic | 05:57
T_601|Yojimbo |106|1961-06-16|Dramatic | 01:50
DA101|Das Boot |110|1981-11-11|Dramatic | 02:29
-</ProgramListing>
-
-</REFSECT1>
-
-<REFSECT1 ID="R1-SQL-UPDATE-3">
-<TITLE>
-Compatibility
-</TITLE>
-<PARA>
-</PARA>
-
-<REFSECT2 ID="R2-SQL-UPDATE-4">
-<REFSECT2INFO>
-<DATE>1998-09-24</DATE>
-</REFSECT2INFO>
-<TITLE>
-SQL92
-</TITLE>
-<PARA>
- SQL92 defines a different syntax for positioned UPDATE statement:
-
-<programlisting>
+ </ProgramListing>
+
+ </REFSECT1>
+
+ <REFSECT1 ID="R1-SQL-UPDATE-3">
+ <TITLE>
+ Compatibility
+ </TITLE>
+ <PARA>
+ </PARA>
+
+ <REFSECT2 ID="R2-SQL-UPDATE-4">
+ <REFSECT2INFO>
+ <DATE>1998-09-24</DATE>
+ </REFSECT2INFO>
+ <TITLE>
+ SQL92
+ </TITLE>
+ <PARA>
+ SQL92 defines a different syntax for positioned UPDATE statement:
+
+ <programlisting>
UPDATE table SET column = expression [, ...]
WHERE CURRENT OF <replaceable class="parameter">cursor</replaceable>
-</programlisting>
+ </programlisting>
- where <replaceable class="parameter">cursor</replaceable>
- identifies an open cursor.
+ where <replaceable class="parameter">cursor</replaceable>
+ identifies an open cursor.
+ </para>
+ </refsect2>
+ </refsect1>
</REFENTRY>
<REFPURPOSE>
Clean and analyze a <productname>Postgres</productname> database
</REFPURPOSE>
+ </refnamediv>
<REFSYNOPSISDIV>
<REFSYNOPSISDIVINFO>
<DATE>1998-10-04</DATE>
VACUUM [ VERBOSE ] ANALYZE [ <REPLACEABLE CLASS="PARAMETER">table</REPLACEABLE> [ (<REPLACEABLE CLASS="PARAMETER">column</REPLACEABLE> [, ...] ) ] ]
</SYNOPSIS>
-<REFSECT2 ID="R2-SQL-VACUUM-1">
-<REFSECT2INFO>
-<DATE>1998-10-04</DATE>
-</REFSECT2INFO>
-<TITLE>
-Inputs
-</TITLE>
-<PARA>
-
-<VARIABLELIST>
-<VARLISTENTRY>
-<TERM>
-VERBOSE
-<LISTITEM>
-<PARA>
-Prints a detailed vacuum activity report for each table.
-
-<VARLISTENTRY>
-<TERM>
-ANALYZE
-<LISTITEM>
-<PARA>
-Updates column statistics used by the optimizer to
-determine the most efficient way to execute a query.
-The statistics represent the disbursion of the data in each column.
-This information is valuable when several execution paths are possible.
-
-<VARLISTENTRY>
-<TERM>
-<REPLACEABLE CLASS="PARAMETER">table</REPLACEABLE>
-<LISTITEM>
-<PARA>
-The name of a specific table to vacuum. Defaults to all tables.
-
-<VARLISTENTRY>
-<TERM>
-<REPLACEABLE CLASS="PARAMETER">column</REPLACEABLE>
-<LISTITEM>
-<PARA>
-The name of a specific column to analyze. Defaults to all columns.
-
-</VARIABLELIST>
-
-</REFSECT2>
-
-<REFSECT2 ID="R2-SQL-VACUUM-2">
-<REFSECT2INFO>
-<DATE>1998-10-04</DATE>
-</REFSECT2INFO>
-<TITLE>
-Outputs
-</TITLE>
-<PARA>
-
-<VARIABLELIST>
-<VARLISTENTRY>
-<TERM>
-<ReturnValue>VACUUM</ReturnValue>
-</TERM>
-<LISTITEM>
-<PARA>
-The command has been accepted and the database is being cleaned.
-
-<VARLISTENTRY>
-<TERM>
-NOTICE: --Relation <REPLACEABLE CLASS="PARAMETER">table</REPLACEABLE>--
-<LISTITEM>
-<PARA>
-The report header for <REPLACEABLE CLASS="PARAMETER">table</REPLACEABLE>.
-
-<VARLISTENTRY>
-<TERM>
-NOTICE: Pages 98: Changed 25, Reapped 74, Empty 0, New 0;
- Tup 1000: Vac 3000, Crash 0, UnUsed 0, MinLen 188, MaxLen 188;
- Re-using: Free/Avail. Space 586952/586952; EndEmpty/Avail. Pages 0/74.
- Elapsed 0/0 sec.
-<LISTITEM>
-<PARA>
-The analysis for <REPLACEABLE CLASS="PARAMETER">table</REPLACEABLE> itself.
-
-<VARLISTENTRY>
-<TERM>
-NOTICE: Index <REPLACEABLE CLASS="PARAMETER">index</REPLACEABLE>: Pages 28;
- Tuples 1000: Deleted 3000. Elapsed 0/0 sec.
-<LISTITEM>
-<PARA>
-The analysis for an index on the target table.
-
-</VARIABLELIST>
-
-</REFSECT2>
-</REFSYNOPSISDIV>
-
-<REFSECT1 ID="R1-SQL-VACUUM-1">
-<REFSECT1INFO>
-<DATE>1998-10-04</DATE>
-</REFSECT1INFO>
-<TITLE>
-Description
-</TITLE>
-<PARA>
-<command>VACUUM</command> serves two purposes in
-<productname>Postgres</productname> as both a means to reclaim storage and
-also a means to collect information for the optimizer.
-
-<para>
-<command>VACUUM</command> opens every class in the database,
-cleans out records from rolled back transactions, and updates statistics in the
-system catalogs. The statistics maintained include the number of
-tuples and number of pages stored in all classes.
-
-Running <command>VACUUM</command>
-periodically will increase the speed of the database in processing user queries.
-
-<REFSECT2 ID="R2-SQL-VACUUM-3">
-<REFSECT2INFO>
-<DATE>1998-10-04</DATE>
-</REFSECT2INFO>
-<TITLE>
-Notes
-</TITLE>
-<PARA>
-The open database is target for <command>VACUUM</command>.
-
-<para>
-We recommend that active production databases be cleaned nightly, in order
-to keep statistics relatively current. The <command>VACUUM</command>
-query may be executed at any time, however. In particular, after
-copying a large class into <productname>Postgres</productname>
-or after deleting a large number of
-records, it may be a good idea to issue a <command>VACUUM</command>
-query. This will update the system catalogs with the results of all
-recent changes, and allow the <productname>Postgres</productname>
-query optimizer to make better choices in planning user queries.
-
-<para>
-If the server crashes during a <command>VACUUM</command> command,
-chances are it will leave a lock file hanging around.
-Attempts to re-run the <command>VACUUM</command> command
-result in an error message about the creation of a lock file. If you
-are sure <command>VACUUM</command> is not running,
-remove the <filename>pg_vlock</filename> file in your
-database directory
-(i.e. <filename><envar>PGDATA</envar>/base/dbname/pg_vlock</filename>).
-</PARA>
-
-</REFSECT2>
-
-<REFSECT1 ID="R1-SQL-VACUUM-2">
-<TITLE>
-Usage
-</TITLE>
-<PARA>
-The following is an example from running <command>VACUUM</command> on a table
-in the regression database:
-
-<ProgramListing>
+ <REFSECT2 ID="R2-SQL-VACUUM-1">
+ <REFSECT2INFO>
+ <DATE>1998-10-04</DATE>
+ </REFSECT2INFO>
+ <TITLE>
+ Inputs
+ </TITLE>
+ <PARA>
+
+ <VARIABLELIST>
+ <VARLISTENTRY>
+ <TERM>
+ VERBOSE
+ </term>
+ <LISTITEM>
+ <PARA>
+ Prints a detailed vacuum activity report for each table.
+ </para>
+ </listitem>
+ </varlistentry>
+ <VARLISTENTRY>
+ <TERM>
+ ANALYZE
+ </term>
+ <LISTITEM>
+ <PARA>
+ Updates column statistics used by the optimizer to
+ determine the most efficient way to execute a query.
+ The statistics represent the disbursion of the data in each column.
+ This information is valuable when several execution paths are possible.
+ </para>
+ </listitem>
+ </varlistentry>
+ <VARLISTENTRY>
+ <TERM>
+ <REPLACEABLE CLASS="PARAMETER">table</REPLACEABLE>
+ </term>
+ <LISTITEM>
+ <PARA>
+ The name of a specific table to vacuum. Defaults to all tables.
+ </para>
+ </listitem>
+ </varlistentry>
+ <VARLISTENTRY>
+ <TERM>
+ <REPLACEABLE CLASS="PARAMETER">column</REPLACEABLE>
+ </term>
+ <LISTITEM>
+ <PARA>
+ The name of a specific column to analyze. Defaults to all columns.
+ </para>
+ </listitem>
+ </varlistentry>
+ </VARIABLELIST>
+ </para>
+ </REFSECT2>
+
+ <REFSECT2 ID="R2-SQL-VACUUM-2">
+ <REFSECT2INFO>
+ <DATE>1998-10-04</DATE>
+ </REFSECT2INFO>
+ <TITLE>
+ Outputs
+ </TITLE>
+ <PARA>
+
+ <VARIABLELIST>
+ <VARLISTENTRY>
+ <TERM>
+ <ReturnValue>VACUUM</ReturnValue>
+ </TERM>
+ <LISTITEM>
+ <PARA>
+ The command has been accepted and the database is being cleaned.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <VARLISTENTRY>
+ <TERM>
+ NOTICE: --Relation <REPLACEABLE CLASS="PARAMETER">table</REPLACEABLE>--
+ </term>
+ <LISTITEM>
+ <PARA>
+ The report header for <REPLACEABLE CLASS="PARAMETER">table</REPLACEABLE>.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <VARLISTENTRY>
+ <TERM>
+ NOTICE: Pages 98: Changed 25, Reapped 74, Empty 0, New 0;
+ Tup 1000: Vac 3000, Crash 0, UnUsed 0, MinLen 188, MaxLen 188;
+ Re-using: Free/Avail. Space 586952/586952; EndEmpty/Avail. Pages 0/74.
+ Elapsed 0/0 sec.
+ </term>
+ <LISTITEM>
+ <PARA>
+ The analysis for <REPLACEABLE CLASS="PARAMETER">table</REPLACEABLE> itself.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <VARLISTENTRY>
+ <TERM>
+ NOTICE: Index <REPLACEABLE CLASS="PARAMETER">index</REPLACEABLE>: Pages 28;
+ Tuples 1000: Deleted 3000. Elapsed 0/0 sec.
+ </term>
+ <LISTITEM>
+ <PARA>
+ The analysis for an index on the target table.
+ </para>
+ </listitem>
+ </varlistentry>
+ </VARIABLELIST>
+ </para>
+ </REFSECT2>
+ </REFSYNOPSISDIV>
+
+ <REFSECT1 ID="R1-SQL-VACUUM-1">
+ <REFSECT1INFO>
+ <DATE>1998-10-04</DATE>
+ </REFSECT1INFO>
+ <TITLE>
+ Description
+ </TITLE>
+ <PARA>
+ <command>VACUUM</command> serves two purposes in
+ <productname>Postgres</productname> as both a means to reclaim storage and
+ also a means to collect information for the optimizer.
+ </para>
+ <para>
+ <command>VACUUM</command> opens every class in the database,
+ cleans out records from rolled back transactions, and updates statistics in the
+ system catalogs. The statistics maintained include the number of
+ tuples and number of pages stored in all classes.
+
+ Running <command>VACUUM</command>
+ periodically will increase the speed of the database in processing user queries.
+ </para>
+
+ <REFSECT2 ID="R2-SQL-VACUUM-3">
+ <REFSECT2INFO>
+ <DATE>1998-10-04</DATE>
+ </REFSECT2INFO>
+ <TITLE>
+ Notes
+ </TITLE>
+ <PARA>
+ The open database is target for <command>VACUUM</command>.
+ </para>
+ <para>
+ We recommend that active production databases be cleaned nightly, in order
+ to keep statistics relatively current. The <command>VACUUM</command>
+ query may be executed at any time, however. In particular, after
+ copying a large class into <productname>Postgres</productname>
+ or after deleting a large number of
+ records, it may be a good idea to issue a <command>VACUUM</command>
+ query. This will update the system catalogs with the results of all
+ recent changes, and allow the <productname>Postgres</productname>
+ query optimizer to make better choices in planning user queries.
+ </para>
+ <para>
+ If the server crashes during a <command>VACUUM</command> command,
+ chances are it will leave a lock file hanging around.
+ Attempts to re-run the <command>VACUUM</command> command
+ result in an error message about the creation of a lock file. If you
+ are sure <command>VACUUM</command> is not running,
+ remove the <filename>pg_vlock</filename> file in your
+ database directory
+ (i.e. <filename><envar>PGDATA</envar>/base/dbname/pg_vlock</filename>).
+ </PARA>
+
+ </REFSECT2>
+ </refsect1>
+
+ <REFSECT1 ID="R1-SQL-VACUUM-2">
+ <TITLE>
+ Usage
+ </TITLE>
+ <PARA>
+ The following is an example from running <command>VACUUM</command> on a table
+ in the regression database:
+
+ <ProgramListing>
regression=> vacuum verbose analyze onek;
NOTICE: --Relation onek--
NOTICE: Pages 98: Changed 25, Reapped 74, Empty 0, New 0;
NOTICE: Index onek_unique2: Pages 19; Tuples 1000: Deleted 1000. Elapsed 0/0 sec.
NOTICE: Index onek_unique1: Pages 17; Tuples 1000: Deleted 1000. Elapsed 0/0 sec.
VACUUM
-</ProgramListing>
-
-</REFSECT1>
-
-<REFSECT1 ID="R1-SQL-VACUUM-3">
-<TITLE>
-Compatibility
-</TITLE>
-<PARA>
-
-<REFSECT2 ID="R2-SQL-VACUUM-4">
-<REFSECT2INFO>
-<DATE>1998-10-04</DATE>
-</REFSECT2INFO>
-<TITLE>
-SQL92
-</TITLE>
-<PARA>
-There is no <COMMAND>VACUUM</COMMAND> statement in SQL92.
-
+ </ProgramListing>
+ </para>
+ </REFSECT1>
+
+ <REFSECT1 ID="R1-SQL-VACUUM-3">
+ <TITLE>
+ Compatibility
+ </TITLE>
+ <REFSECT2 ID="R2-SQL-VACUUM-4">
+ <REFSECT2INFO>
+ <DATE>1998-10-04</DATE>
+ </REFSECT2INFO>
+ <TITLE>
+ SQL92
+ </TITLE>
+ <PARA>
+ There is no <COMMAND>VACUUM</COMMAND> statement in SQL92.
+ </para>
+ </refsect2>
+ </refsect1>
</REFENTRY>
<REFPURPOSE>
Clean and analyze a <productname>Postgres</productname> database
</REFPURPOSE>
+ </refnamediv>
<REFSYNOPSISDIV>
<REFSYNOPSISDIVINFO>
<DATE>1998-10-04</DATE>
[ <replaceable class="parameter">dbname</replaceable> ]
</SYNOPSIS>
-<REFSECT2 ID="R2-APP-VACUUMDB-1">
-<REFSECT2INFO>
-<DATE>1998-10-04</DATE>
-</REFSECT2INFO>
-<TITLE>
-Inputs
-</TITLE>
-<PARA>
-<application>vacuumdb</application> accepts the following command line arguments:
-
-<variablelist>
-<varlistentry>
-<term>
-<replaceable class="parameter">dbname</replaceable>
-</term>
-<listitem>
-<para>
-Specifies the name of the database to be cleaned or analyzed.
-<replaceable class="parameter">dbname</replaceable>
-defaults to the value of the
-<envar>USER</envar>
-environment variable.
-
-<varlistentry>
-<term>
---analyze
-</term>
-<term>
--z
-</term>
-<listitem>
-<para>
-Calculate statistics on the database for use by the optimizer.
-
-<varlistentry>
-<term>
---verbose
-</term>
-<term>
--v
-</term>
-<listitem>
-<para>
-Print detailed information during processing.
-
-<varlistentry>
-<term>
---table <replaceable class="parameter">table</replaceable> [ (<replaceable class="parameter">column</replaceable> [,...]) ]
-</term>
-<term>
--t <replaceable class="parameter">table</replaceable> [ (<replaceable class="parameter">column</replaceable> [,...]) ]
-</term>
-<listitem>
-<para>
-Clean or analyze <replaceable class="parameter">table</replaceable> only.
-Column names may be specified only in conjunction with
- the <option>--analyze</option> option.
-
-</variablelist>
-
-<para>
-<application>vacuumdb</application> also accepts
-the following command line arguments for connection parameters:
-
-<variablelist>
-<varlistentry>
-<term>
--h <replaceable class="parameter">host</replaceable>
-</term>
-<listitem>
-<para>
-Specifies the hostname of the machine on which the
-<application>postmaster</application>
-is running. Defaults to using a local Unix domain socket
- rather than an IP connection..
-
-<varlistentry>
-<term>
--p <replaceable class="parameter">port</replaceable>
-</term>
-<listitem>
-<para>
-Specifies the Internet TCP/IP port or local Unix domain socket file
-extension on which the <application>postmaster</application>
-is listening for connections. The port number defaults to 5432,
- or the value of the <envar>PGPORT</envar>
-environment variable (if set).
-
-<varlistentry>
-<term>
--u
-</term>
-<listitem>
-<para>
-Use password authentication.
-Prompts for
-<replaceable class="parameter">username</replaceable>
- and <replaceable class="parameter">password</replaceable>.
-
-</variablelist>
-
-<REFSECT2 ID="R2-APP-VACUUMDB-2">
-<REFSECT2INFO>
-<DATE>1998-10-04</DATE>
-</REFSECT2INFO>
-<TITLE>
-Outputs
-</TITLE>
-<PARA>
-<application>vacuumdb</application> executes a <command>VACUUM</command> command
-on the specified database, so has not explicit external output.
-
-<variablelist>
-<varlistentry>
-<term>
-ERROR: Can't vacuum columns, only tables. You can 'vacuum analyze' columns.
-vacuumdb: database vacuum failed on <replaceable class="parameter">dbname</replaceable>.
-<listitem>
-<para>
-The non-analyze mode requires cleaning full tables or databases.
-Individual columns may be specified only when analyzing a specific table.
-
-<varlistentry>
-<term>
-Connection to database 'template1' failed.
-connectDB() failed: Is the postmaster running and accepting connections
- at 'UNIX Socket' on port '<replaceable class="parameter">port</replaceable>'?
-<listitem>
-<para>
-<application>vacuumdb</application> could not attach to the
-<application>postmaster</application>
-process on the specified host and port. If you see this message,
-ensure that the <application>postmaster</application>
-is running on the proper host and that you have specified the proper
-port. If your site uses an authentication system, ensure that you
-have obtained the required authentication credentials.
-
-<varlistentry>
-<term>
-Connection to database '<replaceable class="parameter">dbname</replaceable>' failed.
-FATAL 1: SetUserId: user '<replaceable class="parameter">username</replaceable>' is not in 'pg_shadow'
-<listitem>
-<para>
-You do not have a valid entry in the relation <literal>pg_shadow</literal>
-and and will not be allowed to access <productname>Postgres</productname>.
-Contact your <productname>Postgres</productname> administrator.
-
-</variablelist>
-
-<note>
-<para>
-<application>vacuumdb</application> internally executes a
-<command>VACUUM</command> <acronym>SQL</acronym> statement.
-If you have problems running <application>vacuumdb</application>,
-make sure you are able to run <command>VACUUM</command> on the database using, for
-example, <application>psql</application>.
-</note>
+ <REFSECT2 ID="R2-APP-VACUUMDB-1">
+ <REFSECT2INFO>
+ <DATE>1998-10-04</DATE>
+ </REFSECT2INFO>
+ <TITLE>
+ Inputs
+ </TITLE>
+ <PARA>
+ <application>vacuumdb</application> accepts the following command line arguments:
+
+ <variablelist>
+ <varlistentry>
+ <term>
+ <replaceable class="parameter">dbname</replaceable>
+ </term>
+ <listitem>
+ <para>
+ Specifies the name of the database to be cleaned or analyzed.
+ <replaceable class="parameter">dbname</replaceable>
+ defaults to the value of the
+ <envar>USER</envar>
+ environment variable.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ --analyze
+ </term>
+ <term>
+ -z
+ </term>
+ <listitem>
+ <para>
+ Calculate statistics on the database for use by the optimizer.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ --verbose
+ </term>
+ <term>
+ -v
+ </term>
+ <listitem>
+ <para>
+ Print detailed information during processing.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ --table <replaceable class="parameter">table</replaceable> [ (<replaceable class="parameter">column</replaceable> [,...]) ]
+ </term>
+ <term>
+ -t <replaceable class="parameter">table</replaceable> [ (<replaceable class="parameter">column</replaceable> [,...]) ]
+ </term>
+ <listitem>
+ <para>
+ Clean or analyze <replaceable class="parameter">table</replaceable> only.
+ Column names may be specified only in conjunction with
+ the <option>--analyze</option> option.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </para>
+ <para>
+ <application>vacuumdb</application> also accepts
+ the following command line arguments for connection parameters:
+
+ <variablelist>
+ <varlistentry>
+ <term>
+ -h <replaceable class="parameter">host</replaceable>
+ </term>
+ <listitem>
+ <para>
+ Specifies the hostname of the machine on which the
+ <application>postmaster</application>
+ is running. Defaults to using a local Unix domain socket
+ rather than an IP connection..
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ -p <replaceable class="parameter">port</replaceable>
+ </term>
+ <listitem>
+ <para>
+ Specifies the Internet TCP/IP port or local Unix domain socket file
+ extension on which the <application>postmaster</application>
+ is listening for connections. The port number defaults to 5432,
+ or the value of the <envar>PGPORT</envar>
+ environment variable (if set).
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ -u
+ </term>
+ <listitem>
+ <para>
+ Use password authentication.
+ Prompts for
+ <replaceable class="parameter">username</replaceable>
+ and <replaceable class="parameter">password</replaceable>.
+ </para>
+ </listitem>
+ </varlistentry>
-<REFSECT1 ID="R1-APP-VACUUMDB-1">
-<REFSECT1INFO>
-<DATE>1998-10-04</DATE>
-</REFSECT1INFO>
-<TITLE>
-Description
-</TITLE>
-
-<PARA>
-<application>vacuumdb</application> is a utility for cleaning a
-<productname>Postgres</productname> database.
-<application>vacuumdb</application> will also generate internal statistics
-used by the <productname>Postgres</productname> query optimizer.
-
-<REFSECT1 ID="R1-APP-VACUUMDB-2">
-<REFSECT1INFO>
-<DATE>1998-10-04</DATE>
-</REFSECT1INFO>
-<TITLE>
-Notes
-</TITLE>
-
-<para>
-See <xref linkend="vacuum" endterm="vacuum"> for more details.
+ </variablelist>
+ </para>
+ </refsect2>
-<REFSECT1 ID="R1-APP-VACUUMDB-3">
-<REFSECT1INFO>
-<DATE>1998-10-04</DATE>
-</REFSECT1INFO>
-<TITLE>
-Usage
-</TITLE>
-<PARA>
-To clean a database of the same name as the user:
+ <REFSECT2 ID="R2-APP-VACUUMDB-2">
+ <REFSECT2INFO>
+ <DATE>1998-10-04</DATE>
+ </REFSECT2INFO>
+ <TITLE>
+ Outputs
+ </TITLE>
+ <PARA>
+ <application>vacuumdb</application> executes a <command>VACUUM</command> command
+ on the specified database, so has not explicit external output.
-<programlisting>
-% vacuumdb
-</programlisting>
+ <variablelist>
+ <varlistentry>
+ <term>
+ ERROR: Can't vacuum columns, only tables. You can 'vacuum analyze' columns.
+ vacuumdb: database vacuum failed on <replaceable class="parameter">dbname</replaceable>.
+ </term>
+ <listitem>
+ <para>
+ The non-analyze mode requires cleaning full tables or databases.
+ Individual columns may be specified only when analyzing a specific table.
+ </para>
+ </listitem>
+ </varlistentry>
-<para>
-To analyze a database named <literal>bigdb</literal> for the optimizer:
+ <varlistentry>
+ <term>
+ Connection to database 'template1' failed.
+ connectDB() failed: Is the postmaster running and accepting connections
+ at 'UNIX Socket' on port '<replaceable class="parameter">port</replaceable>'?
+ </term>
+ <listitem>
+ <para>
+ <application>vacuumdb</application> could not attach to the
+ <application>postmaster</application>
+ process on the specified host and port. If you see this message,
+ ensure that the <application>postmaster</application>
+ is running on the proper host and that you have specified the proper
+ port. If your site uses an authentication system, ensure that you
+ have obtained the required authentication credentials.
+ </para>
+ </listitem>
+ </varlistentry>
-<programlisting>
-% vacuumdb --analyze bigdb
-</programlisting>
+ <varlistentry>
+ <term>
+ Connection to database '<replaceable class="parameter">dbname</replaceable>' failed.
+ FATAL 1: SetUserId: user '<replaceable class="parameter">username</replaceable>' is not in 'pg_shadow'
+ </term>
+ <listitem>
+ <para>
+ You do not have a valid entry in the relation <literal>pg_shadow</literal>
+ and and will not be allowed to access <productname>Postgres</productname>.
+ Contact your <productname>Postgres</productname> administrator.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </para>
-<para>
-To analyze a single column <literal>bar</literal> in table <literal>foo</literal>
- in a database named <literal>xyzzy</literal> for the optimizer:
+ <note>
+ <para>
+ <application>vacuumdb</application> internally executes a
+ <command>VACUUM</command> <acronym>SQL</acronym> statement.
+ If you have problems running <application>vacuumdb</application>,
+ make sure you are able to run <command>VACUUM</command> on the database using, for
+ example, <application>psql</application>.
+ </para>
+ </note>
+ </refsect2>
+ </refsynopsisdiv>
+
+ <REFSECT1 ID="R1-APP-VACUUMDB-1">
+ <REFSECT1INFO>
+ <DATE>1998-10-04</DATE>
+ </REFSECT1INFO>
+ <TITLE>
+ Description
+ </TITLE>
+
+ <PARA>
+ <application>vacuumdb</application> is a utility for cleaning a
+ <productname>Postgres</productname> database.
+ <application>vacuumdb</application> will also generate internal statistics
+ used by the <productname>Postgres</productname> query optimizer.
+ </para>
+ </refsect1>
-<programlisting>
-% vacuumdb --analyze --verbose --table 'foo(bar)' xyzzy
-</programlisting>
+ <REFSECT1 ID="R1-APP-VACUUMDB-2">
+ <REFSECT1INFO>
+ <DATE>1998-10-04</DATE>
+ </REFSECT1INFO>
+ <TITLE>
+ Notes
+ </TITLE>
+
+ <para>
+ See <xref linkend="vacuum" endterm="vacuum"> for more details.
+ </para>
+ </refsect1>
+
+ <REFSECT1 ID="R1-APP-VACUUMDB-3">
+ <REFSECT1INFO>
+ <DATE>1998-10-04</DATE>
+ </REFSECT1INFO>
+ <TITLE>
+ Usage
+ </TITLE>
+ <PARA>
+ To clean a database of the same name as the user:
+
+ <programlisting>
+ % vacuumdb
+ </programlisting>
+ </para>
+ <para>
+ To analyze a database named <literal>bigdb</literal> for the optimizer:
+ <programlisting>
+ % vacuumdb --analyze bigdb
+ </programlisting>
+ </para>
+ <para>
+ To analyze a single column <literal>bar</literal> in table <literal>foo</literal>
+ in a database named <literal>xyzzy</literal> for the optimizer:
+
+ <programlisting>
+ % vacuumdb --analyze --verbose --table 'foo(bar)' xyzzy
+ </programlisting>
+ </para>
+ </refsect1>
</REFENTRY>
<!-- Keep this comment at the end of the file
is not available, you can set the time zone rules explicitly:
<ProgramListing>
setenv PGTZ PST8PDT7,M04.01.0,M10.05.03
-</ProgramListing>
-</Para>
-
-<Sect1>
-<Title>Directory Layout</Title>
-
-<Para>
-<Note>
-<Para>
-This should become a table in the previous section.
-</Para>
-</Note>
-</Para>
-
-<Para>
-<ProgramListing>
+ </ProgramListing>
+ </Para>
+ </sect1>
+
+ <Sect1>
+ <Title>Directory Layout</Title>
+
+ <Para>
+ <Note>
+ <Para>
+ This should become a table in the previous section.
+ </Para>
+ </Note>
+ </Para>
+
+ <Para>
+ <ProgramListing>
input/ .... .source files that are converted using 'make all' into
some of the .sql files in the 'sql' subdirectory
results/ .. .out files that represent what the results *actually* look
like. Also used as temporary storage for table copy testing.
-</ProgramListing>
-</Para>
-
-</Sect1>
-
-<Sect1>
-<Title>Regression Test Procedure</Title>
-
-<Para>
-Commands were tested on RedHat Linux version 4.2 using the bash shell.
-Except where noted, they will probably work on most systems. Commands
-like <FileName>ps</FileName> and <FileName>tar</FileName> vary wildly on what options you should use on each
-platform. <Emphasis>Use common sense</Emphasis> before typing in these commands.
-</Para>
-
-<Para>
-<Procedure>
-<Title><ProductName>Postgres</ProductName> Regression Configuration</Title>
-
-<Para>
-For a fresh install or upgrading from previous releases of
-<ProductName>Postgres</ProductName>:
-</Para>
-
-<Step Performance="required">
-<Para>
-Build the regression test. Type
-<ProgramListing>
- cd /usr/src/pgsql/src/test/regress
- gmake all
-</ProgramListing>
-</Para>
-</Step>
-
-<Step Performance="optional">
-<Para>
- If you have prevously invoked the regression test, clean up the
- working directory with:
-
-<ProgramListing>
- cd /usr/src/pgsql/src/test/regress
- make clean
-</ProgramListing>
-
-<Step Performance="required">
-<Para>
- The file /usr/src/pgsql/src/test/regress/README has detailed
- instructions for running and interpreting the regression tests.
- A short version follows here:
-</Para>
-
-<Para>
-If the postmaster is not already running, start the postmaster on an
-available window by typing
-<ProgramListing>
- postmaster
-</ProgramListing>
-
-or start the postmaster daemon running in the background by typing
-<ProgramListing>
- cd
- nohup postmaster > regress.log 2>&1 &
-</ProgramListing>
-</Para>
-
-<Para>
- Run postmaster from your <ProductName>Postgres</ProductName> super user account (typically
- account postgres).
-
-<Note>
-<Para>
-Do not run <FileName>postmaster</FileName> from the root account.
-</Para>
-</Note>
-</Para>
-</Step>
-
-<Step Performance="required">
-<Para>
- Run the regression tests. Type
-
-<ProgramListing>
- cd /usr/src/pgsql/src/test/regress
- gmake runtest
-</ProgramListing>
-</Para>
-
-<Para>
-
- You do not need to type "gmake clean" if this is the first time you
- are running the tests.
-</Para>
-</Step>
-
-<Step Performance="required">
-<Para>
-
- You should get on the screen (and also written to file ./regress.out)
- a series of statements stating which tests passed and which tests
- failed. Please note that it can be normal for some of the tests to
- "fail". For the failed tests, use diff to compare the files in
- directories ./results and ./expected. If float8 failed, type
- something like:
-<ProgramListing>
- cd /usr/src/pgsql/src/test/regress
- diff -w expected/float8.out results
-</ProgramListing>
-</Para>
-</Step>
-
-<Step Performance="required">
-<Para>
- After running the tests, type
-<ProgramListing>
- destroydb regression
- cd /usr/src/pgsql/src/test/regress
- gmake clean
-</ProgramListing>
-</Para>
-</Step>
-
-</Procedure>
-
-</Sect1>
-
-<Sect1>
-<Title>Regression Analysis</Title>
-
-<Para>
- <Quote>Failed</Quote> tests may have failed due to slightly different error messages,
- math libraries, or output formatting.
- "Failures" of this type do not indicate a problem with
- <ProductName>Postgres</ProductName>.
-</Para>
-
-<Para>
- For a i686/Linux-ELF platform, no tests failed since this is the
- v6.2.1 regression testing reference platform.
-</Para>
-
-<Para>
- For the SPARC/Linux-ELF platform, using the 970525 beta version of
- <ProductName>Postgres</ProductName> v6.2 the following tests "failed":
- float8 and geometry "failed" due to minor precision differences in
- floating point numbers. select_views produces massively different output,
- but the differences are due to minor floating point differences.
-</Para>
-
-<Para>
- Conclusion? If you do see failures, try to understand the nature of
- the differences and then decide if those differences will affect your
- intended use of <ProductName>Postgres</ProductName>. However, keep in mind that this is likely
- to be the most solid release of <ProductName>Postgres</ProductName> to date, incorporating many
- bug fixes from v6.1, and that previous versions of <ProductName>Postgres</ProductName> have been
- in use successfully for some time now.
-</Para>
-
-<Sect2>
-<Title>Comparing expected/actual output</Title>
-
-<Para>
- The results are in files in the ./results directory. These results
- can be compared with results in the ./expected directory using 'diff'.
- The files might not compare exactly. The following paragraphs attempt
- to explain the differences.
-</Para>
-
-</Sect2>
-
-<Sect2>
-<Title>Error message differences</Title>
-
-<Para>
- Some of the regression tests involve intentional invalid input values.
- Error messages can come from either the Postgres code or from the host
- platform system routines. In the latter case, the messages may vary
- between platforms, but should reflect similar information. These
- differences in messages will result in a "failed" regression test which
- can be validated by inspection.
-</Para>
-
-</Sect2>
-
-<Sect2>
-<Title>OID differences</Title>
-
-<Para>
- There are several places where PostgreSQL OID (object identifiers) appear
- in 'regress.out'. OID's are unique 32-bit integers which are generated
- by the PostgreSQL backend whenever a table row is inserted or updated.
- If you run the regression test on a non-virgin database or run it multiple
- times, the OID's reported will have different values.
-
- The following SQL statements in 'misc.out' have shown this behavior:
-
- QUERY: SELECT user_relns() AS user_relns ORDER BY user_relns;
-
- The 'a,523676' row is composed from an OID.
-</Para>
-
-</Sect2>
-
-<Sect2>
-<Title>Date and time differences</Title>
-
-<Para>
- On many supported platforms, you can force PostgreSQL to believe that it
- is running in the same time zone as Berkeley, California. See details in
- the section on how to run the regression tests.
-
- If you do not explicitly set your time zone environment to PST8PDT, then
- most of the date and time results will reflect your local time zone and
- will fail the regression testing.
-
- There appears to be some systems which do not accept the recommended syntax
- for explicitly setting the local time zone rules. Some systems using the
- public domain time zone package exhibit minor problems with pre-1970 PDT
- times, representing them in PST instead.
-</Para>
-
-</Sect2>
-
-<Sect2>
-<Title>Floating point differences</Title>
-
-<Para>
- Some of the tests involve computing 64-bit (<Type>float8</Type>) number from table
- columns. Differences in results involving mathematical functions of
- <Type>float8</Type> columns have been observed. These differences occur where
- different operating systems are used on the same platform ie:
- BSDI and SOLARIS on Intel/86, and where the same operating system is
- used used on different platforms, ie: SOLARIS on SPARC and Intel/86.
-
- Human eyeball comparison is needed to determine the real significance
- of these differences which are usually 10 places to the right of
- the decimal point.
-
- Some systems signal errors from pow() and exp() differently from
- the mechanism expected by the current Postgres code.
-</Para>
-
-</Sect2>
-
-<Sect2>
-<Title>Polygon differences</Title>
-
-<Para>
- Several of the tests involve operations on geographic date about the
- Oakland/Berkley CA street map. The map data is expressed as polygons
- whose vertices are represented as pairs of <Type>float8</Type> numbers (decimal
- latitude and longitude). Initially, some tables are created and
- loaded with geographic data, then some views are created which join
- two tables using the polygon intersection operator (##), then a select
- is done on the view.
-
- When comparing the results from different platforms, differences occur
- in the 2nd or 3rd place to the right of the decimal point. The SQL
- statements where these problems occur are the folowing:
-
-<ProgramListing>
- QUERY: SELECT * from street;
- QUERY: SELECT * from iexit;
-</ProgramListing>
-</Para>
-
-</Sect2>
-
-<Sect2>
-<Title>Random differences</Title>
-
-<Para>
- There is at least one test case in random.out which is intended to produce
- random results. This causes random to fail the regression testing.
- Typing
-<ProgramListing>
- diff results/random.out expected/random.out
-</ProgramListing>
-
- should produce only
- one or a few lines of differences for this reason, but other floating
- point differences on dissimilar architectures might cause many more
- differences. See the release notes below.
-</Para>
-
-</Sect2>
-
-<Sect2>
-<Title>The <Quote>expected</Quote> files</Title>
-
-<Para>
- The <FileName>./expected/*.out</FileName> files were adapted from the original monolithic
- <FileName>expected.input</FileName> file provided by Jolly Chen et al. Newer versions of these
- files generated on various development machines have been substituted after
- careful (?) inspection. Many of the development machines are running a
- Unix OS variant (FreeBSD, Linux, etc) on Ix86 hardware.
-
- The original <FileName>expected.input</FileName> file was created on a SPARC Solaris 2.4
- system using the <FileName>postgres5-1.02a5.tar.gz</FileName> source tree. It was compared
- with a file created on an I386 Solaris 2.4 system and the differences
- were only in the floating point polygons in the 3rd digit to the right
- of the decimal point. (see below)
-
- The original <FileName>sample.regress.out</FileName> file was from the postgres-1.01 release
- constructed by Jolly Chen and is included here for reference. It may
- have been created on a DEC ALPHA machine as the <FileName>Makefile.global</FileName>
- in the postgres-1.01 release has PORTNAME=alpha.
-</Para>
-
-</Sect2>
-
-</Sect1>
-
+ </ProgramListing>
+ </Para>
+ </Sect1>
+
+ <Sect1>
+ <Title>Regression Test Procedure</Title>
+
+ <Para>
+ Commands were tested on RedHat Linux version 4.2 using the bash shell.
+ Except where noted, they will probably work on most systems. Commands
+ like <FileName>ps</FileName> and <FileName>tar</FileName> vary wildly on what options you should use on each
+ platform. <Emphasis>Use common sense</Emphasis> before typing in these commands.
+ </Para>
+
+ <Procedure>
+ <Title><ProductName>Postgres</ProductName> Regression Configuration</Title>
+
+ <Para>
+ For a fresh install or upgrading from previous releases of
+ <ProductName>Postgres</ProductName>:
+ </Para>
+
+ <Step Performance="required">
+ <Para>
+ Build the regression test. Type
+ <ProgramListing>
+ cd /usr/src/pgsql/src/test/regress
+ gmake all
+ </ProgramListing>
+ </Para>
+ </Step>
+
+ <Step Performance="optional">
+ <Para>
+ If you have prevously invoked the regression test, clean up the
+ working directory with:
+
+ <ProgramListing>
+ cd /usr/src/pgsql/src/test/regress
+ make clean
+ </ProgramListing>
+ </para>
+ </step>
+ <Step Performance="required">
+ <Para>
+ The file /usr/src/pgsql/src/test/regress/README has detailed
+ instructions for running and interpreting the regression tests.
+ A short version follows here:
+ </Para>
+
+ <Para>
+ If the postmaster is not already running, start the postmaster on an
+ available window by typing
+ <ProgramListing>
+ postmaster
+ </ProgramListing>
+
+ or start the postmaster daemon running in the background by typing
+ <ProgramListing>
+ cd
+ nohup postmaster > regress.log 2>&1 &
+ </ProgramListing>
+ </Para>
+
+ <Para>
+ Run postmaster from your <ProductName>Postgres</ProductName> super user account (typically
+ account postgres).
+
+ <Note>
+ <Para>
+ Do not run <FileName>postmaster</FileName> from the root account.
+ </Para>
+ </Note>
+ </Para>
+ </Step>
+
+ <Step Performance="required">
+ <Para>
+ Run the regression tests. Type
+
+ <ProgramListing>
+ cd /usr/src/pgsql/src/test/regress
+ gmake runtest
+ </ProgramListing>
+ </Para>
+
+ <Para>
+
+ You do not need to type "gmake clean" if this is the first time you
+ are running the tests.
+ </Para>
+ </Step>
+
+ <Step Performance="required">
+ <Para>
+
+ You should get on the screen (and also written to file ./regress.out)
+ a series of statements stating which tests passed and which tests
+ failed. Please note that it can be normal for some of the tests to
+ "fail". For the failed tests, use diff to compare the files in
+ directories ./results and ./expected. If float8 failed, type
+ something like:
+ <ProgramListing>
+ cd /usr/src/pgsql/src/test/regress
+ diff -w expected/float8.out results
+ </ProgramListing>
+ </Para>
+ </Step>
+
+ <Step Performance="required">
+ <Para>
+ After running the tests, type
+ <ProgramListing>
+ destroydb regression
+ cd /usr/src/pgsql/src/test/regress
+ gmake clean
+ </ProgramListing>
+ </Para>
+ </Step>
+ </procedure>
+ </Sect1>
+
+ <Sect1>
+ <Title>Regression Analysis</Title>
+
+ <Para>
+ <Quote>Failed</Quote> tests may have failed due to slightly different error messages,
+ math libraries, or output formatting.
+ "Failures" of this type do not indicate a problem with
+ <ProductName>Postgres</ProductName>.
+ </Para>
+
+ <Para>
+ For a i686/Linux-ELF platform, no tests failed since this is the
+ v6.2.1 regression testing reference platform.
+ </Para>
+
+ <Para>
+ For the SPARC/Linux-ELF platform, using the 970525 beta version of
+ <ProductName>Postgres</ProductName> v6.2 the following tests "failed":
+ float8 and geometry "failed" due to minor precision differences in
+ floating point numbers. select_views produces massively different output,
+ but the differences are due to minor floating point differences.
+ </Para>
+
+ <Para>
+ Conclusion? If you do see failures, try to understand the nature of
+ the differences and then decide if those differences will affect your
+ intended use of <ProductName>Postgres</ProductName>. However, keep in mind that this is likely
+ to be the most solid release of <ProductName>Postgres</ProductName> to date, incorporating many
+ bug fixes from v6.1, and that previous versions of <ProductName>Postgres</ProductName> have been
+ in use successfully for some time now.
+ </Para>
+
+ <Sect2>
+ <Title>Comparing expected/actual output</Title>
+
+ <Para>
+ The results are in files in the ./results directory. These results
+ can be compared with results in the ./expected directory using 'diff'.
+ The files might not compare exactly. The following paragraphs attempt
+ to explain the differences.
+ </Para>
+
+ </Sect2>
+
+ <Sect2>
+ <Title>Error message differences</Title>
+
+ <Para>
+ Some of the regression tests involve intentional invalid input values.
+ Error messages can come from either the Postgres code or from the host
+ platform system routines. In the latter case, the messages may vary
+ between platforms, but should reflect similar information. These
+ differences in messages will result in a "failed" regression test which
+ can be validated by inspection.
+ </Para>
+
+ </Sect2>
+
+ <Sect2>
+ <Title>OID differences</Title>
+
+ <Para>
+ There are several places where PostgreSQL OID (object identifiers) appear
+ in 'regress.out'. OID's are unique 32-bit integers which are generated
+ by the PostgreSQL backend whenever a table row is inserted or updated.
+ If you run the regression test on a non-virgin database or run it multiple
+ times, the OID's reported will have different values.
+
+ The following SQL statements in 'misc.out' have shown this behavior:
+
+ QUERY: SELECT user_relns() AS user_relns ORDER BY user_relns;
+
+ The 'a,523676' row is composed from an OID.
+ </Para>
+
+ </Sect2>
+
+ <Sect2>
+ <Title>Date and time differences</Title>
+
+ <Para>
+ On many supported platforms, you can force PostgreSQL to believe that it
+ is running in the same time zone as Berkeley, California. See details in
+ the section on how to run the regression tests.
+
+ If you do not explicitly set your time zone environment to PST8PDT, then
+ most of the date and time results will reflect your local time zone and
+ will fail the regression testing.
+
+ There appears to be some systems which do not accept the recommended syntax
+ for explicitly setting the local time zone rules. Some systems using the
+ public domain time zone package exhibit minor problems with pre-1970 PDT
+ times, representing them in PST instead.
+ </Para>
+
+ </Sect2>
+
+ <Sect2>
+ <Title>Floating point differences</Title>
+
+ <Para>
+ Some of the tests involve computing 64-bit (<Type>float8</Type>) number from table
+ columns. Differences in results involving mathematical functions of
+ <Type>float8</Type> columns have been observed. These differences occur where
+ different operating systems are used on the same platform ie:
+ BSDI and SOLARIS on Intel/86, and where the same operating system is
+ used used on different platforms, ie: SOLARIS on SPARC and Intel/86.
+
+ Human eyeball comparison is needed to determine the real significance
+ of these differences which are usually 10 places to the right of
+ the decimal point.
+
+ Some systems signal errors from pow() and exp() differently from
+ the mechanism expected by the current Postgres code.
+ </Para>
+
+ </Sect2>
+
+ <Sect2>
+ <Title>Polygon differences</Title>
+
+ <Para>
+ Several of the tests involve operations on geographic date about the
+ Oakland/Berkley CA street map. The map data is expressed as polygons
+ whose vertices are represented as pairs of <Type>float8</Type> numbers (decimal
+ latitude and longitude). Initially, some tables are created and
+ loaded with geographic data, then some views are created which join
+ two tables using the polygon intersection operator (##), then a select
+ is done on the view.
+
+ When comparing the results from different platforms, differences occur
+ in the 2nd or 3rd place to the right of the decimal point. The SQL
+ statements where these problems occur are the folowing:
+
+ <ProgramListing>
+ QUERY: SELECT * from street;
+ QUERY: SELECT * from iexit;
+ </ProgramListing>
+ </Para>
+
+ </Sect2>
+
+ <Sect2>
+ <Title>Random differences</Title>
+
+ <Para>
+ There is at least one test case in random.out which is intended to produce
+ random results. This causes random to fail the regression testing.
+ Typing
+ <ProgramListing>
+ diff results/random.out expected/random.out
+ </ProgramListing>
+
+ should produce only
+ one or a few lines of differences for this reason, but other floating
+ point differences on dissimilar architectures might cause many more
+ differences. See the release notes below.
+ </Para>
+
+ </Sect2>
+
+ <Sect2>
+ <Title>The <Quote>expected</Quote> files</Title>
+
+ <Para>
+ The <FileName>./expected/*.out</FileName> files were adapted from the original monolithic
+ <FileName>expected.input</FileName> file provided by Jolly Chen et al. Newer versions of these
+ files generated on various development machines have been substituted after
+ careful (?) inspection. Many of the development machines are running a
+ Unix OS variant (FreeBSD, Linux, etc) on Ix86 hardware.
+
+ The original <FileName>expected.input</FileName> file was created on a SPARC Solaris 2.4
+ system using the <FileName>postgres5-1.02a5.tar.gz</FileName> source tree. It was compared
+ with a file created on an I386 Solaris 2.4 system and the differences
+ were only in the floating point polygons in the 3rd digit to the right
+ of the decimal point. (see below)
+
+ The original <FileName>sample.regress.out</FileName> file was from the postgres-1.01 release
+ constructed by Jolly Chen and is included here for reference. It may
+ have been created on a DEC ALPHA machine as the <FileName>Makefile.global</FileName>
+ in the postgres-1.01 release has PORTNAME=alpha.
+ </Para>
+
+ </Sect2>
+
+ </Sect1>
+
</Chapter>
<para>
This is a bugfix release for 6.3.x.
Refer to the release notes for v6.3 for a more complete summary of new features.
-
+</para>
<para>
Summary:
<para>
Repairs automatic configuration support for some platforms, including Linux,
from breakage inadvertently introduced in v6.3.1.
+</para>
+</listitem>
<listitem>
<para>
Correctly handles function calls on the left side of BETWEEN and LIKE clauses.
+</para>
+</listitem>
</itemizedlist>
-
+</para>
<Para>
A dump/restore is NOT required for those running 6.3 or 6.3.1. A
'make distclean', 'make', and 'make install' is all that is required.
This last step should be performed while the postmaster is not running.
You should re-link any custom applications that use <productname>Postgres</productname> libraries.
-
+</para>
<para>
For upgrades from pre-v6.3 installations,
refer to the installation and migration instructions for v6.3.
+</para>
<sect2>
<title>Detailed Change List</title>
Makefile dependency cleanup(Jeroen van Vianen)
ASSERT fixes(Bruce)
</programlisting>
-
-
+</para>
+</sect2>
+</sect1>
<Sect1>
<Title>Release 6.3.1</Title>
<!--
<listitem>
<para>
Additional support for multi-byte character sets.
+</para>
+</listitem>
<listitem>
<para>
Repair byte ordering for mixed-endian clients and servers.
+</para>
+</listitem>
<listitem>
<para>
Minor updates to allowed SQL syntax.
+</para>
+</listitem>
<listitem>
<para>
Improvements to the configuration autodetection for installation.
-
-<listitem>
-<para>
+</para>
+</listitem>
</itemizedlist>
-
+</para>
<Para>
A dump/restore is NOT required for those running 6.3. A
'make distclean', 'make', and 'make install' is all that is required.
This last step should be performed while the postmaster is not running.
You should re-link any custom applications that use <productname>Postgres</productname> libraries.
-
+</para>
<para>
For upgrades from pre-v6.3 installations,
refer to the installation and migration instructions for v6.3.
+</para>
<sect2>
<title>Detailed Change List</title>
Solaris compile fix(Albert Chin-A-Young)
Better identify tcl and tk libs and includes(Bruce)
</programlisting>
-
-
+</para>
+</sect2>
+</sect1>
<Sect1>
<Title>Release 6.3</Title>
<!--
Many new SQL features, including
full <acronym>SQL92</acronym> subselect capability
(everything is here but target-list subselects).
+</para>
+</listitem>
<listitem>
<para>
Support for client-side environment variables to specify time zone and date style.
+</para>
+</listitem>
<listitem>
<para>
Socket interface for client/server connection. This is the default now
so you may need to start <application>postmaster</application> with the
<quote>-i</quote> flag.
+</para>
+</listitem>
<listitem>
<para>
Better password authorization mechanisms. Default table permissions have changed.
+</para>
+</listitem>
<listitem>
<para>
Old-style <quote>time travel</quote> has been removed. Performance has been improved.
+</para>
+</listitem>
</itemizedlist>
+</para>
<note>
<para>
Bruce Momjian wrote the following notes to introduce the new release.
+</para>
</note>
<para>
There are some general 6.3 issues that I want to mention. These are
only the big items that can not be described in one sentence. A review
of the detailed changes list is still needed.
-
+</para>
<para>
First, we now have subselects. Now that we have them, I would like to
mention that without subselects, SQL is a very limited language.
think. Vadim has put us on the big SQL map with subselects, and fully
functional ones too. The only thing you can't do with subselects is to
use them in the target list.
-
+</para>
<para>
Second, 6.3 uses unix domain sockets rather than TCP/IP by default. To
enable connections from other machines, you have to use the new
postmaster -i option, and of course edit pg_hba.conf. Also, for this
reason, the format of pg_hba.conf has changed.
-
+</para>
<para>
Third, char() fields will now allow faster access than varchar() or
text. Specifically, the text and varchar() have a penalty for access to
you redesign some of your tables, especially if you have short character
columns that you have defined as varchar() or text. This and other
changes make 6.3 even faster than earlier releases.
-
+</para>
<para>
We now have passwords definable independent of any Unix file. There are
new SQL USER commands. See the pg_hba.conf manual page for more
by the postgres super-user. pg_user is now a view of pg_shadow, and is
SELECT-able by PUBLIC. You should keep using pg_user in your
application without changes.
-
+</para>
<para>
User-created tables now no longer have SELECT permission to PUBLIC by
default. This was done because the ANSI standard requires it. You can
of course GRANT any permissions you want after the table is created.
System tables continue to be SELECT-able by PUBLIC.
-
+</para>
<para>
We also have real deadlock detection code. No more sixty-second
timeouts. And the new locking code implements a FIFO better, so there
should be less resource starvation during heavy use.
-
+</para>
<para>
Many complaints have been made about inadequate documenation in previous
releases. Thomas has put much effort into many new manuals for this
release. Check out the doc/ directory.
-
+</para>
<para>
For performance reasons, time travel is gone, but can be implemented
using triggers (see pgsql/contrib/spi/README). Please check out the new
permissions now, not based on the underlying tables, so permissions on
them have to be set separately. Check /pgsql/interfaces for some new
ways to talk to <productname>Postgres</productname>.
-
+</para>
<para>
This is the first release that really required an explanation for
existing users. In many ways, this was necessary because the new
release removes many limitations, and the work-arounds people were using
are no longer needed.
-
+</para>
<sect2>
<title>Migration to v6.3</title>
or <application>pg_dumpall</application>
is required for those wishing to migrate data from any
previous release of <productname>Postgres</productname>.
-
+</para>
+</sect2>
<sect2>
<title>Detailed Change List</title>
Remove un-needed malloc() calls and replace with palloc()(Bruce)
</programlisting>
</Para>
-
+</sect2>
</Sect1>
<Sect1>
<para>
v6.2.1 is a bug-fix and usability release on v6.2.
-
+</para>
<para>
Summary:
<listitem>
<para>
Allow strings to span lines, per <acronym>SQL92</acronym>.
+</para>
+</listitem>
<listitem>
<para>
Include example trigger function for inserting user names on table updates.
+</para>
+</listitem>
</itemizedlist>
-
+</para>
<para>
This is a minor bug-fix release on v6.2.
For upgrades from pre-v6.2 systems, a full dump/reload is required.
Refer to the v6.2 release notes for instructions.
+</para>
<sect2>
<title>Migration from v6.2 to v6.2.1</title>
<para>
This is a minor bug-fix release. A dump/reload is not required from v6.2,
but is required from any release prior to v6.2.
-
+</para>
<para>
In upgrading from v6.2, if you choose to dump/reload you will find that
avg(money) is now calculated correctly. All other bug fixes take effect
upon updating the executables.
-
+</para>
<para>
Another way to avoid dump/reload is to use the following SQL command
from psql to update the existing system table:
update pg_aggregate set aggfinalfn = 'cash_div_flt8'
where aggname = 'avg' and aggbasetype = 790;
</programlisting>
-
+</para>
<para>
This will need to be done to every existing database, including template1.
-
+</para>
+</sect2>
<sect2>
<title>Detailed Change List</title>
Documented new libpq function to return affected rows, PQcmdTuples(Bruce)
Trigger function for inserting user names for INSERT/UPDATE(Brook Milligan)
</programlisting>
+</para>
+</sect2>
</Sect1>
<Sect1>
<para>
A dump/restore is required for those wishing to migrate data from
previous releases of <productname>Postgres</productname>.
+</para>
<sect2>
<title>Migration from v6.1 to v6.2</title>
<para>
This migration requires a complete dump of the 6.1 database and a
restore of the database in 6.2.
-
+</para>
<para>
Note that the pg_dump and pg_dumpall utility from 6.2 should be used
to dump the 6.1 database.
+</para>
+</sect2>
<sect2>
<title>Migration from v1.x to v6.2</title>
<para>
Those migrating from earlier 1.* releases should first upgrade to 1.09
because the COPY output format was improved from the 1.02 release.
+</para>
+</sect2>
<sect2>
<title>Detailed Change List</title>
Files moved to /src/tools directory(Bruce)
SPI and Trigger programming guides (Vadim & D'Arcy)
</programlisting>
-
+</para>
+</sect2>
+</sect1>
<Sect1>
<Title>Release 6.1.1</Title>
This is a minor bug-fix release. A dump/reload is not required from v6.1,
but is required from any release prior to v6.1.
Refer to the release notes for v6.1 for more details.
+</para>
+</sect2>
<sect2>
<title>Detailed Change List</title>
allow underscores in usernames(Bruce)
pg_dumpall now returns proper status, portability fix(Bruce)
</programlisting>
-
-
+</para>
+</sect2>
+</sect1>
<Sect1>
<Title>Release 6.1</Title>
<para>
This migration requires a complete dump of the 6.0 database and a
restore of the database in 6.1.
-
+</para>
<para>
Those migrating from earlier 1.* releases should first upgrade to 1.09
because the COPY output format was improved from the 1.02 release.
+</para>
+</sect2>
<sect2>
<title>Detailed Change List</title>
warn about buggy flex(Bruce)
DG-UX, Ultrix, Irix, AIX portability fixes
</programlisting>
-
+</para>
+</sect2>
+</sect1>
<sect1>
<title>Release v6.0</title>
<para>
A dump/restore is required for those wishing to migrate data from
previous releases of <productname>Postgres</productname>.
+</para>
<sect2>
<title>Migration from v1.09 to v6.0</title>
<para>
This migration requires a complete dump of the 1.09 database and a
restore of the database in 6.0.
+</para>
+</sect2>
<sect2>
<title>Migration from pre-v1.09 to v6.0</title>
<para>
Those migrating from earlier 1.* releases should first upgrade to 1.09
because the COPY output format was improved from the 1.02 release.
+</para>
+</sect2>
<sect2>
<title>Detailed Change List</title>
Restructured port-specific file locations(Bryan, Marc)
Unused/uninialized variables corrected
</programlisting>
-
+</para>
+</sect2>
+</sect1>
<sect1>
<title>Release v1.09</title>
Sorry, we stopped keeping track of changes from 1.02 to 1.09. Some of
the changes listed in 6.0 were actually included in the 1.02.1 to 1.09
releases.
-
+</para>
+</sect1>
<sect1>
<title>Release v1.02</title>
<para>
Here is a new migration file for 1.02.1. It includes the 'copy' change
and a script to convert old ascii files.
-
+</para>
<note>
<para>
The following notes are for the benefit of users who want to migrate
databases from postgres95 1.01 and 1.02 to postgres95 1.02.1.
-
+</para>
<para>
If you are starting afresh with postgres95 1.02.1 and do not need
to migrate old databases, you do not need to read any further.
+</para>
</note>
<para>
In order to upgrade older postgres95 version 1.01 or 1.02 databases to
version 1.02.1, the following steps are required:
-
+</para>
<procedure>
<step>
<para>
Start up a new 1.02.1 postmaster
-
+</para>
+</step>
<step>
<para>
Add the new built-in functions and operators of 1.02.1 to 1.01 or 1.02
Those upgrading 1.02 databases will get a warning when executing the
last two statements in the file because they are already present in 1.02. This is
not a cause for concern.
+</para>
+</step>
</procedure>
+</sect2>
<sect2>
<title>Dump/Reload Procedure</title>
<programlisting>
sed 's/^\.$/\\./g' <in_file >out_file
</programlisting>
-
+</para>
<para>
If you are loading an older binary copy or non-stdout copy, there is no
end-of-data character, and hence no conversion necessary.
create operator ~* (leftarg = varchar, rightarg = text, procedure = texticregexeq);
create operator !~* (leftarg = varchar, rightarg = text, procedure = texticregexne);
</programlisting>
-
+</para>
+</sect2>
<sect2>
<title>Detailed Change List</title>
* added BSDI 2.1 port
* added DGUX port
</programlisting>
-
+</para>
<!--
Contributors (appologies to any missed)
* Kurt J. Lidl <lidl@va.pubnix.com>
* Paul "Shag" Walmsley <ccshag@cclabs.missouri.edu>
* "Alistair G. Crooks" <azcb0@sde.uts.amdahl.com>
-->
+</sect2>
+</sect1>
<sect1>
<title>Release v1.01</title>
<para>
The following notes are for the benefit of users who want to migrate
databases from postgres95 1.0 to postgres95 1.01.
-
+</para>
<para>
If you are starting afresh with postgres95 1.01 and do not need
to migrate old databases, you do not need to read any further.
-
+</para>
<para>
In order to postgres95 version 1.01 with databases created with
postgres95 version 1.0, the following steps are required:
-
+</para>
<procedure>
<step>
<para>
Set the definition of NAMEDATALEN in src/Makefile.global to 16
and OIDNAMELEN to 20.
-
+</para>
+</step>
<step>
<para>
Decide whether you want to use Host based authentication.
-
+</para>
<substeps>
<step>
<para>
If you do, you must create a file name "pg_hba" in your top-level data
directory (typically the value of your $PGDATA). src/libpq/pg_hba
shows an example syntax.
-
+</para>
+</step>
<step>
<para>
If you do not want host-based authentication, you can comment out
HBA = 1
</programlisting>
in src/Makefile.global
-
+</para>
<para>
Note that host-based authentication is turned on by default, and if
you do not take steps A or B above, the out-of-the-box 1.01 will
not allow you to connect to 1.0 databases.
+</para>
+</step>
</substeps>
+</step>
<step>
<para>
Compile and install 1.01, but DO NOT do the initdb step.
-
+</para>
+</step>
<step>
<para>
Before doing anything else, terminate your 1.0 postmaster, and
backup your existing $PGDATA directory.
-
+</para>
+</step>
<step>
<para>
Set your PGDATA environment variable to your 1.0 databases, but set up
path up so that 1.01 binaries are being used.
-
+</para>
+</step>
<step>
<para>
Modify the file $PGDATA/PG_VERSION from 5.0 to 5.1
-
+</para>
+</step>
<step>
<para>
Start up a new 1.01 postmaster
-
+</para>
+</step>
<step>
<para>
Add the new built-in functions and operators of 1.01 to 1.0
create operator ~* (leftarg = text, rightarg = text, procedure = texticregexeq);
create operator !~* (leftarg = text, rightarg = text, procedure = texticregexne);
</programlisting>
-
+</para>
+</step>
</procedure>
+</sect2>
<sect2>
<title>Detailed Change List</title>
* psql now returns non-zero status on errors when using -c
* applied public patches 1-14
</programlisting>
+</para>
+</sect2>
+</sect1>
<sect1>
<title>Release v1.0</title>
* btrees with multiple index never worked, now we tell you they don't
work when you try to use them
</programlisting>
+</para>
+</sect2>
+</sect1>
<sect1>
<title><productname>Postgres95</productname> Beta 0.03</title>
New documentation:
* the user manual has been revised and libpq documentation added.
</programlisting>
-
+</para>
+</sect2>
+</sect1>
<sect1>
<title><productname>Postgres95</productname> Beta 0.02</title>
* CREATE TYPE doesn't accept 'variable' as the internallength
* wrong result using more than 1 aggregate in a SELECT
</programlisting>
-
+</para>
+</sect2>
+</sect1>
<sect1>
<title><productname>Postgres95</productname> Beta 0.01</title>
<para>
Initial release.
-
+</para>
+</sect1>
<Sect1>
<Title>Timing Results</Title>
% make all
% time make runtest
</ProgramListing>
-
+</para>
<Para>
Timing under Linux 2.0.27 seems to have a roughly 5% variation from run
to run, presumably due to the scheduling vagaries of multitasking systems.
-
+</para>
<Sect2>
<Title>v6.4beta</Title>
The times for this release are not directly comparable to those for previous releases
since some additional regression tests have been included.
In general, however, v6.4 should be slightly faster than the previous release (thanks, Bruce!).
-
+</para>
<Para>
<ProgramListing>
Time System
02:26 Dual Pentium Pro 180, 96MB, UW-SCSI, Linux 2.0.30, gcc 2.7.2.1 -O2 -m486
</ProgramListing>
+</para>
+</sect2>
<Sect2>
<Title>v6.3</Title>
since some additional regression tests have been included and some obsolete tests involving
time travel have been removed.
In general, however, v6.3 is substantially faster than previous releases (thanks, Bruce!).
-
+</para>
<Para>
<ProgramListing>
Time System
02:30 Dual Pentium Pro 180, 96MB, UW-SCSI, Linux 2.0.30, gcc 2.7.2.1 -O2 -m486
04:12 Dual Pentium Pro 180, 96MB, EIDE, Linux 2.0.30, gcc 2.7.2.1 -O2 -m486
</ProgramListing>
+</para>
+</sect2>
<Sect2>
<Title>v6.1</Title>
12:06 P-100, 48MB, Linux 2.0.29, gcc
39:58 Sparc IPC 32MB, Solaris 2.5, gcc 2.7.2.1 -O -g
</ProgramListing>
-
+</para>
+</sect2>
+</sect1>
</Chapter>
[<XRef LinkEnd="ONG90" EndTerm="ONG90">]
as well as
[<XRef LinkEnd="STON90b" EndTerm="STON90b">].
-
+</para>
<Sect1>
<Title>What is a Querytree?</Title>
</VarListEntry>
</VariableList>
+</para>
</Sect2>
</Sect1>
create zero or many new parsetrees and can throw away the
original one.
</Para>
-
+</sect2>
<Sect2>
<Title>How These Rules Work</Title>
</Para>
</ListItem>
</ItemizedList>
-
+</para>
<Para>
Finally, if the rule is not INSTEAD, the unchanged original parsetree is
added to the list. Since only qualified INSTEAD rules already add the
<Para>
This chapter outlines the interaction between <Productname>Postgres</Productname> and
the operating system.
-
+</para>
<sect1>
<title>Using <Productname>Postgres</Productname> from Unix</title>
directly from a Unix shell are
found in the directory <quote>.../bin</quote>. Including this directory in
your search path will make executing the commands easier.
-
+</para>
<para>
A collection of system catalogs exist at each site. These include a
class (<literal>pg_user</literal>) that contains an instance for each valid
until an appropriate instance is
installed in this class. Further information on the system catalogs
is available by running queries on the appropriate classes.
+</para>
+</sect1>
+</chapter>
<chapter id="layout">
<Title>System Layout</Title>
Contributed by <ULink url="mailto:dz@cs.unitn.it">Massimo Dal Zotto</ULink>
</Para>
</Note>
+</para>
<para>
<productname>Postgres</productname> uses the following signals for
communication between the postmaster and backends:
+</para>
<para>
<table tocentry="1">
<row>
<entry>
Signal
+</entry>
<entry>
<application>postmaster</application> Action
+</entry>
<entry>
Server Action
+</entry>
+</row>
+</thead>
<tbody>
<row>
<entry>
SIGHUP
+</entry>
<entry>
kill(*,sighup)
+</entry>
<entry>
read_pg_options
+</entry>
+</row>
<row>
<entry>
SIGINT
+</entry>
<entry>
die
+</entry>
<entry>
cancel query
+</entry>
+</row>
<row>
<entry>
SIGQUIT
+</entry>
<entry>
kill(*,sigterm)
+</entry>
<entry>
handle_warn
+</entry>
+</row>
<row>
<entry>
SIGTERM
+</entry>
<entry>
kill(*,sigterm), kill(*,9), die
+</entry>
<entry>
die
+</entry>
+</row>
<row>
<entry>
SIGPIPE
+</entry>
<entry>
ignored
+</entry>
<entry>
die
+</entry>
+</row>
<row>
<entry>
SIGUSR1
+</entry>
<entry>
kill(*,sigusr1), die
+</entry>
<entry>
quickdie
+</entry>
+</row>
<row>
<entry>
SIGUSR2
+</entry>
<entry>
kill(*,sigusr2)
+</entry>
<entry>
async notify (SI flush)
+</entry>
+</row>
<row>
<entry>
SIGCHLD
+</entry>
<entry>
reaper
+</entry>
<entry>
ignored (alive test)
+</entry>
+</row>
<row>
<entry>
SIGTTIN
+</entry>
<entry>
ignored
+</entry>
<entry>
+</entry>
+</row>
<row>
<entry>
SIGTTOU
+</entry>
<entry>
ignored
+</entry>
<entry>
+</entry>
+</row>
<row>
<entry>
SIGCONT
+</entry>
<entry>
dumpstatus
+</entry>
<entry>
+</entry>
+</row>
<row>
<entry>
SIGFPE
+</entry>
<entry>
+</entry>
<entry>
FloatExceptionHandler
+</entry>
+</row>
</tbody>
</tgroup>
<note>
<para>
<quote>kill(*,signal)</quote> means sending a signal to all backends.
+</para>
</note>
+</para>
<para>
The main changes to the old signal handling are the use of SIGQUIT instead
automatically to all the backends without need to know their pids.
To shut down postgres one needs only to send a SIGTERM to postmaster
and it will stop automatically all the backends.
+</para>
<para>
The SIGUSR2 signal is also used to prevent SI cache table overflow
When a backend detects the SI table full at 70% it simply sends a signal
to the postmaster which will wake up all idle backends and make them flush
the cache.
+</para>
<para>
The typical use of signals by programmers could be the following:
kill -HUP $backend_pid
cat old_pg_options > $DATA_DIR/pg_options
</programlisting>
-
+</para>
</chapter>
</LISTITEM>
</VARLISTENTRY>
</VARIABLELIST>
+</para>
</LISTITEM>
</VARLISTENTRY>
</VARIABLELIST>
<PARA>
<FUNCTION>SPI_finish</FUNCTION> closes an existing connection to the <ProductName>Postgres</ProductName> backend.
You should call this function after completing operations through the SPI manager.
-
+</para>
<PARA>
You may get the error return <ReturnValue>SPI_ERROR_UNCONNECTED</ReturnValue> if <Function>SPI_finish</Function> is
called without having a current valid connection.
<ReturnValue>SPI_ERROR_OPUNKNOWN</ReturnValue> if type of query is unknown (this shouldn't occur).
</Member>
</SimpleList>
-
+</para>
<Para>
If execution of your query was successful then one of the following
(non-negative) values will be returned:
executed.
</Para>
</Note>
-
+</para>
<Para>
The actual number of tuples for which the (last) query was executed is
returned in the global variable SPI_processed (if not <ReturnValue>SPI_OK_UTILITY</ReturnValue>).
<PARA>
nargs is number of parameters ($1 ... $nargs - as in SQL-functions),
and nargs may be 0 only if there is not any $1 in query.
-
+</para>
<Para>
Execution of prepared execution plans is sometimes much faster so this
feature may be useful if the same query will be executed many times.
-
+</para>
<Para>
The plan returned by <Function>SPI_prepare</Function> may be used only in current
invocation of the procedure since <Function>SPI_finish</Function> frees memory allocated for a plan.
See <Function>SPI_saveplan</Function>.
-
+</para>
<Para>
If successful, a non-null pointer will be returned. Otherwise, you'll get
a NULL plan. In both cases SPI_result will be set like the value returned
<FUNCTION>SPI_saveplan</FUNCTION>
stores a plan prepared by <Function>SPI_prepare</Function> in safe memory
protected from freeing by <Function>SPI_finish</Function> or the transaction manager.
-
+</para>
<Para>
In the current version of <ProductName>Postgres</ProductName> there is no ability to
store prepared plans in the system
was prepared with some parameters.
</Member>
</SimpleList>
+</para>
</LISTITEM>
</VARLISTENTRY>
<VARLISTENTRY>
<PARA>
initialized as in
<Function>SPI_exec</Function> if successful
+</para>
+</listitem>
</VARLISTENTRY>
</VARIABLELIST>
</REFSECT2>
<FUNCTION>SPI_execp</FUNCTION>
stores a plan prepared by <Function>SPI_prepare</Function> in safe memory
protected from freeing by <Function>SPI_finish</Function> or the transaction manager.
-
+</para>
<Para>
In the current version of <ProductName>Postgres</ProductName> there is no ability to
store prepared plans in the system
is NULL
</Member>
</SimpleList>
+</para>
</LISTITEM>
</VARLISTENTRY>
</VARIABLELIST>
is NULL
</Member>
</SimpleList>
+</para>
</LISTITEM>
</VARLISTENTRY>
<VARLISTENTRY>
attributes in tuple)
</Member>
</SimpleList>
+</para>
</LISTITEM>
</VARLISTENTRY>
</VARIABLELIST>
<ReturnValue>SPI_ERROR_NOATTRIBUTE</ReturnValue> if the named attribute is not found
</Member>
</SimpleList>
+</para>
</LISTITEM>
</VARLISTENTRY>
</VARIABLELIST>
<ReturnValue>SPI_ERROR_NOATTRIBUTE</ReturnValue> on error
</Member>
</SimpleList>
+</para>
</LISTITEM>
</VARLISTENTRY>
</VARIABLELIST>
<ReturnValue>SPI_ERROR_NOOUTFUNC</ReturnValue>)
</Member>
</SimpleList>
+</para>
</LISTITEM>
</VARLISTENTRY>
</VARIABLELIST>
location for the installation. Remember that all database access actually
occurs through the database backend, so that any location specified must
be accessible by the backend.
-
+</para>
<Para>
Alternate database locations are created and referenced by an environment variable
which gives the absolute path to the intended storage location.
Any valid environment variable name may be used to reference an alternate
location, although using variable name with a prefix of PGDATA is recommended
to avoid confusion and conflict with other variables.
-
+</para>
<Note>
<Para>
In previous versions of <ProductName>Postgres</ProductName>,
although it is preferred that the variables be prefixed with "PGDATA"
to eliminate confusion and the possibility of conflicting with or
overwriting other variables.
-
+</para>
<Para>
To create a data storage area in PGDATA2, ensure
that <filename>/home/postgres</filename> already exists and is writable
Creating Postgres database system directory /home/postgres/data/base
</ProgramListing>
-
+</para>
<Para>
To test the new location, create a database <Database>test</Database> by typing
<ProgramListing>
% createdb -D PGDATA2 test
% destroydb test
</ProgramListing>
+</para>
</Sect1>
</Chapter>
<filename>/usr/local/pgsql/bin</filename> to your shell search path.
In most cases, this is all you should have to do in
terms of preparation.
-
+</para>
<Para>
If you get the following error message from a
<ProductName>Postgres</ProductName>
mixing of different data types in the same expression.
<productname>Postgres</productname> has extensive facilities for
evaluating mixed-type expressions.
+</para>
<para>
In many cases a user will not need
can affect the apparent results of a query, and these results
can be tailored by a user or programmer
using <emphasis>explicit</emphasis> type coersion.
+</para>
<para>
This chapter introduces the <productname>Postgres</productname>
type conversion mechanisms and conventions.
Refer to the relevant sections in the User's Guide and Programmer's Guide
for more information on specific data types and allowed functions and operators.
+</para>
<para>
The Programmer's Guide has more details on the exact algorithms used for
implicit type conversion and coersion.
+</para>
<sect1>
<title>Overview</title>
Hence, most type conversion behavior in <productname>Postgres</productname>
should be governed by general rules rather than by ad-hoc heuristics to allow
mixed-type expressions to be meaningful, even with user-defined types.
+</para>
<para>
The <productname>Postgres</productname> scanner/parser decodes lexical elements
has two strings, of type <type>text</type> and <type>point</type>.
If a type is not specified, then the placeholder type <type>unknown</type>
is assigned initially, to be resolved in later stages as described below.
+</para>
<para>
There are four fundamental <acronym>SQL</acronym> constructs requiring
distinct type conversion rules in the <productname>Postgres</productname>
parser:
+</para>
<variablelist>
<varlistentry>
<productname>Postgres</productname> allows expressions with
left- and right-unary (one argument) operators,
as well as binary (two argument) operators.
+</para>
</listitem>
</varlistentry>
<varlistentry>
Much of the <productname>Postgres</productname> type system is built around a rich set of
functions. Function calls have one or more arguments which, for any specific query,
must be matched to the functions available in the system catalog.
+</para>
</listitem>
</varlistentry>
<varlistentry>
<para>
<acronym>SQL</acronym> INSERT statements place the results of query into a table. The expressions
in the query must be matched up with, and perhaps converted to, the target columns of the insert.
+</para>
</listitem>
</varlistentry>
<varlistentry>
<para>
Since all select results from a UNION SELECT statement must appear in a single set of columns, the types
of each SELECT clause must be matched up and converted to a uniform set.
+</para>
</listitem>
</varlistentry>
</variablelist>
There are some heuristics included in the conversion rules to better support
conventions for the <acronym>SQL92</acronym> standard native types such as
<type>smallint</type>, <type>integer</type>, and <type>float</type>.
+</para>
<para>
The <productname>Postgres</productname> parser uses the convention that all
by the parser as such. This simple assumption gives the parser the power
to explore type conversion possibilities without hardcoding, allowing
extended user-defined types to use these same features transparently.
+</para>
<para>
An additional heuristic is provided in the parser to allow better guesses
expressions (those with multiple candidate parsing solutions)
with only one user-defined type can resolve to a single best choice, while those with
multiple user-defined types will remain ambiguous and throw an error.
+</para>
<para>
Ambiguous expressions which have candidate solutions within only one type category are
likely to resolve, while ambiguous expressions with candidates spanning multiple
categories are likely to throw an error and ask for clarification from the user.
+</para>
<sect2>
<title>Guidelines</title>
<listitem>
<para>
Implicit conversions should never have suprising or unpredictable outcomes.
+</para>
+</listitem>
<listitem>
<para>
User-defined types, of which the parser has no apriori knowledge, should be
"higher" in the type heirarchy. In mixed-type expressions, native types shall always
be converted to a user-defined type (of course, only if conversion is necessary).
+</para>
+</listitem>
<listitem>
<para>
does not have information available to it on relationships between types, other than
hardcoded heuristics for built-in types and implicit relationships based on available functions
in the catalog.
+</para>
+</listitem>
<listitem>
<para>
That is, if a query is well formulated and the types already match up, then the query should proceed
without spending extra time in the parser and without introducing unnecessary implicit conversion
functions into the query.
+</para>
<para>
Additionally, if a query usually requires an implicit conversion for a function, and
if then the user defines an explicit function with the correct argument types, the parser
should use this new function and will no longer do the implicit conversion using the old function.
+</para>
+</listitem>
</itemizedlist>
+</para>
+</sect2>
+</sect1>
<sect1>
<title>Operators</title>
<sect2>
<title>Conversion Procedure</title>
-<para>
<procedure>
<title>Operator Evaluation</title>
-<para>
<step performance="required">
<para>
Check for an exact match in the pg_operator system catalog.
+</para>
<substeps>
<step performance="optional">
<para>
If one argument of a binary operator is <type>unknown</type>,
then assume it is the same type as the other argument.
-
+</para>
+</step>
<step performance="required">
<para>
Reverse the arguments, and look for an exact match with an operator which
points to itself as being commutative.
If found, then reverse the arguments in the parse tree and use this operator.
-
+</para>
+</step>
</substeps>
+</step>
<step performance="required">
<para>
Look for the best match.
-
+</para>
<substeps>
<step performance="optional">
<para>
Make a list of all operators of the same name.
-
+</para>
+</step>
<step performance="required">
<para>
If only one operator is in the list, use it if the input type can be coerced,
and throw an error if the type cannot be coerced.
-
+</para>
+</step>
<step performance="required">
<para>
Keep all operators with the most explicit matches for types. Keep all if there
are no explicit matches and move to the next step.
If only one candidate remains, use it if the type can be coerced.
-
+</para>
+</step>
<step performance="required">
<para>
If any input arguments are "unknown", categorize the input candidates as
the correct choice cannot be deduced without more clues.
If only one category is present, then assign the "preferred type"
to the input column which had been previously "unknown".
-
+</para>
+</step>
<step performance="required">
<para>
Choose the candidate with the most exact type matches, and which matches
the "preferred type" for each column category from the previous step.
If there is still more than one candidate, or if there are none,
then throw an error.
+</para>
+</step>
</substeps>
-
+</step>
</procedure>
+</sect2>
<sect2>
<title>Examples</title>
This last form has the least overhead, since no functions are called to do
implicit type conversion. This is not an issue for small queries, but may
have an impact on the performance of queries involving large tables.
+</para>
</note>
+</para>
+</sect3>
<sect3>
<title>String Concatenation</title>
A string-like syntax is used for working with string types as well as for
working with complex extended types.
Strings with unspecified type are matched with likely operator candidates.
+</para>
<para>
One unspecified argument:
abcdef
(1 row)
</programlisting>
+</para>
<para>
In this case the parser looks to see if there is an operator taking <type>text</type>
for both arguments. Since there is, it assumes that the second argument should
be interpreted as of type <type>text</type>.
+</para>
<para>
Concatenation on unspecified types:
abcdef
(1 row)
</programlisting>
+</para>
<para>
In this case there is no initial hint for which type to use, since no types
are specified in the query. So, the parser looks for all candidate operators
and finds that all arguments for all the candidates are string types. It chooses
the "preferred type" for strings, <type>text</type>, for this query.
+</para>
<note>
<para>
If a user defines a new type and defines an operator <quote>||</quote> to work
with it, then this query would no longer succeed as written. The parser would
now have candidate types from two categories, and could not decide which to use.
+</para>
</note>
+</sect3>
<sect3>
<title>Factorial</title>
to be a tool for data manipulation. If a user chooses to take the
factorial of a floating point number, <productname>Postgres</productname>
will try to oblige.
+</para>
</note>
+</para>
+</sect3>
+</sect2>
+</sect1>
<sect1>
<title>Functions</title>
-<para>
-
<procedure>
<title>Function Evaluation</title>
<step performance="required">
<para>
Check for an exact match in the pg_proc system catalog.
-
+</para></step>
<step performance="required">
<para>
Look for the best match.
-
+</para>
<substeps>
<step performance="required">
<para>
Make a list of all functions of the same name with the same number of arguments.
-
+</para></step>
<step performance="required">
<para>
If only one function is in the list, use it if the input types can be coerced,
and throw an error if the types cannot be coerced.
-
+</para></step>
<step performance="required">
<para>
Keep all functions with the most explicit matches for types. Keep all if there
are no explicit matches and move to the next step.
If only one candidate remains, use it if the type can be coerced.
-
+</para></step>
<step performance="required">
<para>
If any input arguments are "unknown", categorize the input candidate arguments as
the correct choice cannot be deduced without more clues.
If only one category is present, then assign the "preferred type"
to the input column which had been previously "unknown".
-
+</para></step>
<step performance="required">
<para>
Choose the candidate with the most exact type matches, and which matches
the "preferred type" for each column category from the previous step.
If there is still more than one candidate, or if there are none,
then throw an error.
+</para></step>
</substeps>
-
+</step>
</procedure>
-
<sect2>
<title>Examples</title>
24
(1 row)
</programlisting>
+</para>
+</sect3>
<sect3>
<title>Substring Function</title>
<para>
There are two <function>substr</function> functions declared in pg_proc. However,
only one takes two arguments, of types <type>text</type> and <type>int4</type>.
+</para>
<para>
If called with a string constant of unspecified type, the type is matched up
34
(1 row)
</programlisting>
+</para>
<para>
If the string is declared to be of type <type>varchar</type>, as might be the case
34
(1 row)
</programlisting>
+</para>
<note>
<para>
There are some heuristics in the parser to optimize the relationship between the
<type>char</type>, <type>varchar</type>, and <type>text</type> types.
For this case, <function>substr</function> is called directly with the <type>varchar</type> string
rather than inserting an explicit conversion call.
+</para>
</note>
<para>
34
(1 row)
</programlisting>
+</para>
+</sect3>
+</sect2>
+</sect1>
<sect1>
<title>Query Targets</title>
-<para>
-
<procedure>
<title>Target Evaluation</title>
<step performance="required">
<para>
Check for an exact match with the target.
-
+</para></step>
<step performance="required">
<para>
Try to coerce the expression directly to the target type if necessary.
+</para></step>
<step performance="required">
<para>
declared with a length) then try to find a sizing function of the same name
as the type taking two arguments, the first the type name and the second an
integer length.
+</para></step>
</procedure>
abcd
(1 row)
</programlisting>
-
+</para>
+</sect3>
+</sect2>
+</sect1>
<sect1>
<title>UNION Queries</title>
<para>
The UNION construct is somewhat different in that it must match up
possibly dissimilar types to become a single result set.
-
+</para>
<procedure>
<title>UNION Evaluation</title>
<step performance="required">
<para>
Check for identical types for all results.
+</para></step>
<step performance="required">
<para>
Coerce each result from the UNION clauses to match the type of the
first SELECT clause or the target column.
-
+</para></step>
</procedure>
<sect2>
b
(2 rows)
</programlisting>
+</para>
+</sect3>
<sect3>
<title>Simple UNION</title>
1.2
(2 rows)
</programlisting>
+</para>
+</sect3>
<sect3>
<title>Transposed UNION</title>
3
(3 rows)
</programlisting>
-
+</para>
<para>
An alternate parser strategy could be to choose the "best" type of the bunch, but
this is more difficult because of the nice recursion technique used in the
3.3
(3 rows)
</programlisting>
-
+</para>
+</sect3>
+</sect2>
+</sect1>
</chapter>
+-------+
</ProgramListing>
</Para>
+</sect2>
<Sect2>
<Title><Acronym>SQL</Acronym> Functions on Composite Types</Title>
|Sam | 2400 |
+-----+-------+
</ProgramListing>
-
+</para>
<Para>
Notice the use of the syntax $1.salary.
Before launching into the subject of functions that
|Sam |
+----------+
</ProgramListing>
-
+</para>
<Para>
As we shall see, however, this is not always the case.
This function notation is important when we want to use
that in which the attributes appear in the CREATE
TABLE statement (or when you execute a .* query).
</Para>
+ </ListItem>
<ListItem>
<Para>
You must typecast the expressions
WARN::function declared to return type EMP does not retrieve (EMP.*)
</ProgramListing>
</Para>
+ </ListItem>
<ListItem>
<Para>
When calling a function that returns an instance, we
+-------+
</ProgramListing>
</Para>
+ </ListItem>
<ListItem>
<Para>
The reason why, in general, we must use the function
WARN:parser: syntax error at or near "."
</ProgramListing>
</Para>
+ </ListItem>
</ItemizedList>
-
+</para>
<Para>
Any collection of commands in the <Acronym>SQL</Acronym> query language
can be packaged together and defined as a function.
+--+
</ProgramListing>
</Para>
+</sect2>
+</sect1>
<Sect1>
<Title>Programming Language Functions</Title>
Base types can have one of three internal formats:
<ItemizedList>
<ListItem><Para>pass by value, fixed-length</Para>
+ </ListItem>
<ListItem><Para>pass by reference, fixed-length</Para>
+ </ListItem>
<ListItem><Para>pass by reference, variable-length</Para>
+ </ListItem>
</ItemizedList>
</Para>
</ProgramListing>
(where <PORTNAME> is the name of the port, e.g.,
alpha or sparc).
+</para>
</ListItem>
<ListItem>
<Para> When allocating memory, use the <ProductName>Postgres</ProductName>
automatically at the end of each transaction,
preventing memory leaks.
</Para>
+ </ListItem>
<ListItem>
<Para> Always zero the bytes of your structures using
memset or bzero. Several routines (such as the
several bytes of alignment padding (holes in the
structure) that may contain garbage values.
</Para>
+ </ListItem>
<ListItem>
<Para> Most of the internal <ProductName>Postgres</ProductName> types are declared
in postgres.h, so it's a good idea to always
include that file as well. Including postgres.h
will also include elog.h and palloc.h for you.
</Para>
+ </ListItem>
<ListItem>
<Para> Compiling and loading your object code so that
it can be dynamically loaded into <ProductName>Postgres</ProductName>
</ItemizedList>
</Para>
</Sect2>
+</sect1>
+</chapter>
+
number (< 0), 0, or a non-zero positive number (> 0).
</Para>
</Note>
-
+</para>
<Para>
The <FileName>amstrategies</FileName> entry in pg_am is just the number of
strategies defined for the access method in question.
<Sect1>
<Title>Installing Procedural Languages</Title>
-<Para>
- <Procedure>
+<Procedure>
<Title>
Procedural Language Installation
</Title>
<para>
A procedural language is installed in the database in three steps.
-
+ </para>
<Step Performance="Required">
<Para>
The shared object for the language handler
PL/Tcl are known to be trusted.
</Para>
</Step>
- </Procedure>
-<Para>
- <Procedure>
+</Procedure>
+
+<Procedure>
<Title>Example</Title>
<Step Performance="Required">
<Para>
languages are available by default.
</Para>
</Step>
- </Procedure>
+</Procedure>
</Sect1> <!-- **** End of PL installation **** -->
<!-- **********
<Replaceable>name</Replaceable> ALIAS FOR $n;
</Term>
<ListItem>
-<Para>
<Para>
For better readability of the code it is possible to define an alias
for a positional parameter to a function.
RENAME <Replaceable>oldname</Replaceable> TO <Replaceable>newname</Replaceable>;
</Term>
<ListItem>
-<Para>
<Para>
Change the name of a variable, record or row. This is useful
if NEW or OLD should be referenced by another name inside a
</Para>
</ListItem>
</ItemizedList>
-
+</para>
<Para>
To define the <Acronym>complex</Acronym> type, we need to create the two
user-defined functions complex_in and complex_out
them, since the system already understands what they
look like inside.
</Para>
-
+</sect2>
<Sect2>
<Title>Large Objects</Title>
If you require a larger type for something like a document
retrieval system or for storing bitmaps, you will
need to use the <ProductName>Postgres</ProductName> large object interface.
-
+</para>
</Sect2>
</Sect1>
</Chapter>
<sect1>
<title>Y2K Statement</title>
-<para>
<note>
<title>Author</title>
Written by
<ulink url="mailto:lockhart@alumni.caltech.edu">Thomas Lockhart</ulink>
on 1998-10-22.
+</para>
</note>
<para>
the <productname>Postgres</productname> software code tree as a public service,
without warranty and without liability for it's behavior or performance.
However, at the time of writing:
+</para>
<itemizedlist>
<listitem>
support team since November, 1996, is not aware of
any problems in the <productname>Postgres</productname> code base related
to time transitions around Jan 1, 2000 (Y2K).
+</para>
+</listitem>
<listitem>
<para>
of <productname>Postgres</productname>. We might have expected
to hear about problems if they existed, given the installed base and
the active participation of users on the support mailing lists.
+</para>
+</listitem>
<listitem>
<para>
For two-digit years, the significant transition year is 1970, not 2000;
e.g. <quote>70-01-01</quote> is interpreted as <quote>1970-01-01</quote>,
whereas <quote>69-01-01</quote> is interpreted as <quote>2069-01-01</quote>.
+</para>
+</listitem>
<listitem>
<para>
Any Y2K problems in the underlying OS related to obtaining "the
current time" may propagate into apparent Y2K problems in
<productname>Postgres</productname>.
+</para>
+</listitem>
</itemizedlist>
<ulink url="http://language.perl.com/news/y2k.html">The Perl Institute</ulink>
for further discussion of Y2K issues, particularly
as it relates to open source, no fee software.
+</para>
-</sect1>
\ No newline at end of file
+</sect1>