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 1wcRrW-003M2p-0t for pgsql-hackers@arkaria.postgresql.org; Wed, 24 Jun 2026 17:58: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 1wcRrU-001wza-2q for pgsql-hackers@arkaria.postgresql.org; Wed, 24 Jun 2026 17:58: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 1wcRrU-001wzS-1m for pgsql-hackers@lists.postgresql.org; Wed, 24 Jun 2026 17:58:08 +0000 Received: from fout-a8-smtp.messagingengine.com ([103.168.172.151]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wcRrS-000000004Dr-0CwQ for pgsql-hackers@lists.postgresql.org; Wed, 24 Jun 2026 17:58:08 +0000 Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfout.phl.internal (Postfix) with ESMTP id 989DEEC02E1; Wed, 24 Jun 2026 13:58:03 -0400 (EDT) Received: from phl-imap-15 ([10.202.2.104]) by phl-compute-05.internal (MEProxy); Wed, 24 Jun 2026 13:58:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=partin.io; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm2; t=1782323883; x=1782410283; bh=FZBXWJ1Hg6zUE9Y0woqXecOzGeX5CE2FZGH9cx3x/vs=; b= T5icJRbgPUwQNHKngzS110WanOcibVMGbPyNacFexchGmKmiyDaS7DZD1LEdCe56 CseTbC7p1vc66+NCAW4gkp02ei0nJqfpGHEWFmTvu+5CW75jLLb/+5n6HGPxv1wv NWrQ4iUkT4KmkaLl8C2RvXzIgyNHO47pceH3S8W/8byYpixjMRVsHayZJ9qwf4kK pa8cJnT9YAHBw7VZ+pqNFP3yNZznatJm1Afm8FsVH/LyO8imksQ2LdMJyovn2pNG O0t81umoz1yUOYeMUJv7ar7dTzeDXVYZuw3bcOu+xF1v4x4+LLcnGmPlwNCi4CTl CkOW6PyDu7XTGDgjfcrKEA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1782323883; x= 1782410283; bh=FZBXWJ1Hg6zUE9Y0woqXecOzGeX5CE2FZGH9cx3x/vs=; b=Q yMjRfVh4o9UFQx4boCCm3HrGakNeb0BeJfR20pGWzyCWVULMbIrdztzbCY6x/CwV RDApxzcHrkNmPe8y2EfXzwKG5HTdkN5faxjJjsRRoDNoIDURHx7STJH5YxJjLJav HQHfo4VXKyET5m3ERWhC3xOztepQXRPfu7gUXciTedRPcpSxobn6gjFUqRfZDpTG c3fS9JN52b6C1MoCT/cw8NPlfV4uDGE0h75rv6IffmrJRqZUhTUN2JQ6/fyxlGPO xJ2aOYdIEv4efL0s2bGkBvXlm331xZO1Hzf6lH2gW3jL7Y7T/gVYNFXnkXgHUPO1 tHKHrDPEjwSzdXMDukXFg== X-ME-Sender: X-ME-Proxy-Cause: dmFkZTGE5momQfH6BG/CClk6soKUxQS8HXqkPwCB5izBWDgYd8CbpPzdXw3K4Bl0SmT+Tk kGBiVpdtW8cjtnuDkjAuG2igE/mcfqDXM6NtgJA2+773st+LCdbiTvlSUZbwxVpXYMII/R AeaHSlydsbOTKQJKG1PwNNP2q2y8lzztPTMZex7I3e/LWRpKTvm02/Hm5nJBhR7jopv5xh JYFYG0diDIowDiWCprnloudQoaHe0zfcuAgHVISctm2imo4fkP5LjbXiMIrKY9icKrXvmy yMvgxl8tHrEb2OuDJqCCZ2mQtmU+z7gGhL+JECJ5UWvbqcwDB3S9jJDjo2Z3U55BGwUmYr q1TyfurApTk4k7wSB6f/9Or7r8CyCQBjC0d9FFHOS0JFR4snX1Nie55FDzUjsAj08VwuOX I4feM+7GNfV5QuMyLDLea6cYLo7peZWhrebcUSiVxYSKrrtP04rhcEMM7k8ST4Bwx9Qx1m 0AHhahF5ePRmO5DKD8y6rsDvOIX3Hglgf8EzvGq3jN3KSvirz4qmkO41ZqrbvAOhSREPb6 W5SRTWnbytkrShy1oJq/WMMMCKcV0uBe7M7H+aLXRi5B9CNgm2EdV7MXJFVg3FKgD0KDg1 O3b4eLH4/++IWtsP3qr0Y4rBo7jOEaBJKlEsDcMD6+Px0eqsih7/j1iHugVw X-ME-Proxy: Feedback-ID: idd01497b:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id E1A44780AB5; Wed, 24 Jun 2026 13:58:02 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Wed, 24 Jun 2026 17:58:02 +0000 Message-Id: Subject: Re: uuidv7 improperly accepts dates before 1970-01-01 To: "Baji Shaik" From: "Tristan Partin" Cc: "Christophe Pettus" , "Andrey Borodin" , , "Masahiko Sawada" X-Mailer: aerc 0.21.0 References: <799A70FA-6E5C-4118-99EB-2FBBE1CBAC54@thebuild.com> <966B5430-8ECD-48FA-B56F-22452D9CDBBF@yandex-team.ru> In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri Jun 12, 2026 at 10:35 PM UTC, Baji Shaik wrote: > On Thu, Jun 11, 2026 at 2:20=E2=80=AFPM Masahiko Sawada > wrote: > >> I think we should go ahead and add both upper and lower bound checks, >> barring objections. >> > > Thanks Masahiko. Here's a patch series that adds both boundary > checks along with the infinity check from my earlier patch: > > 0001 - Reject timestamps before the Unix epoch (lower bound) > 0002 - Reject infinite intervals > 0003 - Reject timestamps beyond the 48-bit field limit (upper bound) > > Christophe's original v1 covered the pre-epoch case; 0001 is > essentially the same fix with slightly different wording. I have > included it here so the series is self-contained and applies > cleanly on HEAD. Happy to drop it in favor of Christophe's > version if you prefer that. > > The infinity check (0002) goes before the epoch conversion so > that uuidv7('infinity'::interval) gets a clear "infinite timestamps" > message rather than falling through to the pre-epoch check > with a confusing detail. > > All three use ERRCODE_DATETIME_VALUE_OUT_OF_RANGE with errdetail. > > Thanks, > Baji Shaik. > +-- uuidv7(interval) rejects timestamps before the Unix epoch > +SELECT uuidv7('-1000 years'::interval); > +ERROR: timestamp out of range for UUID version 7 > +DETAIL: UUID version 7 does not support timestamps before the Unix epoc= h. You might want to steal the test in my patch. You never know if Postgres=20 will be around in 3070, and then this test will start to fail. Slightly=20 joking... lol > +-- uuidv7(interval) rejects timestamps that overflow the 48-bit field > +SELECT uuidv7('8920 years'::interval); > +ERROR: timestamp out of range for UUID version 7 > +DETAIL: UUID version 7 does not support timestamps beyond approximately= year 10889. I think it might better to derive the interval similar to what I am=20 suggesting in my first comment. Neither comment should block merging, and feel free to completely ignore=20 them. Just personal preference on my part. Good work. Great minds think alike! --=20 Tristan Partin PostgreSQL Contributors Team AWS (https://aws.amazon.com)