Thread: nextval parameter is not clear
The following documentation comment has been logged on the website: Page: https://www.postgresql.org/docs/14/functions-sequence.html Description: https://www.postgresql.org/docs/14/functions-sequence.html I don't see here any hints about how to use this function, and what the regclass means. How should I understand that sequence_name should be passed as string in nextval('sequence_name') ? Maybe add some links to other topics or clarify examples for nextval here. Thanks.
On Tue, Oct 18, 2022 at 08:17:12AM +0000, PG Doc comments form wrote: > The following documentation comment has been logged on the website: > > Page: https://www.postgresql.org/docs/14/functions-sequence.html > Description: > > https://www.postgresql.org/docs/14/functions-sequence.html > > I don't see here any hints about how to use this function, and what the > regclass means. > How should I understand that sequence_name should be passed as string in > nextval('sequence_name') ? > > Maybe add some links to other topics or clarify examples for nextval here. Uh, the last sentence in that section says: The sequence to be operated on by a sequence function is specified by a regclass argument, which is simply the OID of the sequence in the pg_class system catalog. You do not have to look up the OID by hand, however, since the regclass data type's input converter will do the work for you. See Section 8.19 for details. -- Bruce Momjian <bruce@momjian.us> https://momjian.us EDB https://enterprisedb.com Indecision is a decision. Inaction is an action. Mark Batterson
On Tue, Nov 22, 2022 at 2:10 PM Bruce Momjian <bruce@momjian.us> wrote:
On Tue, Oct 18, 2022 at 08:17:12AM +0000, PG Doc comments form wrote:
> The following documentation comment has been logged on the website:
>
> Page: https://www.postgresql.org/docs/14/functions-sequence.html
> Description:
>
> https://www.postgresql.org/docs/14/functions-sequence.html
>
> I don't see here any hints about how to use this function, and what the
> Maybe add some links to other topics or clarify examples for nextval here.
Uh, the last sentence in that section says:
The sequence to be operated on by a sequence function is specified by a
regclass argument, which is simply the OID of the sequence in the
pg_class system catalog. You do not have to look up the OID by hand,
however, since the regclass data type's input converter will do the work
for you. See Section 8.19 for details.
As someone who is "newer", I'd like to point out that a "clarifying example" as
simple as SELECT nextval("your_seq"::regclass);
is about 100 times more CLEAR about the essence than that paragraph.
And, yes, I read the page, and I've seen the examples just one paragraph lower.
A huge majority of us are hyper-visual, and learn by example. But that example
below does not translate to this example... Unless you already know it!
I've been frustrated many times to find the documentation, and then struggle
trying to envision how the ultimate code/syntax truly reads.
I've thought about this, and I believe having a GIGANTIC page of PG SQL code,
that could be referenced and linked, would be a WONDERFUL thing.
Then a page like this could literally have a link: "see example".
Everyone who NORMALLY reads these emails are not typically struggling
with the syntax. But the people going to documentation often are!
Regards
PS: I am willing to help create that gigantic page, if we can standardize a way to link to it.
PS: I am willing to help create that gigantic page, if we can standardize a way to link to it.
PPS: Even to the point of successive refinement. Over time, we may add "do this / not this"
On Tue, Nov 22, 2022 at 8:42 PM Kirk Wolak <wolakk@gmail.com> wrote:
On Tue, Nov 22, 2022 at 2:10 PM Bruce Momjian <bruce@momjian.us> wrote:On Tue, Oct 18, 2022 at 08:17:12AM +0000, PG Doc comments form wrote:
> The following documentation comment has been logged on the website:
>
> Page: https://www.postgresql.org/docs/14/functions-sequence.html
> Description:
>
> https://www.postgresql.org/docs/14/functions-sequence.html
>
> I don't see here any hints about how to use this function, and what the
> Maybe add some links to other topics or clarify examples for nextval here.
Uh, the last sentence in that section says:
The sequence to be operated on by a sequence function is specified by a
regclass argument, which is simply the OID of the sequence in the
pg_class system catalog. You do not have to look up the OID by hand,
however, since the regclass data type's input converter will do the work
for you. See Section 8.19 for details.As someone who is "newer", I'd like to point out that a "clarifying example" assimple as SELECT nextval("your_seq"::regclass);is about 100 times more CLEAR about the essence than that paragraph.
We've only fairly recently made incorporating useful and expansive examples into the reference part of the documentation generally doable. I agree that this particular one warrants such an example. If you are willing to do the harder work you describe below, submit a patch for this. It's specific, small, an improvement, and nothing Bruce said indicates it isn't wanted, he just focused on a different aspect of the complaint.
And, yes, I read the page, and I've seen the examples just one paragraph lower.A huge majority of us are hyper-visual, and learn by example. But that examplebelow does not translate to this example... Unless you already know it!
Sure, and the decades old documentation written for the book era, not YouTube and interactive tutorials, doesn't cater for that audience. That isn't going to change at this point, and that is a good thing. But that doesn't mean specific improvements cannot be made.
Regards
PS: I am willing to help create that gigantic page, if we can standardize a way to link to it.PPS: Even to the point of successive refinement. Over time, we may add "do this / not this"
The wiki is an excellent place to prototype and coordinate. Beyond that, this idea falls outside what should be discussed on this thread. Here, let's either patch the docs with some examples, or not.
David J.
On Tue, Nov 22, 2022 at 11:43 PM David G. Johnston <david.g.johnston@gmail.com> wrote:
On Tue, Nov 22, 2022 at 8:42 PM Kirk Wolak <wolakk@gmail.com> wrote:On Tue, Nov 22, 2022 at 2:10 PM Bruce Momjian <bruce@momjian.us> wrote:On Tue, Oct 18, 2022 at 08:17:12AM +0000, PG Doc comments form wrote:
> The following documentation comment has been logged on the website:
>
> Page: https://www.postgresql.org/docs/14/functions-sequence.html
> Description:
>
> https://www.postgresql.org/docs/14/functions-sequence.html
>
> I don't see here any hints about how to use this function, and what the
> Maybe add some links to other topics or clarify examples for nextval here.We've only fairly recently made incorporating useful and expansive examples into the reference part of the documentation generally doable. I agree that this particular one warrants such an example. If you are willing to do the harder work you describe below, submit a patch for this. It's specific, small, an improvement, and nothing Bruce said indicates it isn't wanted, he just focused on a different aspect of the complaint...The wiki is an excellent place to prototype and coordinate. Beyond that, this idea falls outside what should be discussed on this thread. Here, let's either patch the docs with some examples, or not.David J.
David, as requested. I took this page, and created examples in each row of each function.
I took a little liberty to normalize the warning about the error message between the last 2 functions (currval()/lastval()).
I also decorated the comments with -- prefix (because I HATE not being able to quickly copy code and paste and use it).
Also, I added a CREATE SEQUENCE in each block, so that the resulting code will work if you cut/paste it in.
[Who knows, eventually we could add CSS that adds the copy and maybe an Open in PGFiddle someday]
Now I edited this as pure sgml. I have no idea how to make this into html to view. Do you guys use specific tooling?
Have a look. Cut it to shreds. But I believe this is functional and informative.
Regards Kirk
Attachment
On Wed, Nov 23, 2022 at 11:06 PM Kirk Wolak <wolakk@gmail.com> wrote:
On Tue, Nov 22, 2022 at 11:43 PM David G. Johnston <david.g.johnston@gmail.com> wrote:On Tue, Nov 22, 2022 at 8:42 PM Kirk Wolak <wolakk@gmail.com> wrote:..The wiki is an excellent place to prototype and coordinate. Beyond that, this idea falls outside what should be discussed on this thread. Here, let's either patch the docs with some examples, or not.David J.David, as requested. I took this page, and created examples in each row of each function.I took a little liberty to normalize the warning about the error message between the last 2 functions (currval()/lastval()).I also decorated the comments with -- prefix (because I HATE not being able to quickly copy code and paste and use it).Also, I added a CREATE SEQUENCE in each block, so that the resulting code will work if you cut/paste it in.[Who knows, eventually we could add CSS that adds the copy and maybe an Open in PGFiddle someday]Now I edited this as pure sgml. I have no idea how to make this into html to view. Do you guys use specific tooling?Have a look. Cut it to shreds. But I believe this is functional and informative.Regards Kirk
Apologies, I am new to the tools and this approach. I just got the makefile working for the documentation.
When I got it working, I tested copying/pasting each chunk. And caught an error.
Here is the updated version.
Regards Kirk
Attachment
On Thu, Nov 24, 2022 at 2:04 AM Kirk Wolak <wolakk@gmail.com> wrote:
On Wed, Nov 23, 2022 at 11:06 PM Kirk Wolak <wolakk@gmail.com> wrote:On Tue, Nov 22, 2022 at 11:43 PM David G. Johnston <david.g.johnston@gmail.com> wrote:On Tue, Nov 22, 2022 at 8:42 PM Kirk Wolak <wolakk@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...
Attachment
On Thu, 2022-11-24 at 02:41 -0500, Kirk Wolak wrote: > 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... That is no problem. I think the patch is fine. I like the addition of the "--" comments. The one think that should be unified is that you include an explicit cast to "regclass" everywhere, but the pre-existing example does not. I would omit that cast. It might confuse beginners (who are probably satisfied to know that you have to use the sequence name as a string), and it is explained in the last paragraph of the page anyway. Yours, Laurenz Albe
On Thu, Nov 24, 2022 at 5:33 AM Laurenz Albe <laurenz.albe@cybertec.at> wrote:
On Thu, 2022-11-24 at 02:41 -0500, Kirk Wolak wrote:
> 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...
That is no problem.
I think the patch is fine. I like the addition of the "--" comments.
The one think that should be unified is that you include an explicit
cast to "regclass" everywhere, but the pre-existing example does not.
I would omit that cast. It might confuse beginners (who are probably
satisfied to know that you have to use the sequence name as a string),
and it is explained in the last paragraph of the page anyway.
Yours,
Laurenz Albe
Laurenz,
First, thanks for the support..
It's funny you mention that (with and without ::regclass). I went both ways on it.
The reason I did not address it, was that I liked the variety because it sticks out.
I thought about adding a comment like
-- while you can omit the ::regclass casting, it is preferred
The fact that it is different engages the brain of the reader whose pattern matching
just got challenged. It almost begs them to test it out.
I think it might deserve a comment, but I would really prefer to keep it in there.
Regards Kirk
On Thu, Nov 24, 2022 at 7:33 AM Kirk Wolak <wolakk@gmail.com> wrote:
On Thu, Nov 24, 2022 at 5:33 AM Laurenz Albe <laurenz.albe@cybertec.at> wrote:On Thu, 2022-11-24 at 02:41 -0500, Kirk Wolak wrote:
> 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...
That is no problem.
I think the patch is fine. I like the addition of the "--" comments.
The one think that should be unified is that you include an explicit
cast to "regclass" everywhere, but the pre-existing example does not.
I would omit that cast. It might confuse beginners (who are probably
satisfied to know that you have to use the sequence name as a string),
and it is explained in the last paragraph of the page anyway.
Yours,
Laurenz AlbeLaurenz,First, thanks for the support..It's funny you mention that (with and without ::regclass). I went both ways on it.The reason I did not address it, was that I liked the variety because it sticks out.I thought about adding a comment like-- while you can omit the ::regclass casting, it is preferredThe fact that it is different engages the brain of the reader whose pattern matchingjust got challenged. It almost begs them to test it out.I think it might deserve a comment, but I would really prefer to keep it in there.
I dislike having CREATE SEQUENCE in the table examples. Keep those focused on only the syntax of the call expression. That requires removing the nextval calls too and not showing the error path. I'd be fine with not showing examples of code that would produce an error. (if we are going to show the error path I'd suggest we show the actual error message produced)
At the bottom of the page I would add an extended example of how these sequences can be used in practice.
CREATE TABLE seq_example ( id bigint PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY ) -- implicit sequence named seq_example_seq is created (or whatever is generated...)
INSERT INTO seq_example RETURNING id; -- 1
SELECT currval('seq_example_seq'::regclass); -- 1
SELECT setval('seq_example_seq', 10);
INSERT INTO seq_example (id)
VALUES (nextval('seq_example_seq')) -- works as-is due to choosing BY DEFAULT for the identity
RETURNING id; -- 11
SELECT lastval(); -- 11
I would remove the casting of the sequence name from the table examples and just keep one in the main usage example. I agree that having both to make the reader stop and think is a good idea.
David J.
On Thu, Nov 24, 2022 at 10:44 AM David G. Johnston <david.g.johnston@gmail.com> wrote:
On Thu, Nov 24, 2022 at 7:33 AM Kirk Wolak <wolakk@gmail.com> wrote:On Thu, Nov 24, 2022 at 5:33 AM Laurenz Albe <laurenz.albe@cybertec.at> wrote:On Thu, 2022-11-24 at 02:41 -0500, Kirk Wolak wrote:
> 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.
>...I dislike having CREATE SEQUENCE in the table examples. Keep those focused on only the syntax of the call expression. That requires removing the nextval calls too and not showing the error path. I'd be fine with not showing examples of code that would produce an error. (if we are going to show the error path I'd suggest we show the actual error message produced)
David, let me see how that looks. From an approach standpoint, I am hearing:
1) Keep the example near the definition minimal [just this function]
2) It's okay to create an extra "row" [each function is in a <row>], right after the last function, with a detailed example, like you put below!
3) It's okay in the example area to introduce a few ideas [I really like this: RETURNING, etc]
What I LIKE about this... It reminds me of the PHP manual online, where they have TONS of user posted examples (ours will be more moderated, but this opens us up to better and better and even alternative examples).
Let me play with this. I think I want to try a progression of the examples.
I used role="example_code", for the paragraph style, and I think it looks better de-dented to the same level as the functions.
But I have NO IDEA where that css detail would be stored for make..
#docContent table.table p.func_signature, p.example_code {}
At the bottom of the page I would add an extended example of how these sequences can be used in practice.CREATE TABLE seq_example ( id bigint PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY ) -- implicit sequence named seq_example_seq is created (or whatever is generated...)INSERT INTO seq_example RETURNING id; -- 1SELECT currval('seq_example_seq'::regclass); -- 1SELECT setval('seq_example_seq', 10);INSERT INTO seq_example (id)VALUES (nextval('seq_example_seq')) -- works as-is due to choosing BY DEFAULT for the identityRETURNING id; -- 11SELECT lastval(); -- 11I would remove the casting of the sequence name from the table examples and just keep one in the main usage example. I agree that having both to make the reader stop and think is a good idea.David J.
I also tested, and cleaned up the results from your example. Sorry it took me so long, I am very new. Laurenz helped me out with:
make STYLE=website
Let me know what you think now...
(and I removed all but the single embedded SQL. Even when it is trivial, I would prefer to put one in there.)
Here is a screen shot: (is it preferred to use a link to screencast?) https://app.screencast.com/hDW9ma2aPsdQy
Attachment
On Thu, 2022-11-24 at 15:50 -0500, Kirk Wolak wrote: > > David, let me see how that looks. From an approach standpoint, I am hearing: > 1) Keep the example near the definition minimal [just this function] > 2) It's okay to create an extra "row" [each function is in a <row>], right after the last function, with a detailed example,like you put below! The detailed example should not be another row in the table. The table is only for the description of individual functions. The functions "nextval", "setval", "currval" and "lastval" each have their own row. I think the elaborate example should be at the bottom of the page, similar to the "Examples" section in the reference pages. See for example https://www.postgresql.org/docs/current/sql-createstatistics.html > David G. Johnston <david.g.johnston@gmail.com> wrote: > > At the bottom of the page I would add an extended example of how these > > sequences can be used in practice. > > > > CREATE TABLE seq_example ( id bigint PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY ) -- implicit sequence named seq_example_seqis created (or whatever is generated...) > > INSERT INTO seq_example RETURNING id; -- 1 > > SELECT currval('seq_example_seq'::regclass); -- 1 I don't think that is a good example to explain sequences to a beginner. The sequence behind an identity column is an implementation detail, and I wouldn't burden the reader with all that. I think it would be better to create the sequence explicitly and use it in the DEFAULT clause of a column definition. > > I would remove the casting of the sequence name from the table examples and just keep one > > in the main usage example. I agree that having both to make the reader stop and think is a good idea. I think that is a good idea, and you should go with that. Yours, Laurenz Albe
On Fri, Nov 25, 2022 at 12:40 AM Laurenz Albe <laurenz.albe@cybertec.at> wrote:
On Thu, 2022-11-24 at 15:50 -0500, Kirk Wolak wrote:
>
> David, let me see how that looks. From an approach standpoint, I am hearing:
> 1) Keep the example near the definition minimal [just this function]
> 2) It's okay to create an extra "row" [each function is in a <row>], right after the last function, with a detailed example, like you put below!
The detailed example should not be another row in the table. The table is only for
the description of individual functions. The functions "nextval", "setval", "currval"
and "lastval" each have their own row.
I think the elaborate example should be at the bottom of the page, similar to
the "Examples" section in the reference pages. See for example
https://www.postgresql.org/docs/current/sql-createstatistics.html
+1
> >
> > CREATE TABLE seq_example ( id bigint PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY ) -- implicit sequence named seq_example_seq is created (or whatever is generated...)
> > INSERT INTO seq_example RETURNING id; -- 1
> > SELECT currval('seq_example_seq'::regclass); -- 1
I don't think that is a good example to explain sequences to a beginner.
The sequence behind an identity column is an implementation detail, and
I wouldn't burden the reader with all that.
If you are using these functions it is most commonly in a situation where serial/identity is involved. I don't see much benefit to having the example be sanitized to the point of not reflecting realistic usage.
I think it would be better to create the sequence explicitly and use
it in the DEFAULT clause of a column definition.
I wasn't too happy with that comment when I wrote it either.
I would probably do without the DEFAULT if going the explicit route (but it isn't a deal breaker).
However, I remembered that we have:
pg_get_serial_sequence ( table text, column text ) → text
I'd be inclined to stay with the GENERATED example but incorporate that function call into the other examples.
Regardless of the above choice for the example, it seems appropriate for this page, somewhere, to mention this function and link to its page.
I'd even argue for moving that function definition here.
David J.
On Fri, Nov 25, 2022 at 9:58 AM David G. Johnston <david.g.johnston@gmail.com> wrote:
On Fri, Nov 25, 2022 at 12:40 AM Laurenz Albe <laurenz.albe@cybertec.at> wrote:On Thu, 2022-11-24 at 15:50 -0500, Kirk Wolak wrote:
>
> David, let me see how that looks. From an approach standpoint, I am hearing:
> 1) Keep the example near the definition minimal [just this function]
> 2) It's okay to create an extra "row" [each function is in a <row>], right after the last function, with a detailed example, like you put below!
The detailed example should not be another row in the table. The table is only for
the description of individual functions. The functions "nextval", "setval", "currval"
and "lastval" each have their own row.
I think the elaborate example should be at the bottom of the page, similar to
the "Examples" section in the reference pages. See for example
https://www.postgresql.org/docs/current/sql-createstatistics.html+1
> >
> > CREATE TABLE seq_example ( id bigint PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY ) -- implicit sequence named seq_example_seq is created (or whatever is generated...)
> > INSERT INTO seq_example RETURNING id; -- 1
> > SELECT currval('seq_example_seq'::regclass); -- 1
I don't think that is a good example to explain sequences to a beginner.
The sequence behind an identity column is an implementation detail, and
I wouldn't burden the reader with all that.If you are using these functions it is most commonly in a situation where serial/identity is involved. I don't see much benefit to having the example be sanitized to the point of not reflecting realistic usage.
I think it would be better to create the sequence explicitly and use
it in the DEFAULT clause of a column definition.I wasn't too happy with that comment when I wrote it either.I would probably do without the DEFAULT if going the explicit route (but it isn't a deal breaker).
However, I remembered that we have:pg_get_serial_sequence ( table text, column text ) → textI'd be inclined to stay with the GENERATED example but incorporate that function call into the other examples.Regardless of the above choice for the example, it seems appropriate for this page, somewhere, to mention this function and link to its page.I'd even argue for moving that function definition here.David J.
David,
Wow, it's hard to clip this email and keep the flow. Apologies.
I love the feedback. I will pull that function (pg_get_serial_sequence) in here (do I leave it where it is? (probably not))???
And make the other changes. Since I have a "whole" area to put the sample in, and I did not like the flow of the sample that much.
(I was focused on the make/patch process so I can become useful)... Let me now craft it up a bit and apply all of this good feedback.
Let me create a better flow... True beginner (CREATE SEQUENCE ...), then More advanced, like your example, then using this last function,
which qualifies as advanced... relative to someone looking at "nextval", et al.
Thanks!
On Fri, Nov 25, 2022 at 9:58 AM David G. Johnston <david.g.johnston@gmail.com> wrote:
On Fri, Nov 25, 2022 at 12:40 AM Laurenz Albe <laurenz.albe@cybertec.at> wrote:On Thu, 2022-11-24 at 15:50 -0500, Kirk Wolak wrote:
>
> David, let me see how that looks. From an approach standpoint, I am hearing:I think it would be better to create the sequence explicitly and use
it in the DEFAULT clause of a column definition.I wasn't too happy with that comment when I wrote it either.I would probably do without the DEFAULT if going the explicit route (but it isn't a deal breaker).However, I remembered that we have:pg_get_serial_sequence ( table text, column text ) → textI'd be inclined to stay with the GENERATED example but incorporate that function call into the other examples.Regardless of the above choice for the example, it seems appropriate for this page, somewhere, to mention this function and link to its page.I'd even argue for moving that function definition here.David J.
Okay, I've really reworked the example, and it all tests out.
I took the advice of Laurenz about the separate section outside the table.
I did not move the function, it seemed alphabetical where it was (easy enough to move), but I did use that function twice!
Break out the RED ink and let me know what you think!
Kirk
Attachment
On Fri, Nov 25, 2022 at 10:06 PM Kirk Wolak <wolakk@gmail.com> wrote:
On Fri, Nov 25, 2022 at 9:58 AM David G. Johnston <david.g.johnston@gmail.com> wrote:On Fri, Nov 25, 2022 at 12:40 AM Laurenz Albe <laurenz.albe@cybertec.at> wrote:On Thu, 2022-11-24 at 15:50 -0500, Kirk Wolak wrote:
..
Regardless of the above choice for the example, it seems appropriate for this page, somewhere, to mention this function and link to its page.I'd even argue for moving that function definition here.David J.
Okay, I've really reworked the example, and it all tests out.I took the advice of Laurenz about the separate section outside the table.I did not move the function, it seemed alphabetical where it was (easy enough to move), but I did use that function twice!Break out the RED ink and let me know what you think!Kirk
Okay, forgive me again. I've figured out how to rebase against the latest master. There are no changes from the previous post.
But the diff file contains updated references (I have no idea if this helps, but I was unable to "view" someone elses file with diffs without that).
Laurenz,
Your feedback would be appreciated. If we keep the "play" schema, I think a comment at the end of the section reminding them to DROP that schema would be nice.
Kirk
Attachment
On Sat, 2022-11-26 at 23:22 -0500, Kirk Wolak wrote: > Your feedback would be appreciated. > --- a/doc/src/sgml/func.sgml > +++ b/doc/src/sgml/func.sgml > @@ -17625,6 +17625,11 @@ $.* ? (@ like_regex "^\\d+$") > command. > </para> > <para> > +<programlisting> > +SELECT nextval('myseq'::regclass); > +</programlisting> > + </para> > + <para> The indentation of the <para> tags should be the same everywhere. True, the misalignment was pre-existing here, but it would be better to fix it than to repeat the mistake. I think the cast to "regclass" should be only in the more elaborate example at the end > @@ -17669,7 +17674,6 @@ SELECT setval('myseq', 42, false); <lineannotation>Next <function>nextval</fu > sequence. > </para></entry> > </row> > - > <row> > <entry role="func_table_entry"><para role="func_signature"> > <indexterm> I think the empty line is intentional and should stay. We have it everywhere else, and it helps to read the source. > @@ -17707,19 +17714,75 @@ 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> > +SELECT lastval(); > +</programlisting> I have no problem with changing the sentence to a parenthetical remark, although I thing the original wording was fine. However, there is a trailing blank at the end of the line (and in the <programlisting> line as well). Please avoid these. "git diff" highlights such training blanks. I would not add a code sample in this case. The function has no arguments, so what cat we really learn from that? We don't have to have a code sample here just because we had one with all the other functions. > </para> > <para> > This function requires <literal>USAGE</literal> > or <literal>SELECT</literal> privilege on the last used sequence. > </para></entry> > </row> > + <row> > + <entry role="func_table_entry"> > + </entry> > + </row> > </tbody> > </tgroup> > </table> This empty row should definitely go. > + <para>Example I think you should use the <title> tag to render that more conspicuous. > +<programlisting> > +CREATE SCHEMA play; <lineannotation>-- Create a play schema</lineannotation> > [...] Now I think that is taking it too far. Your code sample would be great for a tutorial, but it is too elaborate for the technical documentation. The example should focus on the sequence functions, but more than half of the code describes other parts of PostgreSQL: - schema and search_path - psql commands - INSERT ... RETURNING - pg_get_serial_sequence() I am not saying that this is bad material, but if anything, it should go to chapter 3 (Advanced Features) of the tutorial (and then it could be even more elaborate). I am alright with having a CREATE TABLE with a DEFAULT and an INSERT or two; whatever it takes to show the functions in a realistic scenario. For example, you could INSERT a row that overrides the DEFAULT, then call "setval()" to readjust the sequence. Yours, Laurenz Albe
Laurenz Albe <laurenz.albe@cybertec.at> writes: > Now I think that is taking it too far. Your code sample would be great > for a tutorial, but it is too elaborate for the technical documentation. > The example should focus on the sequence functions, but more than half > of the code describes other parts of PostgreSQL: Yeah, that stuff seems quite out of place here. > I am alright with having a CREATE TABLE with a DEFAULT and an INSERT or two; > whatever it takes to show the functions in a realistic scenario. > For example, you could INSERT a row that overrides the DEFAULT, then call > "setval()" to readjust the sequence. I don't believe we have such detail around very many, if indeed any, of our other functions' documentation. regards, tom lane
On Mon, Nov 28, 2022 at 12:45 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
Laurenz Albe <laurenz.albe@cybertec.at> writes:
> Now I think that is taking it too far. Your code sample would be great
> for a tutorial, but it is too elaborate for the technical documentation.
> The example should focus on the sequence functions, but more than half
> of the code describes other parts of PostgreSQL:
Yeah, that stuff seems quite out of place here.
> I am alright with having a CREATE TABLE with a DEFAULT and an INSERT or two;
> whatever it takes to show the functions in a realistic scenario.
> For example, you could INSERT a row that overrides the DEFAULT, then call
> "setval()" to readjust the sequence.
I don't believe we have such detail around very many, if indeed any,
of our other functions' documentation.
regards, tom lane
my goal is to get an "approach" accepted, this is the first. Ultimately, I would love to see
the documentation of functions with examples like this everywhere. Preferably where someone
can copy/paste the example and see the results. And I fully intend to create them all myself,
if that's what it takes. But I would prefer the hard work now, and then I can stream-line the process.
The driver was my own frustration when I first started learning PG and the lack of concrete examples.
How are these things used, in context? [I learn through reading code]
On Sun, Nov 27, 2022 at 10:34 PM Laurenz Albe <laurenz.albe@cybertec.at> wrote:
On Sat, 2022-11-26 at 23:22 -0500, Kirk Wolak wrote:
> Your feedback would be appreciated.
> + <para>Example
I think you should use the <title> tag to render that more conspicuous.
I tried. it does not MAKE. It is not allowed in that position. I don't know how to allow it there!
Help would be appreciated.
I am not saying that this is bad material, but if anything, it should go to
chapter 3 (Advanced Features) of the tutorial (and then it could be even more
elaborate).
Let me review that section. If we have a place where we can have examples of ALL functions in actual usage
That would be great.
Yours,
Laurenz Albe
I will make the next version based on ALL of your comments. As well as reviewing chapter 3, and feedback on the <title>Example</title>
tag working there...
Kirk Wolak <wolakk@gmail.com> writes: > my goal is to get an "approach" accepted, this is the first. Ultimately, I > would love to see > the documentation of functions with examples like this everywhere. I'm not for that. func.sgml is already massive, and doubling its size with extensive examples doesn't seem like an improvement. Admittedly, we probably don't need long examples for many of the functions, so maybe we wouldn't end up with quite that much bloat; but it still seems like the wrong approach. In my view, that chapter is more in the nature of reference material, so extended examples ought to go somewhere else. I could see adding a section about sequences and identity columns to chapter 3 in the tutorial. > Preferably where someone > can copy/paste the example and see the results. As far as that goes, there's already an idea that src/tutorial/ should contain SQL scripts that you can step-execute to follow along with the tutorial docs. This hasn't been followed through on very well --- chapter 2 is covered, but chapter 3 mostly not. No time like the present to make it better, though. If your ambition is to make self-contained working examples, making sure that they execute as a script is good discipline. regards, tom lane
On Mon, Nov 28, 2022 at 12:47 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
Kirk Wolak <wolakk@gmail.com> writes:
> my goal is to get an "approach" accepted, this is the first. Ultimately, I
> would love to see
> the documentation of functions with examples like this everywhere.
I'm not for that. func.sgml is already massive, and doubling its size
...
reference material, so extended examples ought to go somewhere else.
I could see adding a section about sequences and identity columns to
chapter 3 in the tutorial.
> Preferably where someone
> can copy/paste the example and see the results.
As far as that goes, there's already an idea that src/tutorial/
should contain SQL scripts that you can step-execute to follow
along with the tutorial docs. This hasn't been followed through
on very well --- chapter 2 is covered, but chapter 3 mostly not.
No time like the present to make it better, though. If your
ambition is to make self-contained working examples, making sure
that they execute as a script is good discipline.
regards, tom lane
Two questions follow from the above:
1) For the novice who finds this page (funcs), how will they know to find the tutorial?
2) Should each function link to that? or One link per page? [to the appropriate example section]
I will gladly move my focus to adding to the tutorials... (but I want to know how even I would know it was available if I hit here first)
And I still believe that each function in the documentation section should have at least a one-line example usage???
After a quick review of the tutorial section, if you end up on any random page in the tutorial,
the example code does not stand alone.
[I think this was your point]. I see 2 approaches:
A) Simply expand the current examples so that they include the code to make them stand alone
or
B) Maybe if we had the ENTIRE Tutorial code in one place, runnable (copy/paste).
Then the more detailed explanations that explain what the statements do, like we have now.
We would get the best of both worlds?
Thanks, Kirk
On Mon, Nov 28, 2022 at 12:22 PM Kirk Wolak <wolakk@gmail.com> wrote:
On Mon, Nov 28, 2022 at 12:47 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:Kirk Wolak <wolakk@gmail.com> writes:
> my goal is to get an "approach" accepted, this is the first. Ultimately, I
> would love to see
> the documentation of functions with examples like this everywhere.
I'm not for that. func.sgml is already massive, and doubling its size...
reference material, so extended examples ought to go somewhere else.
I could see adding a section about sequences and identity columns to
chapter 3 in the tutorial.
> Preferably where someone
> can copy/paste the example and see the results.
As far as that goes, there's already an idea that src/tutorial/
should contain SQL scripts that you can step-execute to follow
along with the tutorial docs. This hasn't been followed through
on very well --- chapter 2 is covered, but chapter 3 mostly not.
No time like the present to make it better, though. If your
ambition is to make self-contained working examples, making sure
that they execute as a script is good discipline.
regards, tom laneTwo questions follow from the above:1) For the novice who finds this page (funcs), how will they know to find the tutorial?2) Should each function link to that? or One link per page? [to the appropriate example section]
You would add a sentence, as appropriate to the page, pointing the reader to the tutorial section for further examples. There isn't really a rule-of-thumb here; use existing examples and context to figure out what makes the most sense.
I will gladly move my focus to adding to the tutorials... (but I want to know how even I would know it was available if I hit here first)
And I still believe that each function in the documentation section should have at least a one-line example usage???
There already is guaranteed one example - it is the function signature that begins each row.
On a related point, the word SELECT in table examples is unwanted noise (this page is not the best example to emulate). The example call expressions the supplement the function signature also need not be executable.
The string functions demonstrate good usage examples for the tables.
After a quick review of the tutorial section, if you end up on any random page in the tutorial,the example code does not stand alone.
If you'd like to start a discussion on this I suggest a new email thread, leaving this one to finishing the patch within the reality of the documentation as it exists today. That is to say, making decisions based upon existing prior work and sound arguments about the merits of the content presentation. This isn't the place to experiment and propose an example of some new grand design.
David J.
Hello. I would like to get some opinion on a petite idea I got while reading the "nextval parameter is not clear" thread. Because it may not fit well to the thread itself I managed to create a new one instead... I started to love the way "rustaceans" do their documentation - they produce books with runable examples! Perhaps it would be nice to adopt their approach for new and shiny tutorial book and place (runable?) examples there. The official documentation could refer to proper tutorial sections and vice versa. Also, the tutorial can be more or less structured the same as it is the official documentation (the two documents can be more or less aligned, at least "vaguely"). The very best example of the approach of a book with runable examples is the "The Rust Programming Language" [1][2] aka "The Book". Who has not known about it, please give it few minutes to see how it works and what a great experience it is to read it. :-) I am not sure how hard it would be to fork the mdBook project [3] and add Postgres psql(1), SQL and perhaps PL/PgSQL syntax highlighting with all the nifty features such as the "snippets" etc. (some code is intentionaly hidden while the reader is beying forced to concentrate at just part of it, but still allowed to show the hidden code if she is in need of it). As I understand the mdBook project is general framework to generate such documentations and therefor I suppose it is extensible in some rather sane way. I am also not aware if DB Fiddle or another service allows to run examples covered in such tutorial book via some API or not. If not, the results could still be "pregenerated" and hardcoded at compile time. Maybe, in this case, it would be even better. There are good ways and bad ways how to do things and the learning curve is not always steep enough. As a novice DBA you sometimes follow the wrong path for quite a long time! Good tutorial (expecially with runable examples) will be definitely worth the effort. It should also include good amount of all sorts of errors and warnings that are also very hard to comprehend! It should provide all sorts of "NoGo" things and approaches explained in depth and followed by a couple of "Go" ones. References: [1] https://doc.rust-lang.org/book/ [2] https://github.com/rust-lang/book (source code of "the book") [3] https://rust-lang.github.io/mdBook/format/mdbook.html Best regards, -- Matous Jan Fialka
On Mon, Nov 28, 2022 at 12:45 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
Laurenz Albe <laurenz.albe@cybertec.at> writes:
> Now I think that is taking it too far. Your code sample would be great
> for a tutorial, but it is too elaborate for the technical documentation.
> The example should focus on the sequence functions, but more than half
> of the code describes other parts of PostgreSQL:
Yeah, that stuff seems quite out of place here.
> I am alright with having a CREATE TABLE with a DEFAULT and an INSERT or two;
> whatever it takes to show the functions in a realistic scenario.
> For example, you could INSERT a row that overrides the DEFAULT, then call
> "setval()" to readjust the sequence.
I don't believe we have such detail around very many, if indeed any,
of our other functions' documentation.
regards, tom lane
All changes specified have been addressed.
The Example is significantly reduced, but readable.
The extra "SELECT "'s have been removed off of the inline examples, excluding the existing paragraph.
This is the smallest possible change, that still has an example.
The "Example" is not <title> as every attempt to make it such fails the LINT process.
regards, Kirk
Attachment
On Tue, Nov 29, 2022 at 3:40 AM Matous Jan Fialka <mjf@mjf.cz> wrote:
Hello.
I would like to get some opinion on a petite idea I got while reading
the "nextval
parameter is not clear" thread. Because it may not fit well to the
thread itself
I managed to create a new one instead...
+1 (right approach, I was clearly wrong, learning...)
...
The very best example of the approach of a book with runable examples
is the
"The Rust Programming Language" [1][2] aka "The Book". Who has not
known about it,
please give it few minutes to see how it works and what a great
experience it is
to read it. :-)
I actually recorded this interaction. I think this is cool.
And as I think about WHERE this goes, I DEFINITELY believe it goes
in the tutorial world. I love the "peek" and the "play" icons, on mouse over.
And scroll to the bottom of that page.
...
I am also not aware if DB Fiddle or another service allows to run
examples covered
in such tutorial book via some API or not. If not, the results could
still be
"pregenerated" and hardcoded at compile time. Maybe, in this case, it
would be even
better.
If in the tutorial we used this "hiding" technique to explain the code,
but expanded it so it was runnable, that would be awesome.
I like the idea of it being able to go directly to: https://www.db-fiddle.com/
to either a specific preloaded example, or better, pass in our code...
Especially if we could do it using one CSS/Javascript wrapper!
References:
[1] https://doc.rust-lang.org/book/
[2] https://github.com/rust-lang/book (source code of "the book")
[3] https://rust-lang.github.io/mdBook/format/mdbook.html
--
Matous Jan Fialka
Thanks... Let's hope the discussion gets some traction...
On Tue, Nov 29, 2022 at 2:42 PM Kirk Wolak <wolakk@gmail.com> wrote:
On Tue, Nov 29, 2022 at 3:40 AM Matous Jan Fialka <mjf@mjf.cz> wrote:Hello.
I would like to get some opinion on a petite idea I got while reading
the "nextval
parameter is not clear" thread. Because it may not fit well to the
thread itself
I managed to create a new one instead...+1 (right approach, I was clearly wrong, learning...)...
The very best example of the approach of a book with runable examples
is the
"The Rust Programming Language" [1][2] aka "The Book". Who has not
known about it,
please give it few minutes to see how it works and what a great
experience it is
to read it. :-)I actually recorded this interaction. I think this is cool.And as I think about WHERE this goes, I DEFINITELY believe it goesin the tutorial world. I love the "peek" and the "play" icons, on mouse over.
Haven't dived into these things yet - but I had the thought that maybe the tutorial section of our documentation is not a good place for this. Nor, frankly, do I think sgml be a great technology from which to try and leverage this. Hosting a second "site", and git repository, geared toward this kind of effort, seems like a reasonable thing to do. It doesn't need, nor want, the same versioning and releases cadence policies as the documentation.
I think the main question is, if that were the intended route, how much material would we consider a minimum viable release (done elsewhere probably) to go to the effort to get the infrastructure in place to host long term - i.e., after the initial novelty wears off and committers have to take on ownership? Specifically, require that at minimum the tutorial section of the documentation be removed from the documentation and instead the same material, ideally improved, placed in this new location with the new design goals and requirements published.
We'd get rid of any output formats except HTML (no PDF or man pages). Cross-references would still be desirable and so a plan for those (done as part of the tutorial migration) would be required. There wouldn't be any "older version support" either IMO, just one main release branch.
IOW, I have my doubts regarding the success of a project to retrofit the tutorial to this extent. I don't think teaching the old dog these new tricks is going to go well.
I do like the idea of having a place where people who want to produce this kind of stuff, but not write an entire book or tutorial, or try and market their own blog, can find a home to publish.
I'm not too keen on worrying about "auto-execute" - if anything, convincing the reader to physically type any example code into a fiddle, or their own installation, is a better idea - even to the extent of removing copy-paste...
Any automation or tests that would help ensure the published material is valid should be done during "build" using psql.
David J.
On Tue, Nov 29, 2022 at 5:16 PM David G. Johnston <david.g.johnston@gmail.com> wrote:
On Tue, Nov 29, 2022 at 2:42 PM Kirk Wolak <wolakk@gmail.com> wrote:On Tue, Nov 29, 2022 at 3:40 AM Matous Jan Fialka <mjf@mjf.cz> wrote:Hello.
I would like to get some opinion on a petite idea I got while reading
the "nextval
parameter is not clear" thread. Because it may not fit well to the
thread itself
I managed to create a new one instead...+1 (right approach, I was clearly wrong, learning...)...
The very best example of the approach of a book with runable examples
is the
"The Rust Programming Language" [1][2] aka "The Book". Who has not
known about it,
please give it few minutes to see how it works and what a great
experience it is
to read it. :-)I actually recorded this interaction. I think this is cool.And as I think about WHERE this goes, I DEFINITELY believe it goesin the tutorial world. I love the "peek" and the "play" icons, on mouse over.Haven't dived into these things yet - but I had the thought that maybe the tutorial section of our documentation is not a good place for this. Nor, frankly, do I think sgml be a great technology from which to try and leverage this. Hosting a second "site", and git repository, geared toward this kind of effort, seems like a reasonable thing to do. It doesn't need, nor want, the same versioning and releases cadence policies as the documentation.I think the main question is, if that were the intended route, how much material would we consider a minimum viable release (done elsewhere probably) to go to the effort to get the infrastructure in place to host long term - i.e., after the initial novelty wears off and committers have to take on ownership? Specifically, require that at minimum the tutorial section of the documentation be removed from the documentation and instead the same material, ideally improved, placed in this new location with the new design goals and requirements published.We'd get rid of any output formats except HTML (no PDF or man pages). Cross-references would still be desirable and so a plan for those (done as part of the tutorial migration) would be required. There wouldn't be any "older version support" either IMO, just one main release branch.IOW, I have my doubts regarding the success of a project to retrofit the tutorial to this extent. I don't think teaching the old dog these new tricks is going to go well.I do like the idea of having a place where people who want to produce this kind of stuff, but not write an entire book or tutorial, or try and market their own blog, can find a home to publish.I'm not too keen on worrying about "auto-execute" - if anything, convincing the reader to physically type any example code into a fiddle, or their own installation, is a better idea - even to the extent of removing copy-paste...Any automation or tests that would help ensure the published material is valid should be done during "build" using psql.David J.
David, I don't disagree. This process has been an education process for me.
I actually like the idea of a github account for a postgresql tutorial. It could come out of here, and we could potentially have those that are interested chime in. (Although I would like to occasionally email into this group to ask them to peek and give feedback, looking for that point where we can say it is ready for V1.00 (and PG may refer to it as a replacement for the tutorial they have).
I can think of a few people that might lend a hand (that may have warned me not to get my hopes up here... LOL)
And yes, then that site doesn't need to be a PDF... And starting with the existing Tutorial stuff, and then maybe
a simple cross reference (coverage) of the various functions, etc.
a simple cross reference (coverage) of the various functions, etc.
Maybe Matous [OP] will contact me externally...
regards, Kirk
On Tue, 2022-11-29 at 16:26 -0500, Kirk Wolak wrote: > On Mon, Nov 28, 2022 at 12:45 AM Tom Lane <tgl@sss.pgh.pa.us> wrote: > > Laurenz Albe <laurenz.albe@cybertec.at> writes: > > > Now I think that is taking it too far. Your code sample would be great > > > for a tutorial, but it is too elaborate for the technical documentation. > > > The example should focus on the sequence functions, but more than half > > > of the code describes other parts of PostgreSQL: > > > > Yeah, that stuff seems quite out of place here. > > > > > I am alright with having a CREATE TABLE with a DEFAULT and an INSERT or two; > > > whatever it takes to show the functions in a realistic scenario. > > > For example, you could INSERT a row that overrides the DEFAULT, then call > > > "setval()" to readjust the sequence. > > > > I don't believe we have such detail around very many, if indeed any, > > of our other functions' documentation. > > > > regards, tom lane > > > All changes specified have been addressed. > The Example is significantly reduced, but readable. > The extra "SELECT "'s have been removed off of the inline examples, excluding the existing paragraph. > > This is the smallest possible change, that still has an example. > > The "Example" is not <title> as every attempt to make it such fails the LINT process. You can have <title> only after the start of a section. The new examples in the table don't really add anything to the function declaration... I realized that there already are some examples in the CREATE SEQUENCE documentation, so what about linking there instead of writing more examples? The attached patch does that and removes the less useful examples. What do you think? Yours, Laurenz Albe
Attachment
On Thu, Dec 1, 2022 at 4:21 PM Laurenz Albe <laurenz.albe@cybertec.at> wrote:
On Tue, 2022-11-29 at 16:26 -0500, Kirk Wolak wrote:
> On Mon, Nov 28, 2022 at 12:45 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
> > Laurenz Albe <laurenz.albe@cybertec.at> writes:
> > > Now I think that is taking it too far. Your code sample would be great
> > > for a tutorial, but it is too elaborate for the technical documentation.
> > > The example should focus on the sequence functions, but more than half
> > > of the code describes other parts of PostgreSQL:
> >
> > Yeah, that stuff seems quite out of place here.
> >
> > > I am alright with having a CREATE TABLE with a DEFAULT and an INSERT or two;
> > > whatever it takes to show the functions in a realistic scenario.
> > > For example, you could INSERT a row that overrides the DEFAULT, then call
> > > "setval()" to readjust the sequence.
> >
> > I don't believe we have such detail around very many, if indeed any,
> > of our other functions' documentation.
> >
> > regards, tom lane
>
>
> All changes specified have been addressed.
> The Example is significantly reduced, but readable.
> The extra "SELECT "'s have been removed off of the inline examples, excluding the existing paragraph.
>
> This is the smallest possible change, that still has an example.
>
> The "Example" is not <title> as every attempt to make it such fails the LINT process.
You can have <title> only after the start of a section.
The new examples in the table don't really add anything to the function declaration...
I realized that there already are some examples in the CREATE SEQUENCE documentation,
so what about linking there instead of writing more examples?
The attached patch does that and removes the less useful examples. What do you think?
Yours,
Laurenz Albe
+1
That was feedback on my issue I've never seen before. Thanks so much to all of you.
С уважением, А. И.
вс, 4 дек. 2022 г., 06:03 Kirk Wolak <wolakk@gmail.com>:
On Thu, Dec 1, 2022 at 4:21 PM Laurenz Albe <laurenz.albe@cybertec.at> wrote:On Tue, 2022-11-29 at 16:26 -0500, Kirk Wolak wrote:
> On Mon, Nov 28, 2022 at 12:45 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
> > Laurenz Albe <laurenz.albe@cybertec.at> writes:
> > > Now I think that is taking it too far. Your code sample would be great
> > > for a tutorial, but it is too elaborate for the technical documentation.
> > > The example should focus on the sequence functions, but more than half
> > > of the code describes other parts of PostgreSQL:
> >
> > Yeah, that stuff seems quite out of place here.
> >
> > > I am alright with having a CREATE TABLE with a DEFAULT and an INSERT or two;
> > > whatever it takes to show the functions in a realistic scenario.
> > > For example, you could INSERT a row that overrides the DEFAULT, then call
> > > "setval()" to readjust the sequence.
> >
> > I don't believe we have such detail around very many, if indeed any,
> > of our other functions' documentation.
> >
> > regards, tom lane
>
>
> All changes specified have been addressed.
> The Example is significantly reduced, but readable.
> The extra "SELECT "'s have been removed off of the inline examples, excluding the existing paragraph.
>
> This is the smallest possible change, that still has an example.
>
> The "Example" is not <title> as every attempt to make it such fails the LINT process.
You can have <title> only after the start of a section.
The new examples in the table don't really add anything to the function declaration...
I realized that there already are some examples in the CREATE SEQUENCE documentation,
so what about linking there instead of writing more examples?
The attached patch does that and removes the less useful examples. What do you think?
Yours,
Laurenz Albe+1
On Sat, Dec 3, 2022 at 8:03 PM Kirk Wolak <wolakk@gmail.com> wrote:
On Thu, Dec 1, 2022 at 4:21 PM Laurenz Albe <laurenz.albe@cybertec.at> wrote:On Tue, 2022-11-29 at 16:26 -0500, Kirk Wolak wrote:
> On Mon, Nov 28, 2022 at 12:45 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
> > Laurenz Albe <laurenz.albe@cybertec.at> writes:
> > > Now I think that is taking it too far. Your code sample would be great
> > > for a tutorial, but it is too elaborate for the technical documentation.
> > > The example should focus on the sequence functions, but more than half
> > > of the code describes other parts of PostgreSQL:
> >
> > Yeah, that stuff seems quite out of place here.
> >
> > > I am alright with having a CREATE TABLE with a DEFAULT and an INSERT or two;
> > > whatever it takes to show the functions in a realistic scenario.
> > > For example, you could INSERT a row that overrides the DEFAULT, then call
> > > "setval()" to readjust the sequence.
> >
> > I don't believe we have such detail around very many, if indeed any,
> > of our other functions' documentation.
> >
> > regards, tom lane
>
>
> All changes specified have been addressed.
> The Example is significantly reduced, but readable.
> The extra "SELECT "'s have been removed off of the inline examples, excluding the existing paragraph.
>
> This is the smallest possible change, that still has an example.
>
> The "Example" is not <title> as every attempt to make it such fails the LINT process.
You can have <title> only after the start of a section.
The new examples in the table don't really add anything to the function declaration...
I realized that there already are some examples in the CREATE SEQUENCE documentation,
so what about linking there instead of writing more examples?
The attached patch does that and removes the less useful examples. What do you think?
Yours,
Laurenz Albe+1
While I agree with the conclusion that the function signature is an example, and having more than one for these is probably overkill, we can address the OP's complaint quite easily by doing what we do in many other places, give each parameter in the function signature a name. I've modified v9 to include those and attach it here as v10. I do think this suffices as a response to this complaint.
Bikeshedding on the names for setval, and maybe an attempt to incorporate the parameter name into the prose, can be considered, though.
My thoughts regarding incorporating pg_get_serial_sequence and usage of these functions in a more common, GENERATED AS IDENTITY environment, can be considered in a separate thread should I or anyone else wish to do so.
David J.
Attachment
On Wed, 2022-12-07 at 14:32 -0700, David G. Johnston wrote: > While I agree with the conclusion that the function signature is an example, > and having more than one for these is probably overkill, we can address the > OP's complaint quite easily by doing what we do in many other places, give > each parameter in the function signature a name. I've modified v9 to include > those and attach it here as v10. I do think this suffices as a response > to this complaint. > > Bikeshedding on the names for setval, and maybe an attempt to incorporate > the parameter name into the prose, can be considered, though. Thanks for looking into that, and parameter names are fully sufficient to clarify the usage. Your patch is good, except that you forgot to add the link target on the CREATE SEQUENCE page. > My thoughts regarding incorporating pg_get_serial_sequence and usage of these > functions in a more common, GENERATED AS IDENTITY environment, can be considered > in a separate thread should I or anyone else wish to do so. +1 Yours, Laurenz Albe