Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ozUvA-0002lm-Vq for pgsql-docs@arkaria.postgresql.org; Mon, 28 Nov 2022 03:35:05 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ozUv9-0002t6-TO for pgsql-docs@arkaria.postgresql.org; Mon, 28 Nov 2022 03:35:03 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ozUv9-0002sw-G1 for pgsql-docs@lists.postgresql.org; Mon, 28 Nov 2022 03:35:03 +0000 Received: from mail-ed1-x52d.google.com ([2a00:1450:4864:20::52d]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1ozUv5-0008JA-7O for pgsql-docs@lists.postgresql.org; Mon, 28 Nov 2022 03:35:02 +0000 Received: by mail-ed1-x52d.google.com with SMTP id z18so13718568edb.9 for ; Sun, 27 Nov 2022 19:34:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:date:cc:to:from:subject:message-id:from:to:cc:subject :date:message-id:reply-to; bh=wwyi7zWNIY6Rr2nr/eAGqIdK3AggtgD/71Uo/aATuNM=; b=JQL0/WkagAR65hzgeodkm8Wxa8ZjvvogOkkB0+kzpy2B9A60OZXlSd9IVN7JpPKZJ9 ogv3kVMKUUNwCw9jibgiO6FjdAAEA1s8OUlG8uNFpKCv3gAKX+0TZN9c8TjjxaZzPqTT zn2YySAEBckWbCljwwtiuqxG1WhHNZ/kp2NENf1kRV9CgghEzSUz+8kDxTheqvAT4x6G Am1CzNxyhfJJSGHysOVbBr3nl5UHx6/uCTJXhy2de5Uf1jKJtB+X1Ro15IZuVkWMv81Z jWb/uSmNfujmMs5qBXAcXr/KzNXL7bAmEax7bzPTIQ794JFCX9owARXEYlBb/C10BDtq H2+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=wwyi7zWNIY6Rr2nr/eAGqIdK3AggtgD/71Uo/aATuNM=; b=6iUn4coBiCxM7lc3ny3OO/G2CN/knxdzBrfcQBJUTMTwFUmoR1yw7Q7AnqfrdeO2Sr CTkePyqJF6al+V5Q6lANixFbvMu5uhhVkZlGUX3FRQgbAxUN+/31suOE5bfdddcB2/TN Pf0sxzc7UWnjAJVFHyFOvbrGnXvndpssX1+rloNKHiXLsQeE7pIuwkSNK7b7Z0Rl7ll0 j6DsbutNbX4GlUzgYBMcEwuFZG3gh3mCtD62Pf9SQkT05banXmrJSXGUpDDkdh41q+PV qm8wxQmXUCWakeabF+wOF7czcCMVw4F800tj4rmxePFFE5gvm/waAell849UYUHV+Xyi Vavw== X-Gm-Message-State: ANoB5pnAgB6GzIwKyxl2UjJSyQRdfccFkD0/6U1aTr05YkYh6BoWlX2R zuKDZw5J2dd53BlWfl/pfg7tQw== X-Google-Smtp-Source: AA0mqf6iGoP7xNld8+6mRaO33FOvZc9G13rSFyvlGdXHiRnUFuNlTw6s/AnLFgDytbpV5XoGGEn0tw== X-Received: by 2002:a05:6402:1684:b0:46b:1396:e132 with SMTP id a4-20020a056402168400b0046b1396e132mr4831471edv.421.1669606497860; Sun, 27 Nov 2022 19:34:57 -0800 (PST) Received: from localhost.localdomain (178-190-171-154.adsl.highway.telekom.at. [178.190.171.154]) by smtp.gmail.com with ESMTPSA id kw21-20020a170907771500b007ad94fd48dfsm4401787ejc.139.2022.11.27.19.34.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Nov 2022 19:34:57 -0800 (PST) Message-ID: Subject: Re: nextval parameter is not clear From: Laurenz Albe To: Kirk Wolak , "David G. Johnston" Cc: Bruce Momjian , ailjushkin@gmail.com, pgsql-docs@lists.postgresql.org Date: Mon, 28 Nov 2022 04:34:56 +0100 In-Reply-To: References: <166608103231.2042183.13992576112735261253@wrigleys.postgresql.org> <21e017222199f3ca397fa70549140d226236e4b6.camel@cybertec.at> <0c0eddb287571e72a2df1be8758fbbb0cb7cc378.camel@cybertec.at> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.42.4 (3.42.4-2.fc35) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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. > > > + > +SELECT nextval('myseq'::regclass); > + > + > + The indentation of the 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); Next nextval sequence. > > > - > > > 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); Next nextval identical to currval, 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.) > + > +SELECT lastval(); > + 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 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. > > > This function requires USAGE > or SELECT privilege on the last used sequence. > > > + > + > + > + > > > This empty row should definitely go. > + Example I think you should use the 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