From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | pgsql-committers(at)postgresql(dot)org |
Subject: | pgsql: Fix incorrect search for "x?" style matches in creviterdissect() |
Date: | 2014-09-24 00:26:32 |
Message-ID: | E1XWaPg-00031X-Ls@gemulon.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-committers |
Fix incorrect search for "x?" style matches in creviterdissect().
When the number of allowed iterations is limited (either a "?" quantifier
or a bound expression), the last sub-match has to reach to the end of the
target string. The previous coding here first tried the shortest possible
match (one character, usually) and then gave up and back-tracked if that
didn't work, typically leading to failure to match overall, as shown in
bug #11478 from Christoph Berg. The minimum change to fix that would be to
not decrement k before "goto backtrack"; but that would be a pretty stupid
solution, because we'd laboriously try each possible sub-match length
before finally discovering that only ending at the end can work. Instead,
force the sub-match endpoint limit up to the end for even the first
shortest() call if we cannot have any more sub-matches after this one.
Bug introduced in my rewrite that added the iterdissect logic, commit
173e29aa5deefd9e71c183583ba37805c8102a72. The shortest-first search code
was too closely modeled on the longest-first code, which hasn't got this
issue since it tries a match reaching to the end to start with anyway.
Back-patch to all affected branches.
Branch
------
REL9_2_STABLE
Details
-------
http://git.postgresql.org/pg/commitdiff/3359a818c2dac930f68041c7230a8284e5584447
Modified Files
--------------
src/backend/regex/regexec.c | 4 ++++
src/test/regress/expected/regex.out | 8 ++++++++
src/test/regress/sql/regex.sql | 4 ++++
3 files changed, 16 insertions(+)
From | Date | Subject | |
---|---|---|---|
Next Message | Andrew Dunstan | 2014-09-24 15:25:44 | pgsql: Fix typos in descriptions of json_object functions. |
Previous Message | Stephen Frost | 2014-09-23 01:53:18 | pgsql: Add unicode_*_linestyle to \? variables |