From: Karsten Hilbert <Karsten.Hilbert@gmx.net>
To: pgsql-general@lists.postgresql.org
Subject: Re: Domain based on TIMEZONE WITH TIME ZONE
Date: Thu, 10 May 2018 12:36:08 +0200
Message-ID: <20180510103608.GB3622@hermes.hilbert.loc> (raw)
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>
On Thu, May 10, 2018 at 11:19:36AM +0100, Ben Hood wrote:
> 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?
I dare say it is one of PG's strengths' to be usable as a
"linter".
However, maybe rephrase to:
Is it an anti-pattern to use Postgres as a linter for
apps that forget to use ... timezones *appropriately* ... ?
As long as you can force apps to submit proper timestamp-with-
timezone data is there _really_ a need to care whether apps
do submit in UTC ? After all, it is always converted to UTC
servside anyway ?
In case you want to enforce only ever _handing out_ UTC data
you could wrap the table in a view with forces the output
timezone to UTC and only offers timestamp-withOUT-timezone to
the outside. Then force read access via the view.
Karsten
--
GPG key ID E4071346 @ eu.pool.sks-keyservers.net
E167 67FD A291 2BEA 73BD 4537 78B9 A9F9 E407 1346
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: Karsten.Hilbert@gmx.net
Subject: Re: Domain based on TIMEZONE WITH TIME ZONE
In-Reply-To: <20180510103608.GB3622@hermes.hilbert.loc>
References: <06EAD729-DC35-4E48-AB25-C42F7FA19C28@relops.com> <CA+bJJbz0Gwo8mkyzHa_4qjcNcMV0M00yTZ_LjUtaJu=M=+bpyQ@mail.gmail.com> <188A0270-0A9A-4ADE-A928-9067E99AE7B7@relops.com> <20180510103608.GB3622@hermes.hilbert.loc>
* 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