From a008810f366e6680562f67350d579f811484a74e Mon Sep 17 00:00:00 2001 From: Alex Kasko Date: Thu, 11 Jul 2024 12:53:24 +0100 Subject: [PATCH 1/2] Remove error context handling from string literal hook (#2695) This change removes error context handling call from string literal hook. It seems to be better to have this call in engine so it happens on all code paths. Hook signature is simplified because passing parser state is no longer needed. Engine PR: https://github.com/babelfish-for-postgresql/postgresql_modified_for_babelfish/pull/397 Task: BABEL-5072 Signed-off-by: Alex Kasko --- contrib/babelfishpg_tsql/src/pltsql_coerce.c | 4 +--- test/JDBC/expected/babel_726.out | 14 ++++++++++++++ test/JDBC/input/datatypes/babel_726.sql | 10 ++++++++++ 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/contrib/babelfishpg_tsql/src/pltsql_coerce.c b/contrib/babelfishpg_tsql/src/pltsql_coerce.c index 11c1dc6b8e..1ed4d870d1 100644 --- a/contrib/babelfishpg_tsql/src/pltsql_coerce.c +++ b/contrib/babelfishpg_tsql/src/pltsql_coerce.c @@ -946,7 +946,7 @@ tsql_func_select_candidate(int nargs, } static Node * -tsql_coerce_string_literal_hook(ParseCallbackState *pcbstate, Oid targetTypeId, +tsql_coerce_string_literal_hook(Oid targetTypeId, int32 targetTypeMod, int32 baseTypeMod, Const *newcon, char *value, CoercionContext ccontext, CoercionForm cformat, @@ -1062,8 +1062,6 @@ tsql_coerce_string_literal_hook(ParseCallbackState *pcbstate, Oid targetTypeId, false)); errFunc = makeFuncExpr(errFuncOid, targetTypeId, args, 0, 0, COERCE_EXPLICIT_CALL); - cancel_parser_errposition_callback(pcbstate); - result = (Node *) errFunc; /* If target is a domain, apply constraints. */ diff --git a/test/JDBC/expected/babel_726.out b/test/JDBC/expected/babel_726.out index c4ea1fa6b5..85eed0e9bc 100644 --- a/test/JDBC/expected/babel_726.out +++ b/test/JDBC/expected/babel_726.out @@ -638,6 +638,20 @@ x ~~END~~ +-- check that duplicate view with varbinary cast does not cause crash (#2693) +create view babel_726_v1 as select cast('a' as varbinary) +go + +create view babel_726_v1 as select cast('a' as varbinary) +go +~~ERROR (Code: 2714)~~ + +~~ERROR (Message: relation "babel_726_v1" already exists)~~ + + +drop view babel_726_v1 +go + drop table babel_726_t1 go diff --git a/test/JDBC/input/datatypes/babel_726.sql b/test/JDBC/input/datatypes/babel_726.sql index 9189ed1e1c..51505b2ad0 100644 --- a/test/JDBC/input/datatypes/babel_726.sql +++ b/test/JDBC/input/datatypes/babel_726.sql @@ -290,6 +290,16 @@ go select coalesce(CAST('x'AS VARBINARY), CAST('x' AS NVARCHAR(4000)), 'x') go +-- check that duplicate view with varbinary cast does not cause crash (#2693) +create view babel_726_v1 as select cast('a' as varbinary) +go + +create view babel_726_v1 as select cast('a' as varbinary) +go + +drop view babel_726_v1 +go + drop table babel_726_t1 go From d3747fa4852403187b96961d53a3a1e4e732cd2d Mon Sep 17 00:00:00 2001 From: Tanzeel Khan Date: Thu, 11 Jul 2024 16:16:51 +0000 Subject: [PATCH 2/2] empty commit to rerun actions Signed-off-by: Tanzeel Khan