Skip site navigation (1) Skip section navigation (2)

Re: BUG #2390: check constraint

From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
To: Andreas Kretschmer <andreas(dot)kretschmer(at)schollglas(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #2390: check constraint
Date: 2006-04-13 16:01:57
Message-ID: 20060413085322.E81698@megazone.bigpanda.com (view raw or flat)
Thread:
Lists: pgsql-bugs
On Wed, 12 Apr 2006, Andreas Kretschmer wrote:

> The following bug has been logged online:
>
> Bug reference:      2390
> Logged by:          Andreas Kretschmer
> Email address:      andreas(dot)kretschmer(at)schollglas(dot)com
> PostgreSQL version: 8.1.3
> Operating system:   Debian Linux
> Description:        check constraint
> Details:
>
> i want to add a check constraint like:
>
> create table foo (i char(7) CHECK (i ~ '^[0-9]{6,7}$'));
>
> i doesn't work, but if works, if i change the type for i to varchar(7).

Well, the regex doesn't entirely make sense for char(n) data.  It's not
possible to have 6 characters between beginning and end because it's a
fixed length 7 character string. If you try to insert '000000' into i,
you're actually inserting '000000 ' which is invalid by the constraint.


In response to

Responses

pgsql-bugs by date

Next:From: Peter BrantDate: 2006-04-13 16:10:15
Subject: Re: right sibling is not next child
Previous:From: Peter BrantDate: 2006-04-13 15:49:52
Subject: Permission denied on fsync / Win32 (was right siblingis not next child)

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group