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 1fGoaj-00052J-HZ for pgsql-general@arkaria.postgresql.org; Thu, 10 May 2018 16:38:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fGoai-0005UE-AR for pgsql-general@arkaria.postgresql.org; Thu, 10 May 2018 16:38:52 +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 1fGoah-0005Od-4w for pgsql-general@lists.postgresql.org; Thu, 10 May 2018 16:38:52 +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 1fGoab-0003zb-IK for pgsql-general@lists.postgresql.org; Thu, 10 May 2018 16:38:50 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 5FBB620DF7; Thu, 10 May 2018 12:38:44 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Thu, 10 May 2018 12:38:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.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=VJtLKZadmbsfRo6J+rmURzgya/Pj8 iexrmX8PhQxEvU=; b=no/XaIegvdk4XfpX867SKG9XOSvzLdkfqg97D4TDUDuWE onkWdxeEGp9zk2B4EMiEihBUzBJotIGAhssLB8otCv2dcUGkthcE6M9GYvIMLP2q cY/Pg90Udc9YdYkb5b4Kk6iCBHf/y6TEGCRxZReew35HEMciFBHBjjyJUeLph5WR AlfkOpkHJFcI8vJRgXIgYXUSnHEqNVCWyvNa4SYycBIl2mAkUwOHu69cx1qR7pTi R4zdZ6FtM1SjPVyMg83m2UScpnijxYc0umLVpLF3QbSIYnkR9x5of1RHWySD8Apk xRhkROdJBrgqPPSy0e+ZRFF+1MgqRqTiYtwSQMblQ== 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=VJtLKZ admbsfRo6J+rmURzgya/Pj8iexrmX8PhQxEvU=; b=XhuZl8b2GfXRHqfb88HmNn XyCEHbAoWAzN+/ILup5MaREo7VfIkP5/0yTsQeC+9jN5vJ0qfx0zHkSFGj3E9G6P DNK2ltGyeQO/T41bCsS1pEZAS8K5eRblWxm3Yb5r73X+98FrEAGAvedJiwoiecPN OMAUnHAZCPIXvC3xjMsnMW5aQfRMtbgZCmPrQit0XSoTSek//TZDpRV4MbU8X7u4 EVKg8tVwo6uafX40L6zw6R6D9Ke16vQk7A+6hUm8/TjsW4zXPaxEe8+EaQ7dZQHV p5hNjINz7AlqqD/4Waw5x4Z/JQY/JUb6+CUgAaCMm1fEyuwRdBBO8B/DEpV/3Nnw == X-ME-Sender: Received: from ranger.suse (c-73-239-117-238.hsd1.wa.comcast.net [73.239.117.238]) by mail.messagingengine.com (Postfix) with ESMTPA id AF310E463E; Thu, 10 May 2018 12:38:43 -0400 (EDT) Subject: Re: Domain based on TIMEZONE WITH TIME ZONE To: Ben Hood , pgsql-general@lists.postgresql.org References: <06EAD729-DC35-4E48-AB25-C42F7FA19C28@relops.com> <188A0270-0A9A-4ADE-A928-9067E99AE7B7@relops.com> <20180510103608.GB3622@hermes.hilbert.loc> <5188949D-FEDD-45C6-85CA-2E2AAC5CF1C9@relops.com> From: Adrian Klaver Message-ID: <93d7120e-ca04-467f-4b55-a5ca0e8d255c@aklaver.com> Date: Thu, 10 May 2018 09:38:42 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <5188949D-FEDD-45C6-85CA-2E2AAC5CF1C9@relops.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 05/10/2018 09:09 AM, Ben Hood wrote: > >> On 10 May 2018, at 14:41, Adrian Klaver wrote: >>> OK, so by using TIMESTAMP WITH TIME ZONE, you force all apps to submit timezone qualified timestamps in what language they are written in. >> >> Not really: >> >> https://www.postgresql.org/docs/10/static/datatype-datetime.html >> >> "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.” > > > Many thanks for this clarification. So therefore you can’t rely on the TIMESTAMP WITH TIME ZONE forcing the app to explicitly specify the offset. This is is because if the app is not specific, then the server will default back to its configured timezone. > > So to get deterministic timestamps, you could either: > > a) make sure the server is always configured to run in UTC; > b) issue SET TIME ZONE ‘UTC’; at the beginning of any application session Well if you are using a timestamp with timezone field the value is always going to be stored as UTC. The TimeZone setting just determines the rotation from the input value to the stored value and the reverse. My previous point was just that Postgres will not enforce an offset on input data. > > > >> >>>> After all, it is always converted to UTC >>>> servside anyway ? >>> And because of the internal UTC representation, there is no room for ambiguous timezones. >> >> Define ambiguous timezone? > > What I meant to say that is there should be no possibility for an effective timezone to arise implicitly. > > For example, if you > > (1) didn’t control the db server config > > and > > (2) and you forgot to enforce UTC at a client driver level > > and > > (3) didn’t set the offset in the app session > > > Then the only way to know what the effective zone offset will be is to find out what the server default is. > > Is this plausible? If you mean find the server default then yes: test_(aklaver)> select current_setting('TimeZone'); current_setting ----------------- US/Pacific https://www.postgresql.org/docs/10/static/functions-admin.html#FUNCTIONS-ADMIN-SET > > > > -- Adrian Klaver adrian.klaver@aklaver.com