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 1pg73x-0003gs-Gz for pgsql-docs@arkaria.postgresql.org; Sat, 25 Mar 2023 16:48:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pg73v-0003ld-3j for pgsql-docs@arkaria.postgresql.org; Sat, 25 Mar 2023 16:48:15 +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 1pg73u-0003l9-SO for pgsql-docs@lists.postgresql.org; Sat, 25 Mar 2023 16:48:14 +0000 Received: from mout-u-204.mailbox.org ([2001:67c:2050:101:465::204]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pg73q-0003L7-JD for pgsql-docs@lists.postgresql.org; Sat, 25 Mar 2023 16:48:14 +0000 Received: from smtp102.mailbox.org (smtp102.mailbox.org [10.196.197.102]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-u-204.mailbox.org (Postfix) with ESMTPS id 4PkQ4P6mqrz9sQ3; Sat, 25 Mar 2023 17:48:05 +0100 (CET) Date: Sat, 25 Mar 2023 17:48:05 +0100 (CET) From: Erik Wienhold To: spamsacrime@gmail.com, pgsql-docs@lists.postgresql.org Message-ID: <1711437254.453045.1679762885560@office.mailbox.org> In-Reply-To: <167969074745.3349097.2700599411216770547@wrigleys.postgresql.org> References: <167969074745.3349097.2700599411216770547@wrigleys.postgresql.org> Subject: Re: Split_Part w/negative integer does not work MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Priority: 3 Importance: Normal List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On 24/03/2023 21:45 CET PG Doc comments form wro= te: > > The following documentation comment has been logged on the website: > > Page: https://www.postgresql.org/docs/15/functions-string.html > Description: > > When n is negative, an error occurs. > > Documentation > split_part ( string text, delimiter text, n integer ) =E2=86=92 text > Splits string at occurrences of delimiter and returns the n'th field > (counting from one), or when n is negative, returns the |n|'th-from-last > field. > split_part('abc~@~def~@~ghi', '~@~', 2) =E2=86=92 def > split_part('abc,def,ghi,jkl', ',', -2) =E2=86=92 ghi > > Observation > SELECT split_part('abc,def,ghi,jkl', ',', -1); > generates > ERROR: field position must be greater than zero > SQL state: 22023 Works on 14 and 15. Support for negative indexes was added in 14. What version do you use? https://www.postgresql.org/docs/14/release-14.html#id-1.11.6.12.5.8 -- Erik