跳转到主要内容

colnames

Return column names of a record or composite value

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
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

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
Package Version OS ORG SIZE File URL
colnames_18 1.7.1 el8.x86_64 pigsty 19.5 KiB colnames_18-1.7.1-1PGSTY.el8.x86_64.rpm
colnames_18 1.7.1 el8.aarch64 pigsty 19.7 KiB colnames_18-1.7.1-1PGSTY.el8.aarch64.rpm
colnames_18 1.7.1 el9.x86_64 pigsty 19.4 KiB colnames_18-1.7.1-1PGSTY.el9.x86_64.rpm
colnames_18 1.7.1 el9.aarch64 pigsty 19.4 KiB colnames_18-1.7.1-1PGSTY.el9.aarch64.rpm
colnames_18 1.7.1 el10.x86_64 pigsty 19.4 KiB colnames_18-1.7.1-1PGSTY.el10.x86_64.rpm
colnames_18 1.7.1 el10.aarch64 pigsty 19.6 KiB colnames_18-1.7.1-1PGSTY.el10.aarch64.rpm
postgresql-18-colnames 1.7.1 d12.x86_64 pigsty 8.4 KiB postgresql-18-colnames_1.7.1-1PGSTY~bookworm_amd64.deb
postgresql-18-colnames 1.7.1 d12.aarch64 pigsty 8.4 KiB postgresql-18-colnames_1.7.1-1PGSTY~bookworm_arm64.deb
postgresql-18-colnames 1.7.1 d13.x86_64 pigsty 8.3 KiB postgresql-18-colnames_1.7.1-1PGSTY~trixie_amd64.deb
postgresql-18-colnames 1.7.1 d13.aarch64 pigsty 8.4 KiB postgresql-18-colnames_1.7.1-1PGSTY~trixie_arm64.deb
postgresql-18-colnames 1.7.1 u22.x86_64 pigsty 7.6 KiB postgresql-18-colnames_1.7.1-1PGSTY~jammy_amd64.deb
postgresql-18-colnames 1.7.1 u22.aarch64 pigsty 7.7 KiB postgresql-18-colnames_1.7.1-1PGSTY~jammy_arm64.deb
postgresql-18-colnames 1.7.1 u24.x86_64 pigsty 7.7 KiB postgresql-18-colnames_1.7.1-1PGSTY~noble_amd64.deb
postgresql-18-colnames 1.7.1 u24.aarch64 pigsty 7.6 KiB postgresql-18-colnames_1.7.1-1PGSTY~noble_arm64.deb
postgresql-18-colnames 1.7.1 u26.x86_64 pigsty 7.8 KiB postgresql-18-colnames_1.7.1-1PGSTY~resolute_amd64.deb
postgresql-18-colnames 1.7.1 u26.aarch64 pigsty 8.0 KiB postgresql-18-colnames_1.7.1-1PGSTY~resolute_arm64.deb
Package Version OS ORG SIZE File URL
colnames_17 1.7.1 el8.x86_64 pigsty 19.5 KiB colnames_17-1.7.1-1PGSTY.el8.x86_64.rpm
colnames_17 1.7.1 el8.aarch64 pigsty 19.7 KiB colnames_17-1.7.1-1PGSTY.el8.aarch64.rpm
colnames_17 1.7.1 el9.x86_64 pigsty 19.3 KiB colnames_17-1.7.1-1PGSTY.el9.x86_64.rpm
colnames_17 1.7.1 el9.aarch64 pigsty 19.3 KiB colnames_17-1.7.1-1PGSTY.el9.aarch64.rpm
colnames_17 1.7.1 el10.x86_64 pigsty 19.4 KiB colnames_17-1.7.1-1PGSTY.el10.x86_64.rpm
colnames_17 1.7.1 el10.aarch64 pigsty 19.6 KiB colnames_17-1.7.1-1PGSTY.el10.aarch64.rpm
postgresql-17-colnames 1.7.1 d12.x86_64 pigsty 8.3 KiB postgresql-17-colnames_1.7.1-1PGSTY~bookworm_amd64.deb
postgresql-17-colnames 1.7.1 d12.aarch64 pigsty 8.3 KiB postgresql-17-colnames_1.7.1-1PGSTY~bookworm_arm64.deb
postgresql-17-colnames 1.7.1 d13.x86_64 pigsty 8.3 KiB postgresql-17-colnames_1.7.1-1PGSTY~trixie_amd64.deb
postgresql-17-colnames 1.7.1 d13.aarch64 pigsty 8.4 KiB postgresql-17-colnames_1.7.1-1PGSTY~trixie_arm64.deb
postgresql-17-colnames 1.7.1 u22.x86_64 pigsty 8.0 KiB postgresql-17-colnames_1.7.1-1PGSTY~jammy_amd64.deb
postgresql-17-colnames 1.7.1 u22.aarch64 pigsty 7.9 KiB postgresql-17-colnames_1.7.1-1PGSTY~jammy_arm64.deb
postgresql-17-colnames 1.7.1 u24.x86_64 pigsty 7.7 KiB postgresql-17-colnames_1.7.1-1PGSTY~noble_amd64.deb
postgresql-17-colnames 1.7.1 u24.aarch64 pigsty 7.6 KiB postgresql-17-colnames_1.7.1-1PGSTY~noble_arm64.deb
postgresql-17-colnames 1.7.1 u26.x86_64 pigsty 7.8 KiB postgresql-17-colnames_1.7.1-1PGSTY~resolute_amd64.deb
postgresql-17-colnames 1.7.1 u26.aarch64 pigsty 8.0 KiB postgresql-17-colnames_1.7.1-1PGSTY~resolute_arm64.deb
Package Version OS ORG SIZE File URL
colnames_16 1.7.1 el8.x86_64 pigsty 19.5 KiB colnames_16-1.7.1-1PGSTY.el8.x86_64.rpm
colnames_16 1.7.1 el8.aarch64 pigsty 19.7 KiB colnames_16-1.7.1-1PGSTY.el8.aarch64.rpm
colnames_16 1.7.1 el9.x86_64 pigsty 19.3 KiB colnames_16-1.7.1-1PGSTY.el9.x86_64.rpm
colnames_16 1.7.1 el9.aarch64 pigsty 19.3 KiB colnames_16-1.7.1-1PGSTY.el9.aarch64.rpm
colnames_16 1.7.1 el10.x86_64 pigsty 19.4 KiB colnames_16-1.7.1-1PGSTY.el10.x86_64.rpm
colnames_16 1.7.1 el10.aarch64 pigsty 19.6 KiB colnames_16-1.7.1-1PGSTY.el10.aarch64.rpm
postgresql-16-colnames 1.7.1 d12.x86_64 pigsty 8.3 KiB postgresql-16-colnames_1.7.1-1PGSTY~bookworm_amd64.deb
postgresql-16-colnames 1.7.1 d12.aarch64 pigsty 8.3 KiB postgresql-16-colnames_1.7.1-1PGSTY~bookworm_arm64.deb
postgresql-16-colnames 1.7.1 d13.x86_64 pigsty 8.3 KiB postgresql-16-colnames_1.7.1-1PGSTY~trixie_amd64.deb
postgresql-16-colnames 1.7.1 d13.aarch64 pigsty 8.3 KiB postgresql-16-colnames_1.7.1-1PGSTY~trixie_arm64.deb
postgresql-16-colnames 1.7.1 u22.x86_64 pigsty 7.9 KiB postgresql-16-colnames_1.7.1-1PGSTY~jammy_amd64.deb
postgresql-16-colnames 1.7.1 u22.aarch64 pigsty 7.9 KiB postgresql-16-colnames_1.7.1-1PGSTY~jammy_arm64.deb
postgresql-16-colnames 1.7.1 u24.x86_64 pigsty 7.7 KiB postgresql-16-colnames_1.7.1-1PGSTY~noble_amd64.deb
postgresql-16-colnames 1.7.1 u24.aarch64 pigsty 7.6 KiB postgresql-16-colnames_1.7.1-1PGSTY~noble_arm64.deb
postgresql-16-colnames 1.7.1 u26.x86_64 pigsty 7.8 KiB postgresql-16-colnames_1.7.1-1PGSTY~resolute_amd64.deb
postgresql-16-colnames 1.7.1 u26.aarch64 pigsty 8.0 KiB postgresql-16-colnames_1.7.1-1PGSTY~resolute_arm64.deb
Package Version OS ORG SIZE File URL
colnames_15 1.7.1 el8.x86_64 pigsty 19.5 KiB colnames_15-1.7.1-1PGSTY.el8.x86_64.rpm
colnames_15 1.7.1 el8.aarch64 pigsty 19.7 KiB colnames_15-1.7.1-1PGSTY.el8.aarch64.rpm
colnames_15 1.7.1 el9.x86_64 pigsty 19.3 KiB colnames_15-1.7.1-1PGSTY.el9.x86_64.rpm
colnames_15 1.7.1 el9.aarch64 pigsty 19.3 KiB colnames_15-1.7.1-1PGSTY.el9.aarch64.rpm
colnames_15 1.7.1 el10.x86_64 pigsty 19.4 KiB colnames_15-1.7.1-1PGSTY.el10.x86_64.rpm
colnames_15 1.7.1 el10.aarch64 pigsty 19.6 KiB colnames_15-1.7.1-1PGSTY.el10.aarch64.rpm
postgresql-15-colnames 1.7.1 d12.x86_64 pigsty 8.4 KiB postgresql-15-colnames_1.7.1-1PGSTY~bookworm_amd64.deb
postgresql-15-colnames 1.7.1 d12.aarch64 pigsty 8.3 KiB postgresql-15-colnames_1.7.1-1PGSTY~bookworm_arm64.deb
postgresql-15-colnames 1.7.1 d13.x86_64 pigsty 8.4 KiB postgresql-15-colnames_1.7.1-1PGSTY~trixie_amd64.deb
postgresql-15-colnames 1.7.1 d13.aarch64 pigsty 8.4 KiB postgresql-15-colnames_1.7.1-1PGSTY~trixie_arm64.deb
postgresql-15-colnames 1.7.1 u22.x86_64 pigsty 8.0 KiB postgresql-15-colnames_1.7.1-1PGSTY~jammy_amd64.deb
postgresql-15-colnames 1.7.1 u22.aarch64 pigsty 8.0 KiB postgresql-15-colnames_1.7.1-1PGSTY~jammy_arm64.deb
postgresql-15-colnames 1.7.1 u24.x86_64 pigsty 7.7 KiB postgresql-15-colnames_1.7.1-1PGSTY~noble_amd64.deb
postgresql-15-colnames 1.7.1 u24.aarch64 pigsty 7.6 KiB postgresql-15-colnames_1.7.1-1PGSTY~noble_arm64.deb
postgresql-15-colnames 1.7.1 u26.x86_64 pigsty 7.8 KiB postgresql-15-colnames_1.7.1-1PGSTY~resolute_amd64.deb
postgresql-15-colnames 1.7.1 u26.aarch64 pigsty 8.0 KiB postgresql-15-colnames_1.7.1-1PGSTY~resolute_arm64.deb
Package Version OS ORG SIZE File URL
colnames_14 1.7.1 el8.x86_64 pigsty 19.5 KiB colnames_14-1.7.1-1PGSTY.el8.x86_64.rpm
colnames_14 1.7.1 el8.aarch64 pigsty 19.6 KiB colnames_14-1.7.1-1PGSTY.el8.aarch64.rpm
colnames_14 1.7.1 el9.x86_64 pigsty 19.3 KiB colnames_14-1.7.1-1PGSTY.el9.x86_64.rpm
colnames_14 1.7.1 el9.aarch64 pigsty 19.3 KiB colnames_14-1.7.1-1PGSTY.el9.aarch64.rpm
colnames_14 1.7.1 el10.x86_64 pigsty 19.4 KiB colnames_14-1.7.1-1PGSTY.el10.x86_64.rpm
colnames_14 1.7.1 el10.aarch64 pigsty 19.5 KiB colnames_14-1.7.1-1PGSTY.el10.aarch64.rpm
postgresql-14-colnames 1.7.1 d12.x86_64 pigsty 11.4 KiB postgresql-14-colnames_1.7.1-1PGSTY~bookworm_amd64.deb
postgresql-14-colnames 1.7.1 d12.aarch64 pigsty 11.4 KiB postgresql-14-colnames_1.7.1-1PGSTY~bookworm_arm64.deb
postgresql-14-colnames 1.7.1 d13.x86_64 pigsty 11.4 KiB postgresql-14-colnames_1.7.1-1PGSTY~trixie_amd64.deb
postgresql-14-colnames 1.7.1 d13.aarch64 pigsty 11.4 KiB postgresql-14-colnames_1.7.1-1PGSTY~trixie_arm64.deb
postgresql-14-colnames 1.7.1 u22.x86_64 pigsty 12.0 KiB postgresql-14-colnames_1.7.1-1PGSTY~jammy_amd64.deb
postgresql-14-colnames 1.7.1 u22.aarch64 pigsty 12.0 KiB postgresql-14-colnames_1.7.1-1PGSTY~jammy_arm64.deb
postgresql-14-colnames 1.7.1 u24.x86_64 pigsty 11.7 KiB postgresql-14-colnames_1.7.1-1PGSTY~noble_amd64.deb
postgresql-14-colnames 1.7.1 u24.aarch64 pigsty 11.5 KiB postgresql-14-colnames_1.7.1-1PGSTY~noble_arm64.deb
postgresql-14-colnames 1.7.1 u26.x86_64 pigsty 11.8 KiB postgresql-14-colnames_1.7.1-1PGSTY~resolute_amd64.deb
postgresql-14-colnames 1.7.1 u26.aarch64 pigsty 12.0 KiB postgresql-14-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 via package name, for the active PG version

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
pig install colnames -v 14;   # install for PG 14

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 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.