Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gjxTQ-0000UO-8D for pgsql-bugs@arkaria.postgresql.org; Thu, 17 Jan 2019 02:32:04 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gjxTO-0002w0-Vf for pgsql-bugs@arkaria.postgresql.org; Thu, 17 Jan 2019 02:32:02 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gjxTO-0002vt-PM for pgsql-bugs@lists.postgresql.org; Thu, 17 Jan 2019 02:32:02 +0000 Received: from lungold.riddles.org.uk ([82.68.208.19]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gjxTM-0001NP-TC for pgsql-bugs@lists.postgresql.org; Thu, 17 Jan 2019 02:32:02 +0000 Received: from [192.168.127.1] (port=49812 helo=caithnard.riddles.org.uk) by lungold.riddles.org.uk with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.88 (FreeBSD)) (envelope-from ) id 1gjxTJ-0007Dk-7N; Thu, 17 Jan 2019 02:31:57 +0000 Received: from [127.0.0.1] (port=15735 helo=caithnard.riddles.org.uk) by caithnard.riddles.org.uk with esmtp (Exim 4.89 (FreeBSD)) (envelope-from ) id 1gjxTI-000DfW-Ht; Thu, 17 Jan 2019 02:31:56 +0000 From: Andrew Gierth To: pgsql-bugs@lists.postgresql.org, zhq651@126.com Subject: Re: BUG #15595: matchctx->npatterns is always 1 no matter pattern have 0 or 1 subexpression In-Reply-To: <15595-e6317afee476db49@postgresql.org> (PG Bug reporting form's message of "Thu, 17 Jan 2019 01:30:03 +0000") Message-ID: <875zuoja2s.fsf@news-spur.riddles.org.uk> References: <15595-e6317afee476db49@postgresql.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (berkeley-unix) Date: Thu, 17 Jan 2019 02:31:56 +0000 MIME-Version: 1.0 Content-Type: text/plain List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk >>>>> "PG" == PG Bug reporting form 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)