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 1wSODA-0039QJ-1o for pgsql-hackers@arkaria.postgresql.org; Thu, 28 May 2026 00:02:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wSOD6-00AF1j-1g for pgsql-hackers@arkaria.postgresql.org; Thu, 28 May 2026 00:02:53 +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 1wSOD6-00AF1a-0Z for pgsql-hackers@lists.postgresql.org; Thu, 28 May 2026 00:02:53 +0000 Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wSOD4-00000001lvk-3Ekk for pgsql-hackers@lists.postgresql.org; Thu, 28 May 2026 00:02:52 +0000 Received: by mail-pj1-x1034.google.com with SMTP id 98e67ed59e1d1-36ad15213fbso2319336a91.0 for ; Wed, 27 May 2026 17:02:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1779926568; cv=none; d=google.com; s=arc-20240605; b=SDfUa8diherFwdcG7OT1JBavTZxruF2UzDT1IOBJi5ATfcvLCfFPHSDpduziF4xM2B vO4SDFZvU25v2P99OZ68bVqQK23QSLsE2gNVMlSyCbiiwLxKGJr/IwusjgBx8yw6w040 oFDdsU4nNRL1SChORL6vhid6F5EnogPSf0xsWzMyHt1BVR5h2jS+DxsC0Drz8S+cBJS8 WKGnOMmZDFc9FOU6A2wfgUhFPHhtsq+VsOYVwL5HhjX1mEvR8rNVm8Dp6exjx9LrRedy RZLas1CuoLfO9jC8yUdfpIe/SSwakZgj6g7zs3xEUg7oVvWPO4VckJloqXS0RlGQQTVS pFGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=P42uoe0khitmFhDgOsRMS0XT2fg5V46MbctGxE4rI44=; fh=Q6OjQgd30HCbtQRs8zusNplT9nO9U+3qkaSO0Ma/+7Y=; b=F9cByLZ/oDR9KT50a2+FwYKOaTNENVX76A2WfgDRzvst/lH46edhEm2Wlb4sGGEIGE TFfcyqFPo7DggX5L5jo79m+dwDN9j5N/Ms6IJWV/+OJ5oTUVahefeJ+mbGOYzFokWDSg 8LXmEkzmf3i+fJeOResQA2muTKCLilfmHFMg5NiTbxRKox6VCPKNPag1I7mRSp8+6moL 1w8eD41g3aj8DR3s3V1u4jzAGt+v0aem7cGpY1BUubmJB0YExsFlllKWUk53vSebIUc0 aZH6g2QwLn92zolMgmYTjmcgB8KFMhx+UiL6mmqtQk4ZswyeGF2e46CmhJzbmBWL4lsc ppEg==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779926568; x=1780531368; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=P42uoe0khitmFhDgOsRMS0XT2fg5V46MbctGxE4rI44=; b=UKi5bkhSlFsiL1W7DzmBgvYCvW+4/JFQUdDY7Jf8D8qPi+MeM70ohTq+Pv5sp3DMkk hjl0wuZzGlos8IhbQ0I1FvMDwUeWB0s5Ds8jlHXrhUsyYYZqYvCCPv1tkrid4AqjVgfU X3/BnD/e6dOvcK1uQ01aGrZG0hEGpRwX/rwhn9hvPYd1xagwn2fR9fK/pP6mFThlZIcP gtTMXG1KdfgIyV7mrzkb4FiOAQSP3K92zMXANaHmX88zETlkmJo1HZna2bO+I3ntGLVi YO00jWS0wM6JQDkuq5LfZfBdOIZsNUoLx+sUiYx8Hh0TEZeGS0dH+9N3z4XjPaKK/u22 At0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779926568; x=1780531368; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=P42uoe0khitmFhDgOsRMS0XT2fg5V46MbctGxE4rI44=; b=LgI9sDL6ok8WBa+IJCpQa63paVzeepDFXsWwx0p/B6zohMJpRBQfqf8yQlhJHnNJjt 1IKxJd4NjV9+gelaZmosd7eGueuxTW6duv1dpO9kT8noQD9s7SgReJtaLCyt1IFkzQcB zz9v3FNSZEbE5isfJw3hhoFPVWqjYXG6yaNXUEdZFjVxqtvZfh7/3i4aEVZsXc24ZYhz uHHkyw1b/90esppRXOF07GwjJVGkDyrLArLMhIMpBC9YKRkzm58WTc2wZ/bso3z5kujK +FcKiiuPJss/Jw9Yv9XB+KGoIq9WMixZF75eMKKf1i2+HhLoxabwpnRxE/j94J2I1zLL OhQg== X-Forwarded-Encrypted: i=1; AFNElJ/sNpupiIcWkW8BilOoQe/EKPznMkKU9dpzT9iV1CbS2nDto13IrLuY/0kTEFFFj0j9m3eiXGBcqnqkYUqe@lists.postgresql.org X-Gm-Message-State: AOJu0YwrBnWg7SmoR1JvJ7UYO9K7bDzMATZ6Q9XkwkZ/lq3eMVkk6G3v ZYZNVydhhJX3CYR2TQsvHxDphfVSeb631LWdIP2PBpNjyJv9w1I/KEnFht5BLTkJBZ2qcPWmAAk AItHxITkNK/s/8hBIPOjemFGH44s6J5smchlk X-Gm-Gg: Acq92OGnCMfD4bJhEYMbFXObmRf/CEWlYYZpBP45eQIoTFrSjKzKccyRSdxN680UpdG M3JFhWN4PtlekDRKNdJ/PM2ByG6W3UufwMjSqSXDSrW3rwTgV2nBll8TxVxZ+tn6OGYazWhy3Si 1S1Zf88v85Ohp+IeQWIhTMonCLwe42CWUOR1v0bkn0LSV92CbjvWA7vh9AyiPzOEGrJIMp8vZYY tCt+ok21lP5RlfoPHKi/81+SYq+azrOfFNr5EiVZh+fRWvSnagYHBJcG8OURQTjJlhKuqvp+LXS 3XkklrWw7ErDYXaXt2SbqH2CZOA/dk60mm2NftJvxMZ7xJb4bkI= X-Received: by 2002:a17:90b:3f85:b0:369:7421:7534 with SMTP id 98e67ed59e1d1-36a67765ce2mr24185017a91.8.1779926566548; Wed, 27 May 2026 17:02:46 -0700 (PDT) MIME-Version: 1.0 References: <799A70FA-6E5C-4118-99EB-2FBBE1CBAC54@thebuild.com> <966B5430-8ECD-48FA-B56F-22452D9CDBBF@yandex-team.ru> In-Reply-To: From: Masahiko Sawada Date: Wed, 27 May 2026 17:02:09 -0700 X-Gm-Features: AVHnY4JNo3lNwGC4jEHyTkBr_cssMX98wQtbtgofx8svJ_GPLlSl0mly_JppdFc Message-ID: Subject: Re: uuidv7 improperly accepts dates before 1970-01-01 To: Christophe Pettus Cc: Andrey Borodin , pgsql-hackers@lists.postgresql.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On Mon, Apr 27, 2026 at 3:51=E2=80=AFPM Christophe Pettus wrote: > > > We wrote the specific test that ensures vast space for shift, but not u= nlimited. > > That's another problem: the API gives the impression of a much larger spa= ce than actually exists. > > # select uuidv7('100000 years'::interval); # ~11.2 x total time range i= n a UUID v7. > uuidv7 > -------------------------------------- > 37b45c74-469d-7e1b-9397-1a971a99ab2b > (1 row) > Fair point. > At a minimum, it should reject a shift that creates a time later than a U= UID v7 can represent. I think that if we add a lower-bound check as the proposed patch does an upper-bound check should also be added. > > > Time shifting would become a footgun if we throw an exception when over= flown. > > 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 t= han permit the wraparound. I guess that monotonicity could easily be violated depending on how users shift the wall-clock. Taking Andrey's example, if they use something like uuidv7('-10 years' * shard_id), the monotonicity would be broken with just 6 shards. I guess it would be safer to raise an error in such cases rather than silently allowing wraparound. Otherwise, users might only realize that their UUIDv7 values are no longer sortable years down the road, which would be disastrous. Moreover, raising an error would be consistent with how PostgreSQL natively handles timestamp + interval overflows. That said, while I am leaning toward introducing boundary checks, we should carefully consider this change since it could potentially break existing applications that rely on the current behavior of uuidv7(interval). Regards, --=20 Masahiko Sawada Amazon Web Services: https://aws.amazon.com