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

Fix Datapart functions to be Timezone Invariant #3226

Merged

Conversation

shah-nirmit
Copy link
Contributor

Description

We were incorrectly passing timezone to timestamp2tm function which would cause the datepart functions to be timezone dependent , If we pass tzp by reference to timestamp2tm function, then internally localtime converts the given original timestamp value to date and time values adding timezone offset taking GMT as a reference timezone. However, if NULL is passed instead then we keep the original timestamp intact and that's what actually PG does.

Issues Resolved

BABEL-5453

Signed-off-by: Nirmit Shah nirmisha@amazon.com

Test Scenarios Covered

  • Use case based - YES

  • Boundary conditions - YES

  • Arbitrary inputs -

  • Negative test cases -

  • Minor version upgrade tests -

  • Major version upgrade tests -

  • Performance tests -

  • Tooling impact -

  • Client tests -

Check List

  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is under the terms of the Apache 2.0 and PostgreSQL licenses, and grant any person obtaining a copy of the contribution permission to relicense all or a portion of my contribution to the PostgreSQL License solely to contribute all or a portion of my contribution to the PostgreSQL open source project.

For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Nirmit Shah added 2 commits December 9, 2024 07:21
Signed-off-by: Nirmit Shah <nirmisha@amazon.com>
Signed-off-by: Nirmit Shah <nirmisha@amazon.com>
Nirmit Shah added 2 commits December 11, 2024 05:40
Signed-off-by: Nirmit Shah <nirmisha@amazon.com>
@coveralls
Copy link
Collaborator

coveralls commented Dec 11, 2024

Pull Request Test Coverage Report for Build 12292019918

Details

  • 1 of 1 (100.0%) changed or added relevant line in 1 file are covered.
  • 2 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.004%) to 74.81%

Files with Coverage Reduction New Missed Lines %
contrib/babelfishpg_tds/src/backend/tds/tdscomm.c 2 76.03%
Totals Coverage Status
Change from base Build 12283418632: -0.004%
Covered Lines: 46470
Relevant Lines: 62117

💛 - Coveralls

Nirmit Shah added 2 commits December 12, 2024 07:45
Signed-off-by: Nirmit Shah <nirmisha@amazon.com>
Copy link
Contributor

@jsudrik jsudrik left a comment

Choose a reason for hiding this comment

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

Approved.

@jsudrik jsudrik merged commit 5a092d3 into babelfish-for-postgresql:BABEL_5_X_DEV Dec 13, 2024
44 checks passed
@Anikait143 Anikait143 deleted the jira-babel-5453 branch December 15, 2024 15:13
jsudrik pushed a commit that referenced this pull request Dec 16, 2024
We were incorrectly passing timezone to timestamp2tm function which would cause the datepart functions to be timezone dependent , If we pass tzp by reference to timestamp2tm function, then internally localtime converts the given original timestamp value to date and time values adding timezone offset taking GMT as a reference timezone. However, if NULL is passed instead then we keep the original timestamp intact and that's what actually PG does.

Cherry-pick #3226

Issues Resolved
BABEL-5453

Signed-off-by: Nirmit Shah nirmisha@amazon.com
jsudrik pushed a commit that referenced this pull request Dec 17, 2024
We were incorrectly passing timezone to timestamp2tm function which would cause the datepart functions to be timezone dependent , If we pass tzp by reference to timestamp2tm function, then internally localtime converts the given original timestamp value to date and time values adding timezone offset taking GMT as a reference timezone. However, if NULL is passed instead then we keep the original timestamp intact and that's what actually PG does.

Cherry pick #3226

Issues Resolved
BABEL-5453

Signed-off-by: Nirmit Shah nirmisha@amazon.com
timchang514 pushed a commit to amazon-aurora/babelfish_extensions that referenced this pull request Dec 17, 2024
…esql#3253)

We were incorrectly passing timezone to timestamp2tm function which would cause the datepart functions to be timezone dependent , If we pass tzp by reference to timestamp2tm function, then internally localtime converts the given original timestamp value to date and time values adding timezone offset taking GMT as a reference timezone. However, if NULL is passed instead then we keep the original timestamp intact and that's what actually PG does.

Cherry pick babelfish-for-postgresql#3226

Issues Resolved
BABEL-5453

Signed-off-by: Nirmit Shah nirmisha@amazon.com
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.

5 participants