database

package
v0.7.0-RC1 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2026 License: Apache-2.0, MIT Imports: 14 Imported by: 1 module, 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 (
	ErrInmemoryWithHighConcurrency = errors.New("cannot use in-memory database with concurrency > 1")
	ErrDatabaseNotSupported        = errors.New("database not supported")
)

Functions

func AddPragmaToSQLite added in v0.4.0

func AddPragmaToSQLite(connString string) (string, error)

func CheckDeadlockLoggingEnabled

func CheckDeadlockLoggingEnabled(db *gorm.DB) (bool, error)

CheckDeadlockLoggingEnabled checks if innodb_print_all_deadlocks is enabled.

func DoRetry

func DoRetry(ctx context.Context, f func() error) error

func EnableDeadlockLogging

func EnableDeadlockLogging(db *gorm.DB) error

EnableDeadlockLogging enables logging of all deadlocks to the MySQL error log. By default, MySQL/MariaDB only logs the most recent deadlock. This setting persists until the server is restarted.

func GetDataLockWaits

func GetDataLockWaits(db *gorm.DB) ([]map[string]interface{}, error)

GetDataLockWaits returns current lock wait information from performance_schema. This requires MySQL 8.0.30+ or MariaDB 10.5+.

func GetLockWaitTransactions

func GetLockWaitTransactions(db *gorm.DB) ([]map[string]interface{}, error)

GetLockWaitTransactions returns transactions currently waiting for locks. This requires MySQL 8.0.30+ or MariaDB 10.5+.

func OpenFromCLI added in v0.2.28

func OpenFromCLI(c *cli.Context) (*gorm.DB, io.Closer, error)

func OpenWithLogger added in v0.3.0

func OpenWithLogger(connString string) (*gorm.DB, io.Closer, error)

func PrintDeadlockInfo

func PrintDeadlockInfo(db *gorm.DB) string

PrintDeadlockInfo prints detailed deadlock information from MySQL/MariaDB InnoDB status. This should be called when a deadlock error is detected to help diagnose the issue. Returns the deadlock information as a string, or empty string if not available.

Types

This section is empty.

Jump to

Keyboard shortcuts

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