Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
Signed-off-by: Tanzeel Khan <[email protected]>
  • Loading branch information
tanscorpio7 committed Dec 9, 2024
1 parent 2b17918 commit 93cbed0
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 3 deletions.
7 changes: 4 additions & 3 deletions contrib/babelfishpg_tsql/src/pl_exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -4622,6 +4622,7 @@ exec_stmt_execsql(PLtsql_execstate *estate,
bool fmtonly_enabled = true;
CmdType cmd = CMD_UNKNOWN;
bool enable_txn_in_triggers = !pltsql_disable_txn_in_triggers;
bool support_tsql_trans = pltsql_support_tsql_transactions();
StringInfoData query;
bool need_path_reset = false;
char *cur_dbname = get_cur_db_name();
Expand Down Expand Up @@ -4799,7 +4800,7 @@ exec_stmt_execsql(PLtsql_execstate *estate,
/* Open nesting level in engine */
BeginCompositeTriggers(CurrentMemoryContext);
/* TSQL commands must run inside an explicit transaction */
if (!pltsql_disable_batch_auto_commit && pltsql_support_tsql_transactions() &&
if (!pltsql_disable_batch_auto_commit && support_tsql_trans &&
stmt->txn_data == NULL && !IsTransactionBlockActive())
{
MemoryContext oldCxt = CurrentMemoryContext;
Expand All @@ -4825,7 +4826,7 @@ exec_stmt_execsql(PLtsql_execstate *estate,
portal, expr, cmd, paramLI);
else if (stmt->need_to_push_result)
rc = execute_plan_and_push_result(estate, expr, paramLI);
else if (stmt->txn_data != NULL && !pltsql_support_tsql_transactions())
else if (stmt->txn_data != NULL && !support_tsql_trans)
{
elog(DEBUG2, "TSQL TXN Execute transaction command with PG semantics");
rc = execute_txn_command(estate, stmt);
Expand Down Expand Up @@ -5058,7 +5059,7 @@ exec_stmt_execsql(PLtsql_execstate *estate,
*/
/* TODO To let procedure call from PSQL work with old semantics */
if ((!pltsql_disable_batch_auto_commit || (stmt->txn_data != NULL)) &&
pltsql_support_tsql_transactions() &&
support_tsql_trans &&
(enable_txn_in_triggers || estate->trigdata == NULL) &&
!ro_func && !estate->insert_exec)
{
Expand Down
30 changes: 30 additions & 0 deletions test/JDBC/expected/TestBasicInterop.out
Original file line number Diff line number Diff line change
Expand Up @@ -186,3 +186,33 @@ GO
-- psql
DROP PROCEDURE pg_interop_proc_sp_exec
GO

-- tsql
CREATE TABLE babel_5446 (Test INT NULL)
GO
~~ERROR (Code: 2714)~~

~~ERROR (Message: relation "babel_5446" already exists)~~

INSERT INTO babel_5446 SELECT ISNUMERIC('test') AS my_isnumeric
GO
~~ROW COUNT: 1~~

SELECT @@trancount
GO
~~START~~
int
0
~~END~~


INSERT INTO babel_5446 SELECT ISNUMERIC('test') AS my_isnumeric
SELECT @@trancount
GO
~~ROW COUNT: 1~~

~~START~~
int
0
~~END~~

12 changes: 12 additions & 0 deletions test/JDBC/input/interoperability/TestBasicInterop.mix
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,15 @@ GO
-- psql
DROP PROCEDURE pg_interop_proc_sp_exec
GO

-- tsql
CREATE TABLE babel_5446 (Test INT NULL)
GO
INSERT INTO babel_5446 SELECT ISNUMERIC('test') AS my_isnumeric
GO
SELECT @@trancount
GO

INSERT INTO babel_5446 SELECT ISNUMERIC('test') AS my_isnumeric
SELECT @@trancount
GO

0 comments on commit 93cbed0

Please sign in to comment.