Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fGgeX-0005M7-2m for pgsql-general@arkaria.postgresql.org; Thu, 10 May 2018 08:10:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fGgeV-000550-4j for pgsql-general@arkaria.postgresql.org; Thu, 10 May 2018 08:10:15 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fGgeU-00053w-OQ for pgsql-general@lists.postgresql.org; Thu, 10 May 2018 08:10:14 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fGgeM-0000Zn-Pv for pgsql-general@lists.postgresql.org; Thu, 10 May 2018 08:10:13 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id CF73E229AE; Thu, 10 May 2018 04:10:05 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Thu, 10 May 2018 04:10:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=relops.com; h= content-type:date:from:in-reply-to:message-id:mime-version :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= mesmtp; bh=ZIRCe9R7N+Qs/7icUjkEMjOK9u2QQspAGpLdmeYS10M=; b=ip+1k cdgMVtaO8hblv1jhnvmXjRr02mPz3sj1euLvSzgq6UFcHda6AdECfiGXr9J9dO3W cfL1KdBBM9AJwoYaVxXPo9xYuUnf2RJsudnIA2DFAinQxZrr/WI5EFVa/rxEweVn GVcIK55128waGIzzyxynWh/XI3IzuW6IW7W3wM= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; bh=ZIRCe9R7N+Qs/7icUjkEMjOK9u2QQ spAGpLdmeYS10M=; b=AHGQv9racdEfoRSNCXmqkvPltO/LVPIGKXU1q/LUbwB/y vYks1pI1pIp+FABmCLaKNMhU91L8dcrH06POM70DPcGO8PardXZjlCylEvYOPyP6 //OThyWrN9BF939c0tMPjnjRJWe0ORZNx/Su+bKGgtHn4P2Z7jBWVbPfmYv6GFsK UF6c1eAVLLKwfnuAPNz3BxnjP8fKbHROxm/q/QZ6ngBIB+HId9X/qiRh0FAcTkPO XNxOPpxI0rpLykFgt1vi8Ge42X5RrfIXaIrR63Pp57LM8bkQOaYItMPAXY2kZhLJ gJGEcR9PG4ZzB6ArmsJ/nm1h2AFJp1LWnEEFgkROw== X-ME-Sender: Received: from [172.20.10.3] (unknown [185.69.145.218]) by mail.messagingengine.com (Postfix) with ESMTPA id 3F6AB1025D for ; Thu, 10 May 2018 04:10:05 -0400 (EDT) From: Ben Hood Content-Type: multipart/alternative; boundary="Apple-Mail=_5C6C1F8D-7F7C-4F9C-B2AA-5CCDF35695C2" Mime-Version: 1.0 (Mac OS X Mail 11.3 \(3445.6.18\)) Subject: Re: Domain based on TIMEZONE WITH TIME ZONE Date: Thu, 10 May 2018 09:10:03 +0100 References: <06EAD729-DC35-4E48-AB25-C42F7FA19C28@relops.com> To: pgsql-general@lists.postgresql.org In-Reply-To: <06EAD729-DC35-4E48-AB25-C42F7FA19C28@relops.com> Message-Id: <39189872-897A-4AAF-A967-C064AD28D925@relops.com> X-Mailer: Apple Mail (2.3445.6.18) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --Apple-Mail=_5C6C1F8D-7F7C-4F9C-B2AA-5CCDF35695C2 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii 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 wrote: >=20 > Hi, >=20 > 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. >=20 > 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. >=20 > The domain is defined as: >=20 > CREATE DOMAIN UTC_TIMESTAMP AS TIMESTAMP WITH TIME ZONE CHECK = (EXTRACT(TIMEZONE FROM VALUE) =3D 0); > CREATE TYPE UTC_RANGE AS RANGE ( SUBTYPE =3D UTC_TIMESTAMP ); >=20 > My potentially misguided assumption is that I am effectively re-using = a check constraint across the schema. >=20 > Is this crazy? >=20 > Am I missing the point of how Postgres stores TIMEZONE WITH TIME ZONE = internally? >=20 > Thanks in advance, >=20 > Ben >=20 >=20 --Apple-Mail=_5C6C1F8D-7F7C-4F9C-B2AA-5CCDF35695C2 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=us-ascii 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) =3D 0);
CREATE TYPE = UTC_RANGE AS RANGE ( SUBTYPE =3D 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



= --Apple-Mail=_5C6C1F8D-7F7C-4F9C-B2AA-5CCDF35695C2--