pg_curl
pg_curl
pg_curl : Run curl actions for data transfer in URL syntax
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 4090 | pg_curl | pg_curl | 2.4.5 | UTIL | MIT | C |
| 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 pgjwt gzip bzip zstd pgjq pg_smtp_client |
Packages
| Type | Repo | Version | PG Major Compatibility | Package Pattern | Dependencies |
|---|---|---|---|---|---|
| EXT | PIGSTY | 2.4.5 | 18 17 16 15 14 13 | pg_curl | - |
| RPM | PIGSTY | 2.4.5 | 18 17 16 15 14 13 | pg_curl_$v* | - |
| DEB | PIGSTY | 2.4.5 | 18 17 16 15 14 13 | postgresql-$v-pg-curl | - |
| Linux / PG | PG18 | PG17 | PG16 | PG15 | PG14 | PG13 |
|---|---|---|---|---|---|---|
el8.x86_64 | PIGSTY 2.4.5 | PIGSTY 2.4.5 | PIGSTY 2.4.5 | PIGSTY 2.4.5 | PIGSTY 2.4.5 | PIGSTY 2.4.5 |
el8.aarch64 | PIGSTY 2.4.5 | PIGSTY 2.4.5 | PIGSTY 2.4.5 | PIGSTY 2.4.5 | PIGSTY 2.4.5 | PIGSTY 2.4.5 |
el9.x86_64 | PIGSTY 2.4.5 | PIGSTY 2.4.5 | PIGSTY 2.4.5 | PIGSTY 2.4.5 | PIGSTY 2.4.5 | PIGSTY 2.4.5 |
el9.aarch64 | PIGSTY 2.4.5 | PIGSTY 2.4.5 | PIGSTY 2.4.5 | PIGSTY 2.4.5 | PIGSTY 2.4.5 | PIGSTY 2.4.5 |
el10.x86_64 | PIGSTY 2.4.5 | PIGSTY 2.4.5 | PIGSTY 2.4.5 | PIGSTY 2.4.5 | PIGSTY 2.4.5 | PIGSTY 2.4.5 |
el10.aarch64 | PIGSTY 2.4.5 | PIGSTY 2.4.5 | PIGSTY 2.4.5 | PIGSTY 2.4.5 | PIGSTY 2.4.5 | PIGSTY 2.4.5 |
d12.x86_64 | PIGSTY 2.4.5 | PIGSTY 2.4.5 | PIGSTY 2.4.5 | PIGSTY 2.4.5 | PIGSTY 2.4.5 | PIGSTY 2.4.5 |
d12.aarch64 | PIGSTY 2.4.5 | PIGSTY 2.4.5 | PIGSTY 2.4.5 | PIGSTY 2.4.5 | PIGSTY 2.4.5 | PIGSTY 2.4.5 |
d13.x86_64 | PIGSTY 2.4.5 | PIGSTY 2.4.5 | PIGSTY 2.4.5 | PIGSTY 2.4.5 | PIGSTY 2.4.5 | PIGSTY 2.4.5 |
d13.aarch64 | PIGSTY 2.4.5 | PIGSTY 2.4.5 | PIGSTY 2.4.5 | PIGSTY 2.4.5 | PIGSTY 2.4.5 | PIGSTY 2.4.5 |
u22.x86_64 | PIGSTY 2.4.5 | PIGSTY 2.4.5 | PIGSTY 2.4.5 | PIGSTY 2.4.5 | PIGSTY 2.4.5 | PIGSTY 2.4.5 |
u22.aarch64 | PIGSTY 2.4.5 | PIGSTY 2.4.5 | PIGSTY 2.4.5 | PIGSTY 2.4.5 | PIGSTY 2.4.5 | PIGSTY 2.4.5 |
u24.x86_64 | PIGSTY 2.4.5 | PIGSTY 2.4.5 | PIGSTY 2.4.5 | PIGSTY 2.4.5 | PIGSTY 2.4.5 | PIGSTY 2.4.5 |
u24.aarch64 | PIGSTY 2.4.5 | PIGSTY 2.4.5 | PIGSTY 2.4.5 | PIGSTY 2.4.5 | PIGSTY 2.4.5 | PIGSTY 2.4.5 |
Source
pig build pkg pg_curl; # build rpm / deb with pigInstall
Make sure PGDG and PIGSTY repo available:
pig repo add pgdg pigsty -u # add both repo and update cacheInstall this extension with pig:
pig install pg_curl; # install via package name, for the active PG version
pig install pg_curl -v 18; # install for PG 18
pig install pg_curl -v 17; # install for PG 17
pig install pg_curl -v 16; # install for PG 16
pig install pg_curl -v 15; # install for PG 15
pig install pg_curl -v 14; # install for PG 14
pig install pg_curl -v 13; # install for PG 13Create this extension with:
CREATE EXTENSION pg_curl;Usage
CREATE EXTENSION pg_curl;Perform HTTP Get:
-- wrap curl http get
CREATE OR REPLACE FUNCTION get(url TEXT) RETURNS TEXT LANGUAGE SQL AS $BODY$
WITH s AS (SELECT
curl_easy_reset(),
curl_easy_setopt_url(url),
curl_easy_perform(),
curl_easy_getinfo_data_in()
) SELECT convert_from(curl_easy_getinfo_data_in, 'utf-8') FROM s;
$BODY$;
SELECT get('https://www.postgresql.org/');Perform Email SMTP:
CREATE OR REPLACE FUNCTION email(url TEXT, username TEXT, password TEXT, subject TEXT, sender TEXT, recipient TEXT, body TEXT, type TEXT) RETURNS TEXT LANGUAGE SQL AS $BODY$
WITH s AS (SELECT
curl_easy_reset(),
curl_easy_setopt_mail_from(sender),
curl_easy_setopt_password(password),
curl_easy_setopt_url(url),
curl_easy_setopt_username(username),
curl_header_append('From', sender),
curl_header_append('Subject', subject),
curl_header_append('To', recipient),
curl_mime_data(body, type:=type),
curl_recipient_append(recipient),
curl_easy_perform(),
curl_easy_getinfo_header_in()
) SELECT curl_easy_getinfo_header_in FROM s;
$BODY$;Perform FTP download:
CREATE OR REPLACE FUNCTION download(url TEXT, username TEXT, password TEXT) RETURNS BYTEA LANGUAGE SQL AS $BODY$
WITH s AS (SELECT
curl_easy_reset(),
curl_easy_setopt_password(password),
curl_easy_setopt_url(url),
curl_easy_setopt_username(username),
curl_easy_perform(),
curl_easy_getinfo_data_in()
) SELECT curl_easy_getinfo_data_in FROM s;
$BODY$;Last updated on