pg_inventory
pg_catalog queries
This contains SQL long-form queries generated from Go templates. Each SQL query is tested against a number of example databases.
Directory structure
.
├── pkg
│ └── internal
│ └── test/*.go
├── scripts
│ ├── */*.go
│ └── *.sh
├── bin/*
├── sample_dbs/*.dump.sql
├── db_object_kinds/${kind}
│ ├── ${template_name}.sql.tpl
│ ├── ${template_name}.params.toml
│ └── ${query_name}
│ ├── query.sql
│ └── tests/${sample_db_name}/${test_case_name}
│ ├── params.toml
│ ├── explain.yaml
│ └── results.tsv
├── Makefile
└── README.md
Naming Conventions
- queries named like
${thing}_normalized/query.sql
preserveoid
s, while queries named like${thing}_denormalized/query.sql
join other catalogs for object names and do not contain any oids. This is important for testing, sinceoid
s aren't stable across different instantiations of the same schema in a fresh server. pg_namespace
is always joinedAS ns
and referenced asns.nspname AS schema_name
.- comments are always fetched
AS "comment"
.
Database Object Kinds
- ACCESS_METHOD
- AGGREGATE
- CAST
- COLLATION
- COLUMN
- CONSTRAINT
- CONVERSION
- DATABASE
- DOMAIN
- ENUM
- EVENT_TRIGGER
- EXTENSION
- FOREIGN_DATA_WRAPPER
- FOREIGN_TABLE
- FUNCTION
- INDEX
- LANGUAGE
- MATERIALIZED_VIEW
- OPERATOR
- OPERATOR_CLASS
- OPERATOR_FAMILY
- POLICY
- PROCEDURE
- PUBLICATION
- ROLE
- RULE
- SCHEMA
- SEQUENCE
- SERVER
- STATISTICS
- SUBSCRIPTION
- TABLE
- TABLESPACE
- TEXT_SEARCH_CONFIGURATION
- TEXT_SEARCH_DICTIONARY
- TEXT_SEARCH_PARSER
- TEXT_SEARCH_TEMPLATE
- TRANSFORM
- TRIGGER
- TYPE
- USER_MAPPING
- VIEW