@@ -16,6 +16,7 @@ package mariadb
1616
1717import (
1818 "fmt"
19+ "os"
1920 "strings"
2021 "time"
2122
@@ -50,6 +51,10 @@ type Connector interface {
5051 CreateIDTable (dbName string , tableName string ) error
5152 InsertIDRecord (dbName string , tableName string , id int ) error
5253 DeleteRecords (dbName string , tableName string ) error
54+
55+ // remove master info or relay info
56+ RemoveMasterInfo () error
57+ RemoveRelayInfo () error
5358}
5459
5560func NewDefaultConnector (logger * slog.Logger ) Connector {
@@ -202,6 +207,30 @@ func (c *mySQLCommandConnector) runMysqlCommand(mysqlcmd string) ([]byte, error)
202207 return command .RunWithTimeout (mysqlCommandTimeout , name , args ... )
203208}
204209
210+ func (c * mySQLCommandConnector ) RemoveMasterInfo () error {
211+ _ , err := os .Stat (MasterInfoFilePath )
212+
213+ // do nothing if file is not found
214+ if err != nil {
215+ return nil
216+ }
217+
218+ // delete if file exists
219+ return os .Remove (MasterInfoFilePath )
220+ }
221+
222+ func (c * mySQLCommandConnector ) RemoveRelayInfo () error {
223+ _ , err := os .Stat (RelayInfoFilePath )
224+
225+ // do nothing if file is not found
226+ if err != nil {
227+ return nil
228+ }
229+
230+ // delete if file exists
231+ return os .Remove (RelayInfoFilePath )
232+ }
233+
205234// parseShowReplicaStatusOutput parses the output of the "mysql -e 'show replica status \G'".
206235func parseShowReplicaStatusOutput (out string ) ReplicationStatus {
207236 m := ReplicationStatus {}
0 commit comments