Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

builtins: fix handling of <1 seconds in make_timestamp{tz} #136804

Merged
merged 1 commit into from
Dec 5, 2024

Conversation

rafiss
Copy link
Collaborator

@rafiss rafiss commented Dec 5, 2024

On some platforms, make_timestamp(1, 1, 1, 0, 0, 0) would return a value of 0293-09-22 00:12:43.145224 BC. Now all platforms will compute the correct value of 0001-01-01 00:00:00.

Also, on some platforms a fractional second value that is between 0 and 1 (exclusive), would always be interpeted as zero nanoseconds. Now it will always be converted to nanoseconds correctly.

fixes #126766
Release note (bug fix): Fixed a bug that would cause the make_timestamp and make_timestamptz builtin functions to incorrectly extract the seconds argument if the value was less than 1.

On some platforms, `make_timestamp(1, 1, 1, 0, 0, 0)` would return
a value of `0293-09-22 00:12:43.145224 BC`. Now all platforms will
compute the correct value of `0001-01-01 00:00:00`.

Also, on some platforms a fractional second value that is between
0 and 1 (exclusive), would always be interpeted as zero nanoseconds.
Now it will always be converted to nanoseconds correctly.

Release note (bug fix): Fixed a bug that would cause the make_timestamp
and make_timestamptz builtin functions to incorrectly extract the
`seconds` argument if the value was less than 1.
@rafiss rafiss requested a review from a team as a code owner December 5, 2024 13:50
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Collaborator

@fqazi fqazi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice find!

:lgtm_strong:

Reviewed 2 of 2 files at r1, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @rafiss)

@rafiss
Copy link
Collaborator Author

rafiss commented Dec 5, 2024

tftr!

bors r+

@craig craig bot merged commit f9a6082 into cockroachdb:master Dec 5, 2024
23 checks passed
@rafiss rafiss deleted the fix-make_timestamp-nan branch December 6, 2024 05:23
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.

make_timestamp/make_timestamptz returns invalid timestamp when seconds < 1
3 participants