Re: Domains (was Re: int1?) - Mailing list pgsql-general

From Bruno Wolff III
Subject Re: Domains (was Re: int1?)
Date
Msg-id 20031009201352.GA15173@wolff.to
Whole thread Raw
In response to Re: Domains (was Re: int1?)  (Ron Johnson <ron.l.johnson@cox.net>)
Responses Re: Domains (was Re: int1?)
List pgsql-general
On Thu, Oct 09, 2003 at 14:46:08 -0500,
  Ron Johnson <ron.l.johnson@cox.net> wrote:
> On Thu, 2003-10-09 at 14:46, Bruno Wolff III wrote:
> > On Thu, Oct 09, 2003 at 14:28:57 -0500,
> >   Ron Johnson <ron.l.johnson@cox.net> wrote:
> > >
> > > http://www.postgresql.org/docs/7.3/static/sql-createdomain.html
> > >   CREATE DOMAIN domainname [AS] data_type
> > >        [ DEFAULT default_expr ]
> > >        [ constraint [, ... ] ]
> > >
> > >    where constraint is:
> > >
> > >    [ CONSTRAINT constraint_name ]
> > >    { NOT NULL | NULL }
> > >
> > > test1=# create domain d_tinyint as smallint constraint chk_tinyint CHECK (smallint between 0 and 255);
> > > ERROR:  DefineDomain: CHECK Constraints not supported
> > >
> > > So, how would I create a domain that limits a smallint?
> >
> > You need to use 7.4. In 7.3 you couldn't use check constraints with domains.
>
> So is there a documentation "bug", or, what kind of constraints
> can be placed on domains besides { NOT NULL | NULL }?

I think the documentation is correct. As I read it it says that only NOT NULL
and NULL constraints are allowed. This is easy to overlook. I know I got
caught by this when I tried it.

I started using 7.4 pretty early on since I wanted to use check constraints
in earthdistance to have a domain that represented points on the surface of
the earth on top of the cube data type.

pgsql-general by date:

Previous
From: Gene Vital
Date:
Subject: Re: Parent Id
Next
From: Bruno Wolff III
Date:
Subject: Re: Parent Id