Re: Death by regexp_replace - Mailing list pgsql-hackers

From Benedikt Grundmann
Subject Re: Death by regexp_replace
Date
Msg-id CADbMkNNxTCmCwwR9NHYrUbV_11N5_=APr6wj+qxPE22nunLh3Q@mail.gmail.com
Whole thread
In response to Re: Death by regexp_replace  (Kevin Grittner <kgrittn@gmail.com>)
List pgsql-hackers
9.2.6

On Fri, Jan 15, 2016 at 3:48 PM, Kevin Grittner <kgrittn@gmail.com> wrote:
On Fri, Jan 15, 2016 at 9:33 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:

>> *WARNING DO NOT DO THIS ON A PRODUCTION BOX*
>> select regexp_replace('VODI GR,VOD LN,VOD LN,VODN MM,VODPF US,VOD US,VZC
>> LN', '([^,]+)(,*\1)+', '\1');

> This responds to cancel just fine for me.

> (FWIW, I think you probably wanted ,+ not ,* in the regex, else there's
> practically no constraint there, leading to having to consider O(N^2)
> or more possibilities.)

On master (commit cf7dfbf2) it responds to pg_cancel_backend(),
but it seems to be in an endless loop until you do that.

--
Kevin Grittner
EDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

pgsql-hackers by date:

Previous
From: Konstantin Knizhnik
Date:
Subject: Re: Limit and inherited tables
Next
From: Stephen Frost
Date:
Subject: Re: Multi-tenancy with RLS