Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc789f0f

Browse files
committed
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 remoteserver.- "DblinkGetConnect", when waiting to establish a connection to a remoteserver but it could not be found in the list of already-opened ones.Author: Masahiro IkedaDiscussion:https://postgr.es/m/197bce267fa691a0ac62c86c4ab904c4@oss.nttdata.com
1 parentd61f253 commitc789f0f

File tree

2 files changed

+40
-2
lines changed

2 files changed

+40
-2
lines changed

‎contrib/dblink/dblink.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,10 @@ static void restoreLocalGucs(int nestlevel);
130130
staticremoteConn*pconn=NULL;
131131
staticHTAB*remoteConnHash=NULL;
132132

133+
/* custom wait event values, retrieved from shared memory */
134+
staticuint32dblink_we_connect=0;
135+
staticuint32dblink_we_get_conn=0;
136+
133137
/*
134138
*Following is list that holds multiple remote connections.
135139
*Calling convention of each dblink function changes to accept
@@ -202,8 +206,12 @@ dblink_get_conn(char *conname_or_str,
202206
connstr=conname_or_str;
203207
dblink_connstr_check(connstr);
204208

209+
/* first time, allocate or get the custom wait event */
210+
if (dblink_we_get_conn==0)
211+
dblink_we_get_conn=WaitEventExtensionNew("DblinkGetConnect");
212+
205213
/* OK to make connection */
206-
conn=libpqsrv_connect(connstr,WAIT_EVENT_EXTENSION);
214+
conn=libpqsrv_connect(connstr,dblink_we_get_conn);
207215

208216
if (PQstatus(conn)==CONNECTION_BAD)
209217
{
@@ -292,8 +300,12 @@ dblink_connect(PG_FUNCTION_ARGS)
292300
/* check password in connection string if not superuser */
293301
dblink_connstr_check(connstr);
294302

303+
/* first time, allocate or get the custom wait event */
304+
if (dblink_we_connect==0)
305+
dblink_we_connect=WaitEventExtensionNew("DblinkConnect");
306+
295307
/* OK to make connection */
296-
conn=libpqsrv_connect(connstr,WAIT_EVENT_EXTENSION);
308+
conn=libpqsrv_connect(connstr,dblink_we_connect);
297309

298310
if (PQstatus(conn)==CONNECTION_BAD)
299311
{

‎doc/src/sgml/dblink.sgml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,32 @@
1313
session.
1414
</para>
1515

16+
<para>
17+
<filename>dblink</filename> can report the following wait events under the wait
18+
event type <literal>Extension</literal>.
19+
</para>
20+
21+
<variablelist>
22+
<varlistentry>
23+
<term><literal>DblinkConnect</literal></term>
24+
<listitem>
25+
<para>
26+
Waiting to establish a connection to a remote server.
27+
</para>
28+
</listitem>
29+
</varlistentry>
30+
31+
<varlistentry>
32+
<term><literal>DblinkGetConnect</literal></term>
33+
<listitem>
34+
<para>
35+
Waiting to establish a connection to a remote server when it could not
36+
be found in the list of already-opened connections.
37+
</para>
38+
</listitem>
39+
</varlistentry>
40+
</variablelist>
41+
1642
<para>
1743
See also <xref linkend="postgres-fdw"/>, which provides roughly the same
1844
functionality using a more modern and standards-compliant infrastructure.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp