From 36584d11623273a6028b75a42fe40bbbfaad6888 Mon Sep 17 00:00:00 2001 From: shihao zhong Date: Mon, 12 Oct 2026 03:09:18 -0400 Subject: [PATCH v1 2/2] btree_gin: Test timestamptz bound in repeated DST hour. Check that a timestamp column scan finds all rows when the timestamptz bound is inside the repeated hour of the autumn clock change. --- contrib/btree_gin/expected/timestamp.out | 28 ++++++++++++++++++++++++ contrib/btree_gin/sql/timestamp.sql | 13 +++++++++++ 2 files changed, 41 insertions(+) diff --git a/contrib/btree_gin/expected/timestamp.out b/contrib/btree_gin/expected/timestamp.out index b7565285e68..2e8fa5a420a 100644 --- a/contrib/btree_gin/expected/timestamp.out +++ b/contrib/btree_gin/expected/timestamp.out @@ -343,3 +343,31 @@ SELECT * FROM test_timestamp WHERE i>'4714-11-23 17:00 BC'::timestamptz ORDER BY infinity (7 rows) +-- Repeated hour at the end of DST must not hide rows from the index scan +SET TimeZone = 'America/New_York'; +CREATE TABLE test_timestamp_dst (i timestamp); +INSERT INTO test_timestamp_dst VALUES + ('2026-11-01 00:50'), ('2026-11-01 01:10'), ('2026-11-01 01:20'), + ('2026-11-01 01:40'), ('2026-11-01 02:10'); +CREATE INDEX idx_timestamp_dst ON test_timestamp_dst USING gin (i); +SELECT * FROM test_timestamp_dst + WHERE i >= '2026-11-01 01:30-04'::timestamptz ORDER BY i; + i +-------------------------- + Sun Nov 01 01:10:00 2026 + Sun Nov 01 01:20:00 2026 + Sun Nov 01 01:40:00 2026 + Sun Nov 01 02:10:00 2026 +(4 rows) + +SELECT * FROM test_timestamp_dst + WHERE i > '2026-11-01 01:30-04'::timestamptz ORDER BY i; + i +-------------------------- + Sun Nov 01 01:10:00 2026 + Sun Nov 01 01:20:00 2026 + Sun Nov 01 01:40:00 2026 + Sun Nov 01 02:10:00 2026 +(4 rows) + +RESET TimeZone; diff --git a/contrib/btree_gin/sql/timestamp.sql b/contrib/btree_gin/sql/timestamp.sql index 1ee4edb5ea4..23a8b11de00 100644 --- a/contrib/btree_gin/sql/timestamp.sql +++ b/contrib/btree_gin/sql/timestamp.sql @@ -71,3 +71,16 @@ SELECT * FROM test_timestamp WHERE i>'infinity'::timestamptz ORDER BY i; -- This PST timestamptz will underflow if converted to timestamp SELECT * FROM test_timestamp WHERE i<='4714-11-23 17:00 BC'::timestamptz ORDER BY i; SELECT * FROM test_timestamp WHERE i>'4714-11-23 17:00 BC'::timestamptz ORDER BY i; + +-- Repeated hour at the end of DST must not hide rows from the index scan +SET TimeZone = 'America/New_York'; +CREATE TABLE test_timestamp_dst (i timestamp); +INSERT INTO test_timestamp_dst VALUES + ('2026-11-01 00:50'), ('2026-11-01 01:10'), ('2026-11-01 01:20'), + ('2026-11-01 01:40'), ('2026-11-01 02:10'); +CREATE INDEX idx_timestamp_dst ON test_timestamp_dst USING gin (i); +SELECT * FROM test_timestamp_dst + WHERE i >= '2026-11-01 01:30-04'::timestamptz ORDER BY i; +SELECT * FROM test_timestamp_dst + WHERE i > '2026-11-01 01:30-04'::timestamptz ORDER BY i; +RESET TimeZone; -- 2.37.1 (Apple Git-137.1)