Consult PostgreSQL's pg_dump implementation for guidance on system catalog queries and schema extraction when implementing pgschema features
Reference pg_dump's implementation for correct system catalog queries and schema extraction patterns.
Repository: https://github.com/postgres/postgres/blob/master/src/bin/pg_dump/
Key files:
pg_dump.c - Main implementation with all system catalog queriespg_dump.h - Data structurespg_dump_sort.c - Dependency sortingcommon.c - Shared catalog query utilities| Object | Function | Catalogs |
|--------|----------|----------|
| Tables & Columns | getTables() | pg_class, pg_attribute, pg_type |
| Constraints | getConstraints() | pg_constraint |
| Indexes | getIndexes() | pg_index, pg_class |
| Triggers | getTriggers() | pg_trigger, pg_proc |
| Functions | getFuncs() | pg_proc |
| Views | getViews() | pg_class, pg_rewrite |
| Sequences | getSequences() | pg_sequence, pg_class |
| Policies | getPolicies() | pg_policy |
| Types | getTypes() | pg_type |
| Aggregates | getAggregates() | pg_aggregate, pg_proc |
| Comments | getComments() | pg_description |
pg_get_expr(expr, relation, pretty) - Deparse expressions (defaults, WHEN clauses, index predicates)pg_get_constraintdef(oid, pretty) - Get constraint DDLpg_get_indexdef(oid, column, pretty) - Get index DDLpg_get_triggerdef(oid, pretty) - Get full trigger DDLImportant: For trigger WHEN clauses, always use pg_get_expr(t.tgqual, t.tgrelid, false) from pg_catalog.pg_trigger. Do NOT use information_schema.triggers.action_condition.
fout->remoteVersion checksir/inspector.go or ir/queries/:
Always reference for: system catalog query patterns, correct use of pg_get_* functions, version-specific feature detection, object dependency tracking.
Don't copy: output formatting (pgschema has different conventions), archive/restore logic, full-database scope (pgschema is schema-focused), pre-PG14 compatibility.
// pg_dump query pattern:
// SELECT t.tgname, pg_get_expr(t.tgqual, t.tgrelid, false) as when_clause
// FROM pg_catalog.pg_trigger t WHERE ...
// pgschema adaptation (in ir/inspector.go or ir/queries/):
query := `SELECT t.tgname, pg_get_expr(t.tgqual, t.tgrelid, false)
FROM pg_catalog.pg_trigger t
WHERE t.tgrelid = $1 AND NOT t.tgisinternal`
rows, err := conn.Query(ctx, query, tableOID)
Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer