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 11:19:36 +0100
Message-ID: <188A0270-0A9A-4ADE-A928-9067E99AE7B7@relops.com> (raw)
In-Reply-To: <CA+bJJbz0Gwo8mkyzHa_4qjcNcMV0M00yTZ_LjUtaJu=M=+bpyQ@mail.gmail.com>
References: <06EAD729-DC35-4E48-AB25-C42F7FA19C28@relops.com>
<CA+bJJbz0Gwo8mkyzHa_4qjcNcMV0M00yTZ_LjUtaJu=M=+bpyQ@mail.gmail.com>
> On 10 May 2018, at 09:59, Francisco Olarte <folarte@peoplecall.com> wrote:
>
> On Thu, May 10, 2018 at 10:03 AM, Ben Hood <ben@relops.com> wrote:
> ...
>> Am I missing the point of how Postgres stores TIMEZONE WITH TIME ZONE
>> internally?
>
> After reading in the follow up TIMEZONE is a typo for TIMESTAMP, yes, you are.
>
> Aproximately, postgres stores ( virtually ) a point in the time line,
> for both with and without ts types, same format. Something like a real
> number.
>
> 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 ).
>
> Maybe I'm confussing you more, its not too easy to explain.
>
> 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: “All timezone-aware dates and times are stored internally in UTC”
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 “how does Postgres store the timestamp internally”.
Rather it should read “is 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’t be)”.
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?
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: <188A0270-0A9A-4ADE-A928-9067E99AE7B7@relops.com>
References: <06EAD729-DC35-4E48-AB25-C42F7FA19C28@relops.com> <CA+bJJbz0Gwo8mkyzHa_4qjcNcMV0M00yTZ_LjUtaJu=M=+bpyQ@mail.gmail.com> <188A0270-0A9A-4ADE-A928-9067E99AE7B7@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