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 1rQYyz-0026hA-35 for pgsql-hackers@arkaria.postgresql.org; Thu, 18 Jan 2024 20:27:26 +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 1rQYyy-005K8R-9D for pgsql-hackers@arkaria.postgresql.org; Thu, 18 Jan 2024 20:27:24 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rQYyx-005K8J-Rc for pgsql-hackers@lists.postgresql.org; Thu, 18 Jan 2024 20:27:23 +0000 Received: from mail.ltc.pl ([194.24.180.24]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rQYyq-002WAs-0d for pgsql-hackers@postgresql.org; Thu, 18 Jan 2024 20:27:22 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.ltc.pl (Postfix) with ESMTP id 11A78DF9BB; Thu, 18 Jan 2024 21:27:14 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sztoch.pl; s=mail; t=1705609634; bh=tNyG9Vs/xkA6CFHYuOHDOEBJP8eV5qNP6qP82tG1a6o=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=hX8e4KOd52ahY6O2+Isxs+A0EsiR1E+Pp1WdPRpO3tQQHNRjAoYYq/y90XciKe72v Rrki9TsJgrKGNbBANg46w3XPYz0jHR51Zq0H7PPkD1PwPHctrQB6jKWIcwwuXwfCfh 6qPTmEcREgdjJTK5sZRZZCdARSDtWIdRkCtONtRuSp+wDiwWPsUEXM3VfIzwJ52Xh8 nO+SAozAJr3TrBovOHqy25y6TDe0MLRm2vz0uPL14VQjX5Ag/g89SID9tsKxf9TFui xydFFtxk5Sz0FU/d0Ra/yjcieWWNkfkYxwH+7/a9vjQ+5PqIlDhaBxLrXyjdKabEfk tHxcMGhree0qA== X-Virus-Scanned: Debian amavisd-new at mail.ltc.pl Received: from mail.ltc.pl ([127.0.0.1]) by localhost (mail.ltc.pl [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id yWea6t5qTNdA; Thu, 18 Jan 2024 21:26:56 +0100 (CET) Received: from [192.168.56.98] (fu182.internetdsl.tpnet.pl [80.53.46.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.ltc.pl (Postfix) with ESMTPSA; Thu, 18 Jan 2024 21:26:56 +0100 (CET) Subject: Re: UUID v7 To: Andrey Borodin Cc: Jelte Fennema-Nio , Sergey Prokhorenko , Aleksander Alekseev , pgsql-hackers mailing list , Nick Babadzhanian , Mat Arye , Peter Eisentraut , Tom Lane , Daniel Gustafsson , Matthias van de Meent , Nikolay Samokhvalov , "Kyzer Davis (kydavis)" , Andres Freund , "brad@peabody.io" , Kirk Wolak References: <6941A45B-C7D4-414B-A3A9-ACED172DFBD5@yandex-team.ru> <8DB43887-CA09-4845-83C0-33E8A79D0711@yandex-team.ru> <80E8F728-FC9C-461E-9B61-332E3AAEC066@yandex-team.ru> <2ECBCFF4-57A5-4484-B6D3-872596E40654@yandex-team.ru> <1199536369.1612345.1705423753699@mail.yahoo.com> <5BC4E87A-C6BA-47D6-B723-1F1AABEC09BC@yandex-team.ru> <1ED19D0E-BDA6-4B1B-9722-2322B69CE151@yandex-team.ru> From: =?UTF-8?Q?Przemys=c5=82aw_Sztoch?= Message-ID: <4c8be215-cdf6-e9e5-f9bb-d0eeaa58ad9b@sztoch.pl> Date: Thu, 18 Jan 2024 21:26:55 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 PostboxApp/7.0.60 MIME-Version: 1.0 In-Reply-To: <1ED19D0E-BDA6-4B1B-9722-2322B69CE151@yandex-team.ru> Content-Type: multipart/alternative; boundary="------------F6F08CB93CF1BC6F9EE9CF5E" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------F6F08CB93CF1BC6F9EE9CF5E Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Using localtime would be absurd. Especially since time goes back during summer time change. I believe our implementation should use UTC. No one forbids us from assuming that our local time for generating uuid is UTC. Andrey Borodin wrote on 1/18/2024 2:17 PM: > >> On 17 Jan 2024, at 02:19, Jelte Fennema-Nio wrote: > I want to ask Kyzer or Brad, I hope they will see this message. I'm working on the patch for time extraction for v1, v6 and v7. > > Do I understand correctly, that UUIDs contain local time, not UTC time? For examples in [0] I see that "A.6. Example of a UUIDv7 Value" I see that February 22, 2022 2:22:22.00 PM GMT-05:00 results in unix_ts_ms = 0x017F22E279B0, which is not UTC, but local time. > Is it intentional? Section "5.1. UUID Version 1" states otherwise. > > If so, I should swap signatures of functions from TimestampTz to Timestamp. > I'm hard-coding examples from this standard to tests, so I want to be precise... > > If I follow the standard I see this in tests: > +-- extract UUID v1, v6 and v7 timestamp > +SELECT uuid_extract_time('C232AB00-9414-11EC-B3C8-9F6BDECED846') at time zone 'GMT-05'; > + timezone > +-------------------------- > + Wed Feb 23 00:22:22 2022 > +(1 row) > > Current patch version attached. I've addressed all other requests: function renames, aliases, multiple functions instead of optional params, cleaner catalog definitions, not throwing error when [var,ver,time] value is unknown. > What is left: deal with timezones, improve documentation. > > > Best regards, Andrey Borodin. > > [0] https://datatracker.ietf.org/doc/html/draft-ietf-uuidrev-rfc4122bis#name-example-of-a-uuidv1-value -- Przemysław Sztoch | Mobile +48 509 99 00 66 --------------F6F08CB93CF1BC6F9EE9CF5E Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit Using localtime would be absurd. Especially since time goes back during summer time change.
I believe our implementation should use UTC. No one forbids us from assuming that our local time for generating uuid is UTC.

Andrey Borodin wrote on 1/18/2024 2:17 PM:

On 17 Jan 2024, at 02:19, Jelte Fennema-Nio <postgres@jeltef.nl> wrote:
I want to ask Kyzer or Brad, I hope they will see this message. I'm working on the patch for time extraction for v1, v6 and v7.

Do I understand correctly, that UUIDs contain local time, not UTC time? For examples in [0] I see that "A.6. Example of a UUIDv7 Value" I see that February 22, 2022 2:22:22.00 PM GMT-05:00 results in unix_ts_ms = 0x017F22E279B0, which is not UTC, but local time.
Is it intentional? Section "5.1. UUID Version 1" states otherwise.

If so, I should swap signatures of functions from TimestampTz to Timestamp.
I'm hard-coding examples from this standard to tests, so I want to be precise...

If I follow the standard I see this in tests:
+-- extract UUID v1, v6 and v7 timestamp
+SELECT uuid_extract_time('C232AB00-9414-11EC-B3C8-9F6BDECED846') at time zone 'GMT-05';
+         timezone         
+--------------------------
+ Wed Feb 23 00:22:22 2022
+(1 row)

Current patch version attached. I've addressed all other requests: function renames, aliases, multiple functions instead of optional params, cleaner catalog definitions, not throwing error when [var,ver,time] value is unknown.
What is left: deal with timezones, improve documentation.


Best regards, Andrey Borodin.

[0] https://datatracker.ietf.org/doc/html/draft-ietf-uuidrev-rfc4122bis#name-example-of-a-uuidv1-value

--
Przemysław Sztoch | Mobile +48 509 99 00 66
--------------F6F08CB93CF1BC6F9EE9CF5E--