Documentation
¶
Overview ¶
Package introspect reads pg_catalog and produces a Catalog — the single serializable model that drives schema building, caching, and plugins.
Index ¶
Constants ¶
const CatalogFormatVersion = 2
CatalogFormatVersion is bumped whenever the Catalog wire format changes incompatibly; the cache layer refuses to load mismatched versions.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Catalog ¶
type Catalog struct {
FormatVersion int `json:"format_version"`
ServerVersion string `json:"server_version"`
Schemas []string `json:"schemas"`
Tables []*Table `json:"tables"`
Enums []*Enum `json:"enums"`
Composites []*Composite `json:"composites"`
Functions []*Function `json:"functions"`
}
Catalog is the complete introspected model of the database. It is the only input to GraphQL schema building, which keeps caching trivial and plugin transforms deterministic.
func Introspect ¶
Introspect reads pg_catalog for the given schemas and builds a Catalog. pg_catalog is used instead of information_schema because the latter loses index, RLS, and array/domain detail.
func (*Catalog) Composite ¶
Composite returns the composite type with the given schema+name, or nil.
type Column ¶
type Column struct {
Name string `json:"name"`
Position int `json:"position"`
PGType string `json:"pg_type"` // canonical type name, e.g. int4, text, _text (array)
TypeSchema string `json:"type_schema"` // pg schema of the type (for enums/domains/composites)
IsArray bool `json:"is_array"`
NotNull bool `json:"not_null"`
HasDefault bool `json:"has_default"`
Generated bool `json:"generated"` // identity or generated column: excluded from create/update input
Comment string `json:"comment,omitempty"`
}
type Constraint ¶
type ForeignKey ¶
type Function ¶
type Function struct {
Schema string `json:"schema"`
Name string `json:"name"`
Args []FuncArg `json:"args"`
ReturnType string `json:"return_type"`
ReturnTypeSchema string `json:"return_type_schema"`
ReturnsSet bool `json:"returns_set"`
Volatility Volatility `json:"volatility"`
Comment string `json:"comment,omitempty"`
}
type Privileges ¶
type Querier ¶
type Querier interface {
Query(ctx context.Context, sql string, args ...any) (pgx.Rows, error)
QueryRow(ctx context.Context, sql string, args ...any) pgx.Row
}
Querier is the subset of pgx used by introspection (satisfied by *pgx.Conn, pgxpool.Pool, and pgx.Tx).
type Table ¶
type Table struct {
Schema string `json:"schema"`
Name string `json:"name"`
Kind RelKind `json:"kind"`
Comment string `json:"comment,omitempty"`
RLSEnabled bool `json:"rls_enabled"`
Columns []*Column `json:"columns"`
PrimaryKey *Constraint `json:"primary_key,omitempty"`
Uniques []*Constraint `json:"uniques,omitempty"`
ForeignKeys []*ForeignKey `json:"foreign_keys,omitempty"`
Indexes []*Index `json:"indexes,omitempty"`
Privileges Privileges `json:"privileges"`
}
func (*Table) Deletable ¶
Deletable reports whether generated mutations may DELETE from this relation.
func (*Table) IndexedColumns ¶
IndexedColumns returns the set of column names that are the leading column of at least one index (the filterable set under the indexed-only policy).
func (*Table) Insertable ¶
Insertable reports whether generated mutations may INSERT into this relation.
type Volatility ¶
type Volatility string
Volatility mirrors pg_proc.provolatile.
const ( VolatilityImmutable Volatility = "immutable" VolatilityStable Volatility = "stable" VolatilityVolatile Volatility = "volatile" )