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

Re: BUG #3037: strange behave of CHECK constraint

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Pavel Stehule" <pavel(dot)stehule(at)hotmail(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #3037: strange behave of CHECK constraint
Date: 2007-02-23 04:54:08
Message-ID: 11475.1172206448@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-bugs
"Pavel Stehule" <pavel(dot)stehule(at)hotmail(dot)com> writes:
> root=# create table products(
>   barcode char(13) NOT NULL
>   check (barcode NOT similar to '%[^0-9]%')
> );

> root=# insert into products values('22');
> ERROR:  new row for relation "products" violates check constraint
> "products_barcode_check"

> root=# select '22'  NOT similar to '%[^0-9]%';
>  ?column? 
> ----------
>  t

That isn't a counterexample, because you forgot about the trailing
spaces, which can match [^0-9].

regression=#  select '22'  NOT similar to '%[^0-9]%';
 ?column? 
----------
 t
(1 row)

regression=#  select '22'::char(13)  NOT similar to '%[^0-9]%';
 ?column? 
----------
 f
(1 row)


			regards, tom lane

In response to

Responses

pgsql-bugs by date

Next:From: Tom LaneDate: 2007-02-23 05:22:58
Subject: Re: BUG #3054: getopt_long () misbehaviour
Previous:From: Tom LaneDate: 2007-02-23 04:48:06
Subject: Re: BUG #3040: Domain type handling change in 8.2.2 breaks declarations

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