pg_dump Reference
БесплатноБез исполняемых скриптовНе проверенConsult PostgreSQL's pg_dump implementation for guidance on system catalog queries and schema extraction when implementing pgschema features
от Microck★ 417 звёзд на GitHubОб этом скилле
pg_dump Reference
Use this skill when implementing or debugging pgschema features that involve extracting schema information from PostgreSQL databases. pg_dump is the canonical PostgreSQL schema dumping tool and serves as a reference implementation for how to query system catalogs correctly.
When to Use This Skill
Invoke this skill when:
- Adding support for new PostgreSQL schema objects
- Debugging system catalog queries in
ir/inspector.go - Understanding how PostgreSQL represents objects internally
- Handling version-specific PostgreSQL features (versions 14-17)
- Learning correct DDL formatting patterns
- Understanding object dependency relationships
Source Code Locations
Main pg_dump repository: https://github.com/postgres/postgres/blob/master/src/bin/pg_dump/
Key files to reference:
pg_dump.c- Main implementation with system catalog queriespg_dump.h- Data structures and function declarationspg_dump_sort.c- Dependency sorting logicpg_backup_archiver.c- Output formattingcommon.c- Shared utility functions for querying system catalogs
Step-by-Step Workflow
1. Identify the Schema Object
Determine which PostgreSQL object type you're working with:
- Tables and columns
- Constraints (PRIMARY KEY, FOREIGN KEY, UNIQUE, CHECK)
- Indexes (regular, unique, partial, functional)
- Triggers (including WHEN conditions, constraint triggers)
- Views and materialized views
- Functions and procedures
- Sequences
- Types (enum, composite, domain)
- Policies (row-level security)
- Aggregates
- Comments
2. Find the Relevant pg_dump Function
Search pg_dump.c for the function that handles your object type:
| Object Type | pg_dump Function | System Catalogs Used |
|---|---|---|
| Tables & Columns | getTables() |
pg_class, pg_attribute, pg_type |
| Indexes | getIndexes() |
pg_index, pg_class |
| Triggers | getTriggers() |
pg_trigger, pg_proc |
| Functions | getFuncs() |
pg_proc |
| Procedures | getProcs() |
pg_proc |
| Views | getViews() |
pg_class, pg_rewrite |
| Materialized Views | getMatViews() |
pg_class |
| Sequences | getSequences() |
pg_sequence, pg_class |
| Constraints | getConstraints() |
pg_constraint |
| Policies | getPolicies() |
pg_policy |
| Aggregates | getAggregates() |
pg_aggregate, pg_proc |
| Types | getTypes() |
pg_type |
| Comments | getComments() |
pg_description |
3. Analyze the System Catalog Query
Examine the SQL query used by pg_dump:
- Which system catalog tables are joined
- Which columns are selected
- How version-specific features are handled
- How PostgreSQL internal functions are used (
pg_get_expr,pg_get_constraintdef, etc.)
Example - Extracting trigger WHEN conditions:
-- pg_dump's approach (from getTriggers):
SELECT t.tgname,
pg_get_expr(t.tgqual, t.tgrelid, false) as when_clause
FROM pg_catalog.pg_trigger t
WHERE t.tgqual IS NOT NULL
Note: information_schema.triggers.action_condition is NOT reliable for WHEN clauses. Always use pg_get_expr(t.tgqual, ...) from pg_catalog.pg_trigger.
4. Check for Special Cases
Look for how pg_dump handles:
- Version compatibility: Different queries for different PostgreSQL versions
- NULL handling: How missing values are interpreted
- Default values: System vs. user-defined defaults
- Internal objects: Filtering out system-generated objects
- Dependencies: How object relationships are tracked
5. Adapt for pgschema
Apply the pattern to pgschema's codebase:
For database introspection (ir/inspector.go):
- Adapt the system catalog query for Go/pgx
- Use pgx parameter binding for safety
- Handle NULL values appropriately
- Add proper error handling
For SQL parsing (ir/parser.go):
- Understand how pg_dump formats DDL
- Use pg_query_go to parse SQL statements
- Extract relevant fields into IR structures
For DDL generation (internal/diff/*.go):
- Follow pg_dump's quoting rules
- Use PostgreSQL functions for formatting complex expressions
- Handle version-specific syntax
Key System Catalog Tables
Core Tables
pg_class- Tables, indexes, views, sequencespg_attribute- Table columnspg_type- Data typespg_constraint- Constraints (PK, FK, UNIQUE, CHECK)pg_index- Index definitions
Functions & Triggers
pg_proc- Functions, procedures, trigger functionspg_trigger- Trigger definitionspg_aggregate- Aggregate function definitions
Access Control
pg_policy- Row-level security policies
Metadata
pg_description- Comments on database objectspg_depend- Object dependencies
Helper Functions
pg_get_expr(expr, relation, pretty)- Deparse expressionspg_get_constraintdef(constraint_oid, pretty)- Get constraint definitionpg_get_indexdef(index_oid, column, pretty)- Get index definition- `pg_get_triggerdef(trigger_oid, pretty)
Установить pg_dump Reference в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл pg_dump Reference?
Consult PostgreSQL's pg_dump implementation for guidance on system catalog queries and schema extraction when implementing pgschema features
Как установить скилл pg_dump Reference?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл pg_dump Reference запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic