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 1pg79H-0003xZ-Ao for pgsql-docs@arkaria.postgresql.org; Sat, 25 Mar 2023 16:53:47 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pg79F-00051i-Qr for pgsql-docs@arkaria.postgresql.org; Sat, 25 Mar 2023 16:53:45 +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 1pg79F-00051Y-J4 for pgsql-docs@lists.postgresql.org; Sat, 25 Mar 2023 16:53:45 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pg798-0003Ng-7y for pgsql-docs@lists.postgresql.org; Sat, 25 Mar 2023 16:53:45 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 32PGrZo12601207; Sat, 25 Mar 2023 12:53:35 -0400 From: Tom Lane To: spamsacrime@gmail.com cc: pgsql-docs@lists.postgresql.org Subject: Re: Split_Part w/negative integer does not work In-reply-to: <167969074745.3349097.2700599411216770547@wrigleys.postgresql.org> References: <167969074745.3349097.2700599411216770547@wrigleys.postgresql.org> Comments: In-reply-to PG Doc comments form message dated "Fri, 24 Mar 2023 20:45:47 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <2601205.1679763215.1@sss.pgh.pa.us> Content-Transfer-Encoding: 8bit Date: Sat, 25 Mar 2023 12:53:35 -0400 Message-ID: <2601206.1679763215@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk PG Doc comments form writes: > Page: https://www.postgresql.org/docs/15/functions-string.html > Documentation > split_part ( string text, delimiter text, n integer ) → 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) → def > split_part('abc,def,ghi,jkl', ',', -2) → ghi > Observation > SELECT split_part('abc,def,ghi,jkl', ',', -1); > generates > ERROR: field position must be greater than zero > SQL state: 22023 Apparently, you are reading the v15 documentation and expecting it to be exactly correct for some older server version. The described behavior came in in v14. regards, tom lane