Re: Split_Part w/negative integer does not work

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: spamsacrime(at)gmail(dot)com
Cc: pgsql-docs(at)lists(dot)postgresql(dot)org
Subject: Re: Split_Part w/negative integer does not work
Date: 2023-03-25 16:53:35
Message-ID: 2601206.1679763215@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs

PG Doc comments form <noreply(at)postgresql(dot)org> 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~(at)~def~@~ghi', '~(at)~', 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

In response to

Browse pgsql-docs by date

  From Date Subject
Next Message Daniel Gustafsson 2023-03-26 21:18:24 Re: Misleading "For more information..." placement
Previous Message Erik Wienhold 2023-03-25 16:48:05 Re: Split_Part w/negative integer does not work