diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml
index 82fba48d5f..ee36ba8690 100644
--- a/doc/src/sgml/func.sgml
+++ b/doc/src/sgml/func.sgml
@@ -17625,6 +17625,12 @@ $.* ? (@ like_regex "^\\d+$")
command.
+
+CREATE SEQUENCE myseq;
+SELECT nextval('myseq'::regclass); -- returns 1
+
+
+
This function requires USAGE
or UPDATE privilege on the sequence.
@@ -17657,11 +17663,12 @@ $.* ? (@ like_regex "^\\d+$")
Furthermore, the value reported by currval is not
changed in this case. For example,
-SELECT setval('myseq', 42); Next nextval will return 43
-SELECT setval('myseq', 42, true); Same as above
-SELECT setval('myseq', 42, false); Next nextval will return 42
+CREATE SEQUENCE myseq;
+SELECT setval('myseq', 42); -- The next nextval('myseq') will return 43
+SELECT setval('myseq', 42, true); -- Same as above
+SELECT setval('myseq', 42, false); -- The next nextval('myseq') will return 42
- The result returned by setval is just the value of its
+ The result returned by setval is the value of its
second argument.
@@ -17686,6 +17693,12 @@ SELECT setval('myseq', 42, false); Next nextvalnextval since
the current session did.
+
+CREATE SEQUENCE myseq;
+-- SELECT currval('myseq'::regclass); -- would throw an error here
+SELECT nextval('myseq'::regclass); -- returns 1
+SELECT currval('myseq'::regclass); -- returns 1
+
This function requires USAGE
@@ -17707,9 +17720,14 @@ SELECT setval('myseq', 42, false); Next nextvalcurrval, except that instead
of taking the sequence name as an argument it refers to whichever
sequence nextval was most recently applied to
- in the current session. It is an error to call
- lastval if nextval
- has not yet been called in the current session.
+ in the current session. (An error is reported if nextval has
+ never been called in this session.)
+
+CREATE SEQUENCE myseq;
+-- SELECT lastval(); -- would throw an error here
+SELECT nextval('myseq'::regclass); -- returns 1
+SELECT lastval(); -- returns 1
+
This function requires USAGE