From a35b28b0e286e6a945fba5e9c89d12fc31fa0ac6 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 00bce91f5e1b2b1909c80a073acebb980172c07e) --- 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 e4124c9ca9a..2b63dcf0c42 100644 --- a/src/backend/executor/spi.c +++ b/src/backend/executor/spi.c @@ -2447,8 +2447,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()