Re: Problem with a Pettern Matching Check - Mailing list pgsql-sql

From Dmitri Bichko
Subject Re: Problem with a Pettern Matching Check
Date
Msg-id F18A6F7CF1661F46920F2CF713122FED46CC63@mail.aveo.aveopharma.com
Whole thread Raw
In response to Problem with a Pettern Matching Check  (Sebastian Siewior <lavish@kamp-dsl.de>)
Responses Re: Problem with a Pettern Matching Check
List pgsql-sql
I'm guessing it's because char gets padded with spaces to the specified
length.

Any reason you are using char(3) instead of varchar(3)?  And why are you
storing numbers as a string, anyway?  If you defined the column as a
numeric type, postgres will tell you if you try to insert something
non-numeric.

Dmitri

-----Original Message-----
From: pgsql-sql-owner@postgresql.org
[mailto:pgsql-sql-owner@postgresql.org] On Behalf Of Sebastian Siewior
Sent: Monday, August 15, 2005 6:20 PM
To: pgsql-sql@postgresql.org
Subject: [SQL] Problem with a Pettern Matching Check


Hello hopefully correct List,

I was trying to do something that is not working as it supposed to.
First I created a table:

create table t ( col CHAR (3) CONSTRAINT numonly_col CHECK ( col ~ '^\\d+$' )
);

This check avoids non-numbers like '1a1' and allows '123'. For some
reason, I'm unable to find out why, it also avoids things like '1' and
'12'. Could someone please give me hint? :)

I was trying this one on PostgreSQL 8.0.3

--
Regards
Sebastian Siewior

---------------------------(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
datatypesdo not      match 
The information transmitted is intended only for the person or entity to which it is addressed and may contain
confidentialand/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any
actionin reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you
receivedthis in error, please contact the sender and delete the material from any computer 


pgsql-sql by date:

Previous
From: Sebastian Siewior
Date:
Subject: Problem with a Pettern Matching Check
Next
From: "Dmitri Bichko"
Date:
Subject: Re: SUSPECT: RE: Re: Problem with a Pettern Matching Check