Skip to content

Commit 04761dd

Browse files
authored
Add WaitEventExtensionNew calls for Pg17+ (#203)
1 parent b062c50 commit 04761dd

2 files changed

Lines changed: 23 additions & 2 deletions

File tree

.github/workflows/ci.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ jobs:
1515
fail-fast: true
1616
matrix:
1717
ci:
18-
- { PGVER: 13 }
1918
- { PGVER: 14 }
2019
- { PGVER: 15 }
2120
- { PGVER: 16 }

http.c

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@
6666
#include <utils/fmgroids.h>
6767
#include <utils/guc.h>
6868

69+
#if PG_VERSION_NUM >= 170000
70+
#include <utils/wait_event.h>
71+
#endif
72+
6973
#if PG_VERSION_NUM >= 90300
7074
# include <access/htup_details.h>
7175
#endif
@@ -217,6 +221,10 @@ static size_t http_readback(void *buffer, size_t size, size_t nitems, void *inst
217221
/* Global variables */
218222
static CURL * g_http_handle = NULL;
219223

224+
#if PG_VERSION_NUM >= 170000
225+
static uint32 wait_event_transfer = 0;
226+
#endif
227+
220228
/*
221229
* Interrupt support is dependent on CURLOPT_XFERINFOFUNCTION which
222230
* is only available from 7.39.0 and up
@@ -421,6 +429,10 @@ void _PG_init(void)
421429
*/
422430
http_guc_init();
423431

432+
#if PG_VERSION_NUM >= 170000
433+
wait_event_transfer = WaitEventExtensionNew("HttpTransfer");
434+
#endif
435+
424436
#ifdef HTTP_MEM_CALLBACKS
425437
/*
426438
* Use PgSQL memory management in Curl
@@ -872,7 +884,7 @@ http_check_curl_version(const curl_version_info_data *version_info)
872884

873885
if ( version_info->version_num < CURL_MIN_VERSION )
874886
{
875-
elog(ERROR, "pgsql-http requires Curl version 0.7.20 or higher");
887+
elog(ERROR, "pgsql-http requires Curl version 7.20.0 or higher");
876888
}
877889
}
878890

@@ -1363,10 +1375,20 @@ Datum http_request(PG_FUNCTION_ARGS)
13631375
/* Set the headers */
13641376
CURL_SETOPT(g_http_handle, CURLOPT_HTTPHEADER, headers);
13651377

1378+
#if PG_VERSION_NUM >= 170000
1379+
/* Set up wait event tracking */
1380+
pgstat_report_wait_start(wait_event_transfer);
1381+
#endif
1382+
13661383
/*************************************************************************
13671384
* PERFORM THE REQUEST!
13681385
**************************************************************************/
13691386
http_return = curl_easy_perform(g_http_handle);
1387+
1388+
#if PG_VERSION_NUM >= 170000
1389+
pgstat_report_wait_end();
1390+
#endif
1391+
13701392
elog(DEBUG2, "pgsql-http: queried '%s'", uri);
13711393
elog(DEBUG2, "pgsql-http: http_return '%d'", http_return);
13721394

0 commit comments

Comments
 (0)