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 1fGifw-0005tG-QZ for pgsql-general@arkaria.postgresql.org; Thu, 10 May 2018 10:19:52 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fGifv-0005O9-He for pgsql-general@arkaria.postgresql.org; Thu, 10 May 2018 10:19:51 +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 1fGifu-0005Nz-CF for pgsql-general@lists.postgresql.org; Thu, 10 May 2018 10:19:51 +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 1fGifm-0003cT-I6 for pgsql-general@lists.postgresql.org; Thu, 10 May 2018 10:19:49 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id E8667213FC; Thu, 10 May 2018 06:19:39 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Thu, 10 May 2018 06:19:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=relops.com; h= content-transfer-encoding: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=A+7MJUBe9FDGb4LocK7m7qYVX3 MzOqAb/dnELoEwqKw=; b=R7eowai2y+VbmwRDn3Qweuv1aybUe/OYdwYOwzc2C6 eHhOM9GQeDsq7vO1hFRUKxiej10qWTEs+ZUipFPDW4vkVpFIb1QrnNacEE1/fyxn U2G0wtSxdopiL6YynDW5UELj7tFSBJsRswUnLytSoqEi90+U0Vvs74kpA6aRIfZp E= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding: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=A+7MJU Be9FDGb4LocK7m7qYVX3MzOqAb/dnELoEwqKw=; b=D3hA8TVSS9SgMLjWOkROS9 HfOxa7YqIxoDVmWjgNE6LeVxDlhj2eP0mzaLoHVc66SKQnIarmbWFZoQfbzHliD2 xR1XLTheUEEryW12NPev7UpX6649dVEimBwNPr4d0cApxHyzN6CwIKNl1W86aFKm qii2lvxAJTex7eaKEKA0Cz9iIAlGEEbvDQl8jYSSS49vSXmMBxYpym5Ixi6OvI4/ 6tOybWM7GDd5VKBV48B7JEyoW33h9vWLU0PzLA8y+5kUknApbf5+SsKQOro5558I Jm8Cpj4KE1GK/L8AmOQBHfQAh1sS5d01gxoraLfc6tmlMQCibRdsNvIHcMT1sSAg == X-ME-Sender: Received: from [10.10.197.86] (unknown [31.6.55.187]) by mail.messagingengine.com (Postfix) with ESMTPA id 6D5B1E463E for ; Thu, 10 May 2018 06:19:39 -0400 (EDT) From: Ben Hood Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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 11:19:36 +0100 References: <06EAD729-DC35-4E48-AB25-C42F7FA19C28@relops.com> To: pgsql-general@lists.postgresql.org In-Reply-To: Message-Id: <188A0270-0A9A-4ADE-A928-9067E99AE7B7@relops.com> X-Mailer: Apple Mail (2.3445.6.18) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk > On 10 May 2018, at 09:59, Francisco Olarte = wrote: >=20 > On Thu, May 10, 2018 at 10:03 AM, Ben Hood wrote: > ... >> Am I missing the point of how Postgres stores TIMEZONE WITH TIME ZONE >> internally? >=20 > After reading in the follow up TIMEZONE is a typo for TIMESTAMP, yes, = you are. >=20 > Aproximately, postgres stores ( virtually ) a point in the time line, > for both with and without ts types, same format. Something like a real > number. >=20 > The difference is mainly for transforming from/to text ( bear in mind > when you put a constant in a query you are trasnforming from text ). > In the with time zone case it formats/expects it as a time string in > the session configured time zone, in the without case it treats it ( > aproximately ) as if it was in utc ( and then discards the "+00" after > formating ). >=20 > Maybe I'm confussing you more, its not too easy to explain. >=20 > The point is TIMEZONE is not stored in either of them. Many thanks for clarification, very much appreciated. Your point is consistent with the manual: =E2=80=9CAll timezone-aware = dates and times are stored internally in UTC=E2=80=9D The subtleties of how a TIMESTAMP WITH TIME ZONE is stored versus how it = is rendered by a client or used in calculations and queries have been = discussed in numerous places. On reflection, maybe my question was phrased badly. The question should not be =E2=80=9Chow does Postgres store the = timestamp internally=E2=80=9D. Rather it should read =E2=80=9Cis enforcing the submission of UTC = denominated timestamps in the server by using a domain a sensible way to = enforce a policy that will blow up when apps attempt to use non-UTC = timestamps (when they shouldn=E2=80=99t be)=E2=80=9D. So the question is not how does the timestamp get stored, rather, is it = an anti-pattern to use Postgres as a linter for apps that forget to use = UTC exclusively?