> On 31 Jan 2025, at 00:54, Masahiko Sawada <sawada.m...@gmail.com> wrote:
> 
> I like this idea. Would you like to write a patch, or shall I?

I propose to separate milliseconds from nanoseconds. Please find attached 
implementation of this.
With this patch we can generate correct UUIDs in a very distant future.
postgres=# select x,                                                            
                                                                                
    uuid_extract_timestamp(uuidv7((x::text || ' year'::text)::interval)),       
                                                                                
 
(x::text || ' year'::text)::interval                                            
                                                                      
from generate_series(1,9000,1000) x;
  x   |   uuid_extract_timestamp    |  interval   
------+-----------------------------+------------
    1 | 2026-01-31 12:00:53.084+05  | 1 year
 1001 | 3026-01-31 12:00:53.084+05  | 1001 years
 2001 | 4026-01-31 12:00:53.084+05  | 2001 years
 3001 | 5026-01-31 12:00:53.084+05  | 3001 years
 4001 | 6026-01-31 12:00:53.084+05  | 4001 years
 5001 | 7026-01-31 12:00:53.085+05  | 5001 years
 6001 | 8026-01-31 12:00:53.085+05  | 6001 years
 7001 | 9026-01-31 12:00:53.085+05  | 7001 years
 8001 | 10026-01-31 12:00:53.085+05 | 8001 years
(9 rows)


Best regards, Andrey Borodin.

Attachment: 0001-UUDv7-fix-offset-computations-in-dates-after-2262.patch
Description: Binary data

Reply via email to