pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ben Hood <ben@relops.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: Domain based on TIMEZONE WITH TIME ZONE
Date: Fri, 11 May 2018 08:01:45 +0100
Message-ID: <A8DCC57B-9EDB-4F6C-9AC6-A9996296C551@relops.com> (raw)
In-Reply-To: <20180510211741.icfg5xyqjkdvgmgj@hjp.at>
References: <06EAD729-DC35-4E48-AB25-C42F7FA19C28@relops.com>
	<CA+bJJbz0Gwo8mkyzHa_4qjcNcMV0M00yTZ_LjUtaJu=M=+bpyQ@mail.gmail.com>
	<188A0270-0A9A-4ADE-A928-9067E99AE7B7@relops.com>
	<CA+bJJbyNTns-AMVUbztjb+zeNZ-z0gH=6vXykZCmjCJiK1GogA@mail.gmail.com>
	<D03AF820-9FFF-414F-8747-B3589FBB9224@relops.com>
	<20180510211741.icfg5xyqjkdvgmgj@hjp.at>



> On 10 May 2018, at 22:17, Peter J. Holzer <hjp-pgsql@hjp.at> wrote:
> 
> I don't understand how this can work. As Francisco demonstrated,
> EXTRACT(TIMEZONE FROM ts) doesn't extract the time zone from the value
> ts, it reports the offset of the client's time zone.


Yes, you and Francisco are right.

If you do:

set time zone 'UTC';
select '2018-05-10 23:17:44-02' :: utc_timestamp;

This will work. But if you change the client zone, it will not:

set time zone 'Asia/Pyongyang’;
select '2018-05-10 23:17:44-02' :: utc_timestamp;

[Code: , SQL State: 23514]  ERROR: value for domain utc_timestamp violates check constraint "utc_timestamp_check"


> What your check probably does is to enforce that the client's time zone
> is set to UTC.

Logically you must be right, given

(a) you cannot extract the zone from the stored value, because the stored value does not contain a zone
(b) the examples that only work when the session zone is set to UTC

Therefore the semantics of EXTRACT(TIMEZONE FROM ts) must rely on the session zone only.

Hence all the check does is to enforce the UTC zone.








view thread (36+ messages)  latest in thread

Message-ID: <A8DCC57B-9EDB-4F6C-9AC6-A9996296C551@relops.com>
Permalink:  ../A8DCC57B-9EDB-4F6C-9AC6-A9996296C551@relops.com/
Also on:    postgresql.org/message-id/A8DCC57B-9EDB-4F6C-9AC6-A9996296C551@relops.com

 · 

reply

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: <A8DCC57B-9EDB-4F6C-9AC6-A9996296C551@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> <CA+bJJbyNTns-AMVUbztjb+zeNZ-z0gH=6vXykZCmjCJiK1GogA@mail.gmail.com> <D03AF820-9FFF-414F-8747-B3589FBB9224@relops.com> <20180510211741.icfg5xyqjkdvgmgj@hjp.at> <A8DCC57B-9EDB-4F6C-9AC6-A9996296C551@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