diff options
author | Michael Paquier <michael@paquier.xyz> | 2023-10-05 10:23:22 +0900 |
---|---|---|
committer | Michael Paquier <michael@paquier.xyz> | 2023-10-05 10:23:22 +0900 |
commit | c789f0f6cc5da084f75f2556bada572a1a05e39a (patch) | |
tree | 413fd06460072991dd23cfc6213d3f49b57af8f1 /contrib/dblink/dblink.c | |
parent | d61f2538a39f1dbeead01bc972fca597c769f518 (diff) | |
download | postgresql-c789f0f6cc5da084f75f2556bada572a1a05e39a.tar.gz postgresql-c789f0f6cc5da084f75f2556bada572a1a05e39a.zip |
dblink: Replace WAIT_EVENT_EXTENSION with custom wait events
Two custom wait events are added here:
- "DblinkConnect", when waiting to establish a connection to a remote
server.
- "DblinkGetConnect", when waiting to establish a connection to a remote
server but it could not be found in the list of already-opened ones.
Author: Masahiro Ikeda
Discussion: https://postgr.es/m/197bce267fa691a0ac62c86c4ab904c4@oss.nttdata.com
Diffstat (limited to 'contrib/dblink/dblink.c')
-rw-r--r-- | contrib/dblink/dblink.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/contrib/dblink/dblink.c b/contrib/dblink/dblink.c index 41e1f6c91d6..195b278f559 100644 --- a/contrib/dblink/dblink.c +++ b/contrib/dblink/dblink.c @@ -130,6 +130,10 @@ static void restoreLocalGucs(int nestlevel); static remoteConn *pconn = NULL; static HTAB *remoteConnHash = NULL; +/* custom wait event values, retrieved from shared memory */ +static uint32 dblink_we_connect = 0; +static uint32 dblink_we_get_conn = 0; + /* * Following is list that holds multiple remote connections. * Calling convention of each dblink function changes to accept @@ -202,8 +206,12 @@ dblink_get_conn(char *conname_or_str, connstr = conname_or_str; dblink_connstr_check(connstr); + /* first time, allocate or get the custom wait event */ + if (dblink_we_get_conn == 0) + dblink_we_get_conn = WaitEventExtensionNew("DblinkGetConnect"); + /* OK to make connection */ - conn = libpqsrv_connect(connstr, WAIT_EVENT_EXTENSION); + conn = libpqsrv_connect(connstr, dblink_we_get_conn); if (PQstatus(conn) == CONNECTION_BAD) { @@ -292,8 +300,12 @@ dblink_connect(PG_FUNCTION_ARGS) /* check password in connection string if not superuser */ dblink_connstr_check(connstr); + /* first time, allocate or get the custom wait event */ + if (dblink_we_connect == 0) + dblink_we_connect = WaitEventExtensionNew("DblinkConnect"); + /* OK to make connection */ - conn = libpqsrv_connect(connstr, WAIT_EVENT_EXTENSION); + conn = libpqsrv_connect(connstr, dblink_we_connect); if (PQstatus(conn) == CONNECTION_BAD) { |