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 73ACC3A62DD for ; Sat, 11 Dec 2004 16:35:11 +0000 (GMT) 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 75684-06 for ; Sat, 11 Dec 2004 16:35:02 +0000 (GMT) Received: from tht.net (vista.tht.net [216.126.88.2]) by svr1.postgresql.org (Postfix) with ESMTP id E4CF53A6391 for ; Sat, 11 Dec 2004 16:34:56 +0000 (GMT) Received: from dyn-68-143.tor.dsl.tht.net (dyn-68-143.tor.dsl.tht.net [134.22.68.143]) by tht.net (Postfix) with ESMTP id D3C8E76A63; Sat, 11 Dec 2004 11:34:57 -0500 (EST) Subject: Re: replacing mysql enum From: Rod Taylor To: Stephan Szabo Cc: Ian Barwick , Kenneth Gonsalves , pgsql-sql@postgresql.org In-Reply-To: <20041211074227.J30051@megazone.bigpanda.com> References: <04121110305520.21547@thenilgiris.com> <1d581afe04121104255557ea@mail.gmail.com> <20041211074227.J30051@megazone.bigpanda.com> Content-Type: text/plain Date: Sat, 11 Dec 2004 11:35:01 -0500 Message-Id: <1102782901.26218.173.camel@home> Mime-Version: 1.0 X-Mailer: Evolution 2.0.2 FreeBSD GNOME Team Port Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200412/61 X-Sequence-Number: 19681 On Sat, 2004-12-11 at 07:47 -0800, Stephan Szabo wrote: > On Sat, 11 Dec 2004, Ian Barwick wrote: > > > (Oddly enough, putting the NULL in the CHECK constraint seems > > to make the constraint worthless: > > test=> create table consttest (field varchar(2) check (field in > > (null, 'a','b','c'))); > > CREATE TABLE > > test=> insert into consttest values ('xx'); > > INSERT 408080 1 > > test=> SELECT * from consttest ; > > field > > ------- > > xx > > (1 row) > > > > Not sure what logic is driving this). > > The way NULL is handled in IN (because it's effectively an equality > comparison). Unless I miss-remember the behavior, foo in (NULL, ...) can > never return false and constraints are satisified unless the search > condition returns false for some row. I think this means you need the > more verbose (field is null or field in ('a','b','c')) Actually, he just needs check(field in ('a', 'b', 'c')). NULL is accepted unless explicitly denied (NOT NULL constraint or an IS NOT NULL check). --