Re: Domain based on TIMEZONE WITH TIME ZONE

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: Ben Hood <ben(at)relops(dot)com>, pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Domain based on TIMEZONE WITH TIME ZONE
Date: 2018-05-10 17:29:00
Message-ID: f71d464b-2469-2f27-85a6-54c64b061bd5@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 05/10/2018 09:13 AM, Ben Hood wrote:
>
>> On 10 May 2018, at 15:12, Vick Khera <vivek(at)khera(dot)org
>> <mailto:vivek(at)khera(dot)org>> wrote:
>>
>> On Thu, May 10, 2018 at 7:31 AM, Ben Hood <ben(at)relops(dot)com
>> <mailto:ben(at)relops(dot)com>> wrote:
>>
>> Or are we saying that domains are one way of achieving the
>> timestamp hygiene, but equally, you can get the same result as
>> described above?
>>
>>
>> The *only* way to have timestamp hygiene is to require them to have
>> time zones at all times, even if that time zone is UTC. Any other
>> representation of a time is ambiguous without context.
>
> That makes sense.
>
> The motivation behind narrowing the built in TIMESTAMP WITH TIME ZONE
> down to a domain is to ensure the only permissible zone offset is UTC.
> This would be unambiguous.

Per my previous post a timestamp with timezone is going to be stored as
UTC, so there is no ambiguity there. On reflection I realized your
concern maybe with determining the original input timezone. That
information is not stored by Postgres, so there can be ambiguity as to
their value. Doing all timestamps in UTC is one one way to eliminate
this. The potential issue I see is that you now push the ambiguity into
the app. Namely just from looking at the database values you still do
not know what the original timezone the app lives in is.

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2018-05-10 18:41:26 Re: Selecting strict, immutable text for a composite type.
Previous Message Adrian Klaver 2018-05-10 16:38:42 Re: Domain based on TIMEZONE WITH TIME ZONE