Documentation
¶
Overview ¶
Package mysql is the builtin Orchard provider for MySQL (and MariaDB).
It implements one action, "mysql_query": run a SQL statement and capture the first returned row as outputs, or, for statements that return no rows, LAST_INSERT_ID() and ROW_COUNT(). MySQL has no RETURNING clause, so last_insert_id is how an INSERT's new id gets wired into the next step.
Index ¶
- type Provider
- func (p *Provider) Close() error
- func (p *Provider) Configure(ctx context.Context, config map[string]cty.Value) error
- func (p *Provider) Execute(ctx context.Context, action string, attrs map[string]cty.Value) (map[string]cty.Value, error)
- func (p *Provider) ExecuteUndo(ctx context.Context, action string, attrs map[string]cty.Value, ...) (map[string]cty.Value, *provider.Invocation, error)
- func (p *Provider) PlanAction(ctx context.Context, action string, attrs map[string]cty.Value) (provider.Plan, error)
- func (p *Provider) PlanConfigure(_ context.Context, _ map[string]cty.Value, snap *snapshot.Snapshot) error
- func (p *Provider) PullSchema(ctx context.Context, _ provider.PullOptions) (*provider.Capture, error)
- func (p *Provider) Schema() protocol.ProviderSchema
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider is the MySQL provider implementation.
A zero Provider is valid but not yet usable — Configure must be called before Execute. Schema works on a zero Provider so the engine can validate scenarios before a connection is opened.
func New ¶
func New() *Provider
New returns an unconfigured MySQL provider. Schema is parsed once up front so an error in the embedded schema.hcl fails at binary startup rather than at first use.
func (*Provider) Close ¶
Close closes the pool. Safe to call on an unconfigured provider or to call multiple times.
func (*Provider) Configure ¶
Configure parses the dsn config attribute and opens a pool. Like sql.Open everywhere, this does not dial; Execute surfaces connection errors on first use.
func (*Provider) Execute ¶
func (p *Provider) Execute(ctx context.Context, action string, attrs map[string]cty.Value) (map[string]cty.Value, error)
Execute dispatches to the handler for the given action.
func (*Provider) ExecuteUndo ¶
func (p *Provider) ExecuteUndo(ctx context.Context, action string, attrs map[string]cty.Value, opts provider.InverseOptions) (map[string]cty.Value, *provider.Invocation, error)
ExecuteUndo runs an action like Execute and, for a typed action, also describes its automatic teardown: deleting an inserted row by its primary key, or restoring the previous values of rows an update changed.
func (*Provider) PlanAction ¶
func (p *Provider) PlanAction(ctx context.Context, action string, attrs map[string]cty.Value) (provider.Plan, error)
PlanAction checks a typed action before the run: against the live schema after Configure, or the snapshot during `orchard plan`.
func (*Provider) PlanConfigure ¶
func (p *Provider) PlanConfigure(_ context.Context, _ map[string]cty.Value, snap *snapshot.Snapshot) error
PlanConfigure loads the schema snapshot `orchard plan` checks typed actions against. Without one, typed actions go unchecked at plan time. It doesn't connect.
func (*Provider) PullSchema ¶
func (p *Provider) PullSchema(ctx context.Context, _ provider.PullOptions) (*provider.Capture, error)
PullSchema captures the base tables (not views) of the database the DSN connects to. MySQL databases are single namespaces, so opts.Schemas is ignored.
func (*Provider) Schema ¶
func (p *Provider) Schema() protocol.ProviderSchema
Schema returns the embedded provider schema.