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.
This commit will fix the following issues with T-SQL COALESCE function :
When the arguments contain the mix of variables and constants as shown below, the below query should return 4 as it is the first non-null value. But BBF throws error as we try to evaluate the constant ('dfidhfgi') at the compile time in this case.
DECLARE @abc int = 4 ;
select COALESCE(@abc, 'dfidhfgi')
When the arguments are of varbinary and nvarchar type, BBF throws error as we have defined the CAST between varbinary and nvarchar as ASSIGNMENT, but in this case IMPLICIT casting is used.
select coalesce(CAST('x'AS VARBINARY), CAST('x' AS NVARCHAR(4000)), 'x')
[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 commit will fix the following issues with T-SQL COALESCE function :
varbinary
andnvarchar
type, BBF throws error as we have defined the CAST betweenvarbinary
andnvarchar
as ASSIGNMENT, but in this case IMPLICIT casting is used.Issues Resolved
BABEL-726 Engine PR : https://github.com/babelfish-for-postgresql/postgresql_modified_for_babelfish/pull/380 Signed-off-by: Sai Rohan Basa bsrohan@amazon.com
Test Scenarios Covered
Use case based - babel_726-vu-*.sql
Boundary conditions - babel_726-vu-*.sql
Arbitrary inputs - babel_726-vu-*.sql
Negative test cases - babel_726-vu-*.sql
Minor version upgrade tests - babel_726-vu-*.sql
Major version upgrade tests - babel_726-vu-*.sql
Performance tests - N/A
Tooling impact - N/A
Client tests - N/A
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.