Skip to content

Commit cfa1678

Browse files
authored
Merge pull request #2930 from dolthub/fulghum/source_ssl
Add support for SSL connections to a source MySQL server
2 parents 9ce988e + 13aa162 commit cfa1678

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

sql/binlogreplication/binlog_replication.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ type BinaryLogStatus struct {
131131
type ReplicaStatus struct {
132132
SourceHost string
133133
SourceUser string
134+
SourceSsl bool
134135
SourcePort uint
135136
ConnectRetry uint32
136137
SourceRetryCount uint64

sql/mysql_db/replica_source_info.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
type ReplicaSourceInfo struct {
2828
Host string
2929
User string
30+
Ssl bool
3031
Password string
3132
Port uint16
3233
Uuid string
@@ -58,6 +59,12 @@ func ReplicaSourceInfoToRow(ctx *sql.Context, v *ReplicaSourceInfo) (sql.Row, er
5859
row[replicaSourceInfoTblColIndex_Connect_retry] = v.ConnectRetryInterval
5960
row[replicaSourceInfoTblColIndex_Retry_count] = v.ConnectRetryCount
6061

62+
if v.Ssl {
63+
row[replicaSourceInfoTblColIndex_Enabled_ssl] = 1
64+
} else {
65+
row[replicaSourceInfoTblColIndex_Enabled_ssl] = 0
66+
}
67+
6168
return row, nil
6269
}
6370

@@ -66,9 +73,12 @@ func ReplicaSourceInfoFromRow(ctx *sql.Context, row sql.Row) (*ReplicaSourceInfo
6673
return nil, err
6774
}
6875

76+
ssl := row[replicaSourceInfoTblColIndex_Enabled_ssl] == 1
77+
6978
return &ReplicaSourceInfo{
7079
Host: row[replicaSourceInfoTblColIndex_Host].(string),
7180
User: row[replicaSourceInfoTblColIndex_User_name].(string),
81+
Ssl: ssl,
7282
Password: row[replicaSourceInfoTblColIndex_User_password].(string),
7383
Port: row[replicaSourceInfoTblColIndex_Port].(uint16),
7484
Uuid: row[replicaSourceInfoTblColIndex_Uuid].(string),
@@ -79,6 +89,7 @@ func ReplicaSourceInfoFromRow(ctx *sql.Context, row sql.Row) (*ReplicaSourceInfo
7989

8090
func ReplicaSourceInfoEquals(left, right *ReplicaSourceInfo) bool {
8191
return left.User == right.User &&
92+
left.Ssl == right.Ssl &&
8293
left.Host == right.Host &&
8394
left.Port == right.Port &&
8495
left.Password == right.Password &&

sql/rowexec/show.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -807,6 +807,11 @@ func (b *BaseBuilder) buildShowReplicaStatus(ctx *sql.Context, n *plan.ShowRepli
807807
lastIoErrorTimestamp := formatReplicaStatusTimestamp(status.LastIoErrorTimestamp)
808808
lastSqlErrorTimestamp := formatReplicaStatusTimestamp(status.LastSqlErrorTimestamp)
809809

810+
sslAllowed := "No"
811+
if status.SourceSsl {
812+
sslAllowed = "Yes"
813+
}
814+
810815
row = sql.Row{
811816
"", // Replica_IO_State
812817
status.SourceHost, // Source_Host
@@ -834,7 +839,7 @@ func (b *BaseBuilder) buildShowReplicaStatus(ctx *sql.Context, n *plan.ShowRepli
834839
"None", // Until_Condition
835840
nil, // Until_Log_File
836841
nil, // Until_Log_Pos
837-
"Ignored", // Source_SSL_Allowed
842+
sslAllowed, // Source_SSL_Allowed
838843
nil, // Source_SSL_CA_File
839844
nil, // Source_SSL_CA_Path
840845
nil, // Source_SSL_Cert

0 commit comments

Comments
 (0)