-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WIP] Support mysqlsh -- load-dump/copy-instance
- Loading branch information
Showing
5 changed files
with
133 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package myfunc | ||
|
||
import ( | ||
"github.com/dolthub/go-mysql-server/sql" | ||
"github.com/dolthub/go-mysql-server/sql/expression/function" | ||
"github.com/dolthub/go-mysql-server/sql/types" | ||
) | ||
|
||
type PSCurrentThreadID struct { | ||
function.NoArgFunc | ||
} | ||
|
||
func (c PSCurrentThreadID) IsNonDeterministic() bool { | ||
return true | ||
} | ||
|
||
var _ sql.FunctionExpression = PSCurrentThreadID{} | ||
var _ sql.CollationCoercible = PSCurrentThreadID{} | ||
|
||
func NewPSCurrentThreadID() sql.Expression { | ||
return PSCurrentThreadID{ | ||
NoArgFunc: function.NoArgFunc{"ps_current_thread_id", types.Uint64}, | ||
} | ||
} | ||
|
||
// FunctionName implements sql.FunctionExpression | ||
func (c PSCurrentThreadID) FunctionName() string { | ||
return "ps_current_thread_id" | ||
} | ||
|
||
// Description implements sql.FunctionExpression | ||
func (c PSCurrentThreadID) Description() string { | ||
return "Returns a BIGINT UNSIGNED value representing the Performance Schema thread ID assigned to the current connection." | ||
} | ||
|
||
// CollationCoercibility implements the interface sql.CollationCoercible. | ||
func (PSCurrentThreadID) CollationCoercibility(ctx *sql.Context) (collation sql.CollationID, coercibility byte) { | ||
return sql.Collation_utf8mb3_general_ci, 3 | ||
} | ||
|
||
// Eval implements sql.Expression | ||
func (c PSCurrentThreadID) Eval(ctx *sql.Context, row sql.Row) (interface{}, error) { | ||
// Golang discourages the use of thread ID or goroutine ID as they are not stable, so we use connection ID instead. | ||
return uint64(ctx.ID()), nil | ||
} | ||
|
||
// WithChildren implements sql.Expression | ||
func (c PSCurrentThreadID) WithChildren(children ...sql.Expression) (sql.Expression, error) { | ||
return function.NoArgFuncWithChildren(c, children) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package myfunc | ||
|
||
import "github.com/dolthub/go-mysql-server/sql" | ||
|
||
var ExtraBuiltIns = []sql.Function{ | ||
sql.Function0{Name: "ps_current_thread_id", Fn: NewPSCurrentThreadID}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package replica | ||
|
||
import ( | ||
"github.com/dolthub/go-mysql-server/sql" | ||
"github.com/dolthub/go-mysql-server/sql/types" | ||
) | ||
|
||
// ReplicaOptions holds the options for a replica server. | ||
// https://dev.mysql.com/doc/refman/8.4/en/replication-options-replica.html | ||
type ReplicaOptions struct { | ||
ReportHost string | ||
ReportPort int | ||
ReportUser string | ||
ReportPassword string | ||
} | ||
|
||
func RegisterReplicaOptions(options *ReplicaOptions) { | ||
sql.SystemVariables.AddSystemVariables([]sql.SystemVariable{ | ||
&sql.MysqlSystemVariable{ | ||
Name: "report_host", | ||
Scope: sql.GetMysqlScope(sql.SystemVariableScope_Global), | ||
Dynamic: false, | ||
SetVarHintApplies: false, | ||
Type: types.NewSystemStringType("report_host"), | ||
Default: options.ReportHost, | ||
}, | ||
&sql.MysqlSystemVariable{ | ||
Name: "report_port", | ||
Scope: sql.GetMysqlScope(sql.SystemVariableScope_Global), | ||
Dynamic: false, | ||
SetVarHintApplies: false, | ||
Type: types.NewSystemIntType("report_port", 0, 65535, false), | ||
Default: int64(options.ReportPort), | ||
}, | ||
&sql.MysqlSystemVariable{ | ||
Name: "report_user", | ||
Scope: sql.GetMysqlScope(sql.SystemVariableScope_Global), | ||
Dynamic: false, | ||
SetVarHintApplies: false, | ||
Type: types.NewSystemStringType("report_user"), | ||
Default: options.ReportUser, | ||
}, | ||
&sql.MysqlSystemVariable{ | ||
Name: "report_password", | ||
Scope: sql.GetMysqlScope(sql.SystemVariableScope_Global), | ||
Dynamic: false, | ||
SetVarHintApplies: false, | ||
Type: types.NewSystemStringType("report_password"), | ||
Default: options.ReportPassword, | ||
}, | ||
}) | ||
} |