From 01db33f785f979bb017b1a15964b432033e2caac Mon Sep 17 00:00:00 2001 From: "David G. Johnston" Date: Wed, 7 Dec 2022 21:20:25 +0000 Subject: [PATCH] Improve sequence manipulation function doc --- doc/src/sgml/func.sgml | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml index 2052d3c844..26f71d864b 100644 --- a/doc/src/sgml/func.sgml +++ b/doc/src/sgml/func.sgml @@ -17614,7 +17614,7 @@ $.* ? (@ like_regex "^\\d+$") nextval - nextval ( regclass ) + nextval ( sequence_name regclass ) bigint @@ -17627,7 +17627,7 @@ $.* ? (@ like_regex "^\\d+$") values beginning with 1. Other behaviors can be obtained by using appropriate parameters in the command. - + This function requires USAGE or UPDATE privilege on the sequence. @@ -17639,7 +17639,7 @@ $.* ? (@ like_regex "^\\d+$") setval - setval ( regclass, bigint , boolean ) + setval ( sequence_name regclass, new_current_value bigint , is_called boolean ) bigint @@ -17661,11 +17661,11 @@ $.* ? (@ 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 +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. @@ -17679,7 +17679,7 @@ SELECT setval('myseq', 42, false); Next nextval currval - currval ( regclass ) + currval ( sequence_name regclass ) bigint @@ -17711,9 +17711,8 @@ 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.) This function requires USAGE @@ -17724,6 +17723,11 @@ SELECT setval('myseq', 42, false); Next nextval + + You can see sequence manipulation functions being used in the + . + + To avoid blocking concurrent transactions that obtain numbers from -- 2.25.1