|
66 | 66 | #include <utils/fmgroids.h> |
67 | 67 | #include <utils/guc.h> |
68 | 68 |
|
| 69 | +#if PG_VERSION_NUM >= 170000 |
| 70 | +#include <utils/wait_event.h> |
| 71 | +#endif |
| 72 | + |
69 | 73 | #if PG_VERSION_NUM >= 90300 |
70 | 74 | # include <access/htup_details.h> |
71 | 75 | #endif |
@@ -217,6 +221,10 @@ static size_t http_readback(void *buffer, size_t size, size_t nitems, void *inst |
217 | 221 | /* Global variables */ |
218 | 222 | static CURL * g_http_handle = NULL; |
219 | 223 |
|
| 224 | +#if PG_VERSION_NUM >= 170000 |
| 225 | +static uint32 wait_event_transfer = 0; |
| 226 | +#endif |
| 227 | + |
220 | 228 | /* |
221 | 229 | * Interrupt support is dependent on CURLOPT_XFERINFOFUNCTION which |
222 | 230 | * is only available from 7.39.0 and up |
@@ -421,6 +429,10 @@ void _PG_init(void) |
421 | 429 | */ |
422 | 430 | http_guc_init(); |
423 | 431 |
|
| 432 | +#if PG_VERSION_NUM >= 170000 |
| 433 | + wait_event_transfer = WaitEventExtensionNew("HttpTransfer"); |
| 434 | +#endif |
| 435 | + |
424 | 436 | #ifdef HTTP_MEM_CALLBACKS |
425 | 437 | /* |
426 | 438 | * Use PgSQL memory management in Curl |
@@ -872,7 +884,7 @@ http_check_curl_version(const curl_version_info_data *version_info) |
872 | 884 |
|
873 | 885 | if ( version_info->version_num < CURL_MIN_VERSION ) |
874 | 886 | { |
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"); |
876 | 888 | } |
877 | 889 | } |
878 | 890 |
|
@@ -1363,10 +1375,20 @@ Datum http_request(PG_FUNCTION_ARGS) |
1363 | 1375 | /* Set the headers */ |
1364 | 1376 | CURL_SETOPT(g_http_handle, CURLOPT_HTTPHEADER, headers); |
1365 | 1377 |
|
| 1378 | +#if PG_VERSION_NUM >= 170000 |
| 1379 | + /* Set up wait event tracking */ |
| 1380 | + pgstat_report_wait_start(wait_event_transfer); |
| 1381 | +#endif |
| 1382 | + |
1366 | 1383 | /************************************************************************* |
1367 | 1384 | * PERFORM THE REQUEST! |
1368 | 1385 | **************************************************************************/ |
1369 | 1386 | http_return = curl_easy_perform(g_http_handle); |
| 1387 | + |
| 1388 | +#if PG_VERSION_NUM >= 170000 |
| 1389 | + pgstat_report_wait_end(); |
| 1390 | +#endif |
| 1391 | + |
1370 | 1392 | elog(DEBUG2, "pgsql-http: queried '%s'", uri); |
1371 | 1393 | elog(DEBUG2, "pgsql-http: http_return '%d'", http_return); |
1372 | 1394 |
|
|
0 commit comments