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 1k9Vk8-0002PB-79 for pgsql-docs@arkaria.postgresql.org; Sat, 22 Aug 2020 15:47:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1k9Vk7-00016P-5l for pgsql-docs@arkaria.postgresql.org; Sat, 22 Aug 2020 15:47:43 +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 1k9Vk6-00016I-WB for pgsql-docs@lists.postgresql.org; Sat, 22 Aug 2020 15:47:42 +0000 Received: from momjian.us ([72.94.173.45]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1k9Vk4-00044i-HK for pgsql-docs@lists.postgresql.org; Sat, 22 Aug 2020 15:47:42 +0000 Received: from bruce by momjian.us with local (Exim 4.92) (envelope-from ) id 1k9Vk1-00070C-UZ; Sat, 22 Aug 2020 11:47:37 -0400 Date: Sat, 22 Aug 2020 11:47:37 -0400 From: Bruce Momjian To: "David G. Johnston" Cc: Tom Lane , sean@materialize.io, Pg Docs Subject: Re: Subscript expressions do not have to evaluate to integers Message-ID: <20200822154737.GB26781@momjian.us> References: <159538675800.624.7728794628229799531@wrigleys.postgresql.org> <20200822003331.GN13363@momjian.us> <2099092.1598059351@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="i0/AhcQY5QxfSsSZ" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --i0/AhcQY5QxfSsSZ Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit 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 wrote: > > Bruce Momjian 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 https://momjian.us EnterpriseDB https://enterprisedb.com The usefulness of a cup is in its emptiness, Bruce Lee --i0/AhcQY5QxfSsSZ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="array.diff" diff --git a/doc/src/sgml/syntax.sgml b/doc/src/sgml/syntax.sgml index 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 (Here, the brackets [ ] are meant to appear literally.) Each subscript is itself an expression, - which must yield an integer value. + which will be rounded to the nearest integer value. --i0/AhcQY5QxfSsSZ--