Skip to content
Snippets Groups Projects
Commit 0958666c authored by Thomas G. Lockhart's avatar Thomas G. Lockhart
Browse files

Minor fixes in markup.

Include cross-references in NOTIFY and UNLISTEN.
parent 5e0ea522
No related branches found
No related tags found
No related merge requests found
...@@ -234,10 +234,16 @@ CREATE SEQUENCE <replaceable class="parameter">seqname</replaceable> ...@@ -234,10 +234,16 @@ CREATE SEQUENCE <replaceable class="parameter">seqname</replaceable>
to get a new number from the sequence. to get a new number from the sequence.
The function The function
<function>currval('<replaceable class="parameter">seqname</replaceable>')</function> <function>currval('<replaceable class="parameter">seqname</replaceable>')</function>
may be used may be used to determine the number returned by the last call to
to determine the number returned by the last call to
<function>nextval(<replaceable class="parameter">seqname</replaceable>)</function> <function>nextval(<replaceable class="parameter">seqname</replaceable>)</function>
for the specified sequence in the current session. for the specified sequence in the current session.
The function
<function>setval('<replaceable class="parameter">seqname</replaceable>',
<replaceable class="parameter">newvalue</replaceable>)</function>
may be used to set the current value of the specified sequence.
The next call to
<function>nextval(<replaceable class="parameter">seqname</replaceable>)</function>
will return the given value plus the sequence increment.
</para> </para>
<para> <para>
...@@ -259,10 +265,8 @@ SELECT last_value FROM sequence_name; ...@@ -259,10 +265,8 @@ SELECT last_value FROM sequence_name;
calls to a generator. calls to a generator.
</para> </para>
<para> <caution>
<TITLE> <para>
NOTE:
</TITLE>
Unexpected results may be obtained if a cache setting greater than one 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 is used for a sequence object that will be used concurrently by multiple
backends. Each backend will allocate "cache" successive sequence values backends. Each backend will allocate "cache" successive sequence values
...@@ -273,7 +277,8 @@ SELECT last_value FROM sequence_name; ...@@ -273,7 +277,8 @@ SELECT last_value FROM sequence_name;
will be lost. Furthermore, although multiple backends are guaranteed to will be lost. Furthermore, although multiple backends are guaranteed to
allocate distinct sequence values, the values may be generated out of allocate distinct sequence values, the values may be generated out of
sequence when all the backends are considered. (For example, with a cache 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 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 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 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 to assume that nextval values are generated sequentially; with a cache
...@@ -281,7 +286,7 @@ SELECT last_value FROM sequence_name; ...@@ -281,7 +286,7 @@ SELECT last_value FROM sequence_name;
are all distinct, not that they are generated purely sequentially. are all distinct, not that they are generated purely sequentially.
Also, last_value will reflect the latest value reserved by any backend, Also, last_value will reflect the latest value reserved by any backend,
whether or not it has yet been returned by nextval. whether or not it has yet been returned by nextval.
</para> </caution>
<REFSECT2 ID="R2-SQL-CREATESEQUENCE-3"> <REFSECT2 ID="R2-SQL-CREATESEQUENCE-3">
<REFSECT2INFO> <REFSECT2INFO>
...@@ -327,6 +332,20 @@ nextval ...@@ -327,6 +332,20 @@ nextval
INSERT INTO distributors VALUES (NEXTVAL('serial'),'nothing'); INSERT INTO distributors VALUES (NEXTVAL('serial'),'nothing');
</programlisting> </programlisting>
</para> </para>
<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;
</programlisting>
</para>
</REFSECT1> </REFSECT1>
<REFSECT1 ID="R1-SQL-CREATESEQUENCE-3"> <REFSECT1 ID="R1-SQL-CREATESEQUENCE-3">
......
...@@ -117,16 +117,10 @@ requires the <REPLACEABLE CLASS="PARAMETER">column_constraint_clause</REPLACEABL ...@@ -117,16 +117,10 @@ requires the <REPLACEABLE CLASS="PARAMETER">column_constraint_clause</REPLACEABL
an insert or update operation to succeed. Each constraint an insert or update operation to succeed. Each constraint
must evaluate to a boolean expression. Multiple columns must evaluate to a boolean expression. Multiple columns
may be referenced within a single constraint. may be referenced within a single constraint.
The use of Only one PRIMARY KEY clause may be specified for a table;
<TERM>
PRIMARY KEY <REPLACEABLE>column</REPLACEABLE> PRIMARY KEY <REPLACEABLE>column</REPLACEABLE>
</TERM> (a table constraint) and PRIMARY KEY (a column constraint) are
as a table constraint mutually exclusive..
is mutually incompatible with
<TERM>
PRIMARY KEY
</TERM>
used as a column constraint.
See the table constraint clause for more information. See the table constraint clause for more information.
</PARA> </PARA>
</LISTITEM> </LISTITEM>
......
<REFENTRY ID="SQL-NOTIFY"> <REFENTRY ID="SQL-NOTIFY">
<REFMETA> <REFMETA>
<REFENTRYTITLE> <REFENTRYTITLE id="sql-notify-ref">
NOTIFY NOTIFY
</REFENTRYTITLE> </REFENTRYTITLE>
<REFMISCINFO>SQL - Language Statements</REFMISCINFO> <REFMISCINFO>SQL - Language Statements</REFMISCINFO>
......
...@@ -450,11 +450,11 @@ DEFAULT ...@@ -450,11 +450,11 @@ DEFAULT
<listitem> <listitem>
<para> <para>
Sets the maximum number of rows returned by a query to be unlimited. Sets the maximum number of rows returned by a query to be unlimited.
</varlistentry>
<para> <para>
By default, there is no limit to the number of rows By default, there is no limit to the number of rows
returned by a query. returned by a query.
</varlistentry>
</variablelist> </variablelist>
</VARLISTENTRY> </VARLISTENTRY>
......
...@@ -10,12 +10,12 @@ UNLISTEN ...@@ -10,12 +10,12 @@ UNLISTEN
UNLISTEN UNLISTEN
</REFNAME> </REFNAME>
<REFPURPOSE> <REFPURPOSE>
Stop listening for notification on a notify condition Stop listening for notification
</REFPURPOSE> </REFPURPOSE>
<REFSYNOPSISDIV> <REFSYNOPSISDIV>
<REFSYNOPSISDIVINFO> <REFSYNOPSISDIVINFO>
<DATE>1998-10-07</DATE> <DATE>1998-10-19</DATE>
</REFSYNOPSISDIVINFO> </REFSYNOPSISDIVINFO>
<SYNOPSIS> <SYNOPSIS>
UNLISTEN { <REPLACEABLE CLASS="PARAMETER">notifyname</REPLACEABLE> | * } UNLISTEN { <REPLACEABLE CLASS="PARAMETER">notifyname</REPLACEABLE> | * }
...@@ -23,7 +23,7 @@ UNLISTEN { <REPLACEABLE CLASS="PARAMETER">notifyname</REPLACEABLE> | * } ...@@ -23,7 +23,7 @@ UNLISTEN { <REPLACEABLE CLASS="PARAMETER">notifyname</REPLACEABLE> | * }
<REFSECT2 ID="R2-SQL-UNLISTEN-1"> <REFSECT2 ID="R2-SQL-UNLISTEN-1">
<REFSECT2INFO> <REFSECT2INFO>
<DATE>1998-10-07</DATE> <DATE>1998-10-19</DATE>
</REFSECT2INFO> </REFSECT2INFO>
<TITLE> <TITLE>
Inputs Inputs
...@@ -37,7 +37,7 @@ Inputs ...@@ -37,7 +37,7 @@ Inputs
</TERM> </TERM>
<LISTITEM> <LISTITEM>
<PARA> <PARA>
Name of notify condition to stop listening to. Name of previously registered notify condition.
<VARLISTENTRY> <VARLISTENTRY>
<TERM> <TERM>
...@@ -53,7 +53,7 @@ All current listen registrations for this backend are cleared. ...@@ -53,7 +53,7 @@ All current listen registrations for this backend are cleared.
<REFSECT2 ID="R2-SQL-UNLISTEN-2"> <REFSECT2 ID="R2-SQL-UNLISTEN-2">
<REFSECT2INFO> <REFSECT2INFO>
<DATE>1998-10-07</DATE> <DATE>1998-10-19</DATE>
</REFSECT2INFO> </REFSECT2INFO>
<TITLE> <TITLE>
Outputs Outputs
...@@ -87,49 +87,75 @@ Acknowledgement that statement has executed. ...@@ -87,49 +87,75 @@ Acknowledgement that statement has executed.
<REFSECT1 ID="R1-SQL-UNLISTEN-1"> <REFSECT1 ID="R1-SQL-UNLISTEN-1">
<REFSECT1INFO> <REFSECT1INFO>
<DATE>1998-10-07</DATE> <DATE>1998-10-19</DATE>
</REFSECT1INFO> </REFSECT1INFO>
<TITLE> <TITLE>
Description Description
</TITLE> </TITLE>
<PARA> <PARA>
<command>UNLISTEN</command>
is used to remove an existing <command>NOTIFY</command> registration.
UNLISTEN cancels any existing registration of the current UNLISTEN cancels any existing registration of the current
<productname>Postgres</productname> backend as a listener on the notify <productname>Postgres</productname> session as a listener on the notify
condition <REPLACEABLE CLASS="PARAMETER">notifyname</REPLACEABLE>. condition <REPLACEABLE CLASS="PARAMETER">notifyname</REPLACEABLE>.
The special condition name "*" means to cancel all listener registrations The special condition wildcard "*" cancels all listener registrations
for the current backend. for the current session.
<para> <para>
The backend does not complain if you UNLISTEN something you were not <xref linkend="sql-notify-ref" endterm="sql-notify-ref">
listening for. contains a more extensive
discussion of the use of <command>LISTEN</command> and
<command>NOTIFY</command>.
<REFSECT2 ID="R2-SQL-UNLISTEN-3">
<REFSECT2INFO>
<DATE>1998-10-19</DATE>
</REFSECT2INFO>
<TITLE>
Notes
</TITLE>
<para> <para>
<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>
The backend does not complain if you UNLISTEN something you were not
listening for.
Each backend will automatically execute <command>UNLISTEN *</command> when Each backend will automatically execute <command>UNLISTEN *</command> when
exiting. exiting.
<para> <para>
The reference page for <command>NOTIFY</command> contains a more extensive A restriction in some previous releases of
discussion of the use of <command>LISTEN</command> and <productname>Postgres</productname> that a
<command>NOTIFY</command>. <REPLACEABLE CLASS="PARAMETER">classname</REPLACEABLE>
which does not correspond to an actual table must be enclosed in double-quotes
is no longer present.
</REFSECT2>
<REFSECT1 ID="R1-SQL-UNLISTEN-2"> <REFSECT1 ID="R1-SQL-UNLISTEN-2">
<TITLE> <TITLE>
Usage Usage
</TITLE> </TITLE>
<PARA>
<ProgramListing> <para>
postgres=> listen virtual; <programlisting>
postgres=> LISTEN virtual;
LISTEN LISTEN
postgres=> notify virtual; postgres=> NOTIFY virtual;
NOTIFY NOTIFY
ASYNC NOTIFY of 'virtual' from backend pid '12317' received ASYNC NOTIFY of 'virtual' from backend pid '12317' received
postgres=> unlisten virtual; </programlisting>
<programlisting>
postgres=> UNLISTEN virtual;
UNLISTEN UNLISTEN
postgres=> notify virtual; postgres=> NOTIFY virtual;
NOTIFY NOTIFY
-- notice no NOTIFY event is received -- notice no NOTIFY event is received
postgres=> postgres=>
</ProgramListing> </programlisting>
</REFSECT1> </REFSECT1>
...@@ -141,11 +167,12 @@ Compatibility ...@@ -141,11 +167,12 @@ Compatibility
<REFSECT2 ID="R2-SQL-UNLISTEN-4"> <REFSECT2 ID="R2-SQL-UNLISTEN-4">
<REFSECT2INFO> <REFSECT2INFO>
<DATE>1998-10-07</DATE> <DATE>1998-10-19</DATE>
</REFSECT2INFO> </REFSECT2INFO>
<TITLE> <TITLE>
SQL92 SQL92
</TITLE> </TITLE>
<PARA> <PARA>
There is no <command>UNLISTEN</command> in <acronym>SQL92</acronym>. There is no <command>UNLISTEN</command> in <acronym>SQL92</acronym>.
</REFENTRY> </REFENTRY>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment