pg_describe
pg_describe : Report a query’s parameters and result columns without executing it
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 4350 | pg_describe | pg_describe | 1.0.0 |
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 | describe_resultset colnames ddlx pg_readme pglinter |
Packages
| Type | Repo | Version | PG Major Compatibility | Package Pattern | Dependencies |
|---|---|---|---|---|---|
| EXT | PIGSTY | 1.0.0 |
18 17 16 15 14 | pg_describe |
- |
| RPM | PIGSTY | 1.0.0 |
18 17 16 15 14 | pg_describe_$v |
- |
| DEB | PIGSTY | 1.0.0 |
18 17 16 15 14 | postgresql-$v-pg-describe |
- |
| Linux / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
| el8.x86_64 | PIGSTY 1.0.0 | PIGSTY 1.0.0 | N/A | N/A | N/A |
| el8.aarch64 | PIGSTY 1.0.0 | PIGSTY 1.0.0 | N/A | N/A | N/A |
| el9.x86_64 | PIGSTY 1.0.0 | PIGSTY 1.0.0 | N/A | N/A | N/A |
| el9.aarch64 | PIGSTY 1.0.0 | PIGSTY 1.0.0 | N/A | N/A | N/A |
| el10.x86_64 | PIGSTY 1.0.0 | PIGSTY 1.0.0 | N/A | N/A | N/A |
| el10.aarch64 | PIGSTY 1.0.0 | PIGSTY 1.0.0 | N/A | N/A | N/A |
| d12.x86_64 | PIGSTY 1.0.0 | PIGSTY 1.0.0 | N/A | N/A | N/A |
| d12.aarch64 | PIGSTY 1.0.0 | PIGSTY 1.0.0 | N/A | N/A | N/A |
| d13.x86_64 | PIGSTY 1.0.0 | PIGSTY 1.0.0 | N/A | N/A | N/A |
| d13.aarch64 | PIGSTY 1.0.0 | PIGSTY 1.0.0 | N/A | N/A | N/A |
| u22.x86_64 | PIGSTY 1.0.0 | PIGSTY 1.0.0 | N/A | N/A | N/A |
| u22.aarch64 | PIGSTY 1.0.0 | PIGSTY 1.0.0 | N/A | N/A | N/A |
| u24.x86_64 | PIGSTY 1.0.0 | PIGSTY 1.0.0 | N/A | N/A | N/A |
| u24.aarch64 | PIGSTY 1.0.0 | PIGSTY 1.0.0 | N/A | N/A | N/A |
| u26.x86_64 | PIGSTY 1.0.0 | PIGSTY 1.0.0 | N/A | N/A | N/A |
| u26.aarch64 | PIGSTY 1.0.0 | PIGSTY 1.0.0 | N/A | N/A | N/A |
Source
github.com/sajonaro/pg_describe
pg_describe-1.0.0.tar.gz
Install
Make sure PGDG and PIGSTY repo available:
Install this extension with pig:
Create this extension with:
Usage
Sources:
- pg_describe 1.0.0 README
- pg_describe documentation
- pg_describe 1.0.0 control file
- pg_describe 1.0.0 SQL
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
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
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_describeto inspect objects they could not reference themselves. - Parameter types must be inferable from context; ambiguous
$nparameters 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-genTypeScript 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.