Documentation
¶
Index ¶
- Constants
- func LoadMultiEnvFromDir(ctx context.Context, cfg config.ReadWriteConfig, fs filesys.Filesys, ...) (*env.MultiRepoEnv, error)
- type Config
- type Connector
- type DoltConn
- func (d *DoltConn) Begin() (driver.Tx, error)deprecated
- func (d *DoltConn) BeginTx(ctx context.Context, opts driver.TxOptions) (driver.Tx, error)
- func (d *DoltConn) Close() error
- func (d *DoltConn) ExecContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Result, error)
- func (d *DoltConn) IsValid() bool
- func (d *DoltConn) Ping(ctx context.Context) error
- func (d *DoltConn) Prepare(query string) (driver.Stmt, error)
- func (d *DoltConn) PrepareContext(ctx context.Context, query string) (driver.Stmt, error)
- func (d *DoltConn) QueryContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Rows, error)
- func (d *DoltConn) ResetSession(ctx context.Context) error
- type DoltDataSource
- type QuerySplitter
- type RuneStack
Constants ¶
const ( DoltDriverName = "dolt" CommitNameParam = "commitname" CommitEmailParam = "commitemail" DatabaseParam = "database" MultiStatementsParam = "multistatements" ClientFoundRowsParam = "clientfoundrows" // The following params are passed through to Dolt's local DB loading layer via // engine.SqlEngineConfig.DBLoadParams. They are presence-based flags (values are ignored). DisableSingletonCacheParam = "disable_singleton_cache" FailOnJournalLockTimeoutParam = "fail_on_journal_lock_timeout" )
Variables ¶
This section is empty.
Functions ¶
func LoadMultiEnvFromDir ¶
func LoadMultiEnvFromDir( ctx context.Context, cfg config.ReadWriteConfig, fs filesys.Filesys, path, version string, ) (*env.MultiRepoEnv, error)
LoadMultiEnvFromDir looks at each subfolder of the given path as a Dolt repository and attempts to return a MultiRepoEnv with initialized environments for each of those subfolder data repositories. subfolders whose name starts with '.' are skipped.
Types ¶
type Config ¶ added in v1.83.8
type Config struct {
// DSN is the original datasource name string used to create this config (optional).
DSN string
// Directory is the filesystem directory containing one or more Dolt databases (required).
Directory string
// CommitName and CommitEmail are used for Dolt commit metadata (required).
CommitName string
CommitEmail string
// Database is the initial database to connect to (optional).
Database string
// MultiStatements enables multi-statement support.
MultiStatements bool
// ClientFoundRows toggles the MySQL CLIENT_FOUND_ROWS capability in the session.
ClientFoundRows bool
// Params is the lower-cased DSN query param map as parsed from the DSN (optional).
// This is preserved for forward-compat / feature flags while moving away from
// DSN-driven configuration.
Params map[string][]string
// BackOff enables bounded retries when opening the embedded engine.
//
// If nil, engine open is attempted once.
// If non-nil, NewConnector will retry opens for retryable errors using this BackOff.
//
// Note: BackOff implementations are stateful; callers should generally provide a
// fresh instance per connector, and the connector will call Reset() before use.
BackOff backoff.BackOff
// Version is the Dolt environment version string used when loading repos (optional).
// If empty, the connector will use a reasonable default.
Version string
}
Config configures an embedded Dolt SQL connector / driver.
Typical usage is:
- Parse a DSN with ParseDSN (populates the DSN-derived fields)
- Optionally set BackOff to enable retries when opening the embedded engine
- Pass the config to NewConnector, then use sql.OpenDB(connector)
DSN-derived fields are included so callers can parse once, adjust settings, and construct a connector without re-parsing string DSNs throughout the codebase.
type Connector ¶ added in v1.83.8
type Connector struct {
// contains filtered or unexported fields
}
Connector is a database/sql driver connector for embedded Dolt.
Callers should construct it with NewConnector and then pass it to sql.OpenDB. The connector shares a single underlying embedded engine across connections, and creates a per-connection session context on each Connect.
func NewConnector ¶ added in v1.83.8
NewConnector constructs a new connector for embedded Dolt. The embedded engine is opened lazily on first Connect (and shared thereafter).
If cfg.BackOff is non-nil, opening the engine will be retried for retryable open errors (e.g. lock contention) using that backoff, bounded by the Connect context.
func (*Connector) Close ¶ added in v1.83.8
Close closes the shared embedded engine, if it has been opened. It is safe to call multiple times.
type DoltConn ¶
type DoltConn struct {
// contains filtered or unexported fields
}
DoltConn is a driver.Conn implementation that represents a connection to a dolt database located on the filesystem
func (*DoltConn) BeginTx ¶
BeginTx starts and returns a new transaction. If the context is canceled by the user the sql package will call Tx.Rollback before discarding and closing the connection.
func (*DoltConn) ExecContext ¶ added in v1.84.1
func (d *DoltConn) ExecContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Result, error)
ExecContext implements driver.ExecerContext.
func (*DoltConn) Ping ¶ added in v1.84.1
Ping implements driver.Pinger. It verifies the connection is still alive by executing a lightweight query against the engine.
func (*DoltConn) Prepare ¶
Prepare packages up |query| as a *doltStmt so it can be executed. If multistatements mode has been enabled, then a *doltMultiStmt will be returned, capable of executing multiple statements.
func (*DoltConn) PrepareContext ¶ added in v1.84.1
PrepareContext implements driver.ConnPrepareContext. The supplied context governs the preparation step only; the returned statement inherits the connection's ambient context for its executions.
type DoltDataSource ¶
DoltDataSource provides access to the data provided by the connection string
func ParseDataSource ¶
func ParseDataSource(dataSource string) (*DoltDataSource, error)
ParseDataSource takes the connection string and parses out the parameters and the local filesys directory where the dolt database lives
func (*DoltDataSource) ParamIsTrue ¶
func (ds *DoltDataSource) ParamIsTrue(paramName string) bool
type QuerySplitter ¶
type QuerySplitter struct {
// contains filtered or unexported fields
}
func NewQuerySplitter ¶
func NewQuerySplitter(str string) *QuerySplitter
func (*QuerySplitter) HasMore ¶
func (qs *QuerySplitter) HasMore() bool
func (*QuerySplitter) Next ¶
func (qs *QuerySplitter) Next() (string, error)
type RuneStack ¶
type RuneStack struct {
// contains filtered or unexported fields
}
RuneStack is a simple stack of runes
func NewRuneStack ¶ added in v1.84.1
func NewRuneStack() *RuneStack
NewRuneStack returns a new RuneStack object