-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix valgrind warnings related to varcharvarbinary function (#2231)
Currently, we have defined the following cast functions which call varcharvarbinary C function with only 1 argument. But, in varcharvarbinary function, we are reading two arguments which might lead to memory related issues. sys.binarysysvarchar sys.binaryvarchar sys.rowversionsysvarchar sys.rowversionvarchar This change modifies the above casts to have 3 arguments, one for input, one for typmod (integer) and the other for specifying isExplicit (boolean) This change also replaces varcharTypeName->typeOid with baseTypeId in tsql_coerce_string_literal_hook() function as we are not setting varcharTypeName->typeOid at all which causes failure while trying to fetch the PG view definition as shown below. Ex : -- T-SQL endpoint 1> create view babel_4475_v1 as select cast(cast('a' as binary(2)) as varchar(2)) 2> go -- PSQL endpoint jdbc_testdb=# select pg_catalog.pg_get_viewdef(oid, true) from pg_class where relname = 'babel_4475_v1'; ERROR: cache lookup failed for type 0 jdbc_testdb=# Issues Resolved: BABEL-4475 Signed-off-by: Sai Rohan Basa <[email protected]>
- Loading branch information
1 parent
ed26c7a
commit 82499ad
Showing
19 changed files
with
630 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
drop view babel_4475_v1 | ||
go | ||
|
||
drop view babel_4475_v2 | ||
go | ||
|
||
drop view babel_4475_v3 | ||
go | ||
|
||
drop view babel_4475_v4 | ||
go | ||
|
||
drop function babel_4475_f1 | ||
go | ||
|
||
drop function babel_4475_f2 | ||
go | ||
|
||
drop procedure babel_4475_p1 | ||
go | ||
|
||
drop procedure babel_4475_p2 | ||
go | ||
|
||
drop procedure babel_4475_p3 | ||
go | ||
|
||
drop procedure babel_4475_p4 | ||
go |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
create view babel_4475_v1 as select cast(cast('a' as binary(2)) as varchar(2)) | ||
go | ||
|
||
create function babel_4475_f1() returns table | ||
as return ( | ||
select cast(cast('a' as binary(2)) as varchar(2)) | ||
) | ||
go | ||
|
||
create procedure babel_4475_p1 as select cast(cast('a' as binary(2)) as varchar(2)) | ||
go | ||
|
||
create view babel_4475_v2 as select cast(cast('a' as binary(2)) as pg_catalog.varchar(2)) | ||
go | ||
|
||
create function babel_4475_f2() returns table | ||
as return ( | ||
select cast(cast('a' as binary(2)) as pg_catalog.varchar(2)) | ||
) | ||
go | ||
|
||
create procedure babel_4475_p2 as select cast(cast('a' as binary(2)) as pg_catalog.varchar(2)) | ||
go | ||
|
||
EXEC sp_babelfish_configure 'babelfishpg_tsql.escape_hatch_rowversion', 'ignore'; | ||
go | ||
|
||
create view babel_4475_v3 as select cast(cast('ab' as rowversion) as varchar(2)) | ||
go | ||
|
||
create procedure babel_4475_p3 as select cast(cast('ab' as rowversion) as varchar(2)) | ||
go | ||
|
||
create view babel_4475_v4 as select cast(cast('ab' as rowversion) as pg_catalog.varchar(2)) | ||
go | ||
|
||
create procedure babel_4475_p4 as select cast(cast('ab' as rowversion) as pg_catalog.varchar(2)) | ||
go | ||
|
||
EXEC sp_babelfish_configure 'babelfishpg_tsql.escape_hatch_rowversion', 'strict'; | ||
go |
Oops, something went wrong.