Documentation
¶
Overview ¶
Package db provides the interfaces and libraries for database driver plugins.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ConnectionConfig ¶
type ConnectionConfig struct {
DataSource *storepb.DataSource
ConnectionContext ConnectionContext
Password string
}
ConnectionConfig is the configuration for connections.
type ConnectionContext ¶
type ConnectionContext struct {
EnvironmentID string
InstanceID string
EngineVersion string
// UseDatabaseOwner is used by Postgres for using role of database owner.
UseDatabaseOwner bool
DatabaseName string
DataShare bool
// ReadOnly is only supported for Postgres at the moment.
ReadOnly bool
}
ConnectionContext is the context for connection. It's not used for establishing the db connection, but is useful for logging.
type ConstraintKey ¶
type Driver ¶
type Driver interface {
// General execution
// A driver might support multiple engines (e.g. MySQL driver can support both MySQL and TiDB),
// So we pass the dbType to tell the exact engine.
Open(ctx context.Context, dbType storepb.Engine, config ConnectionConfig) (Driver, error)
// Remember to call Close to avoid connection leak
Close(ctx context.Context) error
Ping(ctx context.Context) error
GetDB() *sql.DB
// Sync schema
// SyncInstance syncs the instance metadata.
SyncInstance(ctx context.Context) (*InstanceMetadata, error)
// SyncDBSchema syncs a single database schema. A database the target no
// longer has must be reported as common.NotFound (not as a plain error), so a
// caller can mirror the target's inventory instead of guessing from the
// message; every other failure keeps its own error.
SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetadata, error)
}
Driver is the interface for database driver.
type InstanceMetadata ¶
type InstanceMetadata struct {
Version string
// Simplified database metadata.
Databases []*storepb.DatabaseSchemaMetadata
Metadata *storepb.Instance
}
InstanceMetadata is the metadata for an instance.
type MigrationStatus ¶
type MigrationStatus string
MigrationStatus is the status of migration.
const ( // Pending is the migration status for PENDING. Pending MigrationStatus = "PENDING" // Done is the migration status for DONE. Done MigrationStatus = "DONE" // Failed is the migration status for FAILED. Failed MigrationStatus = "FAILED" )
type ObjectDefinitionReader ¶
type ObjectDefinitionReader interface {
// GetObjectDefinition returns the DDL of the named object. ok is false when
// this engine has no definition for that object type; the caller then falls
// back to reconstruction.
GetObjectDefinition(ctx context.Context, objectType storepb.MetaType, name string) (definition string, ok bool, err error)
}
ObjectDefinitionReader is an optional capability: a driver that implements it can return the engine's own DDL for an object instead of having it reconstructed from metadata. Reconstruction is lossy for engines whose DDL carries properties the metadata does not model (StarRocks distribution, properties, partitioning), so the syncer prefers this when available.
type SequenceKey ¶
type TableKeyWithColumns ¶
type TableKeyWithColumns struct {
Schema string
Table string
Columns []*storepb.ColumnMetadata
}
Directories
¶
| Path | Synopsis |
|---|---|
|
Package mssql is the plugin for MSSQL driver.
|
Package mssql is the plugin for MSSQL driver. |
|
Package mysql is the plugin for MySQL driver.
|
Package mysql is the plugin for MySQL driver. |
|
Package pg is the plugin for PostgreSQL driver.
|
Package pg is the plugin for PostgreSQL driver. |
|
Package starrocks is the plugin for the StarRocks and Doris drivers.
|
Package starrocks is the plugin for the StarRocks and Doris drivers. |