Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sKf8v-00BVu3-KQ for pgsql-bugs@arkaria.postgresql.org; Fri, 21 Jun 2024 14:21:33 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1sKf8t-001uqR-Do for pgsql-bugs@arkaria.postgresql.org; Fri, 21 Jun 2024 14:21:31 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sKf8t-001ulD-4W for pgsql-bugs@lists.postgresql.org; Fri, 21 Jun 2024 14:21:31 +0000 Received: from momjian.us ([72.94.173.45]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sKf8q-002QPS-Fp for pgsql-bugs@lists.postgresql.org; Fri, 21 Jun 2024 14:21:30 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=momjian.us; s=2024011501; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID: Subject:To:From:Date:Sender:Reply-To:Cc:Content-Transfer-Encoding:Content-ID: Content-Description; bh=U0O3dpkwuNdNxud7v2j9/zquTnXMstPM5/30bse5K4M=; b=ME3ac hqZdoBKyVdXGRIDf7ZZe8eCymLkuQeTV1/6DFbDZmtrPRiibLmj/2COKZ7r4wVvij/3t2KhfaHFJb u1cWYbe1Mmv7F8633QW/rbXKviEOvIVxnYrwSxr0Z1AKviNGvLG2MQEj7GbkZx83t8Wkwz4AoSLre dxnhxIcbuqvFxPuSAV80tlF1Zft0Bw7hGz2Y7F1D2R9ZnEUxWcxXFHB8HmTB808nJOgBnyL+ld6Mj qblKn/3POXDyVzQXsOYuNB1odGR1ikMtCw5q9Hi3mqLzM7oIwIpHLM08ERUY/ASvOM+koXSMGsPz+ GEMtEq8LglUBPQj2iV98Jp6VBmfHQ==; Received: from bruce by momjian.us with local (Exim 4.96) (envelope-from ) id 1sKf8n-005B94-39; Fri, 21 Jun 2024 10:21:25 -0400 Date: Fri, 21 Jun 2024 10:21:25 -0400 From: Bruce Momjian To: nicola.oricchio@vertigis.com, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #18518: ::timestamp add minutes and seconds to the converted values Message-ID: References: <18518-e16f6cc69c9ce413@postgresql.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <18518-e16f6cc69c9ce413@postgresql.org> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, Jun 20, 2024 at 03:33:29PM +0000, PG Bug reporting form wrote: > The following bug has been logged on the website: > > Bug reference: 18518 > Logged by: Nicola Oricchio > Email address: nicola.oricchio@vertigis.com > PostgreSQL version: 12.18 > Operating system: Ubuntu > Description: > > repro: > create table aaa (dat timestamp without time zone); > insert into aaa values ('1892-12-31 23:00:00'); > insert into aaa values ('1893-12-31 23:00:00'); > insert into aaa values ('1992-12-31 13:33:12'); > select dat, (dat at time zone 'utc')::timestamp without time zone from aaa > order by 1; > > output: > dat | timezone > ---------------------+--------------------- > 1892-12-31 23:00:00 | 1893-12-31 23:53:28 <-- it should be 1893-01-01 > 00:00:00 > 1893-12-31 23:00:00 | 1894-01-01 00:00:00 > 1992-12-31 13:33:12 | 1992-12-31 14:33:12 > > it works correctly with 12.2 > dat | timezone > ---------------------+--------------------- > 1892-12-31 23:00:00 | 1893-01-01 00:00:00 > 1893-12-31 23:00:00 | 1894-01-01 00:00:00 > 1992-12-31 13:33:12 | 1992-12-31 14:33:12 > > time zone is CET I just ran your test on PG 12.19, and got the right results in the US/Eastern time zone: $ psql test psql (12.19) Type "help" for help. test=> SELECT version(); version -------------------------------------------------------------------------------------------- PostgreSQL 12.19 on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit (1 row) create table aaa (dat timestamp without time zone); insert into aaa values ('1892-12-31 23:00:00'); insert into aaa values ('1893-12-31 23:00:00'); insert into aaa values ('1992-12-31 13:33:12'); select dat, (dat at time zone 'utc')::timestamp without time zone from aaa order by 1; dat | timezone ---------------------+--------------------- 1892-12-31 23:00:00 | 1892-12-31 18:00:00 1893-12-31 23:00:00 | 1893-12-31 18:00:00 1992-12-31 13:33:12 | 1992-12-31 08:33:12 I am guessing that your time zone database changed in 12.18 as mentioned in the 12.18 release notes: Author: Tom Lane Branch: master [272a7c303] 2024-02-01 15:57:53 -0500 Branch: REL_16_STABLE [b4fb76fb5] 2024-02-01 15:57:53 -0500 Branch: REL_15_STABLE [970b1aeeb] 2024-02-01 15:57:53 -0500 Branch: REL_14_STABLE [35b8b2c4a] 2024-02-01 15:57:53 -0500 Branch: REL_13_STABLE [ac3afc3f7] 2024-02-01 15:57:53 -0500 Branch: REL_12_STABLE [b59ae79b7] 2024-02-01 15:57:53 -0500 Update time zone data files to tzdata release 2024a for DST law changes in Greenland, Kazakhstan, and Palestine, plus corrections for the Antarctic stations Casey and Vostok. Also historical corrections for Vietnam, Toronto, and Miquelon. I would look at changes in the $PG_INSTALLDIR/share/timezonesets/ files for your session timezone value to see the changes that happened between those two releases. There are other time zone updates in other 12.* releases so I don't know which one affected you. If you download 12.2 and 12.18 and do a diff of $PG_INSTALLDIR/share/timezonesets/ you should see the changes. -- Bruce Momjian https://momjian.us EDB https://enterprisedb.com Only you can decide what is important to you.