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

From Andrew Gierth
Subject Re: BUG #15595: matchctx->npatterns is always 1 no matter pattern have 0 or 1 subexpression
Date
Msg-id 875zuoja2s.fsf@news-spur.riddles.org.uk
Whole thread Raw
In response to BUG #15595: matchctx->npatterns is always 1 no matter pattern have 0or 1 subexpression  (PG Bug reporting form <noreply@postgresql.org>)
List pgsql-bugs
>>>>> "PG" == PG Bug reporting form <noreply@postgresql.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)


pgsql-bugs by date:

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