pgsql: Handle interaction of regexp's makesearch and MATCHALL more hone

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Handle interaction of regexp's makesearch and MATCHALL more hone
Date: 2021-08-27 16:19:07
Message-ID: E1mJeZP-0004r8-6R@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Handle interaction of regexp's makesearch and MATCHALL more honestly.

Second thoughts about commit 824bf7190: we apply makesearch() to
an NFA after having determined whether it is a MATCHALL pattern.
Prepending ".*" doesn't make it non-MATCHALL, but it does change the
maximum possible match length, and makesearch() failed to update that.
This has no ill effects given the stylized usage of search NFAs, but
it seems like it's better to keep the data structure consistent. In
particular, fixing this allows more honest handling of the MATCHALL
check in matchuntil(): we can now assert that maxmatchall is infinity,
instead of lamely assuming that it should act that way.

In passing, improve the code in dump[c]nfa so that infinite maxmatchall
is printed as "inf" not a magic number.

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/8f72becd6b9484fbb429651d8859faa36532a35a

Modified Files
--------------
src/backend/regex/regc_nfa.c | 18 ++++++++++++++----
src/backend/regex/regcomp.c | 7 +++++++
src/backend/regex/rege_dfa.c | 8 ++------
3 files changed, 23 insertions(+), 10 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Peter Eisentraut 2021-08-27 16:21:06 pgsql: Change Texinfo output to UTF-8
Previous Message Daniel Gustafsson 2021-08-27 14:25:25 pgsql: Avoid invoking PQfnumber in loop constructs