Help us shape the future of Go! Take the 2026 Go Developer Survey

postgres

package
v0.10.7 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package postgres implements the MDM SQL storage dialect with pgx in database/sql mode.

Design

The dialect supplies numbered placeholders, FOR UPDATE locks, ON CONFLICT upserts, TIMESTAMPTZ columns and unique-error classification. Open parses the DSN before connecting. Shared statements and sealing live in server/sqlstore/sqlcommon.

Integration tests run the common storage contracts. The separate 100,000-row Clear timing gate runs without the race detector and can report timing without enforcement when STORAGE_TIMING=off.

References

Index

Constants

This section is empty.

Variables

View Source
var Dialect = sqlcommon.Dialect{
	Name:              "postgres",
	Dollar:            true,
	ForUpdate:         "FOR UPDATE",
	Upsert:            sqlcommon.UpsertOnConflict,
	Migrations:        sqlcommon.MustSub(migrationFS, "migrations"),
	InsertIgnore:      sqlcommon.InsertIgnoreOnConflict,
	IsUniqueViolation: IsUniqueViolation,
}

Dialect is the PostgreSQL dialect.

View Source
var ErrDSNRequired = errors.New("postgres: DSN is required")

ErrDSNRequired is returned by Open for an empty DSN.

Functions

func IsUniqueViolation

func IsUniqueViolation(err error) bool

IsUniqueViolation reports whether err is a PostgreSQL unique violation.

Types

type Options

type Options struct {
	SkipMigrate bool
	Pool        sqlcommon.Pool
	// Keyring seals the secret columns (decision record 0013); nil keeps
	// them in plaintext.
	Keyring *crypt.Keyring
}

Options tune Open.

type Store

type Store struct{ *sqlcommon.Store }

Store is the PostgreSQL backend.

func Open

func Open(ctx context.Context, dsn string, o Options) (*Store, error)

Open connects with a pgx DSN or URL and migrates the schema. The DSN is parsed before any connection attempt, so a malformed one fails fast.

Jump to

Keyboard shortcuts

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