sqlchelpers

package
v0.74.7 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2026 License: MIT Imports: 11 Imported by: 0

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 *pgxpool.Pool, 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 BoolFromBoolean

func BoolFromBoolean(v bool) pgtype.Bool

func DeferRollback

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

func DurationToPgInterval

func DurationToPgInterval(d time.Duration) pgtype.Interval

func PrepareTx

func PrepareTx(ctx context.Context, pool *pgxpool.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 *pgxpool.Pool, l *zerolog.Logger, timeoutMs int) (pgx.Tx, func(context.Context) error, func(), error)

func TextFromStr

func TextFromStr(str string) pgtype.Text

func TimestampFromTime

func TimestampFromTime(t time.Time) pgtype.Timestamp

func TimestamptzFromTime

func TimestamptzFromTime(t time.Time) pgtype.Timestamptz

func ToInt

func ToInt(i int32) pgtype.Int4

func UUIDFromStr

func UUIDFromStr(uuid string) pgtype.UUID

func UUIDToStr

func UUIDToStr(uuid pgtype.UUID) string

func UniqueSet

func UniqueSet(uuids []pgtype.UUID) []pgtype.UUID

Types

This section is empty.

Jump to

Keyboard shortcuts

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