Ping implements driver.Pinger interface
(ctx context.Context)
| 589 | |
| 590 | // Ping implements driver.Pinger interface |
| 591 | func (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 |
| 610 | func (mc *mysqlConn) BeginTx(ctx context.Context, opts driver.TxOptions) (driver.Tx, error) { |