Unix Technical Forum

BUG #2127: Regular Expression Limits Do Not Work

This is a discussion on BUG #2127: Regular Expression Limits Do Not Work within the pgsql Bugs forums, part of the PostgreSQL category; --> The following bug has been logged online: Bug reference: 2127 Logged by: Kyril Alyoshin Email address: kyrill@technolog.ca PostgreSQL version: ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Bugs

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-10-2008, 10:35 AM
Kyril Alyoshin
 
Posts: n/a
Default BUG #2127: Regular Expression Limits Do Not Work


The following bug has been logged online:

Bug reference: 2127
Logged by: Kyril Alyoshin
Email address: kyrill@technolog.ca
PostgreSQL version: 8.0.3
Operating system: Windows XP
Description: Regular Expression Limits Do Not Work
Details:

I am writing a regex to verify US zipcodes. The expression is very simple,
in a trigger function it looks like this:

IF (NEW.postal_code_name !~ '\\d{5}')
THEN
RAISE EXCEPTION 'error';
END IF;

The bug description is:

If postal_code_name is > 5 digits, the expression would still evaluate to
false, and the error will not be raised.

Please correct this.

Thank you.

Kyrill

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-10-2008, 10:36 AM
Tom Lane
 
Posts: n/a
Default Re: BUG #2127: Regular Expression Limits Do Not Work

"Kyril Alyoshin" <kyrill@technolog.ca> writes:
> IF (NEW.postal_code_name !~ '\\d{5}')


> The bug description is:
> If postal_code_name is > 5 digits, the expression would still evaluate to
> false, and the error will not be raised.


> Please correct this.


Please learn how to use regular expressions ;-)

You probably want '^\\d{5}$' instead, to require the regex to match the
whole string instead of just any part of it.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 04:43 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com