Re: BUG #15595: matchctx->npatterns is always 1 no matter pattern have 0 or 1 subexpression

From: Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org, zhq651(at)126(dot)com
Subject: Re: BUG #15595: matchctx->npatterns is always 1 no matter pattern have 0 or 1 subexpression
Date: 2019-01-17 02:31:56
Message-ID: 875zuoja2s.fsf@news-spur.riddles.org.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

>>>>> "PG" == PG Bug reporting form <noreply(at)postgresql(dot)org> writes:

PG> Hi,
PG> when I use setup_regexp_matches, I found matchctx->npatterns is
PG> always 1 no matter pattern have not or one subexpr subexpression.

This isn't a bug. setup_regexp_matches is just an internal helper
function for use by regexp_match, regexp_matches, regexp_split_to_table,
and regexp_split_to_array, all of which treat the whole match as the
result if there are no subexpression captures in the regexp. npatterns
is therefore forced to be 1 in that case, so that nmatches * npatterns
is the number of position pairs returned in the match_locs array.

--
Andrew (irc:RhodiumToad)

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2019-01-17 02:33:41 Re: BUG #15596: Folders created with wrong permissions when installing an extension with a non-default umask
Previous Message Tom Lane 2019-01-17 02:28:57 Re: BUG #15595: matchctx->npatterns is always 1 no matter pattern have 0 or 1 subexpression