mysql

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 13, 2026 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Overview

Package mysql is the plugin for MySQL driver.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildDSN

func BuildDSN(username, password, protocol, host, port, databaseName string, params []string) string

BuildDSN renders the connection string for a MySQL-wire data source.

databaseName is not a constant chosen at registration time: a schema sync reads it out of the target instance's own catalog. Interpolated as-is, a database named `app?tls=false&` would end the DSN's path segment and turn the rest into driver parameters — the connection would drop TLS, point at the database `app` and let whoever can create a database on the target rewrite the connection the platform opens with its privileged sync account. The name is therefore escaped with url.PathEscape, which is what the driver's own Config.FormatDSN applies to DBName, so an escaped name round-trips through ParseDSN unchanged.

It is exported so StarRocks and Doris build their DSN the same way instead of re-deriving the template.

func GetColumnTypeCanonicalSynonym

func GetColumnTypeCanonicalSynonym(columnType string) string

GetColumnTypeCanonicalSynonym returns the canonical synonyms of the given column types, returns the original one if no synonym was found.

func IsCurrentTimestampLike

func IsCurrentTimestampLike(s string) bool

func QuoteIdentifier

func QuoteIdentifier(name string) string

QuoteIdentifier backtick-quotes a MySQL-wire identifier. Identifiers cannot be bound as statement parameters, so an embedded backtick is escaped by doubling. It is exported so the other MySQL-wire drivers (StarRocks, Doris) quote identifiers the same way instead of letting the escaping drift.

func UnescapeExpressionDefault

func UnescapeExpressionDefault(s string) string

UnescapeExpressionDefault unescapes the default expression for MySQL. This handles the second layer of escaping that MySQL applies when storing expression defaults (like DEFAULT (UUID())) in system catalogs. MySQL stores expressions as escaped strings internally, separate from QUOTE() escaping.

func UnquoteMySQLString

func UnquoteMySQLString(s string) string

UnquoteMySQLString unescapes a string that was escaped by MySQL's QUOTE() function. MySQL's QUOTE() function escapes: - \ → \\ - ' → \' - ASCII NUL (0x00) → \0 - Control-Z (0x1A) → \Z

func ValidateExtraConnectionParameters

func ValidateExtraConnectionParameters(params map[string]string) error

ValidateExtraConnectionParameters validates that no dangerous parameters are present. It is exported so the other MySQL-wire drivers (StarRocks, Doris) enforce the same allowlist instead of letting the check drift.

Types

type Driver

type Driver struct {
	// contains filtered or unexported fields
}

Driver is the MySQL driver.

func (*Driver) Close

func (d *Driver) Close(context.Context) error

Close closes the driver.

func (*Driver) GetDB

func (d *Driver) GetDB() *sql.DB

GetDB gets the database.

func (*Driver) Open

func (d *Driver) Open(ctx context.Context, dbType storepb.Engine, connCfg db.ConnectionConfig) (db.Driver, error)

Open opens a MySQL driver.

func (*Driver) Ping

func (d *Driver) Ping(ctx context.Context) error

Ping pings the database.

func (*Driver) StopConnectionByID

func (d *Driver) StopConnectionByID(id string) error

func (*Driver) SyncDBSchema

func (d *Driver) SyncDBSchema(ctx context.Context) (metadata *storepb.DatabaseSchemaMetadata, err error)

SyncDBSchema syncs a single database schema. A database the target no longer has is reported as common.NotFound, which is what tells a caller mirroring the target's inventory apart from a permission or connectivity failure.

func (*Driver) SyncInstance

func (d *Driver) SyncInstance(ctx context.Context) (*db.InstanceMetadata, error)

SyncInstance syncs the instance.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL