From: Wayne Cuddy <lists-pgsql@useunix.net>
To: PostgreSQL <pgsql-sql@postgresql.org>
Subject: Re: can this be done with a check expression?
Date: Fri, 3 Aug 2012 15:50:53 -0400
Message-ID: <20120803195053.GA16371@slacker.ja10629.home> (raw)
In-Reply-To: <88520F99-849D-438C-9CCD-F80700636A2A@excoventures.com>
References: <20120802231043.GA16173@slacker.ja10629.home>
<88520F99-849D-438C-9CCD-F80700636A2A@excoventures.com>
Thanks for the input.
I don't insert into this table that often so I'll just prevent overlaps
at the application level since I'm running 9.0.X and not really in a
position to upgrade right now.
Thanks again,
Wayne
On Fri, Aug 03, 2012 at 11:50:13AM -0400, Jonathan S. Katz wrote:
> On Aug 2, 2012, at 7:10 PM, Wayne Cuddy wrote:
>
> > I have a table with 3 columns:
> >
> > name text
> > start_id integer
> > end_id integer
> >
> > start_id and end_id are ranges which must not overlap but can have gaps
> > between them. Is it possible to formulate a table check constraint that
> > can verify that either id does not fall within an existing range at
> > insert time? IE prevent overlaps during insert?
> >
> > Thanks,
> > Wayne
>
> So this answer will not help you for the here-and-now, but Postgres 9.2 is going to be released in the near future (though the beta is available) and contains "range types" which have check constraints on them:
>
> http://www.postgresql.org/docs/9.2/static/rangetypes.html#RANGETYPES-CONSTRAINT
>
> You could formulate a check constraint right now to do the equivalent, albeit it will involve a lot of conditions.
>
> Jonathan
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: lists-pgsql@useunix.net
Subject: Re: can this be done with a check expression?
In-Reply-To: <20120803195053.GA16371@slacker.ja10629.home>
* 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