uri
uri
pg_uri : URI Data type for PostgreSQL
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 3840 | uri | pg_uri | 1.20251029 | TYPE | PostgreSQL | C |
| Attribute | Has Binary | Has Library | Need Load | Has DDL | Relocatable | Trusted |
|---|---|---|---|---|---|---|
--s-d-r | No | Yes | No | Yes | yes | no |
| Relationships | |
|---|---|
| See Also | prefix semver unit pgpdf pglite_fusion md5hash asn1oid roaringbitmap |
+int flag
Packages
| Type | Repo | Version | PG Major Compatibility | Package Pattern | Dependencies |
|---|---|---|---|---|---|
| EXT | PIGSTY | 1.20251029 | 18 17 16 15 14 | pg_uri | - |
| RPM | PIGSTY | 1.20251029 | 18 17 16 15 14 | pg_uri_$v | - |
| DEB | PIGSTY | 1.20251029 | 18 17 16 15 14 | postgresql-$v-pg-uri | - |
| Linux / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
el8.x86_64 | PIGSTY 1.20251029 | PIGSTY 1.20251029 | PIGSTY 1.20251029 | PIGSTY 1.20251029 | PIGSTY 1.20251029 |
el8.aarch64 | PIGSTY 1.20251029 | PIGSTY 1.20251029 | PIGSTY 1.20251029 | PIGSTY 1.20251029 | PIGSTY 1.20251029 |
el9.x86_64 | PIGSTY 1.20251029 | PIGSTY 1.20251029 | PIGSTY 1.20251029 | PIGSTY 1.20251029 | PIGSTY 1.20251029 |
el9.aarch64 | PIGSTY 1.20251029 | PIGSTY 1.20251029 | PIGSTY 1.20251029 | PIGSTY 1.20251029 | PIGSTY 1.20251029 |
el10.x86_64 | PIGSTY 1.20251029 | PIGSTY 1.20251029 | PIGSTY 1.20251029 | PIGSTY 1.20251029 | PIGSTY 1.20251029 |
el10.aarch64 | PIGSTY 1.20251029 | PIGSTY 1.20251029 | PIGSTY 1.20251029 | PIGSTY 1.20251029 | PIGSTY 1.20251029 |
d12.x86_64 | PIGSTY 1.20251029 | PIGSTY 1.20251029 | PIGSTY 1.20251029 | PIGSTY 1.20251029 | PIGSTY 1.20251029 |
d12.aarch64 | PIGSTY 1.20251029 | PIGSTY 1.20251029 | PIGSTY 1.20251029 | PIGSTY 1.20251029 | PIGSTY 1.20251029 |
d13.x86_64 | PIGSTY 1.20251029 | PIGSTY 1.20251029 | PIGSTY 1.20251029 | PIGSTY 1.20251029 | PIGSTY 1.20251029 |
d13.aarch64 | PIGSTY 1.20251029 | PIGSTY 1.20251029 | PIGSTY 1.20251029 | PIGSTY 1.20251029 | PIGSTY 1.20251029 |
u22.x86_64 | PIGSTY 1.20251029 | PIGSTY 1.20251029 | PIGSTY 1.20251029 | PIGSTY 1.20251029 | PIGSTY 1.20251029 |
u22.aarch64 | PIGSTY 1.20251029 | PIGSTY 1.20251029 | PIGSTY 1.20251029 | PIGSTY 1.20251029 | PIGSTY 1.20251029 |
u24.x86_64 | PIGSTY 1.20251029 | PIGSTY 1.20251029 | PIGSTY 1.20251029 | PIGSTY 1.20251029 | PIGSTY 1.20251029 |
u24.aarch64 | PIGSTY 1.20251029 | PIGSTY 1.20251029 | PIGSTY 1.20251029 | PIGSTY 1.20251029 | PIGSTY 1.20251029 |
Source
pig build pkg pg_uri; # build rpm/debInstall
Make sure PGDG and PIGSTY repo available:
pig repo add pgsql -u # add both repo and update cacheInstall this extension with pig:
pig install pg_uri; # install via package name, for the active PG version
pig install uri; # install by extension name, for the current active PG version
pig install uri -v 18; # install for PG 18
pig install uri -v 17; # install for PG 17
pig install uri -v 16; # install for PG 16
pig install uri -v 15; # install for PG 15
pig install uri -v 14; # install for PG 14Create this extension with:
CREATE EXTENSION uri;Usage
The uri extension provides a data type for storing URIs with syntax validation per RFC 3986, component extraction functions, and human-friendly sorting.
CREATE EXTENSION uri;
CREATE TABLE links (
id int PRIMARY KEY,
link uri
);
INSERT INTO links VALUES (1, 'https://github.com/petere/pguri');Component Extraction Functions
| Function | Returns | Description |
|---|---|---|
uri_scheme(uri) | text | Scheme (http, ftp, mailto) |
uri_userinfo(uri) | text | User info; NULL if absent |
uri_host(uri) | text | Hostname or IP address |
uri_host_inet(uri) | inet | IP host as inet; NULL if not IP |
uri_port(uri) | integer | Port number; NULL if unspecified |
uri_path(uri) | text | Path component (never NULL) |
uri_path_array(uri) | text[] | Path split by / |
uri_query(uri) | text | Query string; NULL if absent |
uri_fragment(uri) | text | Fragment; NULL if absent |
Utility Functions
-- Normalize URI per RFC 3986
SELECT uri_normalize('HTTP://Example.COM/foo/../bar');
-- Percent-encode text
SELECT uri_escape('hello world', true, false); -- hello+world
-- Decode percent-encoded text
SELECT uri_unescape('hello+world', true, false); -- hello worldExample
SELECT uri_scheme(link), uri_host(link), uri_path(link)
FROM links
WHERE uri_host(link) = 'github.com';Last updated on