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 1fH23x-0001Ep-47 for pgsql-general@arkaria.postgresql.org; Fri, 11 May 2018 07:01:57 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fH23v-0001hD-8x for pgsql-general@arkaria.postgresql.org; Fri, 11 May 2018 07:01:55 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fH23u-0001h4-R5 for pgsql-general@lists.postgresql.org; Fri, 11 May 2018 07:01:55 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fH23q-0006km-8o for pgsql-general@lists.postgresql.org; Fri, 11 May 2018 07:01:53 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id C894F21649; Fri, 11 May 2018 03:01:48 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Fri, 11 May 2018 03:01:48 -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=ptbeIIOxe14dlkyD8OxtXSS5/I VYBGhMa5bJYXjD7cg=; b=mKnveZM+EV1iea/6a/TI0ZK2S+z1V0f6fkMTSYXwb4 lgOaO8Se8J3Vmbplb+D9iATWGJ8O808aVU7CJ3aZ6UTmclBUzMrDhn0ZAWGvBLKx uooNa/JP2yZy2iV4guyXzqX1tM0EAMjO5M7cX1D+pP2KKPOUwboUz5Ye1sN1L9y6 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=ptbeII Oxe14dlkyD8OxtXSS5/IVYBGhMa5bJYXjD7cg=; b=HVUpjJW0NSD5WUQRc5sZnc Btd0A0PaFLutydPrHYTZPANC+pq5/fG+yrglMSuXqfj1WYfZUdvYpvr7zaYkqQ8f UmBQiBHJTbeKz/gNb3F4t+YU1DcMk1BqH8iqresWNNzdkO+k9Wt2mADc4hUD5g+n cXWUeTKl/JYgf5N+JjOVEq5Ar26PxcsA0Ogxbuw0u/L6OPdCWBwo8sX+FlSOJxlY cf4dMeTz2tqefOjnJA+idqBL5B+r60mOQDygNngUrqBqhE6Ey8yo9ZxdaTU6/lNi HKrnaEAYJASO3DDkfYPYl5qRCIycRAx9D9hQNuYQ3QUCF6Xw8QKNmOnA3AeOmqaA == X-ME-Sender: Received: from [10.10.197.93] (unknown [31.6.55.55]) by mail.messagingengine.com (Postfix) with ESMTPA id 300FD1025C for ; Fri, 11 May 2018 03:01:48 -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: Fri, 11 May 2018 08:01:45 +0100 References: <06EAD729-DC35-4E48-AB25-C42F7FA19C28@relops.com> <188A0270-0A9A-4ADE-A928-9067E99AE7B7@relops.com> <20180510211741.icfg5xyqjkdvgmgj@hjp.at> To: pgsql-general@lists.postgresql.org In-Reply-To: <20180510211741.icfg5xyqjkdvgmgj@hjp.at> Message-Id: 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 22:17, Peter J. Holzer wrote: >=20 > 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=E2=80=99; 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.