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()