Re: [PATCH] regexp_positions ( string text, pattern text, flags text ) → setof int4range[]

From: Gilles Darold <gilles(at)darold(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Joel Jacobson <joel(at)compiler(dot)org>
Cc: Mark Dilger <mark(dot)dilger(at)enterprisedb(dot)com>, Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Andreas Karlsson <andreas(at)proxel(dot)se>, David Fetter <david(at)fetter(dot)org>
Subject: Re: [PATCH] regexp_positions ( string text, pattern text, flags text ) → setof int4range[]
Date: 2021-03-04 16:55:20
Message-ID: ad91c3a1-cc0d-11c8-1fb0-0f4c8e71237a@darold.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Le 04/03/2021 à 16:40, Tom Lane a écrit :
> "Joel Jacobson" <joel(at)compiler(dot)org> writes:
>> Having abandoned the cute idea that didn't work,
>> here comes a new patch with a regexp_positions() instead returning
>> setof record (start_pos integer[], end_pos integer[]).
> I wonder if a 2-D integer array wouldn't be a better idea,
> ie {{startpos1,length1},{startpos2,length2},...}. My experience
> with working with parallel arrays in SQL has been unpleasant.
>
> Also, did you see
>
> https://www.postgresql.org/message-id/fc160ee0-c843-b024-29bb-97b5da61971f%40darold.net
>
> Seems like there may be some overlap in these proposals.

The object of regexp_position() is to return all start+end of captured
substrings, it overlaps a little with regexp_instr() in the way that
this function returns the start or end position of a specific captured
substring. I think it is a good idea to have a function that returns all
positions instead of a single one like regexp_instr(), this is not the
same usage. Actually regexp_position() is exactly the same as
regexp_matches() except that it return positions instead of substrings.

I also think that it should return a setof 2-D integer array, an other
solution is to return all start/end positions of an occurrence chained
in an integer array {start1,end1,start2,end2,..}.

Regards,

--
Gilles Darold

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2021-03-04 17:05:36 Re: [HACKERS] PATCH: Batch/pipelining support for libpq
Previous Message Joel Jacobson 2021-03-04 16:53:42 Re: [PATCH] regexp_positions ( string text, pattern text, flags text ) → setof int4range[]