introspect

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 31, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package introspect builds an IR Catalog by querying a live PostgreSQL instance through pg_catalog. The produced *irv1.Catalog has the same shape as the one internal/catalog.Build produces from parsed DDL, so the diff engine can compare a parsed (desired) catalog against an introspected (actual) one.

Object ids follow the same convention as internal/catalog: "schema.name" for schema-scoped objects, "schema.table.column" for columns, and "schema.table.constraint" for constraints. Expressions (defaults, check bodies, index predicates, generated columns) are captured verbatim as the Expr raw_sql escape hatch via pg_get_expr / pg_get_constraintdef / pg_get_indexdef, mirroring how the diff compares text.

The introspector never panics: types it cannot classify fall back to a best-effort TypeRef{PgName: ...}; rows that fail to scan are skipped.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Introspect

func Introspect(ctx context.Context, conn DBTX, schemas []string) (*irv1.Catalog, error)

Introspect builds an *irv1.Catalog from a live PostgreSQL connection, restricted to the given schemas. When schemas is empty it defaults to "public" plus every non-system, non-temp schema. It never panics.

Types

type DBTX

type DBTX interface {
	Query(ctx context.Context, sql string, args ...any) (pgx.Rows, error)
	QueryRow(ctx context.Context, sql string, args ...any) pgx.Row
}

DBTX is the minimal pgx query surface the introspector needs. Both *pgx.Conn and *pgxpool.Pool satisfy it.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL