From: Bruce Momjian <bruce@momjian.us>
To: David G. Johnston <david.g.johnston@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: sean@materialize.io, Pg Docs <pgsql-docs@lists.postgresql.org>
Subject: Re: Subscript expressions do not have to evaluate to integers
Date: Sat, 22 Aug 2020 11:47:37 -0400
Message-ID: <20200822154737.GB26781@momjian.us> (raw)
In-Reply-To: <CAKFQuwY_EtAVCRbu4HxDrHg1Wo0HMnD_uydFw=ZQzTMdDXDFqQ@mail.gmail.com>
References: <159538675800.624.7728794628229799531@wrigleys.postgresql.org>
<20200822003331.GN13363@momjian.us>
<2099092.1598059351@sss.pgh.pa.us>
<CAKFQuwY_EtAVCRbu4HxDrHg1Wo0HMnD_uydFw=ZQzTMdDXDFqQ@mail.gmail.com>
On Fri, Aug 21, 2020 at 07:21:30PM -0700, David G. Johnston wrote:
> On Fri, Aug 21, 2020 at 6:22 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
>
> Bruce Momjian <bruce@momjian.us> writes:
> > On Wed, Jul 22, 2020 at 02:59:18AM +0000, PG Doc comments form wrote:
> >> I believe a more appropriate statement would acknowledge that at least
> some
> >> values undergo an explicit-style conversion to an integer.
>
> > OK, how is the attached patch?
>
> "and" is not an improvement over "which". Otherwise seems OK.
OK, done in the attached patch.
> (The proposed patch for generic subscripting will probably need to
> rewrite this completely, but for now this is an improvement.)
>
>
> I was going to add that maybe we should link to the round(dp or numeric)
> function in the documentation and let it be explicit about the rounding rules
> pertaining to half - which when I look isn't actually documented:
>
> round(dp or numeric) (same as input) round to nearest integer
>
> Maybe everyone just knows that rounding, unless otherwise stated, rounds halves
> away from zero but it doesn't seem like a bad idea to be explicit.
I don't think we use round() directly, to I am hesitant to link to that,
but your idea that we should mention we are rounding to the "nearest"
integer, rather than floor or ceil is a good one, so I mentioned that in
the attached updated patch.
--
Bruce Momjian <bruce@momjian.us> https://momjian.us
EnterpriseDB https://enterprisedb.com
The usefulness of a cup is in its emptiness, Bruce Lee
Attachments:array.diff (text/x-diff, 511B) downloaddiff --git a/doc/src/sgml/syntax.sgml b/doc/src/sgml/syntax.sgmlindex 2f993ca2e0..f1e3402528 100644--- a/doc/src/sgml/syntax.sgml+++ b/doc/src/sgml/syntax.sgml@@ -1378,7 +1378,7 @@ CREATE FUNCTION dept(text) RETURNS dept
</synopsis>
(Here, the brackets <literal>[ ]</literal> are meant to appear literally.)
Each <replaceable>subscript</replaceable> is itself an expression,
- which must yield an integer value.+ which will be rounded to the nearest integer value.
</para>
<para>
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-docs@postgresql.org
Cc: bruce@momjian.us, david.g.johnston@gmail.com, tgl@sss.pgh.pa.us, pgsql-docs@lists.postgresql.org
Subject: Re: Subscript expressions do not have to evaluate to integers
In-Reply-To: <20200822154737.GB26781@momjian.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox