Commit d2a907c6 authored by Thomas G. Lockhart's avatar Thomas G. Lockhart

Markup and editing adjustments...

parent 5a68fd56
......@@ -18,9 +18,9 @@ Modifies table properties
</REFSYNOPSISDIVINFO>
<SYNOPSIS>
ALTER TABLE <REPLACEABLE CLASS="PARAMETER">table</REPLACEABLE>
[*] ADD [COLUMN] <REPLACEABLE CLASS="PARAMETER">column</REPLACEABLE> <REPLACEABLE CLASS="PARAMETER">type</REPLACEABLE>
[ * ] ADD [ COLUMN ] <REPLACEABLE CLASS="PARAMETER">column</REPLACEABLE> <REPLACEABLE CLASS="PARAMETER">type</REPLACEABLE>
ALTER TABLE <REPLACEABLE CLASS="PARAMETER">table</REPLACEABLE>
[*] RENAME [COLUMN] <REPLACEABLE CLASS="PARAMETER">column</REPLACEABLE> TO <REPLACEABLE CLASS="PARAMETER">newcolumn</REPLACEABLE>
[ * ] RENAME [ COLUMN ] <REPLACEABLE CLASS="PARAMETER">column</REPLACEABLE> TO <REPLACEABLE CLASS="PARAMETER">newcolumn</REPLACEABLE>
ALTER TABLE <REPLACEABLE CLASS="PARAMETER">table</REPLACEABLE>
RENAME TO <REPLACEABLE CLASS="PARAMETER">newtable</REPLACEABLE>
</SYNOPSIS>
......@@ -103,14 +103,14 @@ Outputs
<VARIABLELIST>
<VARLISTENTRY>
<TERM>
<ReturnValue>status</ReturnValue>
<replaceable>status</replaceable>
</TERM>
<LISTITEM>
<PARA>
<VARIABLELIST>
<VARLISTENTRY>
<TERM>
<ReturnValue>ALTER</ReturnValue>
<returnvalue>ALTER</returnvalue>
</TERM>
<LISTITEM>
<PARA>
......@@ -121,7 +121,7 @@ Outputs
<VARLISTENTRY>
<TERM>
<ReturnValue>NEW</ReturnValue>
<returnvalue>NEW</returnvalue>
</TERM>
<LISTITEM>
<PARA>
......@@ -156,9 +156,9 @@ Outputs
Description
</TITLE>
<PARA>
ALTER TABLE changes the definition of an existing table.
<command>ALTER TABLE</command> changes the definition of an existing table.
The new columns and their types are specified in the same style
and with the the same restrictions as in CREATE TABLE.
and with the the same restrictions as in <command>CREATE TABLE</command>.
The RENAME clause causes the name of a table or column
to change without changing any of the data contained in
the affected table. Thus, the table or column will
......@@ -178,18 +178,15 @@ Notes
<PARA>
The keyword COLUMN is noise and can be omitted.
<PARA>
ALTER TABLE/RENAME is a PostgreSQL language extension.
<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.
Refer to PostgreSQL User's Guide for further
The PostgreSQL User's Guide has further
information on inheritance.
<PARA>
Refer to the CREATE TABLE reference for further description
Refer to CREATE TABLE for a further description
of valid arguments.
</REFSECT2>
......@@ -232,23 +229,30 @@ Compatibility
SQL92
</TITLE>
<PARA>
SQL92 specifies some additional capabilities for ALTER TABLE
statement which are not yet directly supported by <ProductName>Postgres</ProductName>:
<command>ALTER TABLE/RENAME</command>
is a <productname>Postgres</productname> language extension.
<PARA>
SQL92 specifies some additional capabilities for <command>ALTER TABLE</command>
statement which are not yet directly supported by
<ProductName>Postgres</ProductName>:
<VARIABLELIST>
<VARLISTENTRY>
<TERM>
<Synopsis>
ALTER TABLE <REPLACEABLE CLASS="PARAMETER">table</REPLACEABLE> ALTER [COLUMN] <REPLACEABLE CLASS="PARAMETER">column</REPLACEABLE>
ALTER TABLE <REPLACEABLE CLASS="PARAMETER">table</REPLACEABLE> ALTER [ COLUMN ] <REPLACEABLE CLASS="PARAMETER">column</REPLACEABLE>
SET DEFAULT <REPLACEABLE CLASS="PARAMETER">default</REPLACEABLE>
ALTER TABLE <REPLACEABLE CLASS="PARAMETER">table</REPLACEABLE> ALTER [COLUMN] <REPLACEABLE CLASS="PARAMETER">column</REPLACEABLE>
ADD [CONSTRAINT <REPLACEABLE CLASS="PARAMETER">constraint</REPLACEABLE>] <REPLACEABLE CLASS="PARAMETER">table-constraint</REPLACEABLE>
ALTER TABLE <REPLACEABLE CLASS="PARAMETER">table</REPLACEABLE> ALTER [ COLUMN ] <REPLACEABLE CLASS="PARAMETER">column</REPLACEABLE>
ADD [ CONSTRAINT <REPLACEABLE CLASS="PARAMETER">constraint</REPLACEABLE> ] <REPLACEABLE CLASS="PARAMETER">table-constraint</REPLACEABLE>
</Synopsis>
</TERM>
<LISTITEM>
<PARA>
Puts the default value or constraint specified into the
definition of column in the table. See CREATE TABLE for the
definition of column in the table.
See <command>CREATE TABLE</command> for the
syntax of the default and table-constraint clauses.
If a default clause already exists, it will be replaced by
the new definition. If any constraints on this column already
......@@ -307,7 +311,7 @@ DROP TABLE temp;
<TERM>
<Synopsis>
ALTER TABLE <REPLACEABLE CLASS="PARAMETER">table</REPLACEABLE>
DROP [COLUMN] <REPLACEABLE CLASS="PARAMETER">column</REPLACEABLE> { RESTRICT | CASCADE }
DROP [ COLUMN ] <REPLACEABLE CLASS="PARAMETER">column</REPLACEABLE> { RESTRICT | CASCADE }
</Synopsis>
</TERM>
<LISTITEM>
......@@ -335,23 +339,3 @@ DROP TABLE temp;
</PARA>
</VARIABLELIST>
</REFENTRY>
<!--
<REPLACEABLE CLASS="PARAMETER">
</REPLACEABLE>
<ReturnValue></ReturnValue>
<PARA>
</PARA>
<VARIABLELIST>
<VARLISTENTRY>
<TERM>&bull;
</TERM>
<LISTITEM>
<PARA>
</PARA>
</LISTITEM>
</VARLISTENTRY>
</VARIABLELIST>
<PARA>
</PARA>
-->
......@@ -14,26 +14,26 @@
</REFPURPOSE>
<REFSYNOPSISDIV>
<REFSYNOPSISDIVINFO>
<DATE>1998-04-15</DATE>
<DATE>1998-09-08</DATE>
</REFSYNOPSISDIVINFO>
<synopsis>
ALTER USER <replaceable class="PARAMETER">username</replaceable>
[WITH PASSWORD <replaceable class="PARAMETER">password</replaceable>]
[CREATEDB | NOCREATEDB]
[CREATEUSER | NOCREATEUSER]
[IN GROUP <replaceable class="PARAMETER">groupname</replaceable> [, ...] ]
[VALID UNTIL '<replaceable class="PARAMETER">abstime</replaceable>']
ALTER USER <replaceable class="PARAMETER">username</replaceable>
[ WITH PASSWORD <replaceable class="PARAMETER">password</replaceable> ]
[ CREATEDB | NOCREATEDB ]
[ CREATEUSER | NOCREATEUSER ]
[ IN GROUP <replaceable class="PARAMETER">groupname</replaceable> [, ...] ]
[ VALID UNTIL '<replaceable class="PARAMETER">abstime</replaceable>' ]
</synopsis>
<REFSECT2 ID="R2-SQL-ALTERUSER-1">
<REFSECT2INFO>
<DATE>1998-04-15</DATE>
<DATE>1998-09-08</DATE>
</REFSECT2INFO>
<TITLE>
Inputs
</TITLE>
<PARA>
Refer to CREATE USER statement for a detailed description of each
Refer to <command>CREATE USER</command> for a detailed description of each
clause.
</para>
<VARIABLELIST>
......@@ -47,6 +47,7 @@
</PARA>
</LISTITEM>
</VARLISTENTRY>
<VARLISTENTRY>
<TERM>
<REPLACEABLE CLASS="PARAMETER"> password </REPLACEABLE>
......@@ -57,6 +58,7 @@
</PARA>
</LISTITEM>
</VARLISTENTRY>
<VARLISTENTRY>
<TERM>
<REPLACEABLE CLASS="PARAMETER"> groupname </REPLACEABLE>
......@@ -67,13 +69,15 @@
</PARA>
</LISTITEM>
</VARLISTENTRY>
<VARLISTENTRY>
<TERM>
<REPLACEABLE CLASS="PARAMETER"> abstime </REPLACEABLE>
</TERM>
<LISTITEM>
<PARA>
The date (and, optionally, the time) at which this user's access is to be terminated.
The date (and, optionally, the time)
at which this user's access is to be terminated.
</PARA>
</LISTITEM>
</VARLISTENTRY>
......@@ -82,7 +86,7 @@
<REFSECT2 ID="R2-SQL-ALTERUSER-2">
<REFSECT2INFO>
<DATE>1998-04-15</DATE>
<DATE>1998-09-08</DATE>
</REFSECT2INFO>
<TITLE>
Outputs
......@@ -92,14 +96,14 @@
<VARIABLELIST>
<VARLISTENTRY>
<TERM>
<ReturnValue>status</ReturnValue>
<replaceable>status</replaceable>
</TERM>
<LISTITEM>
<PARA>
<VARIABLELIST>
<VARLISTENTRY>
<TERM>
<ReturnValue>ALTER USER</ReturnValue>
<returnvalue>ALTER USER</returnvalue>
</TERM>
<LISTITEM>
<PARA>
......@@ -110,7 +114,7 @@
<VARLISTENTRY>
<TERM>
<ReturnValue>ERROR: alterUser: user "username" does not exist</ReturnValue>
<returnvalue>ERROR: alterUser: user "username" does not exist</returnvalue>
</TERM>
<LISTITEM>
<PARA>
......@@ -129,16 +133,18 @@
<REFSECT1 ID="R1-SQL-ALTERUSER-1">
<REFSECT1INFO>
<DATE>1998-04-15</DATE>
<DATE>1998-09-08</DATE>
</REFSECT1INFO>
<TITLE>
Description
</TITLE>
<PARA>
ALTER USER is used to change the attributes of a user's
PostgreSQL account. Please note that it is not possible
<command>ALTER USER</command> is used to change the attributes of a user's
<productname>Postgres</productname> account.
Please note that it is not possible
to alter a user's "usesysid" via the alter user
statement. Also, it is only possible for the PostgreSQL
statement. Also, it is only possible for the
<productname>Postgres</productname>
user or any user with read and modify permissions on
"pg_shadow" to alter user passwords.
</PARA>
......@@ -150,21 +156,24 @@
<REFSECT2 ID="R2-SQL-ALTERUSER-3">
<REFSECT2INFO>
<DATE>1998-04-15</DATE>
<DATE>1998-09-08</DATE>
</REFSECT2INFO>
<TITLE>
Notes
</TITLE>
<PARA>
ALTER USER statement is a PostgreSQL language extension.
<command>ALTER USER</command> statement
is a <productname>Postgres</productname>
language extension.
</para>
<para>
Refer to CREATE/DROP USER statements to create/remove an user
Refer to <command>CREATE/DROP USER</command>
to create or remove a user
account.
</para>
<para>
At the current release (6.3.2), the IN GROUP clause is parsed
but has no effect. When it is fully implemented, it is
In the current release (v6.4), the IN GROUP clause is parsed
but has no affect. When it is fully implemented, it is
intended to modify the pg_group relation.
</para>
</REFSECT2>
......@@ -178,13 +187,13 @@
Change a user password
</PARA>
<ProgramListing>
ALTER USER davide WITH PASSWORD hu8jmn3;
ALTER USER davide WITH PASSWORD hu8jmn3;
</ProgramListing>
<para>
Change a user's valid until date
</para>
<ProgramListing>
ALTER USER manuel VALID UNTIL 'Jan 31 2030';
ALTER USER manuel VALID UNTIL 'Jan 31 2030';
</ProgramListing>
<para>
Change a user's valid until date, specifying that his
......@@ -192,19 +201,19 @@ authorisation should expire at midday on 4th May 1998 using
the time zone which is one hour ahead of UTC
</para>
<ProgramListing>
ALTER USER chris VALID UNTIL 'May 4 12:00:00 1998 +1';
ALTER USER chris VALID UNTIL 'May 4 12:00:00 1998 +1';
</ProgramListing>
<para>
Give a user the ability to create other users and new databases.
</para>
<programlisting>
ALTER USER miriam CREATEUSER CREATEDB;
ALTER USER miriam CREATEUSER CREATEDB;
</programlisting>
<para>
Place a user in two groups
</para>
<programlisting>
ALTER USER miriam IN GROUP sales, payroll;
ALTER USER miriam IN GROUP sales, payroll;
</programlisting>
</REFSECT1>
......@@ -217,13 +226,15 @@ the time zone which is one hour ahead of UTC
<REFSECT2 ID="R2-SQL-ALTERUSER-4">
<REFSECT2INFO>
<DATE>1998-04-15</DATE>
<DATE>1998-09-08</DATE>
</REFSECT2INFO>
<TITLE>
SQL92
</TITLE>
<PARA>
There is no ALTER USER statement in SQL92. The standard leaves
There is no <command>ALTER USER</command> statement in
<acronym>SQL92</acronym>.
The standard leaves
the definition of users to the implementation.
</PARA>
</refsect1>
......
......@@ -16,38 +16,26 @@
<REFSYNOPSISDIV>
<REFSYNOPSISDIVINFO>
<DATE>1998-04-15</DATE>
<DATE>1998-09-08</DATE>
</REFSYNOPSISDIVINFO>
<SYNOPSIS>
BEGIN { WORK | TRANSACTION }
BEGIN [ WORK | TRANSACTION ]
</SYNOPSIS>
<REFSECT2 ID="R2-SQL-BEGINWORK-1">
<REFSECT2INFO>
<DATE>1998-04-15</DATE>
<DATE>1998-09-08</DATE>
</REFSECT2INFO>
<TITLE>
Inputs
</TITLE>
<PARA>
</PARA>
<VARIABLELIST>
<VARLISTENTRY>
<TERM>
<ReturnValue>
None
</ReturnValue>
</TERM>
<LISTITEM>
<para></para>
</LISTITEM>
</varlistentry>
</VARIABLELIST>
</REFSECT2>
<REFSECT2 ID="R2-SQL-BEGINWORK-2">
<REFSECT2INFO>
<DATE>1998-04-15</DATE>
<DATE>1998-09-08</DATE>
</REFSECT2INFO>
<TITLE>
Outputs
......@@ -57,14 +45,14 @@
<VARIABLELIST>
<VARLISTENTRY>
<TERM>
status
<replaceable>status</replaceable>
</TERM>
<LISTITEM>
<PARA>
<VARIABLELIST>
<VARLISTENTRY>
<TERM>
<ReturnValue>BEGIN</ReturnValue>
<returnvalue>BEGIN</returnvalue>
</TERM>
<LISTITEM>
<PARA>
......@@ -74,18 +62,12 @@
</VARLISTENTRY>
<VARLISTENTRY>
<TERM>
<ReturnValue>
NOTICE: BeginTransactionBlock and not in default state
</ReturnValue>
<returnvalue>NOTICE: BeginTransactionBlock and not in default state</returnvalue>
</TERM>
<LISTITEM>
<PARA>
This indicates that a transaction was already in progress.
<comment>
What happens to command queries already run
in the transaction? Does this have no effect, or does
it restart the transaction?
</comment>
The current transaction is not affected.
</PARA>
</LISTITEM>
</VARLISTENTRY>
......@@ -99,17 +81,20 @@
<REFSECT1 ID="R1-SQL-BEGINWORK-1">
<REFSECT1INFO>
<DATE>1998-04-15</DATE>
<DATE>1998-09-08</DATE>
</REFSECT1INFO>
<TITLE>
Description
</TITLE>
<para>
BEGIN begins a user transaction which PostgreSQL will
guarantee is serialisable with respect to all concurrently
executing transactions. PostgreSQL uses two-phase locking
<command>BEGIN</command> initiates a user transaction
which <productname>Postgres</productname> will
guarantee is serializable with respect to all concurrently
executing transactions. <productname>Postgres</productname> uses two-phase
locking
to perform this task. If the transaction is committed,
PostgreSQL will ensure either that all updates are done orelse
<productname>Postgres</productname> will ensure either that all updates are
done or else
that none of
them are done. Transactions have the standard ACID
(atomic, consistent, isolatable, and durable) property.
......@@ -117,7 +102,7 @@
<REFSECT2 ID="R2-SQL-BEGINWORK-3">
<REFSECT2INFO>
<DATE>1998-04-15</DATE>
<DATE>1998-09-08</DATE>
</REFSECT2INFO>
<TITLE>
Notes
......@@ -128,16 +113,13 @@
</PARA>
<PARA>
BEGIN statement is a PostgreSQL language extension.
</PARA>
<PARA>
Refer to the LOCK statement for further information about locking
tables inside a transaction.
Refer to the <command>LOCK</command> statement for further information
about locking tables inside a transaction.
</PARA>
<PARA>
Use COMMIT or ROLLBACK to terminate a transaction.
Use <command>COMMIT</command> or <command>ROLLBACK</command>
to terminate a transaction.
</PARA>
</REFSECT2>
......@@ -146,9 +128,9 @@
Usage
</TITLE>
<PARA>To begin a user transaction:
</PARA>
<ProgramListing>
BEGIN WORK;
BEGIN WORK;
</ProgramListing>
</REFSECT1>
......@@ -157,17 +139,19 @@
Compatibility
</TITLE>
<PARA>
</PARA>
<command>BEGIN</command>
is a <productname>Postgres</productname> language extension.
<REFSECT2 ID="R2-SQL-BEGINWORK-4">
<REFSECT2INFO>
<DATE>1998-04-15</DATE>
<DATE>1998-09-08</DATE>
</REFSECT2INFO>
<TITLE>
SQL92
</TITLE>
<PARA>
There is no explicit "BEGIN WORK" in SQL92; transaction initiation
There is no explicit BEGIN WORK command in <acronym>SQL92</acronym>;
transaction initiation
is always implicit and it terminates either with a COMMIT or with
a ROLLBACK statement.
</PARA>
......
......@@ -15,7 +15,7 @@
<REFSYNOPSISDIV>
<REFSYNOPSISDIVINFO>
<DATE>1998-04-15</DATE>
<DATE>1998-09-08</DATE>
</REFSYNOPSISDIVINFO>
<SYNOPSIS>
CLOSE <REPLACEABLE CLASS="PARAMETER">cursor</REPLACEABLE>
......@@ -23,25 +23,16 @@ CLOSE <REPLACEABLE CLASS="PARAMETER">cursor</REPLACEABLE>
<REFSECT2 ID="R2-SQL-CLOSE-1">
<REFSECT2INFO>
<DATE>1998-04-15</DATE>
<DATE>1998-09-08</DATE>
</REFSECT2INFO>
<TITLE>
Inputs
</TITLE>
<PARA>
</PARA>
<VARIABLELIST>
<VARLISTENTRY>
<TERM>
</TERM>
<LISTITEM>
<PARA>
<VARIABLELIST>
<VARLISTENTRY>
<TERM>
<ReturnValue>
<REPLACEABLE CLASS="PARAMETER">cursor</REPLACEABLE>
</ReturnValue>
</TERM>
<LISTITEM>
<PARA>
......@@ -50,14 +41,11 @@ CLOSE <REPLACEABLE CLASS="PARAMETER">cursor</REPLACEABLE>
</LISTITEM>
</VARLISTENTRY>
</variablelist>
</LISTITEM>
</VARLISTENTRY>
</VARIABLELIST>
</REFSECT2>
<REFSECT2 ID="R2-SQL-CLOSE-2">
<REFSECT2INFO>
<DATE>1998-04-15</DATE>
<DATE>1998-09-08</DATE>
</REFSECT2INFO>
<TITLE>
Outputs
......@@ -67,15 +55,16 @@ CLOSE <REPLACEABLE CLASS="PARAMETER">cursor</REPLACEABLE>
<VARIABLELIST>
<VARLISTENTRY>
<TERM>
<replaceable>
status
</replaceable>
</TERM>
<LISTITEM>
<PARA>
<VARIABLELIST>
<VARLISTENTRY>
<TERM>
<ReturnValue>
CLOSE
</ReturnValue>
<ReturnValue>CLOSE</ReturnValue>
</TERM>
<LISTITEM>
<PARA>
......@@ -85,9 +74,7 @@ CLOSE <REPLACEABLE CLASS="PARAMETER">cursor</REPLACEABLE>
</VARLISTENTRY>
<VARLISTENTRY>
<TERM>
<ReturnValue>
NOTICE PerformPortalClose: portal "<REPLACEABLE CLASS="PARAMETER">cursor</REPLACEABLE>" not found
</ReturnValue>
<ReturnValue>NOTICE PerformPortalClose: portal "<REPLACEABLE CLASS="PARAMETER">cursor</REPLACEABLE>" not found</ReturnValue>
</TERM>
<LISTITEM>
<PARA>
......@@ -107,33 +94,35 @@ CLOSE <REPLACEABLE CLASS="PARAMETER">cursor</REPLACEABLE>
<REFSECT1 ID="R1-SQL-CLOSE-1">
<REFSECT1INFO>
<DATE>1998-04-15</DATE>
<DATE>1998-09-08</DATE>
</REFSECT1INFO>
<TITLE>
Description
</TITLE>
<PARA>
CLOSE frees the resources associated with an open cursor.
<command>CLOSE</command> frees the resources associated with an open cursor.
After the cursor is closed, no subsequent operations
are allowed on it. A cursor should be closed when it is
no longer needed.
</PARA>
<PARA>
An implicit close is executed for every open cursor when a
transaction is terminated by COMMIT or ROLLBACK.
transaction is terminated by <command>COMMIT</command>
or <command>ROLLBACK</command>.
</PARA>
<REFSECT2 ID="R2-SQL-CLOSE-3">
<REFSECT2INFO>
<DATE>1998-04-15</DATE>
<DATE>1998-09-08</DATE>
</REFSECT2INFO>
<TITLE>
Notes
</TITLE>
<PARA>
PostgreSQL does not have an explicit OPEN cursor statement;
a cursor is considered open when it is DECLAREd.
Use DECLARE to declare a cursor.
<productname>Postgres</productname> does not have
an explicit <command>OPEN</command> cursor statement;
a cursor is considered open when it is declared.
Use the <command>DECLARE</command> statement to declare a cursor.
</PARA>
</REFSECT2>
</refsect1>
......@@ -146,7 +135,7 @@ CLOSE <REPLACEABLE CLASS="PARAMETER">cursor</REPLACEABLE>
Close the cursor liahona:
</PARA>
<ProgramListing>
CLOSE liahona;
CLOSE liahona;
</ProgramListing>
</REFSECT1>
......@@ -159,13 +148,13 @@ CLOSE <REPLACEABLE CLASS="PARAMETER">cursor</REPLACEABLE>
<REFSECT2 ID="R2-SQL-CLOSE-4">
<REFSECT2INFO>
<DATE>1998-04-15</DATE>
<DATE>1998-09-08</DATE>
</REFSECT2INFO>
<TITLE>
SQL92
</TITLE>
<PARA>
CLOSE is fully compatibile with SQL92.
<command>CLOSE</command> is fully compatible with SQL92.
</PARA>
</refsect2>
</refsect1>
......
......@@ -15,15 +15,15 @@
<REFSYNOPSISDIV>
<REFSYNOPSISDIVINFO>
<DATE>1998-04-15</DATE>
<DATE>1998-09-08</DATE>
</REFSYNOPSISDIVINFO>
<SYNOPSIS>
CLUSTER <REPLACEABLE CLASS="PARAMETER">indexname</REPLACEABLE> ON <REPLACEABLE CLASS="PARAMETER">table</REPLACEABLE>
CLUSTER <REPLACEABLE CLASS="PARAMETER">indexname</REPLACEABLE> ON <REPLACEABLE CLASS="PARAMETER">table</REPLACEABLE>
</SYNOPSIS>
<REFSECT2 ID="R2-SQL-CLUSTER-1">
<REFSECT2INFO>
<DATE>1998-04-15</DATE>
<DATE>1998-09-08</DATE>
</REFSECT2INFO>
<TITLE>
Inputs
......@@ -33,9 +33,7 @@
<VARIABLELIST>
<VARLISTENTRY>
<TERM>
<ReturnValue>
<REPLACEABLE CLASS="PARAMETER">indexname</REPLACEABLE>
</ReturnValue>
</TERM>
<LISTITEM>
<PARA>
......@@ -45,9 +43,7 @@
</VARLISTENTRY>
<VARLISTENTRY>
<TERM>
<ReturnValue>
<REPLACEABLE CLASS="PARAMETER">table</REPLACEABLE>
</ReturnValue>
</TERM>
<LISTITEM>
<PARA>
......@@ -60,7 +56,7 @@
<REFSECT2 ID="R2-SQL-CLUSTER-2">
<REFSECT2INFO>
<DATE>1998-04-15</DATE>
<DATE>1998-09-08</DATE>
</REFSECT2INFO>
<TITLE>
Outputs
......@@ -70,13 +66,14 @@
<VARIABLELIST>
<VARLISTENTRY>
<TERM>
<replaceable>status</replaceable>
</TERM>
<LISTITEM>
<PARA>
<VARIABLELIST>
<VARLISTENTRY>
<TERM>
<ReturnValue>CLUSTER</ReturnValue>
<returnvalue>CLUSTER</returnvalue>
</TERM>
<LISTITEM>
<PARA>
......@@ -86,11 +83,11 @@
</VARLISTENTRY>
<VARLISTENTRY>
<TERM>
<ReturnValue>ERROR: relation &lt;<REPLACEABLE CLASS="PARAMETER">tablerelation_number</REPLACEABLE>&gt; inherits "invoice"</ReturnValue>
<returnvalue>ERROR: relation &lt;<REPLACEABLE CLASS="PARAMETER">tablerelation_number</REPLACEABLE>&gt; inherits "invoice"</returnvalue>
</TERM>
<LISTITEM>
<PARA>
???
<comment>
This is not documented anywhere. It seems not to be possible to
cluster a table that is inherited.
......@@ -100,11 +97,11 @@
</VARLISTENTRY>
<VARLISTENTRY>
<TERM>
<ReturnValue>ERROR: Relation x does not exist!</ReturnValue>
<returnvalue>ERROR: Relation x does not exist!</returnvalue>
</TERM>
<LISTITEM>
<PARA>
???
<comment>
The relation complained of was not shown in the error message,
which contained a random string instead of the relation name.
......@@ -122,27 +119,37 @@
<REFSECT1 ID="R1-SQL-CLUSTER-1">
<REFSECT1INFO>
<DATE>1998-04-15</DATE>
<DATE>1998-09-08</DATE>
</REFSECT1INFO>
<TITLE>
Description
</TITLE>
<PARA>
This command instructs PostgreSQL to cluster the class specified
<command>CLUSTER</command> instructs <productname>Postgres</productname>
to cluster the class specified
by <replaceable class="parameter">classname</replaceable> approximately
based on the index specified by
<replaceable class="parameter">indexname</replaceable>. The index must
already have been defined on <replaceable class="parameter">classname</replaceable>.
already have been defined on
<replaceable class="parameter">classname</replaceable>.
</PARA>
<para>
When a class is clustered, it is physically reordered
based on the index information. The clustering is static.
In other words, as the class is updated, the changes are
not clustered. No attempt is made to keep new instances or
updated tuples clustered. If he wishes, the user can
updated tuples clustered. If one wishes, one can
recluster manually by issuing the command again.
</para>
<REFSECT2 ID="R2-SQL-CLUSTER-3">
<REFSECT2INFO>
<DATE>1998-09-08</DATE>
</REFSECT2INFO>
<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
......@@ -155,16 +162,15 @@
within a table, the actual order of the data in the heap
table is unimportant. However, if you tend to access some
data more than others, and there is an index that groups
them together, you will benefit from using the CLUSTER
command.
them together, you will benefit from using <command>CLUSTER</command>.
</para>
<para>
Another place CLUSTER is good is in cases where you use an
Another place <command>CLUSTER</command> is helpful is in cases where you use an
index to pull out several rows from a table. If you are
requesting a range of indexed values from a table, or a
single indexed value that has multiple rows that match,
CLUSTER will help because once the index identifies the
<command>CLUSTER</command> will help because once the index identifies the
heap page for the first row that matches, all other rows
that match are probably already on the same heap page,
saving disk accesses and speeding up the query.
......@@ -172,25 +178,27 @@
<para>
There are two ways to cluster data. The first is with the
CLUSTER command, which reorders the original table with
<command>CLUSTER</command> command, which reorders the original table with
the ordering of the index you specify. This can be slow
on large tables because the rows are fetched from the heap
in index order, and if the heap table is unordered, the
entries are on random pages, so there is one disk page
retrieved for every row moved. PostgreSQL has a cache,
retrieved for every row moved. <productname>Postgres</productname> has a cache,
but the majority of a big table will not fit in the cache.
</para>
<para>
Another way is to use
<programlisting>SELECT ... INTO TABLE temp FROM ... ORDER BY ...</programlisting>
This uses the PostgreSQL sorting code in
Another way to cluster data is to use
<programlisting>
SELECT ... INTO TABLE <replaceable class="parameter">temp</replaceable> FROM ... ORDER BY ...
</programlisting>
This uses the <productname>Postgres</productname> sorting code in
ORDER BY to match the index, and is much faster for
unordered data. You then drop the old table, use
<programlisting>ALTER TABLE RENAME</programlisting>
to rename 'temp' to the old name, and
recreate the b bindexes. The only problem is that oids
will not be preserved. From then on, CLUSTER should be
<command>ALTER TABLE/RENAME</command>
to rename <replaceable class="parameter">temp</replaceable> to the old name, and
recreate any indexes. The only problem is that <acronym>OID</acronym>s
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>
......@@ -204,7 +212,7 @@
Cluster the employees relation on the basis of its salary attribute
</PARA>
<ProgramListing>
CLUSTER emp_ind ON emp
CLUSTER emp_ind ON emp
</ProgramListing>
</REFSECT1>
......@@ -217,13 +225,13 @@
<REFSECT2 ID="R2-SQL-CLUSTER-4">
<REFSECT2INFO>
<DATE>1998-04-15</DATE>
<DATE>1998-09-08</DATE>
</REFSECT2INFO>
<TITLE>
SQL92
</TITLE>
<PARA>
There is no CLUSTER statement in SQL92.
There is no <command>CLUSTER</command> statement in SQL92.
</PARA>
</refsect2>
</refsect1>
......
......@@ -16,63 +16,43 @@
<REFSYNOPSISDIV>
<REFSYNOPSISDIVINFO>
<DATE>1998-04-15</DATE>
<DATE>1998-09-08</DATE>
</REFSYNOPSISDIVINFO>
<SYNOPSIS>
COMMIT [ WORK ]
COMMIT [ WORK | TRANSACTION ]
</SYNOPSIS>
<REFSECT2 ID="R2-SQL-COMMIT-1">
<REFSECT2INFO>
<DATE>1998-04-15</DATE>
<DATE>1998-09-08</DATE>
</REFSECT2INFO>
<TITLE>
Inputs
</TITLE>
<PARA>
</PARA>
<VARIABLELIST>
<VARLISTENTRY>
<TERM>
</TERM>
<LISTITEM>
<PARA>
<VARIABLELIST>
<VARLISTENTRY>
<TERM>
<ReturnValue>None</ReturnValue>
</TERM>
<LISTITEM>
<PARA>
</PARA>
</LISTITEM>
</VARLISTENTRY>
</variablelist>
</LISTITEM>
</VARLISTENTRY>
</VARIABLELIST>
None
</REFSECT2>
<REFSECT2 ID="R2-SQL-COMMIT-2">
<REFSECT2INFO>
<DATE>1998-04-15</DATE>
<DATE>1998-09-08</DATE>
</REFSECT2INFO>
<TITLE>
Outputs
</TITLE>
<PARA>
</PARA>
<VARIABLELIST>
<VARLISTENTRY>
<TERM>
<replaceable>status</replaceable>
</TERM>
<LISTITEM>
<PARA>
<VARIABLELIST>
<VARLISTENTRY>
<TERM>
<ReturnValue>END</ReturnValue>
<returnvalue>END</returnvalue>
</TERM>
<LISTITEM>
<PARA>
......@@ -82,8 +62,7 @@ Message returned if the transaction is successfully committed.
</VARLISTENTRY>
<VARLISTENTRY>
<TERM>
<ReturnValue>NOTICE EndTransactionBlock and not inprogress/abort state
</ReturnValue>
<returnvalue>NOTICE EndTransactionBlock and not inprogress/abort state</returnvalue>
</TERM>
<LISTITEM>
<PARA>
......@@ -100,29 +79,29 @@ If there is no transaction in progress.
<REFSECT1 ID="R1-SQL-COMMIT-1">
<REFSECT1INFO>
<DATE>1998-04-15</DATE>
<DATE>1998-09-08</DATE>
</REFSECT1INFO>
<TITLE>
Description
</TITLE>
<PARA>
COMMIT commits the current transaction. All
<command>COMMIT</command> commits the current transaction. All
changes made by the transaction become visible to others
and are guaranteed to be durable if a crash occurs.
</PARA>
<REFSECT2 ID="R2-SQL-COMMIT-3">
<REFSECT2INFO>
<DATE>1998-04-15</DATE>
<DATE>1998-09-08</DATE>
</REFSECT2INFO>
<TITLE>
Notes
</TITLE>
<PARA>
The keyword WORK is noise and can be omitted.
The keywords WORK and TRANSACTION are noise and can be omitted.
</PARA>
<para>
Refer to ROLLBACK statements to abort a transaction.
Use the <command>ROLLBACK</command> statement to abort a transaction.
</para>
</REFSECT2>
</refsect1>
......@@ -135,7 +114,7 @@ If there is no transaction in progress.
To make all changes permanent:
</PARA>
<ProgramListing>
COMMIT WORK;
COMMIT WORK;
</ProgramListing>
</REFSECT1>
......@@ -148,7 +127,7 @@ To make all changes permanent:
<REFSECT2 ID="R2-SQL-COMMIT-4">
<REFSECT2INFO>
<DATE>1998-04-15</DATE>
<DATE>1998-09-08</DATE>
</REFSECT2INFO>
<TITLE>
SQL92
......
This diff is collapsed.
This diff is collapsed.
......@@ -17,7 +17,7 @@
<DATE>1998-04-15</DATE>
</REFSYNOPSISDIVINFO>
<SYNOPSIS>
CREATE DATABASE <REPLACEABLE CLASS="PARAMETER">name</REPLACEABLE> [WITH LOCATION = '<replaceable class="parameter">dbpath</replaceable>']
CREATE DATABASE <REPLACEABLE CLASS="PARAMETER">name</REPLACEABLE> [ WITH LOCATION = '<replaceable class="parameter">dbpath</replaceable>' ]
</SYNOPSIS>
<REFSECT2 ID="R2-SQL-CREATEDATABASE-1">
......@@ -27,13 +27,6 @@
<TITLE>
Inputs
</TITLE>
<PARA>
</PARA>
<VARIABLELIST>
<VARLISTENTRY>
<TERM>
</TERM>
<LISTITEM>
<PARA>
<VARIABLELIST>
<VARLISTENTRY>
......@@ -62,9 +55,6 @@
</LISTITEM>
</VARLISTENTRY>
</VARIABLELIST>
</LISTITEM>
</VARLISTENTRY>
</VARIABLELIST>
</REFSECT2>
<REFSECT2 ID="R2-SQL-CREATEDATABASE-2">
......@@ -79,6 +69,7 @@
<VARIABLELIST>
<VARLISTENTRY>
<TERM>
<replaceable>status</replaceable>
</TERM>
<LISTITEM>
<PARA>
......@@ -142,10 +133,11 @@ There was a problem with creating the required directory; this operation will
Notes
</TITLE>
<PARA>
<command>CREATE DATABASE</command> statement is a Postgres language extension.
<command>CREATE DATABASE</command> is a <productname>Postgres</productname>
language extension.
</PARA>
<para>
Refer to <command>DROP DATABASE</command> statement to remove a database.
Use <command>DROP DATABASE</command> to remove a database.
</para>
</REFSECT2>
......@@ -157,18 +149,18 @@ There was a problem with creating the required directory; this operation will
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>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:
<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
......@@ -176,7 +168,7 @@ There was a problem with creating the required directory; this operation will
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>
<prompt>olly=></prompt></computeroutput> <userinput>create database elsewhere with location = '/home/olly/private_db';</userinput>
<computeroutput>CREATEDB</computeroutput>
</ProgramListing>
</REFSECT1>
......@@ -186,8 +178,12 @@ There was a problem with creating the required directory; this operation will
Bugs
</TITLE>
<PARA>
There are security and data integrity issues involved with using alternate database locations
specified with absolute path names. See the Administrator's Guide for more information.
There are security and data integrity issues
involved with using alternate database locations
specified with absolute path names, and by default
only an environment variable known to the backend may be
specified for an alternate location.
See the Administrator's Guide for more information.
</PARA>
</refsect1>
......@@ -207,7 +203,6 @@ Not sure if the dump/reload would guarantee that the alternate data area gets re
Compatibility
</TITLE>
<PARA>
</PARA>
<REFSECT2 ID="R2-SQL-CREATEDATABASE-4">
<REFSECT2INFO>
......@@ -217,7 +212,7 @@ Not sure if the dump/reload would guarantee that the alternate data area gets re
SQL92
</TITLE>
<PARA>
There is no <command>CREATE DATABASE</command> statement on SQL92.
There is no <command>CREATE DATABASE</command> statement in SQL92.
</PARA>
<para>
The equivalent command in standard SQL is <command>CREATE SCHEMA</command>.
......
......@@ -15,10 +15,10 @@
<REFSYNOPSISDIV>
<REFSYNOPSISDIVINFO>
<DATE>1998-04-15</DATE>
<DATE>1998-09-09</DATE>
</REFSYNOPSISDIVINFO>
<SYNOPSIS>
CREATE FUNCTION <replaceable class="parameter">name</replaceable> ([<replaceable class="parameter">ftype</replaceable> [, ...]])
CREATE FUNCTION <replaceable class="parameter">name</replaceable> ( [ <replaceable class="parameter">ftype</replaceable> [, ...] ] )
RETURNS <replaceable class="parameter">rtype</replaceable>
AS <replaceable class="parameter">path</replaceable>
LANGUAGE '<replaceable class="parameter">langname</replaceable>'
......@@ -26,18 +26,11 @@
<REFSECT2 ID="R2-SQL-CREATEFUNCTION-1">
<REFSECT2INFO>
<DATE>1998-04-15</DATE>
<DATE>1998-09-09</DATE>
</REFSECT2INFO>
<TITLE>
Inputs
</TITLE>
<PARA>
</PARA>
<VARIABLELIST>
<VARLISTENTRY>
<TERM>
</TERM>
<LISTITEM>
<PARA>
<VARIABLELIST>
<VARLISTENTRY>
......@@ -87,21 +80,21 @@
</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 language name of a created procedural
language. See <command>CREATE LANGUAGE</command> for details).
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>
</LISTITEM>
</VARLISTENTRY>
</VARIABLELIST>
</REFSECT2>
<REFSECT2 ID="R2-SQL-CREATEFUNCTION-2">
<REFSECT2INFO>
<DATE>1998-04-15</DATE>
<DATE>1998-09-09</DATE>
</REFSECT2INFO>
<TITLE>
Outputs
......@@ -111,6 +104,7 @@
<VARIABLELIST>
<VARLISTENTRY>
<TERM>
<replaceable>status</replaceable>
</TERM>
<LISTITEM>
<PARA>
......@@ -134,32 +128,34 @@
<REFSECT1 ID="R1-SQL-CREATEFUNCTION-1">
<REFSECT1INFO>
<DATE>1998-04-15</DATE>
<DATE>1998-09-09</DATE>
</REFSECT1INFO>
<TITLE>
Description
</TITLE>
<PARA>
With this command, a PostgreSQL user can register a function
with PostgreSQL. Subsequently, this user is treated as the
<command>CREATE FUNCTION</command> allows a
<productname>Postgres</productname> user
to register a function
with a database. Subsequently, this user is treated as the
owner of the function.
</PARA>
<REFSECT2 ID="R2-SQL-CREATEFUNCTION-3">
<REFSECT2INFO>
<DATE>1998-04-15</DATE>
<DATE>1998-09-09</DATE>
</REFSECT2INFO>
<TITLE>
Notes
</TITLE>
<PARA>
Refer to <citetitle>PostgreSQL User's Guide</citetitle> chapter 6 for further information.
<comment>This reference needs to be corrected.</comment>
Refer to the chapter on functions
in the <citetitle>PostgreSQL Programmer's Guide</citetitle>
for further information.
</PARA>
<PARA>
Refer to the <citerefentry>
<refentrytitle>DROP FUNCTION</refentrytitle>
</citerefentry> statement to drop functions.
Use <command>DROP FUNCTION</command>
to drop user-defined functions.
</PARA>
</REFSECT2>
......@@ -171,15 +167,17 @@
To create a simple SQL function:
</PARA>
<ProgramListing>
CREATE FUNCTION one() RETURNS int4
CREATE FUNCTION one() RETURNS int4
AS 'SELECT 1 AS RESULT'
LANGUAGE 'sql';
SELECT one() AS answer;
SELECT one() AS answer;
<computeroutput>answer
------
1 </computeroutput>
<computeroutput>
answer
------
1
</computeroutput>
</ProgramListing>
<para>
To create a C function, calling a routine from a user-created
......@@ -188,17 +186,18 @@
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
(
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>
);</userinput>
</programlisting>
</REFSECT1>
......@@ -216,39 +215,44 @@
Compatibility
</TITLE>
<PARA>
The CREATE FUNCTION statement is a PostgreSQL language extension.
<command>CREATE FUNCTION</command> is
a <productname>Postgres</productname> language extension.
</PARA>
<REFSECT2 ID="R2-SQL-CREATEFUNCTION-4">
<REFSECT2INFO>
<DATE>1998-04-15</DATE>
<DATE>1998-09-09</DATE>
</REFSECT2INFO>
<TITLE>
SQL/PSM<footnote>
SQL/PSM
</TITLE>
<para>
<note>
<para>
PSM stands for Persistent Stored Modules, it is a procedural
PSM stands for Persistent Stored Modules. It is a procedural
language and it was originally hoped that PSM would be ratified
as an official standard by late 1996. However PSM will
as an official standard by late 1996. As of mid-1998, this
has not yet happened, but it is hoped that PSM will
eventually become a standard.
</para>
</footnote>
</TITLE>
<para>
The SQL/PSM CREATE FUNCTION statement has the following syntax:
<programlisting>
CREATE FUNCTION <replaceable class="parameter">name</replaceable>
( [ [IN|OUT|INOUT] <replaceable class="parameter">parm</replaceable> <replaceable class="parameter">type</replaceable> [, ...] ])
</note>
SQL/PSM <command>CREATE FUNCTION</command> has the following syntax:
<synopsis>
CREATE FUNCTION <replaceable class="parameter">name</replaceable>
( [ [ IN | OUT | INOUT ] <replaceable class="parameter">parm</replaceable> <replaceable class="parameter">type</replaceable> [, ...] ] )
RETURNS <replaceable class="parameter">rtype</replaceable>
LANGUAGE '<replaceable class="parameter">langname</replaceable>'
ESPECIFIC <replaceable class="parameter">routine</replaceable>
<replaceable class="parameter">SQL-statement</replaceable>
</programlisting>
</synopsis>
</para>
</refsect2>
</refsect1>
</REFENTRY>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
......
......@@ -14,41 +14,33 @@
</REFPURPOSE>
<REFSYNOPSISDIV>
<REFSYNOPSISDIVINFO>
<DATE>1998-04-15</DATE>
<DATE>1998-09-09</DATE>
</REFSYNOPSISDIVINFO>
<SYNOPSIS>
CREATE [UNIQUE] INDEX <replaceable class="parameter">index_name</replaceable>
ON <replaceable class="parameter">table</replaceable> [USING <replaceable class="parameter">acc_name</replaceable> ]
( <replaceable class="parameter">column</replaceable> [<replaceable class="parameter">ops_name</replaceable>] [, ...] )
CREATE [UNIQUE] INDEX <replaceable class="parameter">index_name</replaceable>
ON <replaceable class="parameter">table</replaceable> [USING <replaceable class="parameter">acc_name</replaceable> ]
CREATE [ UNIQUE ] INDEX <replaceable class="parameter">index_name</replaceable>
ON <replaceable class="parameter">table</replaceable> [ USING <replaceable class="parameter">acc_name</replaceable> ]
( <replaceable class="parameter">column</replaceable> [ <replaceable class="parameter">ops_name</replaceable>] [, ...] )
CREATE [ UNIQUE ] INDEX <replaceable class="parameter">index_name</replaceable>
ON <replaceable class="parameter">table</replaceable> [ USING <replaceable class="parameter">acc_name</replaceable> ]
( <replaceable class="parameter">func_name</replaceable>( <replaceable class="parameter">column</replaceable> [, ... ]) <replaceable class="parameter">ops_name</replaceable> )
</SYNOPSIS>
<REFSECT2 ID="R2-SQL-CREATEINDEX-1">
<REFSECT2INFO>
<DATE>1998-04-15</DATE>
<DATE>1998-09-09</DATE>
</REFSECT2INFO>
<TITLE>
Inputs
</TITLE>
<PARA>
</PARA>
<VARIABLELIST>
<VARLISTENTRY>
<TERM>
</TERM>
<LISTITEM>
<PARA>
<VARIABLELIST>
<VARLISTENTRY>
<TERM>
<function>UNIQUE</function>
UNIQUE
</TERM>
<LISTITEM>
<PARA>
<function>UNIQUE</function> causes the system to check for
Causes the system to check for
duplicate values when the index is created (if data
already exist) and each time data is added. Attempts to
insert or update non-duplicate data will generate an
......@@ -134,8 +126,8 @@
An associated operator class.
The following select list returns all ops_names:
<programlisting>
SELECT am.amname AS acc_name,
<programlisting>
SELECT am.amname AS acc_name,
opc.opcname AS ops_name,
opr.oprname AS ops_comp
FROM pg_am am, pg_amop amop,
......@@ -144,7 +136,8 @@
amop.amopclaid = opc.oid AND
amop.amopopr = opr.oid
ORDER BY acc_name, ops_name, ops_comp
</programlisting>
</programlisting>
</PARA>
</LISTITEM>
</VARLISTENTRY>
......@@ -160,14 +153,12 @@
</LISTITEM>
</VARLISTENTRY>
</variablelist>
</LISTITEM>
</VARLISTENTRY>
</VARIABLELIST>
</REFSECT2>
<REFSECT2 ID="R2-SQL-CREATEINDEX-2">
<REFSECT2INFO>
<DATE>1998-04-15</DATE>
<DATE>1998-09-09</DATE>
</REFSECT2INFO>
<TITLE>
Outputs
......@@ -177,6 +168,7 @@
<VARIABLELIST>
<VARLISTENTRY>
<TERM>
<replaceable>status</replaceable>
</TERM>
<LISTITEM>
<PARA>
......@@ -210,14 +202,23 @@
<REFSECT1 ID="R1-SQL-CREATEINDEX-1">
<REFSECT1INFO>
<DATE>1998-04-15</DATE>
<DATE>1998-09-09</DATE>
</REFSECT1INFO>
<TITLE>
Description
</TITLE>
<PARA>
This command constructs an index called <replaceable class="parameter">index_name</replaceable>.
</PARA>
This command constructs an index
<replaceable class="parameter">index_name</replaceable>.
on the specified
<replaceable class="parameter">table</replaceable>.
<tip>
<para>
Indices are primarily used to enhance database performance.
But inappropriate use will result in slower performance.
</tip>
<para>
In the first syntax shown above, the key fields for the
index are specified as column names; a column may also have
......@@ -242,7 +243,7 @@
<REFSECT2 ID="R2-SQL-CREATEINDEX-3">
<REFSECT2INFO>
<DATE>1998-04-15</DATE>
<DATE>1998-09-09</DATE>
</REFSECT2INFO>
<TITLE>
Notes
......@@ -252,10 +253,8 @@
indices. Up to 7 keys may be specified.
</PARA>
<para>
Use the <citerefentry>
<refentrytitle>DROP INDEX</refentrytitle>
</citerefentry>
statement to remove indexes.
Use <command>DROP INDEX</command>
to remove an index.
</para>
</REFSECT2>
......@@ -267,24 +266,27 @@
in the table <literal>films</literal>:
</PARA>
<ProgramListing>
CREATE UNIQUE INDEX title_idx
CREATE UNIQUE INDEX title_idx
ON films (title);
</ProgramListing>
<!--
<comment>
Is this example correct?
</comment>
<para>
To create a rtree index on a point attribute so that we
can efficiently use box operators on the result of the
conversion function:
</para>
<programlisting>
CREATE INDEX pointloc
CREATE INDEX pointloc
ON points USING RTREE (point2box(location) box_ops);
SELECT * FROM points
SELECT * FROM points
WHERE point2box(points.pointloc) = boxes.box;
<comment>
Is this example correct?
</comment>
</programlisting>
-->
</REFSECT1>
<REFSECT1 ID="R1-SQL-CREATEINDEX-3">
......@@ -296,16 +298,16 @@ Is this example correct?
<REFSECT2 ID="R2-SQL-CREATEINDEX-4">
<REFSECT2INFO>
<DATE>1998-04-15</DATE>
<DATE>1998-09-09</DATE>
</REFSECT2INFO>
<TITLE>
SQL92
</TITLE>
<PARA>
CREATE INDEX is a PostgreSQL language extension.
CREATE INDEX is a <productname>Postgres</productname> language extension.
</PARA>
<para>
There is no CREATE INDEX command in SQL92.
There is no <command>CREATE INDEX</command> command in SQL92.
</para>
</refsect2>
</refsect1>
......
......@@ -15,28 +15,21 @@
<REFSYNOPSISDIV>
<REFSYNOPSISDIVINFO>
<DATE>1998-04-15</DATE>
<DATE>1998-09-09</DATE>
</REFSYNOPSISDIVINFO>
<SYNOPSIS>
CREATE [TRUSTED] PROCEDURAL LANGUAGE '<replaceable class="parameter">langname</replaceable>'
CREATE [ TRUSTED ] PROCEDURAL LANGUAGE '<replaceable class="parameter">langname</replaceable>'
HANDLER <replaceable class="parameter">call_handler</replaceable>
LANCOMPILER '<replaceable class="parameter">comment</replaceable>'
</SYNOPSIS>
<REFSECT2 ID="R2-SQL-CREATELANGUAGE-1">
<REFSECT2INFO>
<DATE>1998-04-15</DATE>
<DATE>1998-09-09</DATE>
</REFSECT2INFO>
<TITLE>
Inputs
</TITLE>
<PARA>
</PARA>
<VARIABLELIST>
<VARLISTENTRY>
<TERM>
</TERM>
<LISTITEM>
<PARA>
<VARIABLELIST>
<VARLISTENTRY>
......@@ -99,14 +92,12 @@
</LISTITEM>
</VARLISTENTRY>
</variablelist>
</LISTITEM>
</VARLISTENTRY>
</VARIABLELIST>
</REFSECT2>
<REFSECT2 ID="R2-SQL-CREATELANGUAGE-2">
<REFSECT2INFO>
<DATE>1998-04-15</DATE>
<DATE>1998-09-09</DATE>
</REFSECT2INFO>
<TITLE>
Outputs
......@@ -116,6 +107,7 @@
<VARIABLELIST>
<VARLISTENTRY>
<TERM>
<replaceable>status</replaceable>
</TERM>
<LISTITEM>
<PARA>
......@@ -152,22 +144,25 @@
<REFSECT1 ID="R1-SQL-CREATELANGUAGE-1">
<REFSECT1INFO>
<DATE>1998-04-15</DATE>
<DATE>1998-09-09</DATE>
</REFSECT1INFO>
<TITLE>
Description
</TITLE>
<PARA>
Using <command>CREATE LANGUAGE</command>, a PostgreSQL user can register
a new language with PostgreSQL. Subsequently, functions and
Using <command>CREATE LANGUAGE</command>, a
<productname>Postgres</productname> user can register
a new language with <productname>Postgres</productname>.
Subsequently, functions and
trigger procedures can be defined in this new language.
The user must have the PostgreSQL superuser privilege to
The user must have the <productname>Postgres</productname>
superuser privilege to
register a new language.
</PARA>
<REFSECT2 ID="R2-SQL-CREATELANGUAGE-3">
<REFSECT2INFO>
<DATE>1998-04-15</DATE>
<DATE>1998-09-09</DATE>
</REFSECT2INFO>
<TITLE>
Writing PL handlers
......@@ -175,9 +170,9 @@
<PARA>
The call handler for a procedural language must be written
in a compiler language such as 'C' and registered with
PostgreSQL as a function taking no arguments and returning
opaque type.
<comment>What does `opaque type' mean?</comment>
<productname>Postgres</productname> as a function taking
no arguments and returning the
<type>opaque</type> type, a placeholder for unspecified or undefined types..
This prevents the call handler from being
called directly as a function from queries.
</para>
......@@ -214,11 +209,11 @@
It's up to the call handler to fetch the
<filename>pg_proc</filename> entry and
to analyze the argument and return types of the called
procedure. The <function>AS</function> clause from the
procedure. The AS clause from the
<command>CREATE FUNCTION</command> of
the procedure will be found in the <literal>prosrc</literal>
attribute of the
<filename>pg_proc</filename> entry. This may be the
<filename>pg_proc</filename> table entry. This may be the
source text in the procedural
language itself (like for PL/Tcl), a pathname to a
file or anything else that tells the call handler what to
......@@ -227,43 +222,40 @@
<REFSECT2 ID="R2-SQL-CREATELANGUAGE-4">
<REFSECT2INFO>
<DATE>1998-04-15</DATE>
<DATE>1998-09-09</DATE>
</REFSECT2INFO>
<TITLE>
Notes
</TITLE>
<PARA>
Use <citerefentry>
<refentrytitle>CREATE FUNCTION</refentrytitle>
</citerefentry>
Use <command>CREATE FUNCTION</command>
to create a function.
</para>
<para>
Use <citerefentry>
<refentrytitle>DROP LANGUAGE</refentrytitle>
</citerefentry> to drop procedural languages.
Use <command>DROP LANGUAGE</command> to drop procedural languages.
</para>
<para>
Refer to the table <filename>pg_language</filename>
for further information:
<programlisting>
<computeroutput>
Table = pg_language
+--------------------------+--------------------------+-------+
| Field | Type | Length|
+--------------------------+--------------------------+-------+
| lanname | name | 32 |
| lancompiler | text | var |
+--------------------------+--------------------------+-------+
<programlisting>
<computeroutput>
Table = pg_language
+--------------------------+--------------------------+-------+
| Field | Type | Length|
+--------------------------+--------------------------+-------+
| lanname | name | 32 |
| lancompiler | text | var |
+--------------------------+--------------------------+-------+
lanname |lancompiler
--------+--------------
internal|n/a
lisp |/usr/ucb/liszt
C |/bin/cc
sql |postgres
</computeroutput>
</programlisting>
lanname |lancompiler
--------+--------------
internal|n/a
lisp |/usr/ucb/liszt
C |/bin/cc
sql |postgres
</computeroutput>
</programlisting>
</para>
</refsect2>
</refsect1>
......@@ -274,11 +266,9 @@
</TITLE>
<PARA>
Since the call handler for a procedural language must be
registered with PostgreSQL in the 'C' language, it inherits
all the restrictions of 'C' functions.
<comment>
What are these restrictions?
</comment>
registered with <productname>Postgres</productname> in the 'C' language,
it inherits
all the capabilities and restrictions of 'C' functions.
</para>
</refsect1>
<REFSECT1 ID="R1-SQL-CREATELANGUAGE-5">
......@@ -340,20 +330,19 @@
</ProgramListing>
<para>
Only a few thousand lines of code have to be added instead
of the dots to complete the PL call handler. See <citerefentry>
<refentrytitle>CREATE FUNCTION</refentrytitle>
</citerefentry> for information on how to compile
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>
The following commands then register the sample procedural
language.</para>
language:
<programlisting>
CREATE FUNCTION plsample_call_handler () RETURNS opaque
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>
......@@ -364,18 +353,18 @@
Compatibility
</TITLE>
<PARA>
CREATE LANGUAGE is a PostgreSQL extension.
CREATE LANGUAGE is a <productname>Postgres</productname> extension.
</PARA>
<REFSECT2 ID="R2-SQL-CREATELANGUAGE-5">
<REFSECT2INFO>
<DATE>1998-04-15</DATE>
<DATE>1998-09-09</DATE>
</REFSECT2INFO>
<TITLE>
SQL92
</TITLE>
<PARA>
There is no CREATE LANGUAGE statement in SQL92.
There is no <command>CREATE LANGUAGE</command> statement in SQL92.
</PARA>
</refsect2>
</refsect1>
......
This diff is collapsed.
This diff is collapsed.
......@@ -18,18 +18,18 @@
<DATE>1998-04-15</DATE>
</REFSYNOPSISDIVINFO>
<SYNOPSIS>
CREATE SEQUENCE <replaceable class="parameter">seqname</replaceable>
[INCREMENT <replaceable class="parameter">increment</replaceable>]
[MINVALUE <replaceable class="parameter">minvalue</replaceable>]
[MAXVALUE <replaceable class="parameter">maxvalue</replaceable>]
[START <replaceable class="parameter">start</replaceable>]
[CACHE <replaceable class="parameter">cache</replaceable>]
[CYCLE]
CREATE SEQUENCE <replaceable class="parameter">seqname</replaceable>
[ INCREMENT <replaceable class="parameter">increment</replaceable> ]
[ MINVALUE <replaceable class="parameter">minvalue</replaceable> ]
[ MAXVALUE <replaceable class="parameter">maxvalue</replaceable> ]
[ START <replaceable class="parameter">start</replaceable> ]
[ CACHE <replaceable class="parameter">cache</replaceable> ]
[ CYCLE ]
</SYNOPSIS>
<REFSECT2 ID="R2-SQL-CREATESEQUENCE-1">
<REFSECT2INFO>
<DATE>1998-04-15</DATE>
<DATE>1998-09-11</DATE>
</REFSECT2INFO>
<TITLE>
Inputs
......@@ -39,13 +39,7 @@
<VARIABLELIST>
<VARLISTENTRY>
<TERM>
</TERM>
<LISTITEM>
<PARA>
<VARIABLELIST>
<VARLISTENTRY>
<TERM>
<ReturnValue><replaceable class="parameter">seqname</replaceable></ReturnValue>
<replaceable class="parameter">seqname</replaceable>
</TERM>
<LISTITEM>
<PARA>
......@@ -55,19 +49,19 @@
</VARLISTENTRY>
<VARLISTENTRY>
<TERM>
<ReturnValue><replaceable class="parameter">increment</replaceable></ReturnValue>
<replaceable class="parameter">increment</replaceable>
</TERM>
<LISTITEM>
<PARA>
The <option>INCREMENT <replaceable class="parameter">increment</replaceable></option> clause is optional. A positive value will make an
ascending sequence, a negative one a descending sequence. The default value
is 1.
ascending sequence, a negative one a descending sequence.
The default value is one (1).
</PARA>
</LISTITEM>
</VARLISTENTRY>
<VARLISTENTRY>
<TERM>
<ReturnValue><replaceable class="parameter">minvalue</replaceable></ReturnValue>
<replaceable class="parameter">minvalue</replaceable>
</TERM>
<LISTITEM>
<PARA>
......@@ -81,7 +75,7 @@
</VARLISTENTRY>
<VARLISTENTRY>
<TERM>
<ReturnValue><replaceable class="parameter">maxvalue</replaceable></ReturnValue>
<replaceable class="parameter">maxvalue</replaceable>
</TERM>
<LISTITEM>
<PARA>
......@@ -95,7 +89,7 @@
</VARLISTENTRY>
<VARLISTENTRY>
<TERM>
<ReturnValue><replaceable class="parameter">start</replaceable></ReturnValue>
<replaceable class="parameter">start</replaceable>
</TERM>
<LISTITEM>
<PARA>
......@@ -107,15 +101,12 @@
for ascending sequences and
<replaceable class="parameter">maxvalue</replaceable>
for descending ones.
<comment>
What happens if the user specifies start outside the range?
</comment>
</PARA>
</LISTITEM>
</VARLISTENTRY>
<VARLISTENTRY>
<TERM>
<ReturnValue><replaceable class="parameter">cache</replaceable></ReturnValue>
<replaceable class="parameter">cache</replaceable>
</TERM>
<LISTITEM>
<PARA>
......@@ -128,7 +119,7 @@
</VARLISTENTRY>
<VARLISTENTRY>
<TERM>
<ReturnValue>CYCLE</ReturnValue>
CYCLE
</TERM>
<LISTITEM>
<PARA>
......@@ -146,14 +137,11 @@
</LISTITEM>
</VARLISTENTRY>
</variablelist>
</LISTITEM>
</VARLISTENTRY>
</variablelist>
</REFSECT2>
<REFSECT2 ID="R2-SQL-CREATESEQUENCE-2">
<REFSECT2INFO>
<DATE>1998-04-15</DATE>
<DATE>1998-09-11</DATE>
</REFSECT2INFO>
<TITLE>
Outputs
......@@ -163,6 +151,7 @@
<VARIABLELIST>
<VARLISTENTRY>
<TERM>
<replaceable>status</replaceable>
</TERM>
<LISTITEM>
<PARA>
......@@ -179,7 +168,7 @@
</VARLISTENTRY>
<VARLISTENTRY>
<TERM>
<ReturnValue>ERROR: amcreate: '<replaceable class="parameter"> seqname</replaceable>' relation already exists</ReturnValue>
<ReturnValue>ERROR: amcreate: '<replaceable class="parameter">seqname</replaceable>' relation already exists</ReturnValue>
</TERM>
<LISTITEM>
<PARA>
......@@ -187,6 +176,36 @@
</PARA>
</LISTITEM>
</VARLISTENTRY>
<VARLISTENTRY>
<TERM>
<ReturnValue>ERROR: DefineSequence: START value (<replaceable class="parameter">start</replaceable>) can't be > MAXVALUE (<replaceable class="parameter">maxvalue</replaceable>)</ReturnValue>
</TERM>
<LISTITEM>
<PARA>
If the specified starting value is out of range.
</PARA>
</LISTITEM>
</VARLISTENTRY>
<VARLISTENTRY>
<TERM>
<ReturnValue>ERROR: DefineSequence: START value (<replaceable class="parameter">start</replaceable>) can't be < MINVALUE (<replaceable class="parameter">minvalue</replaceable>)</ReturnValue>
</TERM>
<LISTITEM>
<PARA>
If the specified starting value is out of range.
</PARA>
</LISTITEM>
</VARLISTENTRY>
<VARLISTENTRY>
<TERM>
<ReturnValue>ERROR: DefineSequence: MINVALUE (<replaceable class="parameter">minvalue</replaceable>) can't be >= MAXVALUE (<replaceable class="parameter">maxvalue</replaceable>)</ReturnValue>
</TERM>
<LISTITEM>
<PARA>
If the minimum and maximum values are inconsistant.
</PARA>
</LISTITEM>
</VARLISTENTRY>
</variablelist>
</LISTITEM>
</VARLISTENTRY>
......@@ -196,7 +215,7 @@
<REFSECT1 ID="R1-SQL-CREATESEQUENCE-1">
<REFSECT1INFO>
<DATE>1998-04-15</DATE>
<DATE>1998-09-11</DATE>
</REFSECT1INFO>
<TITLE>
Description
......@@ -210,18 +229,20 @@
</PARA>
<para>
After the sequence is created, you may use the function
<function>nextval()</function> with the
sequence name as the argument to get a new number from the sequence.
The function <function>currval('<replaceable class="parameter">sequence_name</replaceable>')</function> may be used
<function>nextval(<replaceable class="parameter">seqname</replaceable>)</function>
to get a new number from the sequence.
The function
<function>currval('<replaceable class="parameter">seqname</replaceable>')</function>
may be used
to determine the number returned by the last call to
<function>nextval()</function> for the
specified sequence in the current session.
<function>nextval(<replaceable class="parameter">seqname</replaceable>)</function>
for the specified sequence in the current session.
</para>
<para>
Use a query like
<programlisting>
SELECT * FROM sequence_name;
SELECT * FROM sequence_name;
</programlisting>
to get the parameters of a sequence.
</para>
......@@ -232,7 +253,7 @@
<REFSECT2 ID="R2-SQL-CREATESEQUENCE-3">
<REFSECT2INFO>
<DATE>1998-04-15</DATE>
<DATE>1998-09-11</DATE>
</REFSECT2INFO>
<TITLE>
Notes
......@@ -243,7 +264,7 @@
<para>
Each backend uses its own cache to store allocated numbers.
Numbers that are cached but not used in the current session will be
lost.
lost, resulting in "holes" in the sequence.
</para>
</REFSECT2>
</refsect1>
......@@ -253,25 +274,25 @@
Usage
</TITLE>
<PARA>
Create an ascending sequence called serial, starting at 101:
Create an ascending sequence called <literal>serial</literal>, starting at 101:
</PARA>
<ProgramListing>
CREATE SEQUENCE serial START 101;
CREATE SEQUENCE serial START 101;
</ProgramListing>
<para>
Select the next number from this sequence
<programlisting>
SELECT NEXTVAL ('serial');
SELECT NEXTVAL ('serial');
nextval
-------
nextval
-------
114
</programlisting>
</para>
<para>
Use this sequence in an INSERT:
<programlisting>
INSERT INTO distributors VALUES (NEXTVAL ('serial'),'nothing');
INSERT INTO distributors VALUES (NEXTVAL('serial'),'nothing');
</programlisting>
</para>
</REFSECT1>
......@@ -281,18 +302,20 @@
Compatibility
</TITLE>
<PARA>
CREATE SEQUENCE statement is a PostgreSQL language extension.
<command>CREATE SEQUENCE</command> is a <productname>Postgres</productname>
language extension.
</PARA>
<REFSECT2 ID="R2-SQL-CREATESEQUENCE-4">
<REFSECT2INFO>
<DATE>1998-04-15</DATE>
<DATE>1998-09-11</DATE>
</REFSECT2INFO>
<TITLE>
SQL92
</TITLE>
<PARA>
There is no CREATE SEQUENCE statement on SQL92.
There is no <command>CREATE SEQUENCE</command> statement
in <acronym>SQL92</acronym>.
</PARA>
</refsect2>
</refsect1>
......
......@@ -84,8 +84,8 @@
</TERM>
<LISTITEM>
<PARA>
This message occurs if it is impossible to drop the index
because it does not exist.
This message occurs if "<REPLACEABLE CLASS="PARAMETER">index_name</REPLACEABLE>"
is not an index in the database.
</PARA>
</LISTITEM>
</VARLISTENTRY>
......@@ -121,7 +121,7 @@
</PARA>
<PARA>
Refer to the <command>CREATE INDEX</command> statement for
inforamtion on how to create indexes.
information on how to create indices.
</PARA>
</REFSECT2>
......@@ -152,7 +152,9 @@
SQL92
</TITLE>
<PARA>
There is no <command>DROP INDEX</command> statement on SQL92.
SQL92 defines commands by which to access a generic relational database.
Indices are an implementation-dependent feature and hence
there is no <command>DROP INDEX</command> statement in SQL92.
</PARA>
</refsect2>
</refsect1>
......
......@@ -172,7 +172,7 @@
SQL92
</TITLE>
<PARA>
There is no DROP PROCEDURAL LANGUAGE statement on SQL92.
There is no DROP PROCEDURAL LANGUAGE statement in SQL92.
</PARA>
</refsect2>
</refsect1>
......
......@@ -158,7 +158,7 @@
SQL92
</TITLE>
<PARA>
There is no <command>DROP USER</command> statement on SQL92.
There is no <command>DROP USER</command> statement in SQL92.
</PARA>
</refsect2>
</refsect1>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment