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 1k9HTV-0006T5-O1 for pgsql-docs@arkaria.postgresql.org; Sat, 22 Aug 2020 00:33:37 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1k9HTU-0000Xy-F7 for pgsql-docs@arkaria.postgresql.org; Sat, 22 Aug 2020 00:33:36 +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 1k9HTU-0000Xn-9T for pgsql-docs@lists.postgresql.org; Sat, 22 Aug 2020 00:33:36 +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 1k9HTR-0000t1-N9 for pgsql-docs@lists.postgresql.org; Sat, 22 Aug 2020 00:33:35 +0000 Received: from bruce by momjian.us with local (Exim 4.92) (envelope-from ) id 1k9HTP-00028R-Jj; Fri, 21 Aug 2020 20:33:31 -0400 Date: Fri, 21 Aug 2020 20:33:31 -0400 From: Bruce Momjian To: sean@materialize.io, pgsql-docs@lists.postgresql.org Subject: Re: Subscript expressions do not have to evaluate to integers Message-ID: <20200822003331.GN13363@momjian.us> References: <159538675800.624.7728794628229799531@wrigleys.postgresql.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="HCdXmnRlPgeNBad2" Content-Disposition: inline In-Reply-To: <159538675800.624.7728794628229799531@wrigleys.postgresql.org> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --HCdXmnRlPgeNBad2 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Wed, Jul 22, 2020 at 02:59:18AM +0000, PG Doc comments form wrote: > The following documentation comment has been logged on the website: > > Page: https://www.postgresql.org/docs/12/sql-expressions.html > Description: > > Section 4.2.3. Subscripts of the documentation states: > > > Each subscript is itself an expression, which must yield an integer > value. > > However, the following query works on Postgres 12.1 > > SELECT (ARRAY[1, 2, 3]::integer[])[1.5]; > > array > ------- > 2 > > 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? -- Bruce Momjian https://momjian.us EnterpriseDB https://enterprisedb.com The usefulness of a cup is in its emptiness, Bruce Lee --HCdXmnRlPgeNBad2 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..4930cecd7b 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. + and will be rounded to an integer value. --HCdXmnRlPgeNBad2--