X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 49CF652DF6 for ; Mon, 15 Aug 2005 19:42:49 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 51157-02 for ; Mon, 15 Aug 2005 22:42:46 +0000 (GMT) Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) by svr1.postgresql.org (Postfix) with ESMTP id 0917752943 for ; Mon, 15 Aug 2005 19:42:45 -0300 (ADT) Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) by tigger.fuhr.org (8.13.3/8.13.3) with ESMTP id j7FMg9Zp004202 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 15 Aug 2005 16:42:11 -0600 (MDT) (envelope-from mfuhr@winnie.fuhr.org) Received: from winnie.fuhr.org (localhost [127.0.0.1]) by winnie.fuhr.org (8.13.3/8.13.3) with ESMTP id j7FMg9qI057355; Mon, 15 Aug 2005 16:42:09 -0600 (MDT) (envelope-from mfuhr@winnie.fuhr.org) Received: (from mfuhr@localhost) by winnie.fuhr.org (8.13.3/8.13.3/Submit) id j7FMg898057354; Mon, 15 Aug 2005 16:42:08 -0600 (MDT) (envelope-from mfuhr) Date: Mon, 15 Aug 2005 16:42:08 -0600 From: Michael Fuhr To: Sebastian Siewior Cc: pgsql-sql@postgresql.org Subject: Re: Problem with a Pettern Matching Check Message-ID: <20050815224208.GA51332@winnie.fuhr.org> References: <20050816001950.2225e5b8@mikejones.ghb.fh-furtwangen.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20050816001950.2225e5b8@mikejones.ghb.fh-furtwangen.de> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.005 required=5 tests=[AWL=0.005] X-Spam-Level: X-Archive-Number: 200508/101 X-Sequence-Number: 22329 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 > '12'. Could someone please give me hint? :) The CHAR(3) specification causes the value to be space-padded, so '1' becomes '1 ' (the digit "one" followed by two spaces). See "Character Types" in the documentation: http://www.postgresql.org/docs/8.0/static/datatype-character.html Do you have a reason for using a character type instead of a numeric type like integer? -- Michael Fuhr