aboutsummaryrefslogtreecommitdiff
path: root/src/backend/regex/rege_dfa.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2021-08-27 12:18:58 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2021-08-27 12:18:58 -0400
commit8f72becd6b9484fbb429651d8859faa36532a35a (patch)
tree77d7101b1a8f7300fb51ee5b5a81d332472cb566 /src/backend/regex/rege_dfa.c
parentd782d5987e1022ba70171bcf3507cd87564ef23c (diff)
downloadpostgresql-8f72becd6b9484fbb429651d8859faa36532a35a.tar.gz
postgresql-8f72becd6b9484fbb429651d8859faa36532a35a.zip
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.
Diffstat (limited to 'src/backend/regex/rege_dfa.c')
-rw-r--r--src/backend/regex/rege_dfa.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/src/backend/regex/rege_dfa.c b/src/backend/regex/rege_dfa.c
index 1d79d734468..ba1289c64a9 100644
--- a/src/backend/regex/rege_dfa.c
+++ b/src/backend/regex/rege_dfa.c
@@ -385,14 +385,10 @@ matchuntil(struct vars *v,
{
size_t nchr = probe - v->start;
- /*
- * It might seem that we should check maxmatchall too, but the .* at
- * the front of the pattern absorbs any extra characters (and it was
- * tacked on *after* computing minmatchall/maxmatchall). Thus, we
- * should match if there are at least minmatchall characters.
- */
if (nchr < d->cnfa->minmatchall)
return 0;
+ /* maxmatchall will always be infinity, cf. makesearch() */
+ assert(d->cnfa->maxmatchall == DUPINF);
return 1;
}