Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ADBDEV-6577-p: Use push, pop and restore SPI connection #42

Draft
wants to merge 3 commits into
base: gpdb
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/diskquota_utility.c
Original file line number Diff line number Diff line change
Expand Up @@ -1692,25 +1692,27 @@ check_hash_fullness(HTAB *hashp, int max_size, const char *warning_message, Time
bool
SPI_connect_if_not_yet(void)
{
if (SPI_context()) return false;
bool pushed = SPI_push_conditional();

int rc = SPI_connect();

ereportif(rc != SPI_OK_CONNECT, ERROR,
(errcode(ERRCODE_INTERNAL_ERROR), errmsg("[diskquota] SPI_connect failed"),
errdetail("%s", SPI_result_code_string(rc))));

return true;
return pushed;
}

void
SPI_finish_if(bool connected_in_calling_function)
SPI_finish_if(bool pushed)
{
if (!connected_in_calling_function || !SPI_context()) return;
if (!SPI_context()) SPI_restore_connection();

int rc = SPI_finish();

ereportif(rc != SPI_OK_FINISH, ERROR,
(errcode(ERRCODE_INTERNAL_ERROR), errmsg("[diskquota] SPI_finish failed"),
errdetail("%s", SPI_result_code_string(rc))));

SPI_pop_conditional(pushed);
}
Loading