agora inbox for pgsql-sql@postgresql.org  
help / color / mirror / Atom feed
From: skinner@britvault.co.uk
To: pgsql-sql@postgresql.org
Subject: Re: PostgreSQL 9.2 tstzrange null/infinity CONSTRAINT CHECK
Date: Wed, 16 Oct 2013 15:41:01 +0100
Message-ID: <20131016144101.GA13893@teak.britvault.co.uk> (raw)
In-Reply-To: <20131016125014.GA25474@teak.britvault.co.uk>
References: <20131016125014.GA25474@teak.britvault.co.uk>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-sql>

On 2013-10-16 Wed 13:50 PM |, Craig R. Skinner wrote:
> I'd like to limit a 9.2 tstzrange to valid dates at both ends.
> No NULLs nor 'infinity'.
> 
> CREATE TABLE bill
> (
>   id serial NOT NULL,
>   created_at timestamp with time zone NOT NULL DEFAULT now(),
>   period tstzrange NOT NULL,
>   -- other columns
>   CONSTRAINT bill_pk PRIMARY KEY (id),

This works:

  CONSTRAINT bill_period_not_null_nor_infinity_ck CHECK
  (
    lower(period) IS NOT NULL AND
    upper(period) IS NOT NULL AND
    (lower(period) > '-infinity') AND
    (upper(period) < 'infinity')
  )


Cheers,
-- 
Craig Skinner | http://twitter.com/Craig_Skinner | http://linkd.in/yGqkv7


-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql



view thread (2+ messages)

Message-ID: <20131016144101.GA13893@teak.britvault.co.uk>
Permalink:  ../20131016144101.GA13893@teak.britvault.co.uk/
Also on:    postgresql.org/message-id/20131016144101.GA13893@teak.britvault.co.uk

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: skinner@britvault.co.uk
  Subject: Re: PostgreSQL 9.2 tstzrange null/infinity CONSTRAINT CHECK
  In-Reply-To: <20131016144101.GA13893@teak.britvault.co.uk>

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

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