colnames
colnames : Return column names of a record or composite value
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 4360 | colnames | colnames | 1.7.0 |
UTIL | 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 | pg_describe describe_resultset get_column pltoolbox hstore |
Packages
| Type | Repo | Version | PG Major Compatibility | Package Pattern | Dependencies |
|---|---|---|---|---|---|
| EXT | PIGSTY | 1.7.0 |
18 17 16 15 14 | colnames |
- |
| RPM | PIGSTY | 1.7.1 |
18 17 16 15 14 | colnames_$v |
- |
| DEB | PIGSTY | 1.7.1 |
18 17 16 15 14 | postgresql-$v-colnames |
- |
| Linux / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
| el8.x86_64 | PIGSTY 1.7.1 | PIGSTY 1.7.1 | PIGSTY 1.7.1 | PIGSTY 1.7.1 | PIGSTY 1.7.1 |
| el8.aarch64 | PIGSTY 1.7.1 | PIGSTY 1.7.1 | PIGSTY 1.7.1 | PIGSTY 1.7.1 | PIGSTY 1.7.1 |
| el9.x86_64 | PIGSTY 1.7.1 | PIGSTY 1.7.1 | PIGSTY 1.7.1 | PIGSTY 1.7.1 | PIGSTY 1.7.1 |
| el9.aarch64 | PIGSTY 1.7.1 | PIGSTY 1.7.1 | PIGSTY 1.7.1 | PIGSTY 1.7.1 | PIGSTY 1.7.1 |
| el10.x86_64 | PIGSTY 1.7.1 | PIGSTY 1.7.1 | PIGSTY 1.7.1 | PIGSTY 1.7.1 | PIGSTY 1.7.1 |
| el10.aarch64 | PIGSTY 1.7.1 | PIGSTY 1.7.1 | PIGSTY 1.7.1 | PIGSTY 1.7.1 | PIGSTY 1.7.1 |
| d12.x86_64 | PIGSTY 1.7.1 | PIGSTY 1.7.1 | PIGSTY 1.7.1 | PIGSTY 1.7.1 | PIGSTY 1.7.1 |
| d12.aarch64 | PIGSTY 1.7.1 | PIGSTY 1.7.1 | PIGSTY 1.7.1 | PIGSTY 1.7.1 | PIGSTY 1.7.1 |
| d13.x86_64 | PIGSTY 1.7.1 | PIGSTY 1.7.1 | PIGSTY 1.7.1 | PIGSTY 1.7.1 | PIGSTY 1.7.1 |
| d13.aarch64 | PIGSTY 1.7.1 | PIGSTY 1.7.1 | PIGSTY 1.7.1 | PIGSTY 1.7.1 | PIGSTY 1.7.1 |
| u22.x86_64 | PIGSTY 1.7.1 | PIGSTY 1.7.1 | PIGSTY 1.7.1 | PIGSTY 1.7.1 | PIGSTY 1.7.1 |
| u22.aarch64 | PIGSTY 1.7.1 | PIGSTY 1.7.1 | PIGSTY 1.7.1 | PIGSTY 1.7.1 | PIGSTY 1.7.1 |
| u24.x86_64 | PIGSTY 1.7.1 | PIGSTY 1.7.1 | PIGSTY 1.7.1 | PIGSTY 1.7.1 | PIGSTY 1.7.1 |
| u24.aarch64 | PIGSTY 1.7.1 | PIGSTY 1.7.1 | PIGSTY 1.7.1 | PIGSTY 1.7.1 | PIGSTY 1.7.1 |
| u26.x86_64 | PIGSTY 1.7.1 | PIGSTY 1.7.1 | PIGSTY 1.7.1 | PIGSTY 1.7.1 | PIGSTY 1.7.1 |
| u26.aarch64 | PIGSTY 1.7.1 | PIGSTY 1.7.1 | PIGSTY 1.7.1 | PIGSTY 1.7.1 | PIGSTY 1.7.1 |
Source
github.com/theory/colnames
colnames-1.7.1.tar.gz
Install
Make sure PGDG and PIGSTY repo available:
Install this extension with pig:
Create this extension with:
Usage
Sources:
colnames provides colnames(record), returning the input record’s field names as a name[]. Use it in generic triggers or dynamic SQL helpers that need a composite value’s structure without converting its values to JSON. Distribution version 1.7.1 retains extension version 1.7.0.
Core Workflow
The three calls return {f1,f2,f3}, {id,name}, and {id,name} respectively. Anonymous rows receive generated names; named rows preserve their attribute names. A typed null works because its composite type supplies the descriptor. An untyped null does not identify a composite type.
Function Behavior
colnames(record) returns name[], is STABLE, and is deliberately not STRICT. It preserves column order and quoted identifier spelling, omits dropped columns, and returns an empty array for an empty composite type. It reads the row descriptor rather than table data.
Operational Notes
The extension has no runtime extension dependencies and needs no preload or restart. Its C library loads when the function is called. Creating the extension requires a superuser because the control file does not mark it trusted. It is relocatable and can be installed in a chosen schema or moved with ALTER EXTENSION colnames SET SCHEMA.
Release 1.7.1 documents PostgreSQL 8.2–17 compatibility. The PGSTY package targets PostgreSQL 14–18; PostgreSQL 18 acceptance comes from package and regression testing rather than that release’s compatibility statement.
PostgreSQL 9.3 and later also offer row_to_json with json_object_keys as a pure SQL alternative. If discovered names are used in dynamic SQL, quote identifiers and keep values parameterized.