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 1fGgYM-0004uZ-18 for pgsql-general@arkaria.postgresql.org; Thu, 10 May 2018 08:03:54 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fGgYK-0008NY-Mv for pgsql-general@arkaria.postgresql.org; Thu, 10 May 2018 08:03:52 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fGgYJ-0008NP-Mr for pgsql-general@lists.postgresql.org; Thu, 10 May 2018 08:03:52 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fGgYF-0000Xt-CX for pgsql-general@lists.postgresql.org; Thu, 10 May 2018 08:03:51 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 30F8721E1F; Thu, 10 May 2018 04:03:45 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Thu, 10 May 2018 04:03:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=relops.com; h= content-type:date:from:message-id:mime-version:subject:to :x-me-sender:x-me-sender:x-sasl-enc; s=mesmtp; bh=g0Cwuwj+/25KyO 1mjmzXBbq5lE6gBOt56rqC5EZNaDM=; b=3J/bW76sQTidnX8zChyyoEYQ3D/NZn 9TXT2p/pjUfqXixm4Q06Cz3Ecf1BXeVNcoJN4K+4P4fHB1i+chwmYnmmeC/0OB2B U5w2tSCYFXCo69P+4gL2dAXM6Tn4cC6qtKyC6rmSVlsTNEi/jnWuQAWHOsMntSIP x8sDn30oN4qSM= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:message-id :mime-version:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=g0Cwuwj+/25KyO1mjmzXBbq5lE6gBOt56rqC5EZNaDM=; b=R5bwNpz3 FRANSoxoHWTnbh4u2Y+76Ag5HyDwf0dQXu8t1d0l9Fg4v+zCv/IxLlB5cuTZpZwf y25hMkjKhq/4p+UdAwtcMXWkM9u5OTq+rDlHhzKCNuqI/6hJJUxEuouGI9wRc8tW kUx0MV3F6uOoWDyzZ4SXTMeUqIx03l3DDO8brlLtFZ6CqQ/rJnlV78L8JNmUM7yT E+oxFdPWfxlUXfHR1vcJi3FISemhM3hzp5a0jX2Xl4XSr2XCzy88dkLE824U0lJf YX5C5fmG/Ndud4QjIAuVzDh4PddCKxri5gUZrgbcnPk/6PNRDJJmS2g81+FMuXmc 1IxXToRHyct+LA== X-ME-Sender: Received: from [172.20.10.3] (unknown [185.69.145.218]) by mail.messagingengine.com (Postfix) with ESMTPA id 93BA6E479F for ; Thu, 10 May 2018 04:03:44 -0400 (EDT) From: Ben Hood Content-Type: multipart/alternative; boundary="Apple-Mail=_29CDA99B-0BDD-47CD-81D9-DD059518539E" Mime-Version: 1.0 (Mac OS X Mail 11.3 \(3445.6.18\)) Subject: Domain based on TIMEZONE WITH TIME ZONE Message-Id: <06EAD729-DC35-4E48-AB25-C42F7FA19C28@relops.com> Date: Thu, 10 May 2018 09:03:42 +0100 To: pgsql-general@lists.postgresql.org X-Mailer: Apple Mail (2.3445.6.18) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --Apple-Mail=_29CDA99B-0BDD-47CD-81D9-DD059518539E Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii 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=_29CDA99B-0BDD-47CD-81D9-DD059518539E Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=us-ascii 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=_29CDA99B-0BDD-47CD-81D9-DD059518539E--