From: Ben Hood <ben@relops.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: Domain based on TIMEZONE WITH TIME ZONE
Date: Thu, 10 May 2018 09:10:03 +0100
Message-ID: <39189872-897A-4AAF-A967-C064AD28D925@relops.com> (raw)
In-Reply-To: <06EAD729-DC35-4E48-AB25-C42F7FA19C28@relops.com>
References: <06EAD729-DC35-4E48-AB25-C42F7FA19C28@relops.com>
Sorry about the bug in the subject: the data type is TIMESTAMP WITH TIME ZONE, not TIMEZONE WITH TIME ZONE
> On 10 May 2018, at 09:03, Ben Hood <ben@relops.com> wrote:
>
> Hi,
>
> I'm using a domain to specialize the built in TIMEZONE WITH TIME ZONE type. I want to sanity check this approach before continuing to use this.
>
> I want to prevent timestamps with non-UTC offsets from getting inserted into the database. Having a UTC-only database at the schema level means no app, proc, script or load operation can inadvertently supply a local time offset.
>
> The domain is defined as:
>
> CREATE DOMAIN UTC_TIMESTAMP AS TIMESTAMP WITH TIME ZONE CHECK (EXTRACT(TIMEZONE FROM VALUE) = 0);
> CREATE TYPE UTC_RANGE AS RANGE ( SUBTYPE = UTC_TIMESTAMP );
>
> My potentially misguided assumption is that I am effectively re-using a check constraint across the schema.
>
> Is this crazy?
>
> Am I missing the point of how Postgres stores TIMEZONE WITH TIME ZONE internally?
>
> Thanks in advance,
>
> Ben
>
>
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: ben@relops.com
Subject: Re: Domain based on TIMEZONE WITH TIME ZONE
In-Reply-To: <39189872-897A-4AAF-A967-C064AD28D925@relops.com>
References: <06EAD729-DC35-4E48-AB25-C42F7FA19C28@relops.com> <39189872-897A-4AAF-A967-C064AD28D925@relops.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