summaryrefslogtreecommitdiff
path: root/src/fe_utils/connect_utils.c
diff options
context:
space:
mode:
authorAlvaro Herrera <alvherre@alvh.no-ip.org>2024-03-18 19:28:58 +0100
committerAlvaro Herrera <alvherre@alvh.no-ip.org>2024-03-18 19:28:58 +0100
commit66ab9371a23320cf608e68e8e5d2811992941bea (patch)
treee9b23d614dc8879a6233f60c24aaca94aea74a45 /src/fe_utils/connect_utils.c
parent61f352ece9e7eb89c7154da178d0c3bc69fc72c9 (diff)
dblink/isolationtester/fe_utils: Use new cancel API
Commit 61461a300c1c introduced new functions to libpq for cancelling queries. This replaces the usage of the old ones in parts of the codebase with these newer ones. This specifically leaves out changes to psql and pgbench, as those would need a much larger refactor to be able to call them due to the new functions not being signal-safe; and also postgres_fdw, because the original code there is not clear to me (Álvaro) and not fully tested. Author: Jelte Fennema-Nio <postgres@jeltef.nl> Discussion: https://postgr.es/m/CAGECzQT_VgOWWENUqvUV9xQmbaCyXjtRRAYO8W07oqashk_N+g@mail.gmail.com
Diffstat (limited to 'src/fe_utils/connect_utils.c')
-rw-r--r--src/fe_utils/connect_utils.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/src/fe_utils/connect_utils.c b/src/fe_utils/connect_utils.c
index 808d54461fd..5ed9f3ba17b 100644
--- a/src/fe_utils/connect_utils.c
+++ b/src/fe_utils/connect_utils.c
@@ -157,19 +157,14 @@ connectMaintenanceDatabase(ConnParams *cparams,
void
disconnectDatabase(PGconn *conn)
{
- char errbuf[256];
-
Assert(conn != NULL);
if (PQtransactionStatus(conn) == PQTRANS_ACTIVE)
{
- PGcancel *cancel;
+ PGcancelConn *cancelConn = PQcancelCreate(conn);
- if ((cancel = PQgetCancel(conn)))
- {
- (void) PQcancel(cancel, errbuf, sizeof(errbuf));
- PQfreeCancel(cancel);
- }
+ (void) PQcancelBlocking(cancelConn);
+ PQcancelFinish(cancelConn);
}
PQfinish(conn);