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 ¶
- Decision record 0005: https://github.com/deploymenttheory/go-apple-dm/blob/main/docs/research/decisions/0005-storage-interfaces.md
- Decision record 0012: https://github.com/deploymenttheory/go-apple-dm/blob/main/docs/research/decisions/0012-sql-storage-backends.md
- Decision record 0013: https://github.com/deploymenttheory/go-apple-dm/blob/main/docs/research/decisions/0013-secrets-at-rest.md
- Threat model: https://github.com/deploymenttheory/go-apple-dm/blob/main/docs/security/threat-model.md (Storage rows)
- Apple: https://developer.apple.com/documentation/devicemanagement/check-in
- Apple: https://developer.apple.com/documentation/devicemanagement/handling-notnow-status-responses
Index ¶
Constants ¶
This section is empty.
Variables ¶
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.
var ErrDSNRequired = errors.New("mysql: DSN is required")
ErrDSNRequired is returned by Open for an empty DSN.
Functions ¶
func IsUniqueViolation ¶
IsUniqueViolation reports whether err is a MySQL duplicate key error.
func NormalizeDSN ¶
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.