Re: BUG #3037: strange behave of CHECK constraint - Mailing list pgsql-bugs

From Pavel Stehule
Subject Re: BUG #3037: strange behave of CHECK constraint
Date
Msg-id BAY114-F3882FD09D541A289EBC55BF98E0@phx.gbl
Whole thread Raw
In response to Re: BUG #3037: strange behave of CHECK constraint  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
>"Pavel Stehule" <pavel.stehule@hotmail.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)
>
>

I see it now. Thank You. It's one trick from Joe Celko and I too late
understand it.

Nice  day
Pavel Stehule

_________________________________________________________________
Emotikony a pozadi programu MSN Messenger ozivi vasi konverzaci.
http://messenger.msn.cz/

pgsql-bugs by date:

Previous
From: guru@ap.nic.in
Date:
Subject: ERROR: relation "pg_catalog.pg_user" does not exist
Next
From: Tom Lane
Date:
Subject: Re: ERROR: relation "pg_catalog.pg_user" does not exist