On Thu, Nov 24, 2022 at 2:04 AM Kirk Wolak <wol...@gmail.com> wrote: > On Wed, Nov 23, 2022 at 11:06 PM Kirk Wolak <wol...@gmail.com> wrote: > >> On Tue, Nov 22, 2022 at 11:43 PM David G. Johnston < >> david.g.johns...@gmail.com> wrote: >> >>> On Tue, Nov 22, 2022 at 8:42 PM Kirk Wolak <wol...@gmail.com> wrote: >>> >>>> Here is the updated version. >>>> >>> > Regards Kirk >
Alright, as I have the documentation build working, and a slightly better stylesheet, the comments on the last block were not aligned. They are fixed now. Apologies for spamming this in... My first patch turned into 3 emails...
diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml index 82fba48d5f..e730154c0f 100644 --- a/doc/src/sgml/func.sgml +++ b/doc/src/sgml/func.sgml @@ -17625,6 +17625,12 @@ $.* ? (@ like_regex "^\\d+$") command. </para> <para> +<programlisting> +CREATE SEQUENCE myseq; +SELECT nextval('myseq'::regclass); <lineannotation>-- returns 1</lineannotation> +</programlisting> + </para> + <para> This function requires <literal>USAGE</literal> or <literal>UPDATE</literal> privilege on the sequence. </para></entry> @@ -17657,11 +17663,12 @@ $.* ? (@ like_regex "^\\d+$") Furthermore, the value reported by <function>currval</function> is not changed in this case. For example, <programlisting> -SELECT setval('myseq', 42); <lineannotation>Next <function>nextval</function> will return 43</lineannotation> -SELECT setval('myseq', 42, true); <lineannotation>Same as above</lineannotation> -SELECT setval('myseq', 42, false); <lineannotation>Next <function>nextval</function> will return 42</lineannotation> +CREATE SEQUENCE myseq; +SELECT setval('myseq', 42); <lineannotation>-- The next <function>nextval</function>('myseq') will return 43</lineannotation> +SELECT setval('myseq', 42, true); <lineannotation>-- Same as above</lineannotation> +SELECT setval('myseq', 42, false); <lineannotation>-- The next <function>nextval</function>('myseq') will return 42</lineannotation> </programlisting> - The result returned by <function>setval</function> is just the value of its + The result returned by <function>setval</function> is the value of its second argument. </para> <para> @@ -17686,6 +17693,12 @@ SELECT setval('myseq', 42, false); <lineannotation>Next <function>nextval</fu returning a session-local value, it gives a predictable answer whether or not other sessions have executed <function>nextval</function> since the current session did. +<programlisting> +CREATE SEQUENCE myseq; +<lineannotation>-- SELECT currval('myseq'::regclass); -- would throw an error here</lineannotation> +SELECT nextval('myseq'::regclass); <lineannotation>-- returns 1</lineannotation> +SELECT currval('myseq'::regclass); <lineannotation>-- returns 1</lineannotation> +</programlisting> </para> <para> This function requires <literal>USAGE</literal> @@ -17707,9 +17720,14 @@ SELECT setval('myseq', 42, false); <lineannotation>Next <function>nextval</fu identical to <function>currval</function>, except that instead of taking the sequence name as an argument it refers to whichever sequence <function>nextval</function> was most recently applied to - 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. + in the current session. (An error is reported if <function>nextval</function> has + never been called in this session.) +<programlisting> +CREATE SEQUENCE myseq; +<lineannotation>-- SELECT lastval(); -- would throw an error here</lineannotation> +SELECT nextval('myseq'::regclass); <lineannotation>-- returns 1</lineannotation> +SELECT lastval(); <lineannotation> -- returns 1</lineannotation> +</programlisting> </para> <para> This function requires <literal>USAGE</literal>