mysql

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package mysql implements the MDM SQL storage dialect with go-sql-driver/mysql.

Design

The dialect supplies placeholders, locking, unique-error classification and embedded migrations to sqlcommon. NormalizeDSN enables parsed UTC times; DATETIME(6) preserves microseconds. Upserts use INSERT ... AS new ON DUPLICATE KEY UPDATE and require MySQL 8.0.19 or later.

Shared statement logic and sealing live in server/sqlstore/sqlcommon. Integration tests run storage/storagetest against a configured database through make test-storage.

References

Index

Constants

This section is empty.

Variables

View Source
var Dialect = sqlcommon.Dialect{
	Name:              "mysql",
	ForUpdate:         "FOR UPDATE",
	Upsert:            sqlcommon.UpsertOnDuplicateKey,
	Migrations:        sqlcommon.MustSub(migrationFS, "migrations"),
	InsertIgnore:      sqlcommon.InsertIgnoreDuplicateKey,
	IsUniqueViolation: IsUniqueViolation,
}

Dialect is the MySQL dialect.

View Source
var ErrDSNRequired = errors.New("mysql: DSN is required")

ErrDSNRequired is returned by Open for an empty DSN.

Functions

func IsUniqueViolation

func IsUniqueViolation(err error) bool

IsUniqueViolation reports whether err is a MySQL duplicate key error.

func NormalizeDSN

func NormalizeDSN(dsn string) (string, error)

NormalizeDSN forces the settings the backend needs: parseTime, UTC, utf8mb4, and clientFoundRows so RowsAffected reports matched rows (as PostgreSQL and SQLite do) and idempotent writes are not mistaken for missing rows.

Types

type Options

type Options struct {
	SkipMigrate bool
	Pool        sqlcommon.Pool
	// Keyring seals the secret columns (decision record 0013); nil keeps
	// them in plaintext.
	Keyring *crypt.Keyring
}

Options tune Open.

type Store

type Store struct{ *sqlcommon.Store }

Store is the MySQL backend.

func Open

func Open(ctx context.Context, dsn string, o Options) (*Store, error)

Open connects with a go-sql-driver DSN and migrates the schema.

Jump to

Keyboard shortcuts

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