pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Stephan Szabo <sszabo@megazone.bigpanda.com>
To: Rod Taylor <pg@rbt.ca>
Cc: Ian Barwick <barwick@gmail.com>
Cc: Kenneth Gonsalves <lawgon@thenilgiris.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: replacing mysql enum
Date: Sat, 11 Dec 2004 08:45:19 -0800 (PST)
Message-ID: <20041211084434.F34106@megazone.bigpanda.com> (raw)
In-Reply-To: <1102782901.26218.173.camel@home>
References: <04121110305520.21547@thenilgiris.com>
	<1d581afe04121104255557ea@mail.gmail.com>
	<20041211074227.J30051@megazone.bigpanda.com>
	<1102782901.26218.173.camel@home>


On Sat, 11 Dec 2004, Rod Taylor wrote:

> 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).

Right.  For the same reason, even. Really need to stop answering
messages before I wake up. :)



view thread (9+ messages)  latest in thread

Message-ID: <20041211084434.F34106@megazone.bigpanda.com>
Permalink:  ../20041211084434.F34106@megazone.bigpanda.com/
Also on:    postgresql.org/message-id/20041211084434.F34106@megazone.bigpanda.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: sszabo@megazone.bigpanda.com, pg@rbt.ca, barwick@gmail.com, lawgon@thenilgiris.com
  Subject: Re: replacing mysql enum
  In-Reply-To: <20041211084434.F34106@megazone.bigpanda.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox