postgres

package
v0.1.13 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Overview

Package postgres adapts a PostgreSQL database to the core interfaces: store.DB/Tx, dialect.Dialect, cost.Explainer, and introspect.Introspector. It is the only place that imports the pgx driver; core packages remain driver-free.

Index

Constants

This section is empty.

Variables

View Source
var ErrAnalyzeRequiresReadOnly = errors.New("postgres: EXPLAIN ANALYZE requires a codegen read-only query")

ErrAnalyzeRequiresReadOnly protects the provider boundary from executing EXPLAIN ANALYZE for statements not marked read-only by codegen.

View Source
var ErrPing = errors.New("postgres: ping failed")

ErrPing is returned when the database is unreachable at open time.

Functions

This section is empty.

Types

type Dialect

type Dialect struct{}

Dialect is the PostgreSQL dialect.

func (Dialect) Capabilities

func (Dialect) Capabilities() dialect.Capabilities

func (Dialect) Name

func (Dialect) Name() string

func (Dialect) Placeholder

func (Dialect) Placeholder(i int) string

func (Dialect) QuoteIdent

func (Dialect) QuoteIdent(name string) string

type Provider

type Provider struct {
	sqladapter.Base
	// contains filtered or unexported fields
}

Provider adapts a PostgreSQL database to the core interfaces.

func New

func New(dsn string) (*Provider, error)

New opens a PostgreSQL database and pings it. The DSN uses the pgx driver format. It returns ErrPing (wrapping the cause) if the database is unreachable, failing fast rather than starting up broken.

func NewWithTimeout

func NewWithTimeout(dsn string, timeout time.Duration) (*Provider, error)

NewWithTimeout opens PostgreSQL with a DB-native statement timeout.

func Open added in v0.1.11

func Open(dsn string, opts providerregistry.Options) (*Provider, error)

Open opens PostgreSQL with opts. The statement timeout is a startup parameter, except behind a transaction-mode pooler, which neither forwards it nor keeps named prepared statements: there statements run unprepared and time out through request cancellation.

func (*Provider) ExplainAnalyze

func (p *Provider) ExplainAnalyze(ctx context.Context, compiled codegen.Compiled) (plan cost.Plan, err error)

ExplainAnalyze implements cost.AnalyzeSampler. EXPLAIN ANALYZE executes the compiled read-only statement once more; callers must apply a separate, tightly bounded sampling context.

Jump to

Keyboard shortcuts

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