db

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplySQLiteSessionPragmas added in v0.10.0

func ApplySQLiteSessionPragmas(db *sql.DB) error

func ConnectDB

func ConnectDB() (*sql.DB, error)

func DefaultOperationTimeout added in v0.10.0

func DefaultOperationTimeout() time.Duration

func DefaultStatementTimeout added in v0.10.0

func DefaultStatementTimeout() time.Duration

func EnsurePostgresSchema added in v0.10.0

func EnsurePostgresSchema(dbconn *sql.DB) error

EnsurePostgresSchema validates the runtime PostgreSQL schema. If COLDKEEP_DB_AUTO_BOOTSTRAP is enabled and schema_version is missing, it bootstraps by applying the embedded db/schema_postgres.sql.

func NewOperationContext added in v0.10.0

func NewOperationContext(parent context.Context) (context.Context, context.CancelFunc)

func QueryWithOptionalForUpdate added in v0.10.0

func QueryWithOptionalForUpdate(dbconn *sql.DB, query string) string

QueryWithOptionalForUpdate appends FOR UPDATE only for backends that support it.

func QueryWithOptionalForUpdateNowait added in v0.10.0

func QueryWithOptionalForUpdateNowait(dbconn *sql.DB, query string) string

QueryWithOptionalForUpdateNowait appends FOR UPDATE NOWAIT when supported.

func QueryWithOptionalForUpdateSkipLocked added in v0.10.0

func QueryWithOptionalForUpdateSkipLocked(dbconn *sql.DB, query string) string

QueryWithOptionalForUpdateSkipLocked appends FOR UPDATE SKIP LOCKED when supported.

func RunMigrations added in v0.8.0

func RunMigrations(dbconn *sql.DB) error

RunMigrations applies the embedded SQLite schema to a DB connection. It is intended for simulated/local SQLite contexts only.

func SupportsSelectForUpdate added in v0.10.0

func SupportsSelectForUpdate(dbconn *sql.DB) bool

SupportsSelectForUpdate reports whether SELECT ... FOR UPDATE is supported.

func SupportsSelectForUpdateNowait added in v0.10.0

func SupportsSelectForUpdateNowait(dbconn *sql.DB) bool

SupportsSelectForUpdateNowait reports whether FOR UPDATE NOWAIT is supported.

func SupportsSelectForUpdateSkipLocked added in v0.10.0

func SupportsSelectForUpdateSkipLocked(dbconn *sql.DB) bool

SupportsSelectForUpdateSkipLocked reports whether FOR UPDATE SKIP LOCKED is supported.

Types

type Backend added in v0.10.0

type Backend string

Backend identifies the SQL backend in use for a given *sql.DB.

const (
	BackendUnknown  Backend = "unknown"
	BackendPostgres Backend = "postgres"
	BackendSQLite   Backend = "sqlite"
)

func BackendFromDB added in v0.10.0

func BackendFromDB(dbconn *sql.DB) Backend

BackendFromDB detects the configured backend from the DB driver.

type DBTX

type DBTX interface {
	Exec(query string, args ...any) (sql.Result, error)
	QueryRow(query string, args ...any) *sql.Row
}

DBTX is implemented by *sql.DB and *sql.Tx (so we can reuse helpers inside a tx).

Jump to

Keyboard shortcuts

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