Re: BUG #4525: substring with this pattern works in 8.3.1; does not work in 8.3.4

From: hubert depesz lubaczewski <depesz(at)depesz(dot)com>
To: chris wood <chrisj(dot)wood(at)sympatico(dot)ca>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #4525: substring with this pattern works in 8.3.1; does not work in 8.3.4
Date: 2008-11-12 19:18:11
Message-ID: 20081112191811.GA5774@depesz.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Wed, Nov 12, 2008 at 06:45:27PM +0000, chris wood wrote:
> I apologize in advance for not testing on 8.3.5, but that would be very
> difficult for me.
> I e-mailed this same problem from chris(dot)wood(at)bookitnow(dot)ca and it got
> blocked

http://www.postgresql.org/docs/current/interactive/release-8-3-2.html
...
Fix a corner case in regular-expression substring matching
(substring(string from pattern)) (Tom)

The problem occurs when there is a match to the pattern overall but the
user has specified a parenthesized subexpression and that subexpression
hasn't got a match. An example is substring('foo' from 'foo(bar)?').
This should return NULL, since (bar) isn't matched, but it was
mistakenly returning the whole-pattern match instead (ie, foo).
...

so basically - it is that the code that worked before is considered to
be bad.

how to fix it:
1. change the regexpin substring to:
'^[0-9]{10}(?:,[0-9]{10})*$'

2. change check to:
CHECK ((public_phone ~ '^([0-9]{10}(,[0-9]{10})*)?$')));

choose whichever you prefer.

Best regards,

depesz

--
Linkedin: http://www.linkedin.com/in/depesz / blog: http://www.depesz.com/
jid/gtalk: depesz(at)depesz(dot)com / aim:depeszhdl / skype:depesz_hdl / gg:6749007

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Alvaro Herrera 2008-11-12 19:52:39 Re: BUG #4526: Problem with sorting order by clause and null values(space) in the beginning og a string
Previous Message stella 2008-11-12 19:08:02 BUG #4526: Problem with sorting order by clause and null values(space) in the beginning og a string