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

postgres

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2026 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

Package postgres holds the two server-level statements the rest of the code needs and ent cannot express: the transaction-scoped advisory lock and the server version. Each is written here once; callers pass any client that runs a statement (*sql.DB, *sql.Tx, *ent.Client, *ent.Tx).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LockTx

func LockTx(ctx context.Context, e Execer, key int64) error

LockTx takes the advisory lock key and holds it to the end of the surrounding transaction. Use it to make a value taken inside the transaction commit in the order it was taken.

func ServerMajor

func ServerMajor(ctx context.Context, q Queryer) (int, error)

ServerMajor is the major version of the Postgres server (server_version_num is major*10000+minor from version 10 on).

Types

type Execer

type Execer interface {
	ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)
}

Execer runs a statement that returns no rows.

type Queryer

type Queryer interface {
	QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)
}

Queryer runs a statement that returns rows.

Jump to

Keyboard shortcuts

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