Skip to content

colnames

Return column names of a record or composite value

colnames · Return column names of a record or composite value

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
4360colnamescolnames1.7.0UTILPostgreSQLC
AttributeHas BinaryHas LibraryNeed LoadHas DDLRelocatableTrusted
--s-d-rNoYesNoYesyesno
Relationships
See Alsopg_describe hstore
Distribution 1.7.1 retains extension version 1.7.0; colnames(record) returns name[]. No preload or runtime extension dependencies. Upstream release lists PG8.2-17; PG14-18 verified across all 16 PGSTY target platforms.

Packages

TypeRepoVersionPG Major CompatibilityPackage PatternDependencies
EXTPIGSTY1.7.019 18 17 16 15colnames-
RPMPIGSTY1.7.119 18 17 16 15colnames_$v-
DEBPIGSTY1.7.119 18 17 16 15postgresql-$v-colnames-
Linux / PGPG19PG18PG17PG16PG15
el8.x86_64N/APIGSTY 1.7.1PIGSTY 1.7.1PIGSTY 1.7.1PIGSTY 1.7.1
el8.aarch64N/APIGSTY 1.7.1PIGSTY 1.7.1PIGSTY 1.7.1PIGSTY 1.7.1
el9.x86_64PIGSTY 1.7.1PIGSTY 1.7.1PIGSTY 1.7.1PIGSTY 1.7.1PIGSTY 1.7.1
el9.aarch64PIGSTY 1.7.1PIGSTY 1.7.1PIGSTY 1.7.1PIGSTY 1.7.1PIGSTY 1.7.1
el10.x86_64PIGSTY 1.7.1PIGSTY 1.7.1PIGSTY 1.7.1PIGSTY 1.7.1PIGSTY 1.7.1
el10.aarch64PIGSTY 1.7.1PIGSTY 1.7.1PIGSTY 1.7.1PIGSTY 1.7.1PIGSTY 1.7.1
d12.x86_64PIGSTY 1.7.1PIGSTY 1.7.1PIGSTY 1.7.1PIGSTY 1.7.1PIGSTY 1.7.1
d12.aarch64PIGSTY 1.7.1PIGSTY 1.7.1PIGSTY 1.7.1PIGSTY 1.7.1PIGSTY 1.7.1
d13.x86_64PIGSTY 1.7.1PIGSTY 1.7.1PIGSTY 1.7.1PIGSTY 1.7.1PIGSTY 1.7.1
d13.aarch64PIGSTY 1.7.1PIGSTY 1.7.1PIGSTY 1.7.1PIGSTY 1.7.1PIGSTY 1.7.1
u22.x86_64PIGSTY 1.7.1PIGSTY 1.7.1PIGSTY 1.7.1PIGSTY 1.7.1PIGSTY 1.7.1
u22.aarch64PIGSTY 1.7.1PIGSTY 1.7.1PIGSTY 1.7.1PIGSTY 1.7.1PIGSTY 1.7.1
u24.x86_64PIGSTY 1.7.1PIGSTY 1.7.1PIGSTY 1.7.1PIGSTY 1.7.1PIGSTY 1.7.1
u24.aarch64PIGSTY 1.7.1PIGSTY 1.7.1PIGSTY 1.7.1PIGSTY 1.7.1PIGSTY 1.7.1
u26.x86_64PIGSTY 1.7.1PIGSTY 1.7.1PIGSTY 1.7.1PIGSTY 1.7.1PIGSTY 1.7.1
u26.aarch64PIGSTY 1.7.1PIGSTY 1.7.1PIGSTY 1.7.1PIGSTY 1.7.1PIGSTY 1.7.1
PackageVersionOSORGSIZEFile URL
colnames_191.7.1el9.x86_64pigsty19.5 KiBcolnames_19-1.7.1-1PGSTY.el9.x86_64.rpm
colnames_191.7.1el9.aarch64pigsty19.4 KiBcolnames_19-1.7.1-1PGSTY.el9.aarch64.rpm
colnames_191.7.1el10.x86_64pigsty19.5 KiBcolnames_19-1.7.1-1PGSTY.el10.x86_64.rpm
colnames_191.7.1el10.aarch64pigsty19.6 KiBcolnames_19-1.7.1-1PGSTY.el10.aarch64.rpm
postgresql-19-colnames1.7.1d12.x86_64pigsty11.5 KiBpostgresql-19-colnames_1.7.1-1PGSTY~bookworm_amd64.deb
postgresql-19-colnames1.7.1d12.aarch64pigsty11.5 KiBpostgresql-19-colnames_1.7.1-1PGSTY~bookworm_arm64.deb
postgresql-19-colnames1.7.1d13.x86_64pigsty11.5 KiBpostgresql-19-colnames_1.7.1-1PGSTY~trixie_amd64.deb
postgresql-19-colnames1.7.1d13.aarch64pigsty11.5 KiBpostgresql-19-colnames_1.7.1-1PGSTY~trixie_arm64.deb
postgresql-19-colnames1.7.1u22.x86_64pigsty11.7 KiBpostgresql-19-colnames_1.7.1-1PGSTY~jammy_amd64.deb
postgresql-19-colnames1.7.1u22.aarch64pigsty11.7 KiBpostgresql-19-colnames_1.7.1-1PGSTY~jammy_arm64.deb
postgresql-19-colnames1.7.1u24.x86_64pigsty11.8 KiBpostgresql-19-colnames_1.7.1-1PGSTY~noble_amd64.deb
postgresql-19-colnames1.7.1u24.aarch64pigsty11.6 KiBpostgresql-19-colnames_1.7.1-1PGSTY~noble_arm64.deb
postgresql-19-colnames1.7.1u26.x86_64pigsty11.9 KiBpostgresql-19-colnames_1.7.1-1PGSTY~resolute_amd64.deb
postgresql-19-colnames1.7.1u26.aarch64pigsty12.0 KiBpostgresql-19-colnames_1.7.1-1PGSTY~resolute_arm64.deb
PackageVersionOSORGSIZEFile URL
colnames_181.7.1el8.x86_64pigsty19.4 KiBcolnames_18-1.7.1-1PGSTY.el8.x86_64.rpm
colnames_181.7.1el8.aarch64pigsty19.5 KiBcolnames_18-1.7.1-1PGSTY.el8.aarch64.rpm
colnames_181.7.1el9.x86_64pigsty19.5 KiBcolnames_18-1.7.1-1PGSTY.el9.x86_64.rpm
colnames_181.7.1el9.aarch64pigsty19.4 KiBcolnames_18-1.7.1-1PGSTY.el9.aarch64.rpm
colnames_181.7.1el10.x86_64pigsty19.5 KiBcolnames_18-1.7.1-1PGSTY.el10.x86_64.rpm
colnames_181.7.1el10.aarch64pigsty19.6 KiBcolnames_18-1.7.1-1PGSTY.el10.aarch64.rpm
postgresql-18-colnames1.7.1d12.x86_64pigsty11.5 KiBpostgresql-18-colnames_1.7.1-1PGSTY~bookworm_amd64.deb
postgresql-18-colnames1.7.1d12.aarch64pigsty11.5 KiBpostgresql-18-colnames_1.7.1-1PGSTY~bookworm_arm64.deb
postgresql-18-colnames1.7.1d13.x86_64pigsty11.5 KiBpostgresql-18-colnames_1.7.1-1PGSTY~trixie_amd64.deb
postgresql-18-colnames1.7.1d13.aarch64pigsty11.5 KiBpostgresql-18-colnames_1.7.1-1PGSTY~trixie_arm64.deb
postgresql-18-colnames1.7.1u22.x86_64pigsty11.7 KiBpostgresql-18-colnames_1.7.1-1PGSTY~jammy_amd64.deb
postgresql-18-colnames1.7.1u22.aarch64pigsty11.7 KiBpostgresql-18-colnames_1.7.1-1PGSTY~jammy_arm64.deb
postgresql-18-colnames1.7.1u24.x86_64pigsty11.8 KiBpostgresql-18-colnames_1.7.1-1PGSTY~noble_amd64.deb
postgresql-18-colnames1.7.1u24.aarch64pigsty11.6 KiBpostgresql-18-colnames_1.7.1-1PGSTY~noble_arm64.deb
postgresql-18-colnames1.7.1u26.x86_64pigsty11.9 KiBpostgresql-18-colnames_1.7.1-1PGSTY~resolute_amd64.deb
postgresql-18-colnames1.7.1u26.aarch64pigsty12.0 KiBpostgresql-18-colnames_1.7.1-1PGSTY~resolute_arm64.deb
PackageVersionOSORGSIZEFile URL
colnames_171.7.1el8.x86_64pigsty19.3 KiBcolnames_17-1.7.1-1PGSTY.el8.x86_64.rpm
colnames_171.7.1el8.aarch64pigsty19.5 KiBcolnames_17-1.7.1-1PGSTY.el8.aarch64.rpm
colnames_171.7.1el9.x86_64pigsty19.5 KiBcolnames_17-1.7.1-1PGSTY.el9.x86_64.rpm
colnames_171.7.1el9.aarch64pigsty19.3 KiBcolnames_17-1.7.1-1PGSTY.el9.aarch64.rpm
colnames_171.7.1el10.x86_64pigsty19.4 KiBcolnames_17-1.7.1-1PGSTY.el10.x86_64.rpm
colnames_171.7.1el10.aarch64pigsty19.6 KiBcolnames_17-1.7.1-1PGSTY.el10.aarch64.rpm
postgresql-17-colnames1.7.1d12.x86_64pigsty11.4 KiBpostgresql-17-colnames_1.7.1-1PGSTY~bookworm_amd64.deb
postgresql-17-colnames1.7.1d12.aarch64pigsty11.4 KiBpostgresql-17-colnames_1.7.1-1PGSTY~bookworm_arm64.deb
postgresql-17-colnames1.7.1d13.x86_64pigsty11.4 KiBpostgresql-17-colnames_1.7.1-1PGSTY~trixie_amd64.deb
postgresql-17-colnames1.7.1d13.aarch64pigsty11.5 KiBpostgresql-17-colnames_1.7.1-1PGSTY~trixie_arm64.deb
postgresql-17-colnames1.7.1u22.x86_64pigsty12.1 KiBpostgresql-17-colnames_1.7.1-1PGSTY~jammy_amd64.deb
postgresql-17-colnames1.7.1u22.aarch64pigsty12.1 KiBpostgresql-17-colnames_1.7.1-1PGSTY~jammy_arm64.deb
postgresql-17-colnames1.7.1u24.x86_64pigsty11.7 KiBpostgresql-17-colnames_1.7.1-1PGSTY~noble_amd64.deb
postgresql-17-colnames1.7.1u24.aarch64pigsty11.5 KiBpostgresql-17-colnames_1.7.1-1PGSTY~noble_arm64.deb
postgresql-17-colnames1.7.1u26.x86_64pigsty11.9 KiBpostgresql-17-colnames_1.7.1-1PGSTY~resolute_amd64.deb
postgresql-17-colnames1.7.1u26.aarch64pigsty12.0 KiBpostgresql-17-colnames_1.7.1-1PGSTY~resolute_arm64.deb
PackageVersionOSORGSIZEFile URL
colnames_161.7.1el8.x86_64pigsty19.3 KiBcolnames_16-1.7.1-1PGSTY.el8.x86_64.rpm
colnames_161.7.1el8.aarch64pigsty19.5 KiBcolnames_16-1.7.1-1PGSTY.el8.aarch64.rpm
colnames_161.7.1el9.x86_64pigsty19.5 KiBcolnames_16-1.7.1-1PGSTY.el9.x86_64.rpm
colnames_161.7.1el9.aarch64pigsty19.3 KiBcolnames_16-1.7.1-1PGSTY.el9.aarch64.rpm
colnames_161.7.1el10.x86_64pigsty19.4 KiBcolnames_16-1.7.1-1PGSTY.el10.x86_64.rpm
colnames_161.7.1el10.aarch64pigsty19.6 KiBcolnames_16-1.7.1-1PGSTY.el10.aarch64.rpm
postgresql-16-colnames1.7.1d12.x86_64pigsty11.4 KiBpostgresql-16-colnames_1.7.1-1PGSTY~bookworm_amd64.deb
postgresql-16-colnames1.7.1d12.aarch64pigsty11.4 KiBpostgresql-16-colnames_1.7.1-1PGSTY~bookworm_arm64.deb
postgresql-16-colnames1.7.1d13.x86_64pigsty11.4 KiBpostgresql-16-colnames_1.7.1-1PGSTY~trixie_amd64.deb
postgresql-16-colnames1.7.1d13.aarch64pigsty11.5 KiBpostgresql-16-colnames_1.7.1-1PGSTY~trixie_arm64.deb
postgresql-16-colnames1.7.1u22.x86_64pigsty12.1 KiBpostgresql-16-colnames_1.7.1-1PGSTY~jammy_amd64.deb
postgresql-16-colnames1.7.1u22.aarch64pigsty12.1 KiBpostgresql-16-colnames_1.7.1-1PGSTY~jammy_arm64.deb
postgresql-16-colnames1.7.1u24.x86_64pigsty11.7 KiBpostgresql-16-colnames_1.7.1-1PGSTY~noble_amd64.deb
postgresql-16-colnames1.7.1u24.aarch64pigsty11.5 KiBpostgresql-16-colnames_1.7.1-1PGSTY~noble_arm64.deb
postgresql-16-colnames1.7.1u26.x86_64pigsty11.9 KiBpostgresql-16-colnames_1.7.1-1PGSTY~resolute_amd64.deb
postgresql-16-colnames1.7.1u26.aarch64pigsty12.0 KiBpostgresql-16-colnames_1.7.1-1PGSTY~resolute_arm64.deb
PackageVersionOSORGSIZEFile URL
colnames_151.7.1el8.x86_64pigsty19.3 KiBcolnames_15-1.7.1-1PGSTY.el8.x86_64.rpm
colnames_151.7.1el8.aarch64pigsty19.5 KiBcolnames_15-1.7.1-1PGSTY.el8.aarch64.rpm
colnames_151.7.1el9.x86_64pigsty19.5 KiBcolnames_15-1.7.1-1PGSTY.el9.x86_64.rpm
colnames_151.7.1el9.aarch64pigsty19.3 KiBcolnames_15-1.7.1-1PGSTY.el9.aarch64.rpm
colnames_151.7.1el10.x86_64pigsty19.5 KiBcolnames_15-1.7.1-1PGSTY.el10.x86_64.rpm
colnames_151.7.1el10.aarch64pigsty19.6 KiBcolnames_15-1.7.1-1PGSTY.el10.aarch64.rpm
postgresql-15-colnames1.7.1d12.x86_64pigsty11.5 KiBpostgresql-15-colnames_1.7.1-1PGSTY~bookworm_amd64.deb
postgresql-15-colnames1.7.1d12.aarch64pigsty11.4 KiBpostgresql-15-colnames_1.7.1-1PGSTY~bookworm_arm64.deb
postgresql-15-colnames1.7.1d13.x86_64pigsty11.5 KiBpostgresql-15-colnames_1.7.1-1PGSTY~trixie_amd64.deb
postgresql-15-colnames1.7.1d13.aarch64pigsty11.5 KiBpostgresql-15-colnames_1.7.1-1PGSTY~trixie_arm64.deb
postgresql-15-colnames1.7.1u22.x86_64pigsty12.1 KiBpostgresql-15-colnames_1.7.1-1PGSTY~jammy_amd64.deb
postgresql-15-colnames1.7.1u22.aarch64pigsty12.1 KiBpostgresql-15-colnames_1.7.1-1PGSTY~jammy_arm64.deb
postgresql-15-colnames1.7.1u24.x86_64pigsty11.8 KiBpostgresql-15-colnames_1.7.1-1PGSTY~noble_amd64.deb
postgresql-15-colnames1.7.1u24.aarch64pigsty11.5 KiBpostgresql-15-colnames_1.7.1-1PGSTY~noble_arm64.deb
postgresql-15-colnames1.7.1u26.x86_64pigsty11.9 KiBpostgresql-15-colnames_1.7.1-1PGSTY~resolute_amd64.deb
postgresql-15-colnames1.7.1u26.aarch64pigsty12.0 KiBpostgresql-15-colnames_1.7.1-1PGSTY~resolute_arm64.deb

Source

pig build pkg colnames;		# 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 colnames;		# install by package name

pig install colnames -v 19;   # install for PG 19
pig install colnames -v 18;   # install for PG 18
pig install colnames -v 17;   # install for PG 17
pig install colnames -v 16;   # install for PG 16
pig install colnames -v 15;   # install for PG 15

Create this extension with:

CREATE EXTENSION colnames;

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

CREATE EXTENSION colnames;

SELECT colnames(ROW(1, 'foo', 458.0));
SELECT colnames(t)
FROM (SELECT 1 AS id, 'Ada'::text AS name) AS t;

CREATE TYPE contact AS (id integer, name text);
SELECT colnames(NULL::contact);

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 15–19; 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.

Table reader