summaryrefslogtreecommitdiff
path: root/doc/src
diff options
context:
space:
mode:
authorNeil Conway <neilc@samurai.com>2005-06-07 07:08:35 +0000
committerNeil Conway <neilc@samurai.com>2005-06-07 07:08:35 +0000
commit657c098e41b0bb29d30d13d9aa1ac858a07f3493 (patch)
tree6d55885d0e4fd2dbeec8edde846fc33dcebdcebe /doc/src
parentc59887f91618b95f42a33d4c62dac35165a7910a (diff)
Add a function lastval(), which returns the value returned by the
last nextval() or setval() performed by the current session. Update the docs, add regression tests, and bump the catalog version. Patch from Dennis Björklund, various improvements by Neil Conway.
Diffstat (limited to 'doc/src')
-rw-r--r--doc/src/sgml/func.sgml27
1 files changed, 26 insertions, 1 deletions
diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml
index 5bd29793e81..7eb2c4c6b13 100644
--- a/doc/src/sgml/func.sgml
+++ b/doc/src/sgml/func.sgml
@@ -1,5 +1,5 @@
<!--
-$PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.251 2005/06/06 16:29:01 tgl Exp $
+$PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.252 2005/06/07 07:08:34 neilc Exp $
PostgreSQL documentation
-->
@@ -6488,6 +6488,9 @@ SELECT TIMESTAMP 'now'; -- incorrect for use with DEFAULT
<primary>currval</primary>
</indexterm>
<indexterm>
+ <primary>lastval</primary>
+ </indexterm>
+ <indexterm>
<primary>setval</primary>
</indexterm>
@@ -6519,6 +6522,12 @@ SELECT TIMESTAMP 'now'; -- incorrect for use with DEFAULT
<row>
<entry><literal><function>currval</function>(<type>text</type>)</literal></entry>
<entry><type>bigint</type></entry>
+ <entry>Return value most recently obtained with
+ <function>nextval</function> for specified sequence</entry>
+ </row>
+ <row>
+ <entry><literal><function>lastval</function>()</literal></entry>
+ <entry><type>bigint</type></entry>
<entry>Return value most recently obtained with <function>nextval</function></entry>
</row>
<row>
@@ -6588,6 +6597,22 @@ nextval('foo') <lineannotation>searches search path for <literal>fo
</varlistentry>
<varlistentry>
+ <term><function>lastval</function></term>
+ <listitem>
+ <para>
+ Return the value most recently returned by
+ <function>nextval</> in the current session. This function is
+ identical to <function>currval</function>, except that instead
+ of taking the sequence name as an argument it fetches the
+ value of the last sequence that <function>nextval</function>
+ was used on in the current session. It is an error to call
+ <function>lastval</function> if <function>nextval</function>
+ has not yet been called in the current session.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
<term><function>setval</function></term>
<listitem>
<para>