| From: | shihao zhong <zhong950419(at)gmail(dot)com> |
|---|---|
| To: | pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | [PG19] btree_gin misses rows for a timestamptz bound in the repeated DST hour |
| Date: | 2026-10-13 03:50:08 |
| Message-ID: | CAGRkXqQio=7PWgTfKvjyQY9-7A_0A36E3put1gxJeDypgqFSzw@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi hackers,
This is Medium 4 from my list in [1].
Since fc896821c44, a btree_gin index on a timestamp column can be
used to compare with a timestamptz value. When that value is in the
first pass of the repeated hour at the end of DST, the index scan
misses rows.
create extension btree_gin;
set timezone = 'America/New_York';
create table t (ts timestamp);
insert into t values ('2026-11-01 01:10'), ('2026-11-01 01:40');
create index on t using gin (ts);
set enable_seqscan = off;
select * from t where ts >= '2026-11-01 01:30-04'::timestamptz;
master returns only 01:40. 18 returns both rows, and so does master
with a seq scan.
0001 converts the start key back to timestamptz. If the result is
after the bound, it moves the key earlier by the difference. Here the
key becomes 00:30. The scan already rechecks each entry with the real
operator, so nothing extra is returned. 0002 adds a test. The patches
apply to master and REL_19_STABLE.
A date column goes through the same kind of conversion. I could not
make it fail, also not in the Cuba time zone where midnight repeats.
A bound in the spring gap can give wrong rows too, but a plain btree
index does the same there, so I left it alone.
The commit came from [2].
[1]
https://postgr.es/m/CAGRkXqSFdjqZP_kwRz7dv6LHX-CSrkDnynNXgntRsCEnQTKxmg@mail.gmail.com
[2] https://postgr.es/m/262624.1738460652@sss.pgh.pa.us
Thanks,
Shihao
| Attachment | Content-Type | Size |
|---|---|---|
| v1-0002-btree_gin-Test-timestamptz-bound-in-repeated-DST-.patch | application/octet-stream | 2.9 KB |
| v1-0001-btree_gin-Fix-timestamptz-lower-bound-in-repeated.patch | application/octet-stream | 1.5 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Sho Ito | 2026-10-13 03:54:57 | [PATCH v1] Fix tab completion for concurrent materialized view refresh |
| Previous Message | jian he | 2026-10-13 03:40:29 | Re: Row pattern recognition |