Skip to content

Fix wrong results when filtering a date column to a timestamptz value#9990

Open
svenklemm wants to merge 1 commit into
mainfrom
sven/date_timestamp_cmp
Open

Fix wrong results when filtering a date column to a timestamptz value#9990
svenklemm wants to merge 1 commit into
mainfrom
sven/date_timestamp_cmp

Conversation

@svenklemm
Copy link
Copy Markdown
Member

@svenklemm svenklemm commented Jun 7, 2026

The comparison was rewritten by casting the timestamptz to a date, which
drops the time of day and can change the result.
This is correct only for "date > value" and "date <= value". For the other
operators we now keep the original comparison.

This affected vectorized filtering and chunk exclusion.

Fixes: #9976

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 7, 2026

@dbeck, @pnthao: please review this pull request.

Powered by pull-review

@svenklemm svenklemm force-pushed the sven/date_timestamp_cmp branch from 8a33beb to 4848c0e Compare June 7, 2026 19:22
@svenklemm svenklemm added this to the v2.28.0 milestone Jun 7, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 7, 2026

Codecov Report

❌ Patch coverage is 81.25000% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/nodes/chunk_append/transform.c 75.00% 1 Missing and 1 partial ⚠️
src/planner/expand_hypertable.c 87.50% 0 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

The comparison was rewritten by casting the timestamptz to a date, which
drops the time of day and can change the result.
This is correct only for "date > value" and "date <= value". For the other
operators we now keep the original comparison.

This affected vectorized filtering and chunk exclusion.

Fixes: #9976
@svenklemm svenklemm force-pushed the sven/date_timestamp_cmp branch from 4848c0e to 8dc023d Compare June 7, 2026 20:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

incorrect transformation of datetime comparison leads to wrong query result

1 participant