Babelfish for PostgreSQL provides the capability for PostgreSQL to work with applications written for Microsoft SQL Server. Babelfish understands the SQL Server wire-protocol and T-SQL, the Microsoft SQL Server query and procedural language, so you don’t have to switch database drivers or rewrite all of your application queries.
For converting string to datetime2, datetimeoffset and smalldatetime using convert function, we are directly using cast function which will convert the string to given type with default style. Added support to use corresponding SQL helper functions defined which will fix this issue.
For conversion of string to date, datetime, smalldatetime and time using convert function, there are helper functions defined but are unable to handle all the supported datetime string literals. Refactored these definitions and fixed this issue.
For conversion of string to datetime2 and datetimeoffset using convert function, there are no helper functions defined which handles this conversion as there are for conversion of string to date, datetime, smalldatetime and time. Added definitions to handle these datatypes as well.
Function sys.babelfish_get_microsecs_from_fractsecs() is unable to handle the edge case where fractional seconds get overflowed after rounding it to given scale.
Function babelfish_get_timeunit_from_string only returns HOURS, MINUTES, SECONDS and FRACTSECONDS from a given time string. Extended this function to return OFFHOURS, OFFMINUTES and OFFSIGN to get details of timeoffset from time string.
[x] 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.
Description
This PR will add fix for following issues:
First commit changes cherry-picked from: https://github.com/babelfish-for-postgresql/babelfish_extensions/pull/2613
Authored-by: Rohit Bhagat rohitbgt@amazon.com Signed-off-by: Rohit Bhagat rohitbgt@amazon.com
Issues Resolved
BABEL-4896
Test Scenarios Covered
Use case based - YES
Boundary conditions - YES
Arbitrary inputs - YES
Negative test cases - YES
Minor version upgrade tests - YES
Major version upgrade tests - YES
Performance tests - NA
Tooling impact - NA
Client tests - YES
Check List
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.