pgsql: Fix regex match failures for backrefs combined with non-greedy q

Started by Tom Laneabout 13 years ago3 messagescomitters
Jump to latest
#1Tom Lane
tgl@sss.pgh.pa.us

Fix regex match failures for backrefs combined with non-greedy quantifiers.

An ancient logic error in cfindloop() could cause the regex engine to fail
to find matches that begin later than the start of the string. This
function is only used when the regex pattern contains a back reference,
and so far as we can tell the error is only reachable if the pattern is
non-greedy (i.e. its first quantifier uses the ? modifier). Furthermore,
the actual match must begin after some potential match that satisfies the
DFA but then fails the back-reference's match test.

Reported and fixed by Jeevan Chalke, with cosmetic adjustments by me.

Branch
------
REL9_3_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/f8463fba2434d083bb699d1cc8a7d7159d614a7b

Modified Files
--------------
src/backend/regex/regexec.c | 20 +++++++++++---------
src/test/regress/expected/regex.out | 15 +++++++++++++++
src/test/regress/sql/regex.sql | 5 +++++
3 files changed, 31 insertions(+), 9 deletions(-)

--
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers

#2Alvaro Herrera
alvherre@2ndquadrant.com
In reply to: Tom Lane (#1)
Re: pgsql: Fix regex match failures for backrefs combined with non-greedy q

Tom Lane wrote:

Fix regex match failures for backrefs combined with non-greedy quantifiers.

Should we report this to the Tcl developers?

--
�lvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

--
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers

#3Alvaro Herrera
alvherre@2ndquadrant.com
In reply to: Alvaro Herrera (#2)
Re: pgsql: Fix regex match failures for backrefs combined with non-greedy q

Alvaro Herrera wrote:

Tom Lane wrote:

Fix regex match failures for backrefs combined with non-greedy quantifiers.

Should we report this to the Tcl developers?

Ah, I see now that you already reported it.

--
�lvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

--
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers