BUG #11478: regexp_matches regression in 9.2

Lists: pgsql-bugs
From: myon(at)debian(dot)org
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #11478: regexp_matches regression in 9.2
Date: 2014-09-23 20:41:18
Message-ID: 20140923204118.17175.66823@wrigleys.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 11478
Logged by: Christoph Berg
Email address: myon(at)debian(dot)org
PostgreSQL version: 9.2.9
Operating system: any
Description:

The following was reported in
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760564 :

select regexp_matches('foo/bar/baz',
'^([^/]+?)(?:/([^/]+?))(?:/([^/]+?))?$', '');

Correct 9.1 result:

regexp_matches
----------------
{foo,bar,baz}

Bad 9.2 and later result:

regexp_matches
----------------
(0 rows)

Removing the last or second-last ? brings the match back.

Perl also thinks the regexp should match:

$ perl -wle 'print "$1 $2 $3" if "foo/bar/baz" =~
m!^([^/]+?)(?:/([^/]+?))(?:/([^/]+?))?$!'
foo bar baz

(There should probably be much less ? in the regexp in the first place, but
a regression/bug is a bug.)


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: myon(at)debian(dot)org
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #11478: regexp_matches regression in 9.2
Date: 2014-09-24 00:27:41
Message-ID: 32339.1411518461@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

myon(at)debian(dot)org writes:
> select regexp_matches('foo/bar/baz',
> '^([^/]+?)(?:/([^/]+?))(?:/([^/]+?))?$', '');

> Correct 9.1 result:

> regexp_matches
> ----------------
> {foo,bar,baz}

> Bad 9.2 and later result:

> regexp_matches
> ----------------
> (0 rows)

Even better, it Asserts() in an assert-enabled build :-(.

Fixed, thanks for the report!

regards, tom lane