MCPcopy
hub / github.com/go-sql-driver/mysql / Ping

Method Ping

connection.go:591–607  ·  view source on GitHub ↗

Ping implements driver.Pinger interface

(ctx context.Context)

Source from the content-addressed store, hash-verified

589
590// Ping implements driver.Pinger interface
591func (mc *mysqlConn) Ping(ctx context.Context) (err error) {
592 if mc.closed.Load() {
593 return driver.ErrBadConn
594 }
595
596 if err = mc.watchCancel(ctx); err != nil {
597 return
598 }
599 defer mc.finish()
600
601 handleOk := mc.clearResult()
602 if err = mc.writeCommandPacket(comPing); err != nil {
603 return mc.markBadConn(err)
604 }
605
606 return handleOk.readResultOK()
607}
608
609// BeginTx implements driver.ConnBeginTx interface
610func (mc *mysqlConn) BeginTx(ctx context.Context, opts driver.TxOptions) (driver.Tx, error) {

Callers 10

TestCleanCancelFunction · 0.95
TestPingErrInvalidConnFunction · 0.95
runTestsFunction · 0.80
TestTLSFunction · 0.80
TestUnixSocketAuthFailFunction · 0.80
TestPingFunction · 0.80
TestEmptyPasswordFunction · 0.80
TestNewConnectorFunction · 0.80

Calls 6

watchCancelMethod · 0.95
finishMethod · 0.95
clearResultMethod · 0.95
writeCommandPacketMethod · 0.95
markBadConnMethod · 0.95
readResultOKMethod · 0.80

Tested by 10

TestCleanCancelFunction · 0.76
TestPingErrInvalidConnFunction · 0.76
runTestsFunction · 0.64
TestTLSFunction · 0.64
TestUnixSocketAuthFailFunction · 0.64
TestPingFunction · 0.64
TestEmptyPasswordFunction · 0.64
TestNewConnectorFunction · 0.64