cat_tools

Tools for interfacing with the PostgreSQL catalog

Overview

PackageVersionCategoryLicenseLanguage
cat_tools0.3.0ADMINMITSQL
IDExtensionBinLibLoadCreateTrustRelocSchema
5290cat_toolsNoNoNoYesNoNocat_tools
Relatedplpgsql pg_catalog_get_defs pg_global_catalog meta_triggers pg_catcheck pgdd ddlx meta object_reference
Depended Byextension_drop object_reference

Promoted from a source-only universe row to PIGSTY RPM and DEB packages at 0.3.0; control fixes schema cat_tools and META declares the plpgsql runtime dependency.

Version

TypeRepoVersionPG VerPackageDeps
EXTPIGSTY0.3.01817161514cat_toolsplpgsql
RPMPIGSTY0.3.01817161514cat_tools_$v-
DEBPIGSTY0.3.01817161514postgresql-$v-cat-tools-
OS / PGPG18PG17PG16PG15PG14
el8.x86_64
el8.aarch64
el9.x86_64
el9.aarch64
el10.x86_64
el10.aarch64
d12.x86_64
PIGSTY 0.3.0
PIGSTY 0.3.0
PIGSTY 0.3.0
PIGSTY 0.3.0
PIGSTY 0.3.0
d12.aarch64
PIGSTY 0.3.0
PIGSTY 0.3.0
PIGSTY 0.3.0
PIGSTY 0.3.0
PIGSTY 0.3.0
d13.x86_64
PIGSTY 0.3.0
PIGSTY 0.3.0
PIGSTY 0.3.0
PIGSTY 0.3.0
PIGSTY 0.3.0
d13.aarch64
PIGSTY 0.3.0
PIGSTY 0.3.0
PIGSTY 0.3.0
PIGSTY 0.3.0
PIGSTY 0.3.0
u22.x86_64
PIGSTY 0.3.0
PIGSTY 0.3.0
PIGSTY 0.3.0
PIGSTY 0.3.0
PIGSTY 0.3.0
u22.aarch64
PIGSTY 0.3.0
PIGSTY 0.3.0
PIGSTY 0.3.0
PIGSTY 0.3.0
PIGSTY 0.3.0
u24.x86_64
PIGSTY 0.3.0
PIGSTY 0.3.0
PIGSTY 0.3.0
PIGSTY 0.3.0
PIGSTY 0.3.0
u24.aarch64
PIGSTY 0.3.0
PIGSTY 0.3.0
PIGSTY 0.3.0
PIGSTY 0.3.0
PIGSTY 0.3.0
u26.x86_64
PIGSTY 0.3.0
PIGSTY 0.3.0
PIGSTY 0.3.0
PIGSTY 0.3.0
PIGSTY 0.3.0
u26.aarch64
PIGSTY 0.3.0
PIGSTY 0.3.0
PIGSTY 0.3.0
PIGSTY 0.3.0
PIGSTY 0.3.0

Build

You can build the RPM / DEB packages for cat_tools using pig build:

pig build pkg cat_tools         # build RPM / DEB packages

Install

You can install cat_tools directly. First, make sure the PGDG and PIGSTY repositories are added and enabled:

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

Install the extension using pig or apt/yum/dnf:

pig install cat_tools;          # Install for current active PG version
pig ext install -y cat_tools -v 18  # PG 18
pig ext install -y cat_tools -v 17  # PG 17
pig ext install -y cat_tools -v 16  # PG 16
pig ext install -y cat_tools -v 15  # PG 15
pig ext install -y cat_tools -v 14  # PG 14
dnf install -y cat_tools_18       # PG 18
dnf install -y cat_tools_17       # PG 17
dnf install -y cat_tools_16       # PG 16
dnf install -y cat_tools_15       # PG 15
dnf install -y cat_tools_14       # PG 14
apt install -y postgresql-18-cat-tools   # PG 18
apt install -y postgresql-17-cat-tools   # PG 17
apt install -y postgresql-16-cat-tools   # PG 16
apt install -y postgresql-15-cat-tools   # PG 15
apt install -y postgresql-14-cat-tools   # PG 14

Create Extension:

CREATE EXTENSION cat_tools CASCADE;  -- requires: plpgsql

Usage

Sources:

cat_tools provides typed views, enums, and helper functions for PostgreSQL catalog introspection. It is designed for database code that needs a more stable and readable interface than repeatedly decoding raw pg_catalog fields; the views still track PostgreSQL’s catalogs and must be reviewed across major-version upgrades.

Install and Grant Access

CREATE EXTENSION cat_tools;
GRANT cat_tools__usage TO app_introspection;

The extension installs in the fixed cat_tools schema, requires plpgsql, and is not relocatable. Grant the cat_tools__usage role rather than exposing internal _cat_tools helpers directly.

Inspect Relations and Columns

SELECT cat_tools.relation__kind(c.relkind::text)
FROM pg_catalog.pg_class AS c
WHERE c.oid = 'public.orders'::regclass;

SELECT cat_tools.relation__column_names('public.orders'::regclass);
SELECT cat_tools.pg_attribute__get('public.orders'::regclass, 'id');

Useful relation helpers include pg_class(regclass), relation__is_catalog, relation__is_temp, relation__kind, and relation__relkind. Typed mapping functions make the one-character catalog codes explicit.

Inspect Routines

Version 0.3 adds functions and types that cover both functions and procedures:

SELECT cat_tools.routine__arg_types(
  'public.calculate_total(integer, numeric)'::regprocedure
);

SELECT cat_tools.routine__parse_arg_names(
  'IN account_id integer, INOUT total numeric'
);

The routine surface includes routine__parse_arg_types, routine__parse_arg_names, routine__arg_types, routine__arg_names, their text variants, and mappings for routine kind, argument mode, volatility, and parallel safety. function__arg_types and function__arg_types_text are deprecated; use the routine parsers.

Version 0.3.0 and Caveats

  • Version 0.3.0 supports PostgreSQL 12-18+ upstream; current Pigsty packages cover PostgreSQL 14-18.
  • The release corrects the c, f, and m mappings for composite types, foreign tables, and materialized views. Re-test any code that worked around the old mapping.
  • Internal _cat_tools helpers now revoke EXECUTE from PUBLIC; callers should inherit cat_tools__usage and use the supported surface.
  • The 0.2.3-to-0.3.0 update adds enum values and therefore cannot run on PostgreSQL 11 or earlier. Upgrade the database major version and extension in the order documented upstream.
  • PostgreSQL does not promise catalog compatibility across major releases. Pin tests to every supported PostgreSQL major even when using these wrappers.

Last Modified: 2026-08-09: update extension count (24575456)