Skip to content
This repository was archived by the owner on Oct 17, 2023. It is now read-only.

Commit ea0f7c5

Browse files
committed
Disable foreign key checks once per client
This is better. Move from Writer to Client. We can use this in lieu of the ping test. Strictly speaking we do not need this set for reading, but it's not going to do any harm.
1 parent 9618d84 commit ea0f7c5

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

adaptor/mysql/client.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,11 @@ func (c *Client) Connect() (client.Session, error) {
104104
c.db = uri.Path[1:]
105105
}
106106
}
107-
err = c.mysqlSession.Ping()
107+
// Replace Ping with an Exec that we need to run for imports anyway
108+
// TODO: Remove below rather than just have commented out
109+
//err = c.mysqlSession.Ping()
110+
// We need to disable Foreign Key Checks for imports
111+
// Ideally we don't want to send this _every_ time just once per session
112+
_, err = c.mysqlSession.Exec("SET FOREIGN_KEY_CHECKS=0;")
108113
return &Session{c.mysqlSession, c.db}, err
109114
}

adaptor/mysql/writer.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,6 @@ func (w *Writer) Write(msg message.Msg) func(client.Session) (message.Msg, error
4343
}
4444
return msg, nil
4545
}
46-
// We need to disable Foreign Key Checks for imports
47-
// Ideally we don't want to send this _every_ time just once per session
48-
s.(*Session).mysqlSession.Exec("SET FOREIGN_KEY_CHECKS=0;")
4946
if err := writeFunc(msg, s.(*Session).mysqlSession); err != nil {
5047
return nil, err
5148
}

0 commit comments

Comments
 (0)