pg_try_cast
Overview
| Package | Version | Category | License | Language |
|---|---|---|---|---|
pg_try_cast | 1.0 | FUNC | PostgreSQL | C |
| ID | Extension | Bin | Lib | Load | Create | Trust | Reloc | Schema |
|---|---|---|---|---|---|---|---|---|
| 4855 | pg_try_cast | No | Yes | No | Yes | Yes | Yes | - |
Release 1.0.0 installs control/SQL 1.0; META provides.version says 1.0.0. PG16+ required, CI covers 16-18; input types without soft-error support may still raise errors.
Version
| Type | Repo | Version | PG Ver | Package | Deps |
|---|---|---|---|---|---|
| EXT | PIGSTY | 1.0 | 1817161514 | pg_try_cast | - |
| RPM | PIGSTY | 1.0.0 | 1817161514 | pg_try_cast_$v | - |
| DEB | PIGSTY | 1.0.0 | 1817161514 | postgresql-$v-pg-try-cast | - |
| OS / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
| el8.x86_64 | PIGSTY 1.0.0 el8.x86_64.pg18 : pg_try_cast_18 pg_try_cast_18-1.0.0-1PGSTY.el8.x86_64.rpm
| PIGSTY 1.0.0 el8.x86_64.pg17 : pg_try_cast_17 pg_try_cast_17-1.0.0-1PGSTY.el8.x86_64.rpm
| PIGSTY 1.0.0 el8.x86_64.pg16 : pg_try_cast_16 pg_try_cast_16-1.0.0-1PGSTY.el8.x86_64.rpm
| N/A | N/A |
| el8.aarch64 | PIGSTY 1.0.0 el8.aarch64.pg18 : pg_try_cast_18 pg_try_cast_18-1.0.0-1PGSTY.el8.aarch64.rpm
| PIGSTY 1.0.0 el8.aarch64.pg17 : pg_try_cast_17 pg_try_cast_17-1.0.0-1PGSTY.el8.aarch64.rpm
| PIGSTY 1.0.0 el8.aarch64.pg16 : pg_try_cast_16 pg_try_cast_16-1.0.0-1PGSTY.el8.aarch64.rpm
| N/A | N/A |
| el9.x86_64 | PIGSTY 1.0.0 el9.x86_64.pg18 : pg_try_cast_18 pg_try_cast_18-1.0.0-1PGSTY.el9.x86_64.rpm
| PIGSTY 1.0.0 el9.x86_64.pg17 : pg_try_cast_17 pg_try_cast_17-1.0.0-1PGSTY.el9.x86_64.rpm
| PIGSTY 1.0.0 el9.x86_64.pg16 : pg_try_cast_16 pg_try_cast_16-1.0.0-1PGSTY.el9.x86_64.rpm
| N/A | N/A |
| el9.aarch64 | PIGSTY 1.0.0 el9.aarch64.pg18 : pg_try_cast_18 pg_try_cast_18-1.0.0-1PGSTY.el9.aarch64.rpm
| PIGSTY 1.0.0 el9.aarch64.pg17 : pg_try_cast_17 pg_try_cast_17-1.0.0-1PGSTY.el9.aarch64.rpm
| PIGSTY 1.0.0 el9.aarch64.pg16 : pg_try_cast_16 pg_try_cast_16-1.0.0-1PGSTY.el9.aarch64.rpm
| N/A | N/A |
| el10.x86_64 | PIGSTY 1.0.0 el10.x86_64.pg18 : pg_try_cast_18 pg_try_cast_18-1.0.0-1PGSTY.el10.x86_64.rpm
| PIGSTY 1.0.0 el10.x86_64.pg17 : pg_try_cast_17 pg_try_cast_17-1.0.0-1PGSTY.el10.x86_64.rpm
| PIGSTY 1.0.0 el10.x86_64.pg16 : pg_try_cast_16 pg_try_cast_16-1.0.0-1PGSTY.el10.x86_64.rpm
| N/A | N/A |
| el10.aarch64 | PIGSTY 1.0.0 el10.aarch64.pg18 : pg_try_cast_18 pg_try_cast_18-1.0.0-1PGSTY.el10.aarch64.rpm
| PIGSTY 1.0.0 el10.aarch64.pg17 : pg_try_cast_17 pg_try_cast_17-1.0.0-1PGSTY.el10.aarch64.rpm
| PIGSTY 1.0.0 el10.aarch64.pg16 : pg_try_cast_16 pg_try_cast_16-1.0.0-1PGSTY.el10.aarch64.rpm
| N/A | N/A |
| d12.x86_64 | PIGSTY 1.0.0 d12.x86_64.pg18 : postgresql-18-pg-try-cast postgresql-18-pg-try-cast_1.0.0-1PGSTY~bookworm_amd64.deb
| PIGSTY 1.0.0 d12.x86_64.pg17 : postgresql-17-pg-try-cast postgresql-17-pg-try-cast_1.0.0-1PGSTY~bookworm_amd64.deb
| PIGSTY 1.0.0 d12.x86_64.pg16 : postgresql-16-pg-try-cast postgresql-16-pg-try-cast_1.0.0-1PGSTY~bookworm_amd64.deb
| N/A | N/A |
| d12.aarch64 | PIGSTY 1.0.0 d12.aarch64.pg18 : postgresql-18-pg-try-cast postgresql-18-pg-try-cast_1.0.0-1PGSTY~bookworm_arm64.deb
| PIGSTY 1.0.0 d12.aarch64.pg17 : postgresql-17-pg-try-cast postgresql-17-pg-try-cast_1.0.0-1PGSTY~bookworm_arm64.deb
| PIGSTY 1.0.0 d12.aarch64.pg16 : postgresql-16-pg-try-cast postgresql-16-pg-try-cast_1.0.0-1PGSTY~bookworm_arm64.deb
| N/A | N/A |
| d13.x86_64 | PIGSTY 1.0.0 d13.x86_64.pg18 : postgresql-18-pg-try-cast postgresql-18-pg-try-cast_1.0.0-1PGSTY~trixie_amd64.deb
| PIGSTY 1.0.0 d13.x86_64.pg17 : postgresql-17-pg-try-cast postgresql-17-pg-try-cast_1.0.0-1PGSTY~trixie_amd64.deb
| PIGSTY 1.0.0 d13.x86_64.pg16 : postgresql-16-pg-try-cast postgresql-16-pg-try-cast_1.0.0-1PGSTY~trixie_amd64.deb
| N/A | N/A |
| d13.aarch64 | PIGSTY 1.0.0 d13.aarch64.pg18 : postgresql-18-pg-try-cast postgresql-18-pg-try-cast_1.0.0-1PGSTY~trixie_arm64.deb
| PIGSTY 1.0.0 d13.aarch64.pg17 : postgresql-17-pg-try-cast postgresql-17-pg-try-cast_1.0.0-1PGSTY~trixie_arm64.deb
| PIGSTY 1.0.0 d13.aarch64.pg16 : postgresql-16-pg-try-cast postgresql-16-pg-try-cast_1.0.0-1PGSTY~trixie_arm64.deb
| N/A | N/A |
| u22.x86_64 | PIGSTY 1.0.0 u22.x86_64.pg18 : postgresql-18-pg-try-cast postgresql-18-pg-try-cast_1.0.0-1PGSTY~jammy_amd64.deb
| PIGSTY 1.0.0 u22.x86_64.pg17 : postgresql-17-pg-try-cast postgresql-17-pg-try-cast_1.0.0-1PGSTY~jammy_amd64.deb
| PIGSTY 1.0.0 u22.x86_64.pg16 : postgresql-16-pg-try-cast postgresql-16-pg-try-cast_1.0.0-1PGSTY~jammy_amd64.deb
| N/A | N/A |
| u22.aarch64 | PIGSTY 1.0.0 u22.aarch64.pg18 : postgresql-18-pg-try-cast postgresql-18-pg-try-cast_1.0.0-1PGSTY~jammy_arm64.deb
| PIGSTY 1.0.0 u22.aarch64.pg17 : postgresql-17-pg-try-cast postgresql-17-pg-try-cast_1.0.0-1PGSTY~jammy_arm64.deb
| PIGSTY 1.0.0 u22.aarch64.pg16 : postgresql-16-pg-try-cast postgresql-16-pg-try-cast_1.0.0-1PGSTY~jammy_arm64.deb
| N/A | N/A |
| u24.x86_64 | PIGSTY 1.0.0 u24.x86_64.pg18 : postgresql-18-pg-try-cast postgresql-18-pg-try-cast_1.0.0-1PGSTY~noble_amd64.deb
| PIGSTY 1.0.0 u24.x86_64.pg17 : postgresql-17-pg-try-cast postgresql-17-pg-try-cast_1.0.0-1PGSTY~noble_amd64.deb
| PIGSTY 1.0.0 u24.x86_64.pg16 : postgresql-16-pg-try-cast postgresql-16-pg-try-cast_1.0.0-1PGSTY~noble_amd64.deb
| N/A | N/A |
| u24.aarch64 | PIGSTY 1.0.0 u24.aarch64.pg18 : postgresql-18-pg-try-cast postgresql-18-pg-try-cast_1.0.0-1PGSTY~noble_arm64.deb
| PIGSTY 1.0.0 u24.aarch64.pg17 : postgresql-17-pg-try-cast postgresql-17-pg-try-cast_1.0.0-1PGSTY~noble_arm64.deb
| PIGSTY 1.0.0 u24.aarch64.pg16 : postgresql-16-pg-try-cast postgresql-16-pg-try-cast_1.0.0-1PGSTY~noble_arm64.deb
| N/A | N/A |
| u26.x86_64 | PIGSTY 1.0.0 u26.x86_64.pg18 : postgresql-18-pg-try-cast postgresql-18-pg-try-cast_1.0.0-1PGSTY~resolute_amd64.deb
| PIGSTY 1.0.0 u26.x86_64.pg17 : postgresql-17-pg-try-cast postgresql-17-pg-try-cast_1.0.0-1PGSTY~resolute_amd64.deb
| PIGSTY 1.0.0 u26.x86_64.pg16 : postgresql-16-pg-try-cast postgresql-16-pg-try-cast_1.0.0-1PGSTY~resolute_amd64.deb
| N/A | N/A |
| u26.aarch64 | PIGSTY 1.0.0 u26.aarch64.pg18 : postgresql-18-pg-try-cast postgresql-18-pg-try-cast_1.0.0-1PGSTY~resolute_arm64.deb
| PIGSTY 1.0.0 u26.aarch64.pg17 : postgresql-17-pg-try-cast postgresql-17-pg-try-cast_1.0.0-1PGSTY~resolute_arm64.deb
| PIGSTY 1.0.0 u26.aarch64.pg16 : postgresql-16-pg-try-cast postgresql-16-pg-try-cast_1.0.0-1PGSTY~resolute_arm64.deb
| N/A | N/A |
Build
You can build the RPM / DEB packages for pg_try_cast using pig build:
Install
You can install pg_try_cast directly. First, make sure the PGDG and PIGSTY repositories are added and enabled:
Install the extension using pig or apt/yum/dnf:
Create Extension:
Usage
Sources:
pg_try_cast provides try_cast and try_convert for converting text without aborting a query on supported input errors. Release 1.0.0 installs SQL version 1.0. PostgreSQL 16 or later is required; upstream CI covers 16–18. It is trusted and relocatable, with no preload requirement.
Core Workflow
Operational Boundaries
try_cast(value text, fallback anyelement) takes its result type and error fallback from the second argument; try_convert(fallback anyelement, value text) reverses the order. NULL input returns NULL. Give the fallback an explicit type. Type modifiers and domain constraints are checked. This covers text input, not arbitrary native casts. Input functions without soft-error support can still raise an error, including malformed type names passed to regtype. A role with CREATE privilege on the database can install this trusted extension after its files are installed.
Was this page helpful?
Thanks—your feedback helps us improve this page.
What got in the way? (optional)