From 50fba00c2d56ab844cd9c8b3dc47e8197f191ddc Mon Sep 17 00:00:00 2001 From: Tanzeel Khan <140405735+tanscorpio7@users.noreply.github.com> Date: Tue, 9 Jan 2024 18:43:36 +0530 Subject: [PATCH] Fix SPI clean up incase of errors for insert into execute with @tablevarible (#274) Introduce functions to fetch SPI connected value (spi stack depth). Extension PR: https://github.com/babelfish-for-postgresql/babelfish_extensions/pull/2183 Issues Resolved: BABEL-4360 Signed-off-by: Tanzeel Khan --- src/backend/executor/spi.c | 6 ++++++ src/include/executor/spi.h | 1 + 2 files changed, 7 insertions(+) diff --git a/src/backend/executor/spi.c b/src/backend/executor/spi.c index d9d970d589f..e99b74bae61 100644 --- a/src/backend/executor/spi.c +++ b/src/backend/executor/spi.c @@ -3432,3 +3432,9 @@ SPI_setCurrentInternalTxnMode(bool mode) { _SPI_current->internal_xact = mode; } + +int +SPI_get_depth(void) +{ + return _SPI_connected; +} diff --git a/src/include/executor/spi.h b/src/include/executor/spi.h index fc685292dca..07ecabef3f6 100644 --- a/src/include/executor/spi.h +++ b/src/include/executor/spi.h @@ -213,4 +213,5 @@ extern void AtEOSubXact_SPI(bool isCommit, SubTransactionId mySubid); extern bool SPI_inside_nonatomic_context(void); extern void SPI_setCurrentInternalTxnMode(bool mode); +extern int SPI_get_depth(void); #endif /* SPI_H */