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 1fGoLK-0003uX-Il for pgsql-general@arkaria.postgresql.org; Thu, 10 May 2018 16:22:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fGoLJ-0006zR-7x for pgsql-general@arkaria.postgresql.org; Thu, 10 May 2018 16:22:57 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fGoLI-0006zI-VL for pgsql-general@lists.postgresql.org; Thu, 10 May 2018 16:22:57 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fGoLE-0003co-D4 for pgsql-general@lists.postgresql.org; Thu, 10 May 2018 16:22:56 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id D23F22299F; Thu, 10 May 2018 12:22:50 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Thu, 10 May 2018 12:22:50 -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=pflo078fDZSn8K7+anMIryarRI u9xAjfXEztOg1gHRM=; b=AoPlNmYJwdpsajhE8xy9nSrqRXI0E2lgdkmFqtdKBh wu3lDR56ZM1MwmOrNV+e6FhsFzEagu+9UvdqCk+wS0MgBRSiKOsOwSglicx9IhCk F52GNK49iCCXodMRao1y66tn81zXBW1PGxgtThThOVQ3SHQz3u19X+gVFieEAHt0 Q= 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=pflo07 8fDZSn8K7+anMIryarRIu9xAjfXEztOg1gHRM=; b=GcHawwsfAj4FRGOGI0DBox BbfAKAIWxe7mDieWEApgurE/mOdX+x46/XwObrzJLxnsniUXdInn4HbgiGSekIAE Azyh0gq9QBQj2OagCOHd8wbPTW1PeZg2tytYA8NRtRO2jGV12klaARLn6ZV89L/c zW2FmrfKnFpazI6YqNl9MrjZgmvPE/uSRrAFLlZHnPuh+kKHbXOXWdtufpePeZ1S oK+Dp7hdOwvuxTg8I/GGMgM4zOUmjGe/0Qc+J54Og0GNtwmtPKmuw+n1BM0J6Jpi oPXh5EOvZUfOA7J3W0V1YX2k5lb+tIpeVn/0zldAuKGrqnHm2Li8A3+LSCeWQrYQ == X-ME-Sender: Received: from [192.168.15.94] (unknown [161.12.41.14]) by mail.messagingengine.com (Postfix) with ESMTPA id 5B239E47A0 for ; Thu, 10 May 2018 12:22:50 -0400 (EDT) From: Ben Hood Content-Type: text/plain; charset=us-ascii 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: Thu, 10 May 2018 17:22:49 +0100 References: <06EAD729-DC35-4E48-AB25-C42F7FA19C28@relops.com> <188A0270-0A9A-4ADE-A928-9067E99AE7B7@relops.com> <20180510103608.GB3622@hermes.hilbert.loc> <20180510141721.GE3622@hermes.hilbert.loc> To: pgsql-general@lists.postgresql.org In-Reply-To: <20180510141721.GE3622@hermes.hilbert.loc> Message-Id: <46C4DE46-4F28-43CB-BF2D-FB47822BDD9D@relops.com> 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 15:17, Karsten Hilbert = wrote: >=20 >> Not really: >>=20 >> https://www.postgresql.org/docs/10/static/datatype-datetime.html >>=20 >> "For timestamp with time zone, the internally stored value is always = in UTC >> (Universal Coordinated Time, traditionally known as Greenwich Mean = Time, >> GMT). An input value that has an explicit time zone specified is = converted >> to UTC using the appropriate offset for that time zone. If no time = zone is >> stated in the input string, then it is assumed to be in the time zone >> indicated by the system's TimeZone parameter, and is converted to UTC = using >> the offset for the timezone zone." >=20 > True enough, I didn't remember that behaviour. >=20 > And since a BEFORE UPDATE/INSERT trigger will see the data to > be inserted PG will have already done that while parsing from > on-the-wire data into in-memory ts-w-tz presentation so we > can't simply use a trigger to enforce explicit specification > of a timezone. >=20 > Therefore, a domain could work but will require client > language support for easy integration. For reference, the domain based solution has been working for a while. It has fleshed out bugs in apps that failed to set the zone either on = the session level at the field level. In those circumstances, the server raised an exception to say that a = non-UTC timestamp was submitted. It could have been the timestamp had a specific zone other than UTC. In = this case, the behavior would be that Postgres stores it as UTC and = therefore all is good. But it also would be that a timestamp WITHOUT a zone was submitted, in = which case, the server default would take precedence. >=20 >>> And because of the internal UTC representation, there is no room for = ambiguous timezones. >>=20 >> Define ambiguous timezone? >=20 > OP likely means underspecified for his use case (=3D not > assuming "unspecified" to mean "TimeZone value"). But, then, > OP could always force TimeZone to UTC on his servers :-) That is what the OP meant. That the zone value was not explicit in all = cases. For example, if you fallback to the server default. And yes, the OP could have set UTC both on the DB servers (assuming OP = controls them) and within each server app (assuming OP controls them).