sqlchelpers

package
v0.120.24 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: MIT Imports: 15 Imported by: 2 modules, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DeadlockRetry = func(l *zerolog.Logger, f func() error) error {
	return genericRetry(l.Warn(), 3, f, "deadlock", func(err error) (bool, error) {
		return strings.Contains(err.Error(), "deadlock detected"), err
	}, 50*time.Millisecond, 200*time.Millisecond)
}

Functions

func AcquireConnectionWithStatementTimeout added in v0.74.3

func AcquireConnectionWithStatementTimeout(ctx context.Context, pool rawAcquirer, l *zerolog.Logger, timeoutMs int) (*pgx.Conn, func(), error)

AcquireConnectionWithStatementTimeout acquires a connection from the pool and overwrites the default statement timeout on it. It does not support timeout values lower than the default timeout (if called with such a value, it will just use the default timeout).

func AdvisoryLockKey added in v0.96.0

func AdvisoryLockKey(name string) int64

func BoolFromBoolean

func BoolFromBoolean(v bool) pgtype.Bool

func BoolFromMaybeBoolean added in v0.117.1

func BoolFromMaybeBoolean(v *bool) pgtype.Bool

BoolFromMaybeBoolean maps nil to SQL NULL and keeps an explicit false as false.

func DeferRollback

func DeferRollback(ctx context.Context, l *zerolog.Logger, rollback func(context.Context) error)

func DisableJITForTransaction added in v0.108.3

func DisableJITForTransaction(ctx context.Context, tx execer) error

func DurationToPgInterval

func DurationToPgInterval(d time.Duration) pgtype.Interval

func JSONBToStringMap added in v0.82.0

func JSONBToStringMap(data []byte) map[string]string

func MinTimestamptz added in v0.110.14

func MinTimestamptz(timestamps []pgtype.Timestamptz) pgtype.Timestamptz

func PrepareTx

func PrepareTx(ctx context.Context, pool Pool, l *zerolog.Logger) (pgx.Tx, func(context.Context) error, func(), error)

func PrepareTxWithStatementTimeout added in v0.74.3

func PrepareTxWithStatementTimeout(ctx context.Context, pool Pool, l *zerolog.Logger, timeoutMs int, opts ...pgx.TxOptions) (pgx.Tx, func(context.Context) error, func(), error)

func TextFromMaybeStr added in v0.100.18

func TextFromMaybeStr(str *string) pgtype.Text

func TextFromStr

func TextFromStr(str string) pgtype.Text

func TextToPtr added in v0.82.0

func TextToPtr(t pgtype.Text) *string

func TimestampFromTime

func TimestampFromTime(t time.Time) pgtype.Timestamp

func TimestamptzFromTime

func TimestamptzFromTime(t time.Time) pgtype.Timestamptz

func TimestamptzFromUnixMicros added in v0.105.3

func TimestamptzFromUnixMicros(micros int64) pgtype.Timestamptz

func ToBigInt added in v0.80.0

func ToBigInt(i *int64) pgtype.Int8

func ToInt

func ToInt(i *int32) pgtype.Int4

Types

type Pool added in v0.114.8

type Pool interface {
	Begin(context.Context) (pgx.Tx, error)
	BeginTx(context.Context, pgx.TxOptions) (pgx.Tx, error)
	Stat() *pgxpool.Stat
}

Pool is the subset of a pgx pool used to start a transaction. *pgxpool.Pool and a fairpool.Handle (ForTenant or ForShared) both satisfy it.

type TimeBounds added in v0.120.17

type TimeBounds struct {
	Min pgtype.Timestamptz
	Max pgtype.Timestamptz
}

func PartitionPruningTimeBounds added in v0.120.17

func PartitionPruningTimeBounds(timestamps []pgtype.Timestamptz) TimeBounds

Jump to

Keyboard shortcuts

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