Documentation
¶
Overview ¶
Package mysql adapts a MySQL database to the core interfaces. The Adapter (store.DB/Tx) is also reused by the oceanbase provider, since OceanBase speaks the MySQL wire protocol.
Index ¶
- func NewIntrospector(db *sql.DB) introspect.Introspector
- type Adapter
- func (a *Adapter) BeginTx(ctx context.Context, opts *store.TxOptions) (store.Tx, error)
- func (a *Adapter) Close() error
- func (a *Adapter) DB() *sql.DB
- func (a *Adapter) ExecContext(ctx context.Context, query string, args ...any) (store.Result, error)
- func (a *Adapter) PrepareContext(ctx context.Context, query string) (store.Prepared, error)
- func (a *Adapter) QueryContext(ctx context.Context, query string, args ...any) (store.Rows, error)
- type Dialect
- type Introspector
- type Provider
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewIntrospector ¶
func NewIntrospector(db *sql.DB) introspect.Introspector
NewIntrospector returns an introspect.Introspector backed by db.
Types ¶
type Adapter ¶
type Adapter struct {
// contains filtered or unexported fields
}
Adapter wraps *sql.DB for the MySQL protocol, satisfying store.DB and store.TxBeginner. Shared with the oceanbase provider.
func NewAdapter ¶
NewAdapter opens a MySQL-compatible database and pings it (fail-fast). It injects sql_safe_updates=1 as a DB-native backstop against full-table UPDATE/DELETE (defense in depth alongside the cost gate's WriteGuard); a DSN that sets sql_safe_updates explicitly is respected.
func NewAdapterWithTimeout ¶
func NewAdapterWithTimeout(dsn string, timeout time.Duration, oceanBaseVariable string) (*Adapter, error)
NewAdapterWithTimeout opens a MySQL-compatible database with a DB-native statement timeout. oceanBaseVariable may be "ob_query_timeout".
func (*Adapter) ExecContext ¶
ExecContext implements store.DB.
func (*Adapter) PrepareContext ¶
PrepareContext implements store.Preparer for MySQL and OceanBase.
type Dialect ¶
type Dialect struct{}
Dialect is the MySQL dialect. EXPLAIN estimates are less reliable than PostgreSQL's, so the gate weakens the Estimate layer and leans on EnforceCap + max_execution_time + sql_safe_updates.
func (Dialect) Capabilities ¶
func (Dialect) Capabilities() dialect.Capabilities
func (Dialect) ExplainSQL ¶
func (Dialect) Placeholder ¶
func (Dialect) QuoteIdent ¶
type Introspector ¶
type Introspector struct {
// contains filtered or unexported fields
}
Introspector discovers entities from information_schema. Exported so the oceanbase provider can reuse it (OceanBase is MySQL-protocol compatible).
type Provider ¶
type Provider struct {
*Adapter
// contains filtered or unexported fields
}
Provider adapts a MySQL database to the core interfaces.
func NewWithTimeout ¶
NewWithTimeout opens MySQL with a DB-native SELECT timeout.
func (*Provider) Introspector ¶
func (p *Provider) Introspector() introspect.Introspector
Introspector returns the schema introspector.