Skip to content

pg_describe

Report a query’s parameters and result columns without executing it

pg_describe · Report a query’s parameters and result columns without executing it

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
4350pg_describepg_describe1.0.0UTILMITC
AttributeHas BinaryHas LibraryNeed LoadHas DDLRelocatableTrusted
--s-d-rNoYesNoYesyesno
Relationships
See Alsocolnames ddlx pg_readme pglinter
Uses PostgreSQL parser and analyzer without invoking the executor; upstream and PIGSTY packages require PostgreSQL 17 or newer.

Packages

TypeRepoVersionPG Major CompatibilityPackage PatternDependencies
EXTPIGSTY1.0.019 18 17 16 15pg_describe-
RPMPIGSTY1.0.019 18 17 16 15pg_describe_$v-
DEBPIGSTY1.0.019 18 17 16 15postgresql-$v-pg-describe-
Linux / PGPG19PG18PG17PG16PG15
el8.x86_64N/APIGSTY 1.0.0PIGSTY 1.0.0N/AN/A
el8.aarch64N/APIGSTY 1.0.0PIGSTY 1.0.0N/AN/A
el9.x86_64PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0N/AN/A
el9.aarch64PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0N/AN/A
el10.x86_64PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0N/AN/A
el10.aarch64PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0N/AN/A
d12.x86_64PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0N/AN/A
d12.aarch64PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0N/AN/A
d13.x86_64PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0N/AN/A
d13.aarch64PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0N/AN/A
u22.x86_64PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0N/AN/A
u22.aarch64PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0N/AN/A
u24.x86_64PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0N/AN/A
u24.aarch64PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0N/AN/A
u26.x86_64PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0N/AN/A
u26.aarch64PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0N/AN/A
PackageVersionOSORGSIZEFile URL
pg_describe_191.0.0el9.x86_64pigsty42.0 KiBpg_describe_19-1.0.0-1PGSTY.el9.x86_64.rpm
pg_describe_191.0.0el9.aarch64pigsty41.8 KiBpg_describe_19-1.0.0-1PGSTY.el9.aarch64.rpm
pg_describe_191.0.0el10.x86_64pigsty41.8 KiBpg_describe_19-1.0.0-1PGSTY.el10.x86_64.rpm
pg_describe_191.0.0el10.aarch64pigsty42.0 KiBpg_describe_19-1.0.0-1PGSTY.el10.aarch64.rpm
postgresql-19-pg-describe1.0.0d12.x86_64pigsty36.1 KiBpostgresql-19-pg-describe_1.0.0-1PGSTY~bookworm_amd64.deb
postgresql-19-pg-describe1.0.0d12.aarch64pigsty35.9 KiBpostgresql-19-pg-describe_1.0.0-1PGSTY~bookworm_arm64.deb
postgresql-19-pg-describe1.0.0d13.x86_64pigsty36.0 KiBpostgresql-19-pg-describe_1.0.0-1PGSTY~trixie_amd64.deb
postgresql-19-pg-describe1.0.0d13.aarch64pigsty36.0 KiBpostgresql-19-pg-describe_1.0.0-1PGSTY~trixie_arm64.deb
postgresql-19-pg-describe1.0.0u22.x86_64pigsty37.9 KiBpostgresql-19-pg-describe_1.0.0-1PGSTY~jammy_amd64.deb
postgresql-19-pg-describe1.0.0u22.aarch64pigsty37.9 KiBpostgresql-19-pg-describe_1.0.0-1PGSTY~jammy_arm64.deb
postgresql-19-pg-describe1.0.0u24.x86_64pigsty37.3 KiBpostgresql-19-pg-describe_1.0.0-1PGSTY~noble_amd64.deb
postgresql-19-pg-describe1.0.0u24.aarch64pigsty37.0 KiBpostgresql-19-pg-describe_1.0.0-1PGSTY~noble_arm64.deb
postgresql-19-pg-describe1.0.0u26.x86_64pigsty37.3 KiBpostgresql-19-pg-describe_1.0.0-1PGSTY~resolute_amd64.deb
postgresql-19-pg-describe1.0.0u26.aarch64pigsty37.3 KiBpostgresql-19-pg-describe_1.0.0-1PGSTY~resolute_arm64.deb
PackageVersionOSORGSIZEFile URL
pg_describe_181.0.0el8.x86_64pigsty41.8 KiBpg_describe_18-1.0.0-1PGSTY.el8.x86_64.rpm
pg_describe_181.0.0el8.aarch64pigsty42.0 KiBpg_describe_18-1.0.0-1PGSTY.el8.aarch64.rpm
pg_describe_181.0.0el9.x86_64pigsty42.0 KiBpg_describe_18-1.0.0-1PGSTY.el9.x86_64.rpm
pg_describe_181.0.0el9.aarch64pigsty41.8 KiBpg_describe_18-1.0.0-1PGSTY.el9.aarch64.rpm
pg_describe_181.0.0el10.x86_64pigsty41.8 KiBpg_describe_18-1.0.0-1PGSTY.el10.x86_64.rpm
pg_describe_181.0.0el10.aarch64pigsty42.0 KiBpg_describe_18-1.0.0-1PGSTY.el10.aarch64.rpm
postgresql-18-pg-describe1.0.0d12.x86_64pigsty36.1 KiBpostgresql-18-pg-describe_1.0.0-1PGSTY~bookworm_amd64.deb
postgresql-18-pg-describe1.0.0d12.aarch64pigsty35.9 KiBpostgresql-18-pg-describe_1.0.0-1PGSTY~bookworm_arm64.deb
postgresql-18-pg-describe1.0.0d13.x86_64pigsty36.0 KiBpostgresql-18-pg-describe_1.0.0-1PGSTY~trixie_amd64.deb
postgresql-18-pg-describe1.0.0d13.aarch64pigsty36.0 KiBpostgresql-18-pg-describe_1.0.0-1PGSTY~trixie_arm64.deb
postgresql-18-pg-describe1.0.0u22.x86_64pigsty37.9 KiBpostgresql-18-pg-describe_1.0.0-1PGSTY~jammy_amd64.deb
postgresql-18-pg-describe1.0.0u22.aarch64pigsty37.9 KiBpostgresql-18-pg-describe_1.0.0-1PGSTY~jammy_arm64.deb
postgresql-18-pg-describe1.0.0u24.x86_64pigsty37.3 KiBpostgresql-18-pg-describe_1.0.0-1PGSTY~noble_amd64.deb
postgresql-18-pg-describe1.0.0u24.aarch64pigsty37.0 KiBpostgresql-18-pg-describe_1.0.0-1PGSTY~noble_arm64.deb
postgresql-18-pg-describe1.0.0u26.x86_64pigsty37.3 KiBpostgresql-18-pg-describe_1.0.0-1PGSTY~resolute_amd64.deb
postgresql-18-pg-describe1.0.0u26.aarch64pigsty37.3 KiBpostgresql-18-pg-describe_1.0.0-1PGSTY~resolute_arm64.deb
PackageVersionOSORGSIZEFile URL
pg_describe_171.0.0el8.x86_64pigsty41.7 KiBpg_describe_17-1.0.0-1PGSTY.el8.x86_64.rpm
pg_describe_171.0.0el8.aarch64pigsty41.9 KiBpg_describe_17-1.0.0-1PGSTY.el8.aarch64.rpm
pg_describe_171.0.0el9.x86_64pigsty42.0 KiBpg_describe_17-1.0.0-1PGSTY.el9.x86_64.rpm
pg_describe_171.0.0el9.aarch64pigsty41.8 KiBpg_describe_17-1.0.0-1PGSTY.el9.aarch64.rpm
pg_describe_171.0.0el10.x86_64pigsty41.8 KiBpg_describe_17-1.0.0-1PGSTY.el10.x86_64.rpm
pg_describe_171.0.0el10.aarch64pigsty41.9 KiBpg_describe_17-1.0.0-1PGSTY.el10.aarch64.rpm
postgresql-17-pg-describe1.0.0d12.x86_64pigsty36.0 KiBpostgresql-17-pg-describe_1.0.0-1PGSTY~bookworm_amd64.deb
postgresql-17-pg-describe1.0.0d12.aarch64pigsty35.9 KiBpostgresql-17-pg-describe_1.0.0-1PGSTY~bookworm_arm64.deb
postgresql-17-pg-describe1.0.0d13.x86_64pigsty36.0 KiBpostgresql-17-pg-describe_1.0.0-1PGSTY~trixie_amd64.deb
postgresql-17-pg-describe1.0.0d13.aarch64pigsty35.9 KiBpostgresql-17-pg-describe_1.0.0-1PGSTY~trixie_arm64.deb
postgresql-17-pg-describe1.0.0u22.x86_64pigsty40.3 KiBpostgresql-17-pg-describe_1.0.0-1PGSTY~jammy_amd64.deb
postgresql-17-pg-describe1.0.0u22.aarch64pigsty40.3 KiBpostgresql-17-pg-describe_1.0.0-1PGSTY~jammy_arm64.deb
postgresql-17-pg-describe1.0.0u24.x86_64pigsty37.3 KiBpostgresql-17-pg-describe_1.0.0-1PGSTY~noble_amd64.deb
postgresql-17-pg-describe1.0.0u24.aarch64pigsty37.0 KiBpostgresql-17-pg-describe_1.0.0-1PGSTY~noble_arm64.deb
postgresql-17-pg-describe1.0.0u26.x86_64pigsty37.2 KiBpostgresql-17-pg-describe_1.0.0-1PGSTY~resolute_amd64.deb
postgresql-17-pg-describe1.0.0u26.aarch64pigsty37.2 KiBpostgresql-17-pg-describe_1.0.0-1PGSTY~resolute_arm64.deb

Source

pig build pkg pg_describe;		# build rpm/deb

Install

Make sure PGDG and PIGSTY repo available:

pig repo add pgsql -u   # add both repo and update cache

Install this extension with pig:

pig install pg_describe;		# install by package name

pig install pg_describe -v 19;   # install for PG 19
pig install pg_describe -v 18;   # install for PG 18
pig install pg_describe -v 17;   # install for PG 17

Create this extension with:

CREATE EXTENSION pg_describe;

Usage

Sources:

pg_describe reports the parameters and result columns of a SQL statement without executing it. It uses PostgreSQL parsing and analysis to infer parameter types, wire-visible result types, source-column provenance, and outer-join-aware nullability. Use it for code generation, migration checks, and query-contract tooling.

Describe a Query

CREATE EXTENSION pg_describe;

SELECT *
FROM pg_describe(
  'SELECT id, email FROM users WHERE id = $1'
);

Rows with kind = 'param' describe $1, $2, and later parameters. Rows with kind = 'column' describe result-column order, name, type OID/name, source table/column, base NOT NULL status, and whether the final expression is known non-null.

Check Join Nullability

SELECT *
FROM pg_describe($query$
  SELECT o.id, c.email
  FROM orders AS o
  LEFT JOIN customers AS c ON c.id = o.customer_id
  WHERE o.placed_at >= $1
$query$);

Even when customers.email is declared NOT NULL, result_not_null is false because a left join can null-extend the row. This distinction is useful when generating nullable client types.

Execution and Security Boundary

  • The statement is parsed and analyzed but not executed. Describing a DELETE, volatile function call, or expensive query does not run the statement.
  • Normal name resolution and privilege checks still apply. Callers cannot use pg_describe to inspect objects they could not reference themselves.
  • Parameter types must be inferable from context; ambiguous $n parameters still produce PostgreSQL analysis errors.
  • The result describes PostgreSQL’s analyzed output, not dynamic SQL assembled later by an application.

Requirements and Caveats

  • Upstream 1.0.0 requires PostgreSQL 17; PostgreSQL 16 is described as possibly working but untested. Pigsty packages target PostgreSQL 17 and 18.
  • The extension is relocatable and does not require preloading or a restart.
  • The companion pg-describe-gen TypeScript tool is a separate npm package. The PostgreSQL extension works without it.
  • This is a young API. Pin the extension/tool versions in CI and review generated changes alongside schema migrations.

Table reader