postgresqlmeta

package
v0.44.0 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

README

PostgreSQL Metadata Provider Module

PostgreSQL metadata provider used for optional metadata-aware DeltaScope audits against PostgreSQL.

Files

File Responsibility
open.go Formats PostgreSQL metadata connection DSNs and opens pgx stdlib database/sql handles
open_test.go Verifies TCP and unix-socket DSN/address formatting helpers
provider.go Loads normalized dialect, schema, instance-fact, table snapshot, and plain-EXPLAIN plan-estimate data from PostgreSQL catalogs and planner stats
provider_test.go Verifies catalog-backed schema discovery, reltuples/statistics loading, PK constraint truth, and plain-EXPLAIN estimation without a live database

Exports

  • ConnectionConfig
  • OpenDB(config)
  • Provider
  • NewProvider(db *sql.DB)
  • Provider.DetectDialect(ctx)
  • Provider.FindSchemasForTable(ctx, table)
  • Provider.LoadPlanEstimate(ctx, statement)

Dependencies

  • Upstream: internal/application/audit
  • Downstream: database/sql, github.com/jackc/pgx/v5, github.com/jackc/pgx/v5/stdlib, internal/domain/spec

Update Rule

  • If members/interfaces/dependencies change, update this file in same change.

Documentation

Overview

Package postgresqlmeta implements metadata-aware audit adapters over PostgreSQL. input: connection configs for PostgreSQL metadata reads output: pgx stdlib database/sql handles for metadata providers pos: infrastructure connection opener for PostgreSQL metadata access note: if this file changes, update this header and module README.md.

Package postgresqlmeta implements metadata-aware audit adapters over PostgreSQL. input: sql.DB access plus version/schema/table lookup requests and PostgreSQL catalog queries output: normalized instance facts, dialect detection, schema discovery, table snapshots, and plan estimates for application-level audit enrichment pos: infrastructure metadata adapter between database/sql and domain metadata specs note: if this file changes, update this header and module README.md.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OpenDB

func OpenDB(config ConnectionConfig) (*sql.DB, error)

OpenDB connects to a PostgreSQL database for metadata reads.

Types

type ConnectionConfig

type ConnectionConfig struct {
	Host     string
	Port     int
	Socket   string
	Database string
	User     string
	Password string
	SSLMode  string
}

ConnectionConfig describes one PostgreSQL metadata connection.

func (ConnectionConfig) Address

func (c ConnectionConfig) Address() string

Address reports the driver address for the connection.

func (ConnectionConfig) DSN

func (c ConnectionConfig) DSN() string

DSN formats the config for the pgx database/sql driver.

func (ConnectionConfig) DatabaseName

func (c ConnectionConfig) DatabaseName() string

DatabaseName reports the configured database or the PostgreSQL default.

type Provider

type Provider struct {
	// contains filtered or unexported fields
}

Provider loads metadata facts through a PostgreSQL SQL connection.

func NewProvider

func NewProvider(db *sql.DB) *Provider

NewProvider builds a metadata provider on top of an existing SQL handle.

func (*Provider) DetectDialect

func (p *Provider) DetectDialect(ctx context.Context) (spec.Dialect, error)

DetectDialect reads server version information and classifies the SQL dialect.

func (*Provider) FindSchemasForTable

func (p *Provider) FindSchemasForTable(ctx context.Context, table string) ([]string, error)

FindSchemasForTable lists schemas that currently contain the named table.

func (*Provider) LoadInstanceFacts

func (p *Provider) LoadInstanceFacts(ctx context.Context, _ spec.Dialect, _ string) (*spec.InstanceFacts, error)

LoadInstanceFacts reads server-level settings that influence audit behavior.

func (*Provider) LoadPlanEstimate

func (p *Provider) LoadPlanEstimate(ctx context.Context, statement spec.Statement) (*spec.ImpactEstimate, error)

LoadPlanEstimate reads a conservative row estimate using plain EXPLAIN output.

func (*Provider) LoadTableSnapshot

func (p *Provider) LoadTableSnapshot(ctx context.Context, _ spec.Dialect, schema string, table string) (*spec.TableSnapshot, error)

func (*Provider) ResolveTableForIndex

func (p *Provider) ResolveTableForIndex(ctx context.Context, _ spec.Dialect, schema string, index string) (string, error)

LoadTableSnapshot reads one target table shape from PostgreSQL catalogs.

Jump to

Keyboard shortcuts

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