Re: [PG19] btree_gin misses rows for a timestamptz bound in the repeated DST hour

From: shihao zhong <zhong950419(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: [PG19] btree_gin misses rows for a timestamptz bound in the repeated DST hour
Date: 2026-10-14 03:40:58
Message-ID: CAGRkXqQXoxVXFm_mhLWh_8sSn==+J6q2tyXywya61f0mfrPdDg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Tom,

I think that's assuming way too much about the behavior of the
> timezone code. I'd be inclined to use logic more along the line
> of "compare to the original value using the relevant comparison
> function; if greater, subtract an hour and try again".

Done in v2. cvt_timestamptz_timestamp now moves the key back an hour
while timestamp_cmp_timestamptz_internal() says it is later than the
bound.

> Also, doesn't cvt_timestamptz_date have the same issue?

I could not make it fail in a test over every backward clock change
in tzdata, and the code agrees. The key is the local date of the
bound. An earlier date can only compare as later than the bound if
the clock goes back by more than a whole day. The biggest step back
in tzdata is exactly 24 hours, Alaska in 1867. If you'd rather not
rely on that, the same loop with result-- works there and I can add
it.

Thanks,
Shihao

Attachment Content-Type Size
v2-0001-btree_gin-Fix-timestamptz-lower-bound-in-repeated.patch application/octet-stream 1.3 KB
v2-0002-btree_gin-Test-timestamptz-bound-in-repeated-DST-.patch application/octet-stream 2.9 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Bharath Rupireddy 2026-10-14 03:45:00 Parallel vacuum: workers together with leader could overrun cost budget
Previous Message shihao zhong 2026-10-14 03:33:18 Re: [PG19] psql backslash commands fail with translated messages and a non UTF-8 client encoding