Re: Uninterruptable regexp_replace in 9.3.1 ?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Craig Ringer <craig(at)2ndquadrant(dot)com>, Florian Pflug <fgp(at)phlo(dot)org>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>, Sandro Santilli <strk(at)keybit(dot)net>
Subject: Re: Uninterruptable regexp_replace in 9.3.1 ?
Date: 2014-02-22 01:17:36
Message-ID: 646.1393031856@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

I wrote:
> Craig Ringer <craig(at)2ndquadrant(dot)com> writes:
>> So I'd like to confirm that this issue doesn't affect 9.1.

> It doesn't. I suspect it has something to do with 173e29aa5 or one
> of the nearby commits in backend/regex/.

Indeed, git bisect fingers that commit as introducing the problem.

What seems to be happening is that citerdissect() is trying some
combinatorially large number of ways to split the input string into
substrings that can satisfy the argument of the outer "+" iterator.
It keeps failing on the substring starting with the first '$', and
then vainly looking for other splits that dodge the problem.

I'm not entirely sure how come the previous coding didn't fall into
the same problem. It's quite possible Henry Spencer is smarter than
I am, but there was certainly nothing there before that was obviously
avoiding this hazard.

Worthy of note is that I think pre-9.2 is actually giving the wrong
answer --- it's claiming the whole string matches the regex,
which it does not if I'm reading it right. This may be related to
the problem that commit 173e29aa5 was trying to fix, ie failure to
enforce backref matches in some cases. So one possible theory is
that by failing to notice that it *didn't* have a valid match,
the old code accidentally failed to go down the rabbit hole of trying
zillions of other ways to match.

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2014-02-23 20:28:18 Re: Re: [HACKERS] Re: BUG #9210: PostgreSQL string store bug? not enforce check with correct characterSET/encoding
Previous Message Noah Misch 2014-02-21 23:43:32 Re: [HACKERS] Re: BUG #9210: PostgreSQL string store bug? not enforce check with correct characterSET/encoding

Browse pgsql-hackers by date

  From Date Subject
Next Message Thom Brown 2014-02-22 01:37:14 Re: pg_stat_tmp files for dropped databases
Previous Message Tomas Vondra 2014-02-22 01:07:23 Re: pg_stat_tmp files for dropped databases