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.96) (envelope-from ) id 1wHUnO-007EMf-1p for pgsql-hackers@arkaria.postgresql.org; Mon, 27 Apr 2026 22:51:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wHUnN-00FDlx-1P for pgsql-hackers@arkaria.postgresql.org; Mon, 27 Apr 2026 22:51:17 +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.96) (envelope-from ) id 1wHUnN-00FDlg-0T for pgsql-hackers@lists.postgresql.org; Mon, 27 Apr 2026 22:51:17 +0000 Received: from smtp77.iad3a.emailsrvr.com ([173.203.187.77]) by makus.postgresql.org with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wHUnK-0000000363V-20hv for pgsql-hackers@lists.postgresql.org; Mon, 27 Apr 2026 22:51:15 +0000 X-Auth-ID: xof@thebuild.com Received: by smtp18.relay.iad3a.emailsrvr.com (Authenticated sender: xof-AT-thebuild.com) with ESMTPSA id 5F6B8251D7; Mon, 27 Apr 2026 18:51:13 -0400 (EDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3776.700.51.11.8\)) Subject: Re: uuidv7 improperly accepts dates before 1970-01-01 From: Christophe Pettus In-Reply-To: <966B5430-8ECD-48FA-B56F-22452D9CDBBF@yandex-team.ru> Date: Mon, 27 Apr 2026 15:51:12 -0700 Cc: pgsql-hackers@lists.postgresql.org Content-Transfer-Encoding: quoted-printable Message-Id: References: <799A70FA-6E5C-4118-99EB-2FBBE1CBAC54@thebuild.com> <966B5430-8ECD-48FA-B56F-22452D9CDBBF@yandex-team.ru> To: Andrey Borodin X-Mailer: Apple Mail (2.3776.700.51.11.8) X-Classification-ID: 648b8035-7503-41ec-a01b-8bc38ce56a06-1-1 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, Andrey, Thanks for the response! I'm moving it to -hackers since it's not = really a bug related conversation at this point. (resending with the = right list this time!) > On Apr 25, 2026, at 05:26, Andrey Borodin = wrote: > We consulted with RFC authors > about this feature, and they confirmed that shifting time is compliant = with RFC wording. Time shifting doesn't automatically imply allowing a pre-epoch input = time to construct a UUIDv7, though, just that you can construct a UUIDv7 = with something other than wall-clock time. > We wrote the specific test that ensures vast space for shift, but not = unlimited. That's another problem: the API gives the impression of a much larger = space than actually exists. # select uuidv7('100000 years'::interval); # ~11.2 x total time range = in a UUID v7. uuidv7 =20 -------------------------------------- 37b45c74-469d-7e1b-9397-1a971a99ab2b (1 row) At a minimum, it should reject a shift that creates a time later than a = UUID v7 can represent. > Time shifting would become a footgun if we throw an exception when = overflown. I don't understand why. If the concern is that someone will pick a = value that's close to the maximum, and get a surprising exception when = the time overflows that, the right answer is to caution them not to do = that rather than permit the wraparound. And is anyone actually doing this? Using a very large interval with a = large enough number of shards that wraparound is a real possibility? = (In that case, I'd argue they should construct the 48 bit field directly = rather than kind of dancing around it by using a time shift.)=