From d0c5bccabd631e0f0c8debe728ece7512ce6c810 Mon Sep 17 00:00:00 2001 From: Tanzeel Khan Date: Thu, 24 Oct 2024 10:05:56 +0000 Subject: [PATCH] BABEL: fix babelfish commit/rollback inside subtransaction post commit 25d639ee Signed-off-by: Tanzeel Khan (cherry picked from commit 831461774c33b0845df71e7473e51ca8dfe0019e) (cherry picked from commit f11c2b9228dd349ad296fc2801bb59fbd438a106) --- src/backend/executor/spi.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/backend/executor/spi.c b/src/backend/executor/spi.c index 750ede4ba1c..3fb829062ca 100644 --- a/src/backend/executor/spi.c +++ b/src/backend/executor/spi.c @@ -2442,8 +2442,15 @@ _SPI_execute_plan(SPIPlanPtr plan, const SPIExecuteOptions *options, * not inside a subtransaction. The latter two tests match whether * _SPI_commit() would allow a commit; see there for more commentary. */ - allow_nonatomic = options->allow_nonatomic && - !_SPI_current->atomic && !IsSubTransaction(); + if (check_pltsql_support_tsql_transactions_hook && (*check_pltsql_support_tsql_transactions_hook)()) + { + allow_nonatomic = options->allow_nonatomic && !_SPI_current->atomic; + } + else + { + allow_nonatomic = options->allow_nonatomic && + !_SPI_current->atomic && !IsSubTransaction(); + } /* * Setup error traceback support for ereport()