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 1wGc6H-006P76-1Y for pgsql-bugs@arkaria.postgresql.org; Sat, 25 Apr 2026 12:27:10 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wGc6G-008zHd-0I for pgsql-bugs@arkaria.postgresql.org; Sat, 25 Apr 2026 12:27:08 +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.96) (envelope-from ) id 1wGc6F-008zHV-2F for pgsql-bugs@lists.postgresql.org; Sat, 25 Apr 2026 12:27:07 +0000 Received: from forwardcorp1d.mail.yandex.net ([178.154.239.200]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wGc6D-00000002z1F-0w4s for pgsql-bugs@lists.postgresql.org; Sat, 25 Apr 2026 12:27:07 +0000 Received: from mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net [IPv6:2a02:6b8:c42:65a0:0:640:e1de:0]) by forwardcorp1d.mail.yandex.net (Yandex) with ESMTPS id F28FE80758; Sat, 25 Apr 2026 15:27:03 +0300 (MSK) Received: from smtpclient.apple (unknown [2a02:6bf:8080:7a8::1:37]) by mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net (smtpcorp) with ESMTPSA id 2RVKlR0MhOs0-V9Ds4N9w; Sat, 25 Apr 2026 15:27:03 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1777120023; bh=E8x9MLVZY8tE8vmACNcL/FjNBhctLxtBjqq/pnFz6SI=; h=Message-Id:To:Date:References:Cc:In-Reply-To:From:Subject; b=TZyxjnwnLDrXvY4Gm8V5AynwoFXruU8/eC78IKLn7uNGnK5L2AEb+EKqqRM9yRrq6 TZWj6nWyqPOFVP0TxcJqrUbWBCQZS3EnGd08gnL/eSvOlFupfv1Wx4qkBctSu3jvnO 4KposbIRrkuvwtpSp8xD7VeE5lgeXQ/YEPe+VGUU= Authentication-Results: mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3864.500.181\)) Subject: Re: uuidv7 improperly accepts dates before 1970-01-01 From: Andrey Borodin In-Reply-To: <799A70FA-6E5C-4118-99EB-2FBBE1CBAC54@thebuild.com> Date: Sat, 25 Apr 2026 17:26:51 +0500 Cc: PostgreSQL mailing lists Content-Transfer-Encoding: quoted-printable Message-Id: <966B5430-8ECD-48FA-B56F-22452D9CDBBF@yandex-team.ru> References: <799A70FA-6E5C-4118-99EB-2FBBE1CBAC54@thebuild.com> To: Christophe Pettus X-Mailer: Apple Mail (2.3864.500.181) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On 25 Apr 2026, at 05:19, Christophe Pettus wrote: >=20 > "Don't do that" is one answer, but for good hygiene, here's a patch = that adds a < 0 check and a regression test. Hi Christophe! We intentionally left ability to overflow unix_ts_ms bits. In some cases = one might want to intentionally break time locality by using construction like SELECT = uuidv7(INTERVAL '1000 years' * shard_id); This will give time locality for UUIDs generated on each shard. We = consulted with RFC authors about this feature, and they confirmed that shifting time is compliant = with RFC wording. We wrote the specific test that ensures vast space for shift, but not = unlimited. Time shifting would become a footgun if we throw an exception when = overflown. If you use SELECT uuidv7(INTERVAL '-1000 years'); for generating = identifiers, they will still be unique and time-local, and more over - they will be ascending for a single backend. = So no documented guarantees are broken. Thank you! Best regards, Andrey Borodin.=