Re: nextval parameter is not clear - Mailing list pgsql-docs

From Kirk Wolak
Subject Re: nextval parameter is not clear
Date
Msg-id CACLU5mRn-xHKP9irkBQvYCQYKNDCcud66zJHHaHNHoOMA4kmVQ@mail.gmail.com
Whole thread Raw
In response to Re: nextval parameter is not clear  ("David G. Johnston" <david.g.johnston@gmail.com>)
Responses Re: nextval parameter is not clear  (Laurenz Albe <laurenz.albe@cybertec.at>)
List pgsql-docs
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; -- 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.

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
image.png
 
Attachment

pgsql-docs by date:

Previous
From: "David G. Johnston"
Date:
Subject: Re: nextval parameter is not clear
Next
From: Laurenz Albe
Date:
Subject: Re: nextval parameter is not clear