postgres

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package postgres implements a verify.Verifier for PostgreSQL using the pgx native driver (github.com/jackc/pgx/v5). It provides full origin-trace and type refinement per RFC 0004:

  • Each query is prepared via pgx.Conn.Prepare, which returns pgconn.StatementDescription with typed FieldDescriptions.
  • DataTypeOID is resolved to a pg type name via a pg_type cache built once per connection.
  • When TableOID != 0, (TableOID, TableAttributeNumber) is resolved to (table, column) via pg_class/pg_attribute (lazily cached).
  • The resulting verify.Column carries DeclType (the pg type name), TableName, and OriginName when available, so the overlay can apply the UseDeclType path for expression/aggregate columns.

MySQL origin

MySQL does not surface reliable origin information via the standard database/sql ColumnType; see internal/verify/mysql for the type-only refinement path.

Integration tests

The live connect/prepare path is integration-only and is skipped when DB_CATALYST_VERIFY_DSN is unset. The core mapping logic (fieldsToColumns) is fully unit-tested with constructed fakes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(dsn string) verify.Verifier

New returns a PostgreSQL verify.Verifier that connects via pgx. dsn should be a postgres:// URL or libpq-style connection string accepted by pgx (e.g. "postgres://user:pass@host/dbname").

Types

type FieldLike

type FieldLike interface {
	ColName() string  // result column name
	TblOID() uint32   // origin table OID; 0 for expressions
	AttNum() uint16   // attribute number within the table; 0 for expressions
	DTypeOID() uint32 // data type OID
}

FieldLike abstracts one result-column description so that fieldsToColumns can be unit-tested with constructed fakes without a live pgx connection.

Jump to

Keyboard shortcuts

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