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 ¶
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.
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) Placeholder ¶
func (Dialect) QuoteIdent ¶
type Provider ¶
type Provider struct {
*sqladapter.Pool
// contains filtered or unexported fields
}
Provider adapts a PostgreSQL database to the core interfaces.
func New ¶
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 ¶
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.
func (*Provider) Introspector ¶
func (p *Provider) Introspector() introspect.Introspector
Introspector returns the schema introspector.