1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-28 23:42:10 +03:00

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.
This commit is contained in:
Neil Conway
2005-06-07 07:08:35 +00:00
parent c59887f916
commit 657c098e41
7 changed files with 202 additions and 36 deletions

View File

@ -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
-->
@ -6487,6 +6487,9 @@ SELECT TIMESTAMP 'now'; -- incorrect for use with DEFAULT
<indexterm>
<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>
@ -6587,6 +6596,22 @@ nextval('foo') <lineannotation>searches search path for <literal>fo
</listitem>
</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>