[SQL] Problem with a Pettern Matching Check

2005-08-15 Thread Sebastian Siewior
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

Re: [SQL] Problem with a Pettern Matching Check

2005-08-15 Thread Dmitri Bichko
-numeric. Dmitri -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 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

Re: [SQL] Problem with a Pettern Matching Check

2005-08-15 Thread Andreas Seltenreich
Sebastian Siewior schrob: Hello hopefully correct List, perfectly. 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'

Re: SUSPECT: RE: Re: [SQL] Problem with a Pettern Matching Check

2005-08-15 Thread Dmitri Bichko
, 2005 6:34 PM To: Dmitri Bichko Subject: SUSPECT: RE: Re: [SQL] Problem with a Pettern Matching Check ANTISPAM UOL » TIRA-TEIMA Olá, Você enviou uma mensagem para [EMAIL PROTECTED] Para que sua mensagem seja encaminhada, por favor, clique aqui Esta confirmação é necessária porque [EMAIL

Re: [SQL] Problem with a Pettern Matching Check

2005-08-15 Thread Michael Fuhr
On Tue, Aug 16, 2005 at 12:19:50AM +0200, Sebastian Siewior wrote: 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

Re: [SQL] Problem with a Pettern Matching Check

2005-08-15 Thread Sebastian Siewior
On Mon, 15 Aug 2005 18:37:52 -0400 Dmitri Bichko [EMAIL PROTECTED] wrote: I'm guessing it's because char gets padded with spaces to the specified length. argh. Thank you. Any reason you are using char(3) instead of varchar(3)? The numbers will have 2 or 3 digits so I tried to save some

Re: [SQL] Problem with a Pettern Matching Check

2005-08-15 Thread Dmitri Bichko
Any reason you are using char(3) instead of varchar(3)? The numbers will have 2 or 3 digits so I tried to save some space :) Well, smallint is only 2 bytes, so it would be more compact than either char(3) or varchar(3). Dmitri The information transmitted is intended only for the person or

Re: [SQL] Problem with a Pettern Matching Check

2005-08-15 Thread Tom Lane
Michael Fuhr [EMAIL PROTECTED] writes: The CHAR(3) specification causes the value to be space-padded, so '1' becomes '1 ' (the digit one followed by two spaces). Actually, we seem to be going out of our way to make this case fail. Given that we consider trailing spaces in char(n) to be

Re: [SQL] Problem with a Pettern Matching Check

2005-08-15 Thread Michael Fuhr
On Mon, Aug 15, 2005 at 08:21:23PM -0400, Tom Lane wrote: Michael Fuhr [EMAIL PROTECTED] writes: The CHAR(3) specification causes the value to be space-padded, so '1' becomes '1 ' (the digit one followed by two spaces). Actually, we seem to be going out of our way to make this case fail.

Re: [SQL] Problem with a Pettern Matching Check

2005-08-15 Thread Tom Lane
Michael Fuhr [EMAIL PROTECTED] writes: On Mon, Aug 15, 2005 at 08:21:23PM -0400, Tom Lane wrote: Given that we consider trailing spaces in char(n) to be semantically insignificant, would it make sense to strip them before doing the regex pattern match? How standards-compliant would that be?