From: Nikhil Benesch <nikhil.benesch@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: David G. Johnston <david.g.johnston@gmail.com>
Cc: pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: split_part for the last element
Date: Fri, 23 Oct 2020 14:41:57 -0400
Message-ID: <CAPWqQZT5ynRpC0Tzek_ocU44ZcaLEJXvO2Lf4soTwxB1YTVjKQ@mail.gmail.com> (raw)
In-Reply-To: <222396.1603478100@sss.pgh.pa.us>
References: <CAPWqQZR+-5pAZNSSrnmYczRaX-huemc=oO8URvDZvUA-M=MOBA@mail.gmail.com>
<CAKFQuwZyK0NOuy5jaaV_VuSh1x7SKyTgcvaM0mwCaxfZ=QNBhg@mail.gmail.com>
<222396.1603478100@sss.pgh.pa.us>
On Fri, Oct 23, 2020 at 2:35 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
>
> "David G. Johnston" <david.g.johnston@gmail.com> writes:
> > On Fri, Oct 23, 2020 at 8:47 AM Nikhil Benesch <nikhil.benesch@gmail.com>
> > wrote:
> >> Is there another option I'm missing? Would there be interest in
> >> extending split part so that negative indices counted from the end, as
> >> in:
> >> split_part('foo bar baz', ' ', -1) -> 'baz'
>
> > I'm torn here because this would be the first usage of this concept in
> > PostgreSQL (I think).
>
> We already have some JSON functions that act like that, not to mention
> the left() and right() string functions, so I don't see that much of an
> argument against extending split_part to do it.
Oh, I didn't realize left and right already worked this way. That
makes this design much more compelling, at least to me.
If the consensus is this extension is ok, I'd be happy to prepare a patch.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: nikhil.benesch@gmail.com, tgl@sss.pgh.pa.us, david.g.johnston@gmail.com
Subject: Re: split_part for the last element
In-Reply-To: <CAPWqQZT5ynRpC0Tzek_ocU44ZcaLEJXvO2Lf4soTwxB1YTVjKQ@mail.gmail.com>
References: <CAPWqQZR+-5pAZNSSrnmYczRaX-huemc=oO8URvDZvUA-M=MOBA@mail.gmail.com> <CAKFQuwZyK0NOuy5jaaV_VuSh1x7SKyTgcvaM0mwCaxfZ=QNBhg@mail.gmail.com> <222396.1603478100@sss.pgh.pa.us> <CAPWqQZT5ynRpC0Tzek_ocU44ZcaLEJXvO2Lf4soTwxB1YTVjKQ@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox