pg_curl
pg_curl : Run curl actions for data transfer in URL syntax
Overview
| Attribute | Has Binary | Has Library | Need Load | Has DDL | Relocatable | Trusted |
|---|---|---|---|---|---|---|
| --s-d-r | No | Yes | No | Yes | yes | no |
| Relationships | |
|---|---|
| See Also | http pg_net omni_httpc pg_graphql documentdb |
Packages
| Linux / PG | PG19 | PG18 | PG17 | PG16 | PG15 |
|---|---|---|---|---|---|
| el8.x86_64 | N/A | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 |
| el8.aarch64 | N/A | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 |
| el9.x86_64 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 |
| el9.aarch64 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 |
| el10.x86_64 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 |
| el10.aarch64 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 |
| d12.x86_64 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 |
| d12.aarch64 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 |
| d13.x86_64 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 |
| d13.aarch64 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 |
| u22.x86_64 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 |
| u22.aarch64 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 |
| u24.x86_64 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 |
| u24.aarch64 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 |
| u26.x86_64 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 |
| u26.aarch64 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 |
Source
github.com/RekGRpth/pg_curl
pg_curl-2.5.0.tar.gz
Install
Make sure PGDG and PIGSTY repo available:
Install this extension with pig:
Create this extension with:
Usage
Sources:
pg_curl exposes libcurl transfers as SQL functions. Upstream release 2.5.0 uses SQL extension version 2.5. Requests run in the database backend with the server’s network and filesystem access; installing the extension requires an administrator. Ordinary calls need no preload.
A Request in One Transaction
curl_easy_reset clears the handle, curl_easy_setopt_url chooses the destination, and curl_easy_perform performs the transfer. curl_easy_getinfo_data_in returns response bytes and curl_easy_getinfo_header_in returns headers. pg_curl.transaction defaults to true: handles are released at transaction end, so keep a multi-statement request in one transaction. Network/file side effects are not rolled back with SQL.
Access and Whitelists
A superuser grants allowed prefixes to an existing application role:
Reconnect to apply a role default. With an unset pg_curl.whitelist, superusers are unrestricted and other roles are denied. A configured whitelist also restricts superusers. Only matching HTTP, HTTPS and file URLs are allowed while it applies; FTP, SMTP and other protocols are denied. HTTP paths match at segment boundaries, not arbitrary string prefixes.
Local-file options are checked too. File paths are resolved and must already exist, including an output cookie-jar file. Redirect targets are checked; restricted redirect following requires libcurl 7.80.0 or later. Explicit proxy and DNS-over-HTTPS options are denied while restricted, although the server’s proxy environment can still apply. Limit allowed hosts and paths deliberately; stored credentials and server-local files remain sensitive.
Other Operations and Upgrade
curl_postfield_append, curl_easy_setopt_postfields and curl_header_append construct form or JSON requests. curl_mime_data and curl_mime_file construct MIME parts; 2.5 adds a head text[] overload for multiple headers. Header array elements cannot be NULL or contain carriage returns/newlines. The MIME data overload accepts text or binary data.
Check pg_extension.extversion before upgrading. This distribution includes the 2.4-to-2.5 update script; it does not supply a 2.4.1-to-2.5 edge, so do not assume an existing installation reporting 2.4.1 can use an automatic update. For an installation actually at SQL 2.4, after installing matching files:
Use the new whitelist rules before granting execution to application roles. Review libcurl’s supported protocols and use the matching library on all database hosts.